Problem with CALIBRATE and SEEK commands

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Problem with CALIBRATE and SEEK commands

Post by oib111 »

I'm writing a driver for Floppy Drives, and I'm having a bit of trouble with the CALIBRATE and SEEK commands. Both the wiki and another article I was looking at specified that you should wait for IRQ6 to fire after sending the command, but it never seems to fire. I tried polling the "disk active" bits in the MSR to figure out when the head movement was finished, but it never finished. Any suggestions?
Ferrarius
Member
Member
Posts: 69
Joined: Sun Oct 28, 2007 4:10 pm

Re: Problem with CALIBRATE and SEEK commands

Post by Ferrarius »

Try waiting say 50 ms after issuing the command before sensing for any interrupt. It worked at my end, it should not make a difference in bochs
Modular Interface Kernel With a lot of bugs ;)
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Problem with CALIBRATE and SEEK commands

Post by oib111 »

I popped a sleep(50) in there, but it didn't help :?
User avatar
Andr3w
Member
Member
Posts: 76
Joined: Tue Jun 09, 2009 4:09 am
Location: Somewhere

Re: Problem with CALIBRATE and SEEK commands

Post by Andr3w »

oib111 wrote:I popped a sleep(50) in there, but it didn't help :?
I hope that you have enabled IRQ 6, haven't you? :oops:
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Problem with CALIBRATE and SEEK commands

Post by AJ »

Hi,

I once had a really odd problem with an emulator and a really basic kernel where I issued the FDD commands and then started listening for an IRQ. I eventally worked out that the IRQ appeared never to happen because it occurred before I started listening for it #-o Is there any chance that this could be happening?

Cheers,
Adam
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Problem with CALIBRATE and SEEK commands

Post by oib111 »

I don't think that's happening. In fdc_wait_irq() I just do a while loop checking if bIRQ is false. If IRQ6 fired, bIRQ would be true, and my loop wouldn't even start, bIRQ would be set back to false and that'd be that.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Problem with CALIBRATE and SEEK commands

Post by pcmattman »

Is bIrq volatile?
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Problem with CALIBRATE and SEEK commands

Post by oib111 »

No.

EDIT:

Changed it to volatile and now I catch IRQ6 (only when calibrating, still can't catch it when seeking), but I still can't seem to calibrate correctly. It always stays at cylinder 218.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Problem with CALIBRATE and SEEK commands

Post by Dex »

My driver is coded and commented to go along with the per-do code in the intel controller pdf, it may help.
[EDIT]Link to code removed[/EDIT]
Last edited by Dex on Thu Dec 10, 2009 9:52 pm, edited 1 time in total.
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Problem with CALIBRATE and SEEK commands

Post by oib111 »

You seem to be doing the same thing as me except for at the end where you check ST0.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Problem with CALIBRATE and SEEK commands

Post by bewing »

Hi oib111! I am also writing floppy drivers.

I may be part of the source of your problems. Sorry!
I just last week rewrote that entire FDC article -- it used to be a stub with no info at all. But I am afraid that I made a few mistakes when I wrote the current article. The article describes fairly well how things work in EMULATORS ONLY.

After doing much more extensive testing on real hardware, I find that ALL the emulators have MULTIPLE problems with their FDC emulation.

So, the very first question is: are you running this on an emulator, or on real hardware? Because they are so very different.

Sadly, I am also having lots of trouble with seek and recalibrate on real hardware. I will be happy to share info with you when I have it working myself. (And, OF COURSE, I will be updating the in-progress wiki article as I figure out each new detail for certain.) I am embarrassed that you happened to read the wiki article at this very moment, before I can get it completely perfect.
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Problem with CALIBRATE and SEEK commands

Post by oib111 »

Oh, well you're doing a great job on the wiki article, and I've been mostly testing this on Bochs and VirtualBox.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Problem with CALIBRATE and SEEK commands

Post by bewing »

OK, on bochs:

Bochs has an extremely long "wait" after a recalibrate or seek. Try something more like a 3 second timeout when you are waiting for the IRQ6.
Also: did you send a Configure command like I said in the wiki article? Especially, did you turn OFF polling? If you did, then in bochs, that seems like it may turn off the IRQ6 from Recalibrate and Seek. I'm not sure yet, though.

If you would care to send me some of your bare floppy routines, I may be able to hack up a wrapper for them, set some breakpoints in bochs, and see why it's not sending an IRQ6, or what the delay actually is.
oib111
Member
Member
Posts: 55
Joined: Fri Sep 04, 2009 12:39 am

Re: Problem with CALIBRATE and SEEK commands

Post by oib111 »

Oh no, the IRQ fires when I'm testing on Bochs and VirtualBox, but it doesn't seem to fire when I test it on my laptop. And no, I didn't send the CONFIGURE command. The other article I was reading didn't mention that and I was using your wiki article for explanations on things that the other article didn't explain, so I never really saw the CONFIGURE command. Is it mandatory?
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Problem with CALIBRATE and SEEK commands

Post by bewing »

No, the Configure command is not mandatory. In fact, I am still trying to test each feature, to see if changing any of the Configure settings will disable the floppy controller -- because there may actually be a reason that no sample floppy drivers that I have ever seen use any Configure features.

However, the 16 byte buffer in the floppy controller remains disabled if you never send a Configure command. So your floppy data transfer performance will be extra bad.

As to your specific issue: are you sure that on your laptop that your floppy disk is an internal disk (controlled by a 82077AA chip lookalike) -- or might it be a USB floppy?

Try this: make your test program wait 10 seconds. Then display something to the screen, and try setting all the upper bits of the FDC DOR to ON.
Does the MOTOR for the drive turn on?

I am very interested in cases where bochs does not properly match the functionality of real hardware.
I would like to hear anything you eventualy figure out on this problem.
Post Reply