Floppy Disk Controller: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m fixed wrong header |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 70:
This can be described in C with the following code:
<
void lba_2_chs(uint32_t lba, uint16_t* cyl, uint16_t* head, uint16_t* sector)
{
Line 77:
*sector = ((lba % (2 * FLOPPY_144_SECTORS_PER_TRACK)) % FLOPPY_144_SECTORS_PER_TRACK + 1);
}
</syntaxhighlight>
You would then send this data to the floppy controller.
Line 155:
The basic set of floppy registers can be found in the following enumeration:
<
enum FloppyRegisters
{
Line 168:
CONFIGURATION_CONTROL_REGISTER = 0x3F7 // write-only
};
</syntaxhighlight>
All commands, parameter information, result codes, and disk data transfers go through the FIFO port.
Line 190:
=== Tape Drive Register ===
TDR: The Tape Drive Register is a R/W register which is identical in all modes. According to the documentation for the Intel 82077AA, the two least significant bits form a number between 1 and 3 (0 is an invalid value, drive 0 may not be selected) that assigns tape support to one particular drive out of four total drives. It is probably
=== DOR bitflag definitions ===
Line 515:
with a * and a comment.
<
enum FloppyCommands
{
Line 540:
SCAN_HIGH_OR_EQUAL = 29
};
</syntaxhighlight>
==== "Deleted sectors" ====
Deleted sectors is a legacy feature, dating back to the 1970s, when IBM data entry terminals stored a single database record in each (128 byte) floppy sector, and a record could be marked as deleted by writing a different address mark before the sector. This feature was almost never used with IBM PC and compatibles – exceptions were occasional abuse by copy protection schemes, and (possibly) hiding bad sectors. Few (if any) emulators emulate this functionality, and many late model FDCs didn't implement it.
The "WRITE_DELETED_DATA" command can be used to create a deleted sector, and the "READ_DELETED_DATA" command can be used to read one back.
==== Option bits ====
Line 550 ⟶ 555:
===== Bit MF =====
Value = 0x40. "MFM" magnetic encoding mode. Always set it for read/write/format/verify operations.
A zero value represents the old "single density" FM format, which (on IBM PCs) was only used by 8-inch floppies (which were extremely rare). Few people ever used FM format, except for data interchange with non-PC systems (such as CP/M or minicomputers). Later model FDCs (e.g. Intel 82078) dropped support for it.
===== Bit SK =====
Value = 0x20. Skip mode.
Ignore this bit and leave it cleared, unless you have a really good reason not to.
==== Status Registers ====
Line 796 ⟶ 806:
The following code intentionally contains a common bug that causes an infinite loop (waiting for IRQ6) on most emulators.
<
volatile byte ReceivedIRQ = false;
Line 820 ⟶ 830:
WaitForIRQ();
}
</syntaxhighlight>
Sure this code ''looks'' OK, but some emulators or floppy drives might manage to be faster than your code. What if you've just returned from
Line 826 ⟶ 836:
set it to false again and then infinitely loop, waiting for an IRQ that has already been received. It's usually better to do something like:
<
volatile byte ReceivedIRQ = false;
Line 861 ⟶ 871:
outb(Controller.FIFO, headload_ndma);
}
</syntaxhighlight>
== Related Links ==
Line 883 ⟶ 893:
=== Implementations ===
* [
* [http://bos.asmhackers.net/docs/floppy/snippet_9/fdc.c GazOS] (C, GPL)
* [http://bos.asmhackers.net/docs/floppy/snippet_5/FLOPPY.ASM RDOS] (Assembly, GPL)
* [
[[de:Floppy Disk Controller]]
|