Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
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.
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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.