From: Alan Cox Date: Thu, 1 Feb 2018 00:42:57 +0000 (+0000) Subject: ubee: floppy transfer routines X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=25bca78685c1746bc3cab22d7896ca97c3bb2346;p=FUZIX.git ubee: floppy transfer routines We now appear to read sectors correctly. Next stop is to sort out how the dd/sd and side detect should work as well as what to do about 9/10 sector media. Then I guess we can try a real root file system! --- diff --git a/Kernel/platform-ubee/devfd.c b/Kernel/platform-ubee/devfd.c index c3f90c2c..77aa7ac8 100644 --- a/Kernel/platform-ubee/devfd.c +++ b/Kernel/platform-ubee/devfd.c @@ -70,7 +70,6 @@ static int fd_transfer(uint8_t minor, bool is_read, uint8_t rawflag) dptr = (uint16_t)udata.u_dptr; block = udata.u_block; - kprintf("Reading from block %d\n", block); while(ct < udata.u_nblock) { cmd[0] = is_read ? FD_READ : FD_WRITE; /* Double sided assumed FIXME */ @@ -86,7 +85,6 @@ static int fd_transfer(uint8_t minor, bool is_read, uint8_t rawflag) err = fd_operation(cmd, driveptr); if (err == 0) break; - kprintf("Try %d err %d\n", tries, err); if (tries > 1) fd_reset(driveptr); } @@ -96,7 +94,6 @@ static int fd_transfer(uint8_t minor, bool is_read, uint8_t rawflag) udata.u_dptr += 512; ct++; } - kprintf("Read return %x\n", ct << BLKSHIFT); return ct << BLKSHIFT; bad: kprintf("fd%d: error %x\n", minor, err); diff --git a/Kernel/platform-ubee/floppy.s b/Kernel/platform-ubee/floppy.s index 835a78dc..3252a370 100644 --- a/Kernel/platform-ubee/floppy.s +++ b/Kernel/platform-ubee/floppy.s @@ -169,13 +169,10 @@ fdiosetup: out (FDCSEC), a in a, (FDCREG) ; Clear any pending status - ld a, CMD(ix) + ld c, CMD(ix) ld de, #0 ; timeout handling - out (FDCREG), a ; issue the command - ld b, #0 -rwiowt: djnz rwiowt ld a, DIRECT(ix) dec a ld a, (fdcctrl) @@ -185,8 +182,11 @@ rwiowt: djnz rwiowt ld (fdc_active), a ; NMI pop and jump jr z, fdio_in jr nc, fdio_out + ld a,c + out (FDCREG), a ; issue the command ; -; Status registers +; Status registers. At this point A also holds the state returned +; from the FDCREG poll for data xfers but we dont currently use it. ; fdxferdone: ei @@ -204,55 +204,40 @@ fdxferdone2: ; Read from the disk - HL points to the target buffer ; fdio_in: + ld a,c ld e, #0x16 ; bits to check ld bc, #FDCDATA ; 512 bytes/sector, c is our port -fdio_inl: + out (FDCREG), a ; issue the command + di +fdio_in1: in a, (FDCREG) and e - jr z, fdio_inl - ini - di - ld a, d -fdio_inbyte: - out (FDCCTRL), a ; stalls + jr z, fdio_in1 ini - jr nz, fdio_inbyte -fdio_inbyte2: - out (FDCCTRL), a ; stalls + jr nz, fdio_in1 +fdio_in2: + in a, (FDCREG) + and e + jr z, fdio_in2 ini - jr nz, fdio_inbyte2 + jr nz, fdio_in2 jr fdxferdone ; ; Read from the disk - HL points to the target buffer ; fdio_out: - set 6,d ; halt mode bit + ld a, c ld c, #FDCDATA ; C is our port ld e, #0x76 -fdio_outl: + out (FDCREG), a ; issue the command + di +fdio_out1: in a, (FDCREG) ; Wait for DRQ (or error) and e - jr z, fdio_outl + jr z, fdio_out1 outi ; Stuff byte into FDC while we think - di - in a, (FDCREG) ; No longer busy ?? - rra - jr nc, fdxferbad ; Bugger... - ld b, (hl) ; Next byte - inc hl -fdio_waitlock: - ld a, d - out (FDCCTRL), a ; wait states on - in a, (FDCREG) - and e - jr z, fdio_waitlock - out (c), b - ld a, d -fdio_outbyte: - out (FDCCTRL), a ; stalls - outi - jr fdio_outbyte + jr nz,fdio_out1 fdio_nmiout: ; ; Now tidy up @@ -343,17 +328,10 @@ _fd_motor_on: push hl push de ; - ; Select drive B + ; Select drive ; - cp l - jr z, was_selected -; -; Select our drive -; -notsel: ld a, l out (FDCCTRL), a - out (FDCCTRL), a ; TRS80 erratum apparently needs this ld (fdcctrl), a ld bc, #0x7F00 ; Long delay (may need FE or FF for some disks) call nap @@ -363,7 +341,6 @@ notsel: ; ; All is actually good ; -was_selected: ld hl, #0 ret