Floppy Disk Controller Confusion

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
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Floppy Disk Controller Confusion

Post by Nessphoro »

Hey guys,

So I've been reading Floppy Disk Controller tutorial, and this part is unclear to me.
Send a Version command to the controller.
Verify that the result byte is 0x90 -- if it is not, it might be a good idea to abort and not support the floppy subsystem. Almost all of the code based on this article will work, even on the oldest chipsets -- but there are a few commands that will not.
If you don't want to bother having to send another Configure command after every Reset procedure, then:
Send a better Configure command to the controller. A suggestion would be: drive polling mode off, FIFO on, threshold = 8, implied seek on, precompensation 0.
send a Lock command.
Do a Controller Reset procedure.
Send a Recalibrate command to each of the drives.
Send a Version command to the controller??? What port?
Verify the result byte is 0x90??? What port?

Thats what I'm wondering about,

Thanks
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Floppy Disk Controller Confusion

Post by bluemoon »

Nessphoro wrote:Send a Version command to the controller??? What port?
Verify the result byte is 0x90??? What port?
wiki wrote:All commands, parameter information, result codes, and disk data transfers go through the FIFO port.
It's noted on the same tutorial page
Nessphoro wrote:So I've been reading Floppy Disk Controller tutorial
No, you don't.
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Floppy Disk Controller Confusion

Post by Nessphoro »

Okay, then why when I do this
(DATA_FIFO and else are taken from the article)

Code: Select all

outb(DATA_FIFO,VERSION);
unsigned char result= inb(DATA_FIFO);
I always get 0?
(Using QEMU)
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: Floppy Disk Controller Confusion

Post by Nessphoro »

Problem solved
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Floppy Disk Controller Confusion

Post by Brendan »

Hi,
Nessphoro wrote:Okay, then why when I do this
(DATA_FIFO and else are taken from the article)

Code: Select all

outb(DATA_FIFO,VERSION);
unsigned char result= inb(DATA_FIFO);
I always get 0?
(Using QEMU)
You need to start by writing some small, very low level routines to access various registers correctly. For most things, you can't just read/write the registers, but have to poll certain status flags until the device is ready before reading/writing, and have a time-out in case something is wrong.

For example, to send any command byte you have to poll the MSR register in a loop (with a time-out in case something is wrong) until the RQM flag is 1 and the DIO flag is 0, and only when these flags are right can you send your command byte to the FIFO register. Write a "int send_command_byte(unsigned char byte)" function to do this for you (that returns an "TIMEOUT" error if something is wrong).

For another example, before reading a result byte you have to poll the MSR register in a loop (with a time-out in case something is wrong) until the RQM flag is 1 and the DIO flag is 1, and only then can you read the result byte from the FIFO register. Write a "int get_result_byte(unsigned char *outByte)" function to do this for you (that returns an "TIMEOUT" error if something is wrong).

Then you'd do something like:

Code: Select all

    status = send_command_byte(COMMAND_VERSION);
    if(status == OK) {
        status = get_result_byte(&version);
    }
    if(status != OK) {
        /* Handle time-out error - maybe reset the controller and retry, and if it fails
         * a second time give up (assume device is faulty)
         */
    }

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.
Post Reply