Double fault on (presumed) PIC interrupt (IRQs are remapped)
Posted: Wed May 29, 2013 6:59 am
Hello,
I'm sitting on this one since over a week now and decided to bother you with this.
I have set up my GDT. I have set up an IDT. I can use software interrupts, thats no problem, so I presume its not because something went wrong with the segment. Some time after I activate the interrupts using sti I get a double fault (following by GPFs if I don't halt the kernel). The error code seems to change occasionally.
As mentioned in the title, I did remap the IRQ. I tried this with the code from several tutorials to ensure that it isn't a fault of my remapping code (I did it with far more macros but that shouldn't be that bad). The ISR machine code handlers wich invoke my C handlers are copied from tutorials (and I won't write own ones while this double fault occurs - after that you can bet on it). (By the way: on my research on the PIC I found out about this auto-end-of-interrupt bit. Why does no tutorial just set it and leave out the sending of end of interrupt in the IRQ handler? Where's the disadvantage?)
Here's the code of the IDT installation function:
And idtSetGate:
(I don't use a cross compiler YET. I'm working on this.)
I have no clue where the bug can be. (I had a working version, but it was unstructured and evil, partly copied from tutorials.)
If I can post anything else (code, information...) just let me know.
Greetings,
Lasse
I'm sitting on this one since over a week now and decided to bother you with this.
I have set up my GDT. I have set up an IDT. I can use software interrupts, thats no problem, so I presume its not because something went wrong with the segment. Some time after I activate the interrupts using sti I get a double fault (following by GPFs if I don't halt the kernel). The error code seems to change occasionally.
As mentioned in the title, I did remap the IRQ. I tried this with the code from several tutorials to ensure that it isn't a fault of my remapping code (I did it with far more macros but that shouldn't be that bad). The ISR machine code handlers wich invoke my C handlers are copied from tutorials (and I won't write own ones while this double fault occurs - after that you can bet on it). (By the way: on my research on the PIC I found out about this auto-end-of-interrupt bit. Why does no tutorial just set it and leave out the sending of end of interrupt in the IRQ handler? Where's the disadvantage?)
Here's the code of the IDT installation function:
Code: Select all
tidtPtr.limit = (sizeof(idtEntry) * IDT_ENTRIES)-1;
tidtPtr.base = &idt;
memset((void *)idt, 0, sizeof(idtEntry)*IDT_ENTRIES);
//set gates for all exceptions
idtSetGate(0 , (uint32_t)isr0 , CALC_SEL(1), I_PRESENT | I_DPL(0) | I_INT_GATE);
.
.
.
idtSetGate(47, (uint32_t)irq15, CALC_SEL(1), I_PRESENT | I_DPL(0) | I_INT_GATE);
//flush :)
cli();
remapIrqs();
lidt(tidtPtr);
Code: Select all
static void idtSetGate(const uint8_t index, const uint32_t entry, const uint16_t selector, const uint16_t attr)
{
idt[index].zero = 0x00;
idt[index].attr = attr;
idt[index].selector = selector;
idt[index].entryLow = 0xFFFF & entry;
idt[index].entryHigh = (entry>>16) & 0xFFFF;
}
I have no clue where the bug can be. (I had a working version, but it was unstructured and evil, partly copied from tutorials.)
If I can post anything else (code, information...) just let me know.
Greetings,
Lasse