Page 1 of 1

Floppy Disk Controller's Main Status Register

Posted: Sun Mar 25, 2007 1:20 am
by XCHG
Do we have to have a TIMEOUT for the MRQ bit (Bit #7) in the MSR of the Floppy Disk Controller to become 1 before attempting to reset the drive? I'd appreciate your responses.

Posted: Sun Mar 25, 2007 10:55 am
by Dex
Do you mean this

Code: Select all

 ;----------------------------------------------------;
 ; FdcSendByteReady   ;floppy control  sendbyte ready ;
 ;----------------------------------------------------;

FdcSendByteReady:
        push  eax
        push  edx
        mov   [Timer],30 	                        ; 20 = about 1 second,we use (1.5 seconds).
        mov   [TimerOn],1                               ; start couting.
FdcSendByteReadyLoop:
        mov   al,[TimerOn]                              ; we test if
	or    al,al                                     ; timeout is up yet?.
        jz    FdcSendByteReadyError                     ; if it is we exit,with error.
        mov   dx,MsReg                                  ; check status reg
        in    al,dx
        and   al,11000000b
        cmp   al,10000000b                              ; are we ok to write
        jnz   FdcSendByteReadyLoop                      ; if not do another loop.
        pop   edx
        pop   eax
        clc                                             ; we end here if we write:-)
	ret

FdcSendByteReadyError:                                  ; we end up here if we run out of time:-(.
        pop   edx
        pop   eax
        stc
        ret
example from DexOS floppy driver, if so then yes, but you just return with error and error-code, then like in int 13h, you should try to read/write 3 times, with a reset.

Posted: Mon Mar 26, 2007 1:42 am
by XCHG
Thank you Dex, that code really helped me understand some points. My question now is that when I attempt to send the Fix Drive Data command to th FDD, I get this error message by Bochs:
Bochs wrote:write 0x03f5: receiving new command 0x03, old one (0x08) pending
Well command 0x08 is for Check Interrupt Status which I have sent before Fix Drive Data but what does that message mean. Does it mean that the FDD has not yet processed my first command? Do I have to wait for a certain amount of time before it processes my request?

Thanks in advance.

Posted: Mon Mar 26, 2007 10:48 am
by Dex
Here is my full floppy code it is commented to go with the per-do code in the Intel floppy controller pdf.

Also try to do has much testing on real floppy drives, because alot of time it works OK in emulators, but not on real PC, eg: delays are more important on real floppy drives than emulators.

Posted: Wed Mar 28, 2007 2:57 am
by XCHG
Thank you so much Dex. I think for now there is something much more important for me to implement in my kernel which is paging. Then I will be able to use DMA and thus implement the floppy driver.

Posted: Wed Mar 28, 2007 9:29 am
by bubach
Pages as referred to in the DMA code is more like real mode segments and has nothing to do with paging. DMA code works fine without paging enabled, all you have to do is chose an address below 16mb for DMA buffer.

Posted: Wed Mar 28, 2007 10:55 am
by Dex
Bubach is right, the word paging in DMA is miss leading and has nothing to do with paging as in the normal pmode sense.
DexOS has not got paging enabled, but DexOS floppy driver users DMA.
So you should be fine :) .

Posted: Wed Mar 28, 2007 8:33 pm
by XCHG
Well then that's awesome. Thank you guys. Appreciations.