This is my first time on this forum, so I'd like to greet everybody.
I am developing an OS based on the BrokenThorn and osdever.net tutorials:
https://sites.google.com/site/forthoperatingsystem/
Currently I am developing the ATA hard disk driver (hasn't been uploaded yet but the links are below) with PIO according to this page:
http://wiki.osdev.org/ATA_PIO_Mode
My OS is a single task one, so I use polling instead of DMA (IRQ).
The problem is that I can read/write sectors from/to the winchester in emulators (Bochs and QEMU) but on real hardware there is always an interrupt.
According to the osdev.org article (link above) the nIEN bit needs to be set in 0x3F6 (primary bus crtl-register) and 0x376 (secondary bus ctrl-register).
Pseudo code:
Code: Select all
outb(0x3F6, 2)
outb(0x376, 2)
but the IRQ kept comming.
I also tried to select the device(it's "Detecting Device Types" in the PIO artile above) and only then set the nIEN bit:
Code: Select all
out(0x1F6, 0xA0)
inb(0x3F6)
inb(0x3F6)
inb(0x3F6)
inb(0x3F6)
outb(0x3F6, 2)
Unfortunately the IRQ still came.
Maybe I should disable the nIEN-bit on all possible busses (ctrl-ports: 0x3F6, 0x170, 0x0x3E6, 0x366)?
How could I prevent the winchester from firing an IRQ?
The kernel calls hd_detect in hd.asm:
http://pastebin.com/5pCiqW7E
and hd.asm uses ata.asm:
http://pastebin.com/mCK2c8d4
Maybe also delays are missing from the code, but it works with Bochs because it is much slower than real hw.
Can this code work on real hardware after I manage to get rid of the interrupt?
I have wasted so many CDs so far so I decided to ask this question.
Regards,
Rob