No interrupt on floppy read
Posted: Mon Jan 05, 2009 5:03 am
Hello again,
I am sorry to post this here because it might after all just be some bug in my code, but cause I have tried pretty much everything and still not getting it right I assumed it to be necessary.
Where I stand:
I am writing a pmode floppy driver based on http://forum.osdev.org/viewtopic.php?t=13538.
My reset and seek functions seem to work both on bochs and real hardware.
The trouble is on the read-sector function I never get the interrupt to receive the results.
Here is my code fragment:
(PrepareWaitForInterrupt() sets a bool to false - WaitForInterrupt() halts the cpu until my isr sets it to true again (which is of course working in every other floppy function))
I have even replaced CMD_READ_DATA with commands like CMD_SEEK or CMD_RECALIBRATE happily getting interrupts, but both reading and writing (sector-wise as well as track-wise) don't trigger the interrupt line.
Any suggestions would be helpful, thanks in advice.
I am sorry to post this here because it might after all just be some bug in my code, but cause I have tried pretty much everything and still not getting it right I assumed it to be necessary.
Where I stand:
I am writing a pmode floppy driver based on http://forum.osdev.org/viewtopic.php?t=13538.
My reset and seek functions seem to work both on bochs and real hardware.
The trouble is on the read-sector function I never get the interrupt to receive the results.
Here is my code fragment:
Code: Select all
void Read()
{
byte sec = 1, cyl = 0, head = 0;
word base = PRIM_FLOPPY_BASE;
if(!FloppySeek(base, cyl, 0))
{
cle->Print("Failed seek\n");
return;
}
/*if(!FloppySeek(base, cyl, 1))
{
cle->Print("Failed seek\n");
return;
}*/
TurnOnFloppyMotor(base == PRIM_FLOPPY_BASE ? 0 : 1);
Wait(10);
//send the read command
PrepareWaitForInterrupt();
if(!SendCommand(base, CMD_READ_DATA)) // | 0x0C)) // MFM (double density) mode and multi-track
cle->Print("Error rdd_0\n");
if(!SendCommand(base, head << 2))
cle->Print("Error rdd_1\n"); //head and drive
if(!SendCommand(base, cyl))
cle->Print("Error rdd_2\n");
if(!SendCommand(base, head))
cle->Print("Error rdd_3\n");
if(!SendCommand(base, sec))
cle->Print("Error rdd_4\n");
if(!SendCommand(base, 2))
cle->Print("Error rdd_5\n"); // bytes per sector (2 = 512)
if(!SendCommand(base, 18))
cle->Print("Error rdd_6\n"); // "end of track" the final sector of this track (I have no idea what it does)
if(!SendCommand(base, 0x1B))
cle->Print("Error rdd_7\n"); //GAP3 length
if(!SendCommand(base, 0xFF))
cle->Print("Error rdd_8\n"); //data length (0xFF because bytes per sector != 0)
cle->Print("\nbefore interrupt");
WaitForInterrupt();
cle->Print("\nafter interrupt");
// ...
I have even replaced CMD_READ_DATA with commands like CMD_SEEK or CMD_RECALIBRATE happily getting interrupts, but both reading and writing (sector-wise as well as track-wise) don't trigger the interrupt line.
Any suggestions would be helpful, thanks in advice.