Page 1 of 1
General Protection Fault
Posted: Wed Jun 30, 2004 4:10 am
by Whodoo
I got exceptions and software interrupts working.. and I decided to try some IRQs..so I created a ISR and the stuff in the IDT..but when I unmask the keyboard IRQ (IRQ #1) I get "General Protection Fault".
Any ideas?
Re:General Protection Fault
Posted: Wed Jun 30, 2004 4:20 am
by Solar
...your interrupt handling is not working?
Re:General Protection Fault
Posted: Wed Jun 30, 2004 4:34 am
by Whodoo
well interrupthandling..isnt that the same thing as exceptions? (something like that)... Ive written a ISR and all that and Im setting up and IDT and all that.. is there something special I need to do when it comes to IRQs (thats different from exception), except of unmasking the IRQ?
Re:General Protection Fault
Posted: Wed Jun 30, 2004 4:45 am
by Solar
Whatever you did set up to handle IRQ1 generates a General Protection Fault, which is successfully caught by the GPF exception handler. (Or you'd be triple-faulting.) So, yes, your exception handlers do work. Your interrupt handlers don't.
And without additional information, it is difficult to say more.
Re:General Protection Fault
Posted: Wed Jun 30, 2004 4:45 am
by Whodoo
My bad, it works better now..
but when an interrupt has occured..what should I do then? Cause the handler runs but then nothing?s happening..I want to return to the code and all that...
Re:General Protection Fault
Posted: Wed Jun 30, 2004 4:56 am
by Pype.Clicker
From
Help? cannot get Interrupts working... in
TroubleShooting category of the FAQ:
* pops everything you push, but no more
Another common source of error at this point comes from misimplementation of ISR in C. Check the InterruptServiceRoutines page for enlightenment ...
Things would be easier if you could provide the handler code. This is an ASM handler, right ? you're not trying to have IRQ directly dispatched to a C function, are you ?
Re:General Protection Fault
Posted: Wed Jun 30, 2004 5:01 am
by Whodoo
Here?s the code for the ISR
ASM ISR:
[extern _int_21]
[global _int21]
_int21:
pusha
push ds
push es
push fs
push gs
mov eax,0x10
mov ds,eax
mov es,eax
call _int_21 ; C function
pop gs
pop fs
pop es
pop ds
popa
iret
The C function:
void int_21(void)
{
print("A key has been pressed: ", WHITE_TXT);
out(0x20, 0x20);
}
When I hit a key, the message is displayed(wee).. but only once, I cant recieve more than one IRQ..when pressing a key the next time, nothing?s happening..
Re:General Protection Fault
Posted: Wed Jun 30, 2004 5:11 am
by Curufir
I'd check your out(0x20,0x20) is actually doing what it's advertising.
Re:General Protection Fault
Posted: Wed Jun 30, 2004 5:23 am
by Whodoo
hmm I guess I also need to clear the interrupt at the deviice that caused it? Done by reading an I/O register? But how do I convert the scancode to ascii?
Re:General Protection Fault
Posted: Wed Jun 30, 2004 6:03 am
by Pype.Clicker
the keyboard controller has its own internal logic. It delivers an IRQ when a new character becomes available and then waits for the CPU to read the character out of its internal buffer.
If you handle IRQ1 without reading the available byte on port 0x60 (keyboard scancode), the keyboard controller cannot emit another IRQ for the next keystrike.