972
edits
[unchecked revision] | [unchecked revision] |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
|||
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 515:
with a * and a comment.
<
enum FloppyCommands
{
Line 540:
SCAN_HIGH_OR_EQUAL = 29
};
</syntaxhighlight>
==== "Deleted sectors" ====
Line 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 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 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 871:
outb(Controller.FIFO, headload_ndma);
}
</syntaxhighlight>
== Related Links ==
|