PEBKAC floppy driver
Posted: Tue Feb 13, 2007 11:08 am
I must be retarded. So I am programming a simple floppy driver. Kernel boots using GRUB, PIC is mapped out, paging is used.
The command for read_sector works great on BOCHS, but fails on a real computer (specifically an 80386SX with 2MB RAM). After the command on the real pc, st0 is 0x40 (command could not be terminated properly) and st1 is 0x4 (no data).
My outportb has the value first, then the port number
Here is the flowchart for my driver.
RESET_
outportb(0, DOR)
wait 100 MS
outportb (0xC, DOR)
wait for interrupt
(command 0x08, checky interrupt status) X 4
...sendFloppyCommand(data_register, CHECK_INTERRUPT_STATUS);
......wait until MSR says it is ready to recieve
......outportb(command, DATA_REGISTER)
...wait until MSR says it is ready
...*st0 = inportb(data_register);
...wait until MSR says it is ready
...*cylinder = inportb(data_register);
outportb(0, CONFIG_CONTROL_REG)
configure_drive_command
...sends the three bytes of the command with sendFloppyCommand
calibrate_drive_command
...enable motor for disk drive
...send two bytes for calibrate drive command
...wait for interrupt
...check interrupt status
...if st0 != 0x20 (success) print error
...send command again if cylinder != 0
DMA is programmed
seek command is issued
...send three bytes of command
...wait for interrupt
...check interrupt status
...repeat if cylinder is not in the right place
wait the proper amount of time
wait 10,000 milliseconds (timer at IRQ 0 is at 1KHz)
send all bytes of read sector commands
wait for interrupt
//the guide says to check interrupt status, but complains about controller having data to send me
get all results bytes and print them to the screen
I must be missing something here. Bochs doesn't complain about DMA, although it still might be the problem. I used the excessively long delay becuase the floppy drive is very slow on the 80386 (several seconds delay for each interrupt it expects to get)
I have tried 0x44, 0x45, and 0x46 for the DMA codes but they all do the same. Not sure what to try now. I've tried everything listed in all the other floppy drive posts.
EDITED: Had to use '.' to align it so it would look right.
The command for read_sector works great on BOCHS, but fails on a real computer (specifically an 80386SX with 2MB RAM). After the command on the real pc, st0 is 0x40 (command could not be terminated properly) and st1 is 0x4 (no data).
My outportb has the value first, then the port number
Here is the flowchart for my driver.
RESET_
outportb(0, DOR)
wait 100 MS
outportb (0xC, DOR)
wait for interrupt
(command 0x08, checky interrupt status) X 4
...sendFloppyCommand(data_register, CHECK_INTERRUPT_STATUS);
......wait until MSR says it is ready to recieve
......outportb(command, DATA_REGISTER)
...wait until MSR says it is ready
...*st0 = inportb(data_register);
...wait until MSR says it is ready
...*cylinder = inportb(data_register);
outportb(0, CONFIG_CONTROL_REG)
configure_drive_command
...sends the three bytes of the command with sendFloppyCommand
calibrate_drive_command
...enable motor for disk drive
...send two bytes for calibrate drive command
...wait for interrupt
...check interrupt status
...if st0 != 0x20 (success) print error
...send command again if cylinder != 0
DMA is programmed
seek command is issued
...send three bytes of command
...wait for interrupt
...check interrupt status
...repeat if cylinder is not in the right place
wait the proper amount of time
wait 10,000 milliseconds (timer at IRQ 0 is at 1KHz)
send all bytes of read sector commands
wait for interrupt
//the guide says to check interrupt status, but complains about controller having data to send me
get all results bytes and print them to the screen
I must be missing something here. Bochs doesn't complain about DMA, although it still might be the problem. I used the excessively long delay becuase the floppy drive is very slow on the 80386 (several seconds delay for each interrupt it expects to get)
I have tried 0x44, 0x45, and 0x46 for the DMA codes but they all do the same. Not sure what to try now. I've tried everything listed in all the other floppy drive posts.
EDITED: Had to use '.' to align it so it would look right.