From: Alan Cox Date: Sun, 14 Dec 2014 23:00:31 +0000 (+0000) Subject: mtx: Further work on the floppy driver X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=bb927241ce507f673acee1e816f85082bba707b8;p=FUZIX.git mtx: Further work on the floppy driver We now load the superblocks and find the inode etc for init Note that the order on the virtual disk is odd with the second head after the first full set of tracks --- diff --git a/Kernel/platform-mtx/devfd.c b/Kernel/platform-mtx/devfd.c index 122c7cab..23e56589 100644 --- a/Kernel/platform-mtx/devfd.c +++ b/Kernel/platform-mtx/devfd.c @@ -3,6 +3,11 @@ #include #include +/* + * TODO: Debug, low density is half the sectors/track, + * what to do about 80 v 40 track ? + * + */ /* Two drives but minors 2,3 are single density mode */ #define MAX_FD 4 @@ -15,7 +20,7 @@ static uint8_t motorct; static uint8_t fd_selected = 0xFF; -static uint8_t fd_tab[MAX_FD]; +static uint8_t fd_tab[MAX_FD] = { 0xFF, 0xFF }; /* * We only support normal block I/O @@ -28,7 +33,7 @@ static int fd_transfer(uint8_t minor, bool is_read, uint8_t rawflag) int ct = 0; int tries; uint8_t err = 0; - uint8_t *driveptr = fd_tab + minor; + uint8_t *driveptr = &fd_tab[minor & 1]; uint8_t cmd[6]; if(rawflag) @@ -43,16 +48,17 @@ static int fd_transfer(uint8_t minor, bool is_read, uint8_t rawflag) dptr = (uint16_t)udata.u_buf->bf_data; block = udata.u_buf->bf_blk; -// kprintf("Issue command: drive %d\n", minor); + kprintf("Issue command: drive %d block %d\n", minor, block); cmd[0] = is_read ? FD_READ : FD_WRITE; - cmd[1] = block / 8; /* 2 sectors per block */ - cmd[2] = ((block & 7) << 1) + 1; + cmd[1] = block / 16; /* 2 sectors per block */ + cmd[2] = ((block & 15) << 1); /* 0 - 1 base is corrected in asm */ cmd[3] = is_read ? OPDIR_READ: OPDIR_WRITE; cmd[4] = dptr & 0xFF; cmd[5] = dptr >> 8; while (ct < 2) { for (tries = 0; tries < 4 ; tries++) { + kprintf("Sector: %d Track %d\n", cmd[2]+1, cmd[1]); err = fd_operation(cmd, driveptr); if (err == 0) break; diff --git a/Kernel/platform-mtx/floppy.s b/Kernel/platform-mtx/floppy.s index ac1e4a10..2a9768d4 100644 --- a/Kernel/platform-mtx/floppy.s +++ b/Kernel/platform-mtx/floppy.s @@ -83,12 +83,23 @@ fdsetup: out (FDCTRK), a cp TRACK(ix) jr z, fdiosetup - ; ; So we can verify ; + bit 4, SECTOR(ix) ; side ? + ld a, (fdcctrl) + jr z, seekside1 + set 1, a + jr seekside +seekside1: + res 1, a +seekside: + out (FDCCTRL), a ld a, SECTOR(ix) + inc a out (FDCSEC), a + ld a, TRACK(ix) + out (FDCDATA), a ; target ; ; Need to seek the disk ; @@ -101,18 +112,23 @@ fdsetup: call waitdisk jr nz, setuptimeout and #0x18 ; error bits - jr z, fdiosetup + jr z, seekgood ; seek failed, not good setuptimeout: ; NE = bad ld a, #0xff ; we have no idea where we are, force a seek ld (de), a ; zap track info ret ; -; Head in the right place +; Seek worked ok ; -fdiosetup: +seekgood: + in a, (FDCREG) ld a, TRACK(ix) ld (de), a ; save track +; +; Head in the right place +; +fdiosetup: ; cmp #22 ; FIXME ; jr nc, noprecomp ; ld a, (fdcctrl) @@ -121,7 +137,7 @@ fdiosetup: ;noprecomp: ld a, (fdcctrl) ;precomp1: - bit 3, SECTOR(ix) ; check if we need side 1 + bit 4, SECTOR(ix) ; check if we need side 1 jr nz, fdio_s1 res 1, a jr fdio_setsec @@ -129,7 +145,7 @@ fdio_s1:set 1, a fdio_setsec: out (FDCCTRL), a ld a, SECTOR(ix) - and #7 ; remove side bit + inc a ; 1 based out (FDCSEC), a in a, (FDCREG) ; Clear any pending status