a disgusting bug
Posted: Sun Jul 03, 2016 1:06 am
I have kept on debugging it more than 7 hours, and i can't solve it.
My kernel runs well on qemu and bochs.
But on a real machine, it can't respond to an interrupt for a second time.
For example, after it responds to a timer interrupt, it will never respond to timer interrupt again. Of course , it can still respond to a network card interrupt. But still, after receive a network package, it can not receive the second one.
I can guarantee i have configured 8259A in a right way, like EOI.
A strange phenomenon i found is that, whenever the kernel trapped into kernel due to an interrupt, the ISR value is zero !
And even more strangely, the bit of IMR corresponding to that interrupt is set to 1 !
For example:
before timer interrupt occurs(irq 0), IMR = 0xf3f8 , and then 0xf3f9.
before keyboard interrupt(irq 1) occurs, IMR = 0xf3f9, and then 0xf3fb.
before NIC interrupt(irq 10) occurs, IMR = 0xf3fb, and then 0xf7fb.
I promise i never touched IMR after initializing it!
My kernel runs well on qemu and bochs.
But on a real machine, it can't respond to an interrupt for a second time.
For example, after it responds to a timer interrupt, it will never respond to timer interrupt again. Of course , it can still respond to a network card interrupt. But still, after receive a network package, it can not receive the second one.
I can guarantee i have configured 8259A in a right way, like EOI.
A strange phenomenon i found is that, whenever the kernel trapped into kernel due to an interrupt, the ISR value is zero !
And even more strangely, the bit of IMR corresponding to that interrupt is set to 1 !
For example:
before timer interrupt occurs(irq 0), IMR = 0xf3f8 , and then 0xf3f9.
before keyboard interrupt(irq 1) occurs, IMR = 0xf3f9, and then 0xf3fb.
before NIC interrupt(irq 10) occurs, IMR = 0xf3fb, and then 0xf7fb.
I promise i never touched IMR after initializing it!