Floppy Disk Controller Question

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.
Post Reply
User avatar
BASICFreak
Member
Member
Posts: 284
Joined: Fri Jan 16, 2009 8:34 pm
Location: Louisiana, USA

Floppy Disk Controller Question

Post 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?
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
Sortie wrote:
  • Don't play the role of an operating systems developer, be one.
  • Be truly afraid of undefined [behavior].
  • Your operating system should be itself, not fight what it is.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Floppy Disk Controller Question

Post 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
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.
User avatar
BASICFreak
Member
Member
Posts: 284
Joined: Fri Jan 16, 2009 8:34 pm
Location: Louisiana, USA

Re: Floppy Disk Controller Question

Post 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"
BOS Source Thanks to GitHub
BOS Expanded Commentary
Both under active development!
Sortie wrote:
  • Don't play the role of an operating systems developer, be one.
  • Be truly afraid of undefined [behavior].
  • Your operating system should be itself, not fight what it is.
Post Reply