Page 1 of 1

Floppy Disk Controller Confusion

Posted: Sun May 29, 2011 7:09 pm
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

Re: Floppy Disk Controller Confusion

Posted: Sun May 29, 2011 7:16 pm
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.

Re: Floppy Disk Controller Confusion

Posted: Sun May 29, 2011 7:28 pm
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)

Re: Floppy Disk Controller Confusion

Posted: Sun May 29, 2011 7:51 pm
by Nessphoro
Problem solved

Re: Floppy Disk Controller Confusion

Posted: Sun May 29, 2011 8:05 pm
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