Page 1 of 2

pmode FDC driver

Posted: Fri Jun 13, 2003 10:34 am
by HOS
hi, i am working on a pmode FDC driver and i am wondering how to go about reading the result phase of the commands sent to the fdc controller. i try sending commands (for instance a seek command) and i hear the drive move, then i get a fdc interrupt. it is this point where i have the question. once i get the fdc interrupt, can i want till the Main Status Register says there is data available, and then when it does begin reading the result phase bytes? do i have to wait till the MSR says there is data available between each result byte? and do i have to do anything to acknowledge that i read the results other than reading from the port?

thanks a lot in advance!!

Re:pmode FDC driver

Posted: Fri Jun 13, 2003 10:57 am
by HOS
ok, one more thing: in protected mode, does the fdc still set a bit of the bios data area at 40:3E? if so, where is this in protected mode? right where it would be in real mode?

Re:pmode FDC driver

Posted: Fri Jun 13, 2003 4:12 pm
by Peter_Vigren
HOS wrote: ok, one more thing: in protected mode, does the fdc still set a bit of the bios data area at 40:3E? if so, where is this in protected mode? right where it would be in real mode?
When the FDC is done, it issues an IRQ linked to an interrupt (normally #6?). In Pmode, you have to set up your own Interrupt Table which means that the code can do whatever you want when the FDC is done. Yes, it should be at the same spot but you have to use the linear address.

Re:pmode FDC driver

Posted: Fri Jun 13, 2003 4:42 pm
by Peter_Vigren
HOS wrote: hi, i am working on a pmode FDC driver and i am wondering how to go about reading the result phase of the commands sent to the fdc controller. i try sending commands (for instance a seek command) and i hear the drive move, then i get a fdc interrupt. it is this point where i have the question. once i get the fdc interrupt, can i want till the Main Status Register says there is data available, and then when it does begin reading the result phase bytes? do i have to wait till the MSR says there is data available between each result byte? and do i have to do anything to acknowledge that i read the results other than reading from the port?

thanks a lot in advance!!
No. To my knowledge, you check only once if the FDC is ready to send the result bytes. And reading them is the only acknowledge it needs.

Re:pmode FDC driver

Posted: Sun Jun 15, 2003 8:51 am
by HOS
Thank you for your replies.

I have a ISR set up for IRQ 6 which displays "FDC interrupt" and then reads & displays the results. when i issue a command, "FDC interrupt" is displayed and then the results, this appears to be fine. the problem is that i issue another command but then i do not get another interrupt. i monitor linear address 0x43E before and after command and results but it does not change at all (is it possible it changes only in real mode if the bios is handling IRQ 6?) so i still do not know if there is another way to acknowledge the results or am i doing something else wrong?

Re:pmode FDC driver

Posted: Sun Jun 15, 2003 3:31 pm
by Peter_Vigren
HOS wrote: Thank you for your replies.

I have a ISR set up for IRQ 6 which displays "FDC interrupt" and then reads & displays the results. when i issue a command, "FDC interrupt" is displayed and then the results, this appears to be fine. the problem is that i issue another command but then i do not get another interrupt. i monitor linear address 0x43E before and after command and results but it does not change at all (is it possible it changes only in real mode if the bios is handling IRQ 6?) so i still do not know if there is another way to acknowledge the results or am i doing something else wrong?
Wait... in your ISR, do you set the highest bit at 0x43E? And do you send EOI (End Of Interrupt) to both the PIC's in order to acknowledge the interrupt?

Re:pmode FDC driver

Posted: Mon Jun 16, 2003 6:24 am
by HOS
Aha! its amazing how we forget the little things when concentrating so hard on details... a simple call to eoi() enabled me to get results every time i sent a command. eoi() just sends 0x20 to 0x20. is this sufficient? also, it still seems that my readSector function is not working correctly. could be my dma initialization. could you confirm my numbers for floppy disks (of the 1.40 meg 3.5" variety):
head: 0 or 1
cylinder: 1 to 80
sector: 1 to 18
sectors per track: 18

this could also be causing me some problems...

Re:pmode FDC driver

Posted: Mon Jun 16, 2003 7:59 am
by Jamethiel
I thought it was cylinder 0 to 79, but I could be wrong about that, it's been a while.

Did you remember to issue the SPECIFY command, with parameters #xDF #x03? (at least, it's #xDF #x03 on my system)

--Jamethiel

Re:pmode FDC driver

Posted: Mon Jun 16, 2003 8:20 am
by HOS
Well, i tried to send 0 for cylinder and 1 for sector and that returned bit 2 of ST1 set (no data - could not find sector) so i tried sending 1 and 1 and that returned 0 for ST1. so does that mean cylinder numbers start at 1?

no, i did not send the Specify command. i did not know i had to, (this is my first time programming the fdc :)) but i will try that. should that be done immediately before every read command or just once before using any commands?

Thank you.

Re:pmode FDC driver

Posted: Mon Jun 16, 2003 1:23 pm
by nullify
Just send SPECIFY once.

Re:pmode FDC driver

Posted: Tue Jun 17, 2003 6:58 am
by HOS
ok, i sent a SPECIFY command once before sending the read command. the byte sequence was:

0x03 (specify command)
0xDF
0x02 (i am using dma mode)

however, this did not change what happened after i sent a readSector command, it still does not appear to read a thing. i get the result phase back from the command, and it looks fine, but it seems like it didn't read a thing. could i test to see if my dma init is my problem by putting the fdc in non-dma mode? if so, is an interrupt triggered every time a byte is read or what?

thanks

Re:pmode FDC driver

Posted: Tue Jun 17, 2003 9:30 am
by Peter_Vigren
HOS wrote: Aha! its amazing how we forget the little things when concentrating so hard on details... a simple call to eoi() enabled me to get results every time i sent a command. eoi() just sends 0x20 to 0x20. is this sufficient? also, it still seems that my readSector function is not working correctly. could be my dma initialization. could you confirm my numbers for floppy disks (of the 1.40 meg 3.5" variety):
head: 0 or 1
cylinder: 1 to 80
sector: 1 to 18
sectors per track: 18

this could also be causing me some problems...
No, from what I know that is not sufficient. You should send EOI to both PICs (0x20 and 0xA0). At least this is the way I have understood it.

The cylinder number should be 0 to 79.

In non-DMA, the interrupt should be triggered (once) when the drive has completed (when it is ready to send data).

Re:pmode FDC driver

Posted: Tue Jun 17, 2003 9:36 am
by HOS
Ok, if cylinder #'s are 0-79 then why when i send a 0 for cylinder do i get NDAT in ST1 back?

and in non-dma mode if i get an interrupt does that mean that i can read a byte at a time, each byte of the result phase and then immediately afterwards each byte of the actual data read from the sector? or does the actual data go somewhere else?

Thank you once again :)

Re:pmode FDC driver

Posted: Wed Jun 18, 2003 5:04 pm
by Peter_Vigren
HOS wrote: Ok, if cylinder #'s are 0-79 then why when i send a 0 for cylinder do i get NDAT in ST1 back?

and in non-dma mode if i get an interrupt does that mean that i can read a byte at a time, each byte of the result phase and then immediately afterwards each byte of the actual data read from the sector? or does the actual data go somewhere else?

Thank you once again :)
I have really no idea... maybe that is the error I get too... Maybe some clever guy like Pype knows...

As I've understood it, you get the result bytes and after that you poll the drive for one byte at a time... and places it where you want it to be...

Re:pmode FDC driver

Posted: Thu Jun 19, 2003 1:27 am
by Pype.Clicker
sorry, i have virtually no practice of floppy programming so far ...