Page 1 of 1

Polling PMode Floppy Driver

Posted: Sat May 23, 2020 1:40 pm
by benjidial
I'm currently writing a floppy driver for a 32-bit protected mode OS. I'm planning not to use DMA or any other asynchronous things for now, as my OS is single-tasking. I have interrupts disabled in the floppy controller for the same reason. I read the wiki page here on the floppy controller, but I can't figure out how to read a sector from a drive properly. My current floppy driver source code (32-bit GNU C) is attached. panic prints the supplied message and a stacktrace, then halts. SPT is the sectors per track, taken from the FAT record in the boot sector. On boot, my kernel calls init_floppy, then uses read_sectors to read the FAT from disk into memory. When I run my kernel, the panic function on line 95 in floppy_out is called. Going up the stack, this is called from line 102 in floppy_sense, from line 168 in read_sector, from line 192 in read_sectors. I'm not sure what's going wrong here. Am I not supposed to do a sense interrupt after issuing a read command? Is my read command malformed? Is there an earlier error that goes undetected until now?

Re: Polling PMode Floppy Driver

Posted: Tue May 26, 2020 4:38 am
by Octocontrabass
benjidial wrote:Am I not supposed to do a sense interrupt after issuing a read command?
You're supposed to poll MSR. The sense interrupt command is meant to be used with the seek and recalibrate commands.

(I'd argue that you're supposed to use DMA and IRQs, but it's your OS and you can make it however you want.)