Page 1 of 1

Floppy Disk Controller Question

Posted: Mon Mar 03, 2014 5:29 pm
by BASICFreak
So, I'm reading through the wiki and taking notes Floppy_Disk_Controller

and I've come to this part:
Status Registers
There are 3 registers that hold information about the last error encountered. The st0 register information is passed back with the result bytes of most commands. The st1 and st2 information is returned in the result bytes of read/write commands. They can also be retrieved with a Dumpreg command.
st0
The top 2 bits (value = 0xC0) are set after a reset procedure, with polling on. Either bit being set at any other time is an error indication. Bit 5 (value = 0x20) is set after every Recalibrate, Seek, or an implied seek. The other bits are not useful.
st1
The st1 register provides more detail about errors during read/write operations.
Bit 7 (value = 0x80) is set if the floppy had too few sectors on it to complete a read/write. This is often caused by not subtracting 1 when setting the DMA byte count. Bit 4 (value = 0x10) is set if your driver is too slow to get bytes in or out of the FIFO port in time. Bit 1 (value = 2) is set if the media is write protected. The rest of the bits are for various types of data errors; indicating bad media, or a bad drive.
st2
The st2 register provides more (useless) detail about errors during read/write operations.
The bits all indicate various types of data errors for either bad media, or a bad drive.
now I know the three status registers are (as listed in the wiki):
Status Register A - 0x3F0
Status Register B - 0x3F1
Main Status Register - 0x3F4

what order are they in when stated in above quote? I prefer not to assume and/or randomly test.

OR did I miss something?

Re: Floppy Disk Controller Question

Posted: Tue Mar 04, 2014 3:02 am
by Brendan
Hi,
BASICFreak wrote:OR did I miss something?
You've missed something. ;)

There are status registers that tell you the status of the controller; and there are bytes returned by various commands that tell you the command's response. These are 2 completely different things.

To get the status of the controller, you use the status registers.

To get a command's response you wait for the IRQ and then read the command's "result bytes" (which is a group of between 0 and 7 bytes, depending on the command). To do that; in a loop, you poll the controller's main status register to check if it's ready to send the next "result byte" , and then read from the controller's "data" register to get the actual byte.

Also note that the "result bytes" of different commands are different. For example, after an "identify" command you might only get 1 byte (that is not any kind of status); from a "read" command you might get a total of 7 bytes (where the first three bytes are status), and from a "sense interrupt status" command you might get a total of 2 bytes (where only one is status).


Cheers,

Brendan

Re: Floppy Disk Controller Question

Posted: Tue Mar 04, 2014 12:46 pm
by BASICFreak
Thanks for the reply, I now got my code to compile - time to see if it works [-o<



P.S. I like the selections of "smilies"