Won't execute default interrupt handler..
Posted: Sat May 01, 2010 9:49 am
Hello everyone!
My problem is that my OS triple faults when I use my "generateInterrupt(int interrupt)" function, instead of executing my default interrupt handler (the function that's going to get executed if an "unmapped" interrupt occurs) which I installed in every of the 256 descriptors of the IDT, to test it .
This is my "installIDT(short selector)" function:
My "installIR(size32 index, size16 flags, size16 selector, IRQHandler IRQ)" function:
And these are my "loadIDT(short limit, int base)" & "generateInterrupt(int interrupt)" functions:
And this is how I call the functions:
If I comment out the "generateInterrupt(0x0015)" function call, it works fine so it's probably the inline assembly in my "generateInterrupt(0x0015)" function, that causes the trouble.
(I suck at inline assembly (too complicated in my opinion ))
Best regards,
Benjamin.
EDIT:
I'm sorry about the formatting of the code, but the forums always screws some parts of the code .
My problem is that my OS triple faults when I use my "generateInterrupt(int interrupt)" function, instead of executing my default interrupt handler (the function that's going to get executed if an "unmapped" interrupt occurs) which I installed in every of the 256 descriptors of the IDT, to test it .
This is my "installIDT(short selector)" function:
Code: Select all
void installIDT(size16 selector){
size16 nullIndex = 0;
size16 handlerIndex = 0;
for(nullIndex = 0; nullIndex < sizeof(IDT) * 256 - 1; nullIndex++){
memorySet(&IDT[nullIndex], 0);
}
for(handlerIndex = 0; handlerIndex < 256; handlerIndex++){
installIR(handlerIndex, 0x0080 | 0x000e, selector, (IRQHandler)defaultHandler);
}
loadIDT(sizeof(struct descriptor) * 256 - 1, (size32)&IDT[0]);
}
Code: Select all
void installIR(size32 index, size16 flags, size16 selector, IRQHandler IRQ){
if(index > 256){
return;
}
if(!IRQ){
return;
}
size64 base = (size64)&(*IRQ);
IDT[index].baseLow = base & 0xffff;
IDT[index].baseHigh = (base >> 16) & 0xffff;
IDT[index].reserved = 0;
IDT[index].flags = flags;
IDT[index].selector = selector;
}
Code: Select all
void generateInterrupt(size32 interrupt){
size32 number = interrupt;
asm(
"movb (%0), %%al\n\t"
"mov %%al, (execute + 1)\n\t"
"jmp execute\n\t"
"execute: int $0"
:
: "a" (number));
}
void loadIDT(size16 limit, size32 base){
struct{
size16 limit;
size32 base;
}entry;
entry.limit = limit;
entry.base = base;
asm("lidt (%0)" : : "p" (&entry));
}
Code: Select all
installIDT(0x0008);
generateInterrupt(0x0015);
(I suck at inline assembly (too complicated in my opinion ))
Best regards,
Benjamin.
EDIT:
I'm sorry about the formatting of the code, but the forums always screws some parts of the code .