Page 1 of 1

No interrupt on floppy read

Posted: Mon Jan 05, 2009 5:03 am
by wndproc
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:

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");

// ...
(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.

Re: No interrupt on floppy read

Posted: Mon Jan 05, 2009 2:08 pm
by System123
I encounted the same problem while doing my floppy driver. I cant off hand remember what i did to fix the issue but it all works fine now. I know the one thing is that i used the value 0x80 in place of 0xC0.Also make sure that the interrupt boolean is set to true before waitin on an interrupt. I will post my code for comparison in the morning if it is still needed.

Re: No interrupt on floppy read

Posted: Mon Jan 05, 2009 6:01 pm
by wndproc
Thanks for the reply, unfortunately I'm still stuck
I know the one thing is that i used the value 0x80 in place of 0xC0.
I tried every possible flag combination, but still no interrupt.
Also make sure that the interrupt boolean is set to true before waitin on an interrupt.
I do also print something like "int fired" directly inside my isr to prohibit such issues, giving the me result that no int gets fired whatsoever.
I will post my code for comparison in the morning if it is still needed.
I would appreciate that, thank you.

Re: No interrupt on floppy read

Posted: Tue Jan 06, 2009 4:08 am
by System123
Here is a link to my code http://code.google.com/p/gizmicos/downloads/list Download GizmicOS 0.03 and you will find my Floppy code in the Kernel Directory. The code is in Pascal but I am sure you can follow it.