Floppy Disk Controller: Difference between revisions

Jump to navigation Jump to search
added source tags
[unchecked revision][unchecked revision]
(→‎Forum Posts:: - added PIO mode link)
(added source tags)
Line 4:
 
Floppy controller is programmed through 8 registers accessed from 0x3F0 through 0x3F7 I/O ports. As usual on PC architecture, some of those registers have different meaning depending on whether you read or write them. For extra info, refer to the datasheet (see link below). Note that snippets and datasheets name those registers from their trigrams (e.g. SRA, MSR, DIR, CCR, etc)
<source lang="c">
 
enum FloppyRegisters {
STATUS_REGISTER_A = 0x3F0, // read-only
Line 16:
CONFIGURATION_CONTROL_REGISTER = 0x3F7, //write only
};
</source>
 
 
Note that all command parameter information and disk data transfers go through the FIFO. The other registers barely tell you if the disk/controller is busy or not (MSR), control the transfer rate (DIR, CCR, DRS) and select disks (DOR).
 
Beyond that basic configuration, you talk to the floppy controller by the way of _commands_ sent through the data fifo. Each command is a sequence of bytes that start with a command code and optional parameters. Note that most of these commands have 'option' bits (such as MFM, MT) which are not covered here.
<source lang="c">
 
enum FloppyCommands {
READ_TRACK = 2,
Line 43:
SCAN_HIGH_OR_EQUAL = 29,
};
</source>
 
There are several things you need to take into account when programming a floppy controller:
*motor spinning: You need to turn the motor on and wait for a suitable amount of time after that so that the motor has reached the speed needed for data transfer. You're also welcome to stop the motor after you're done reading (but preferably not too early). The recommended "motor on" delays are 300 mS for a 3.5 inch floppy and 500 mS for a 5.25 inch floppy (these values should be conservative). If you start a read immediately after turning the floppy motor on, the internal electronics will fail to "lock on" to the signal being read and you'll get an error. It is possible to use this to minimize (or avoid) the "motor on" delay by repeatedly retrying the read until it works successfully. Typically a delay of 2 seconds is used for the "motor off" delay - longer delays increase the chance that the "motor on" delay can be avoided for additional data transfers (but leaving the motor on for longer can give users the perception that data is still being transfered, and that it's taking too long!).
Line 70:
 
Taken and translated from "floppy_tutorial" (see below). steprate, head unload time and other parameters could be retrieved from BIOS tables, as specified in the tutorial.
<source lang="c">
 
outportb(controller.DOR,0x00);
outportb(controller.DOR,0x0C);
Line 87:
send_data_byte(headload_ndma);
}
</source>
 
===Sequence of Events===
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu