I completed installing IDT for my OS by declaring all the exception function pointers in an array (in C file, since all the exception handlers are C routines) and assigning it to all the interrupt descriptors (in assembly file). The "iret" is given as inline assembly instruction in the exception handler. While debugging the code, I found that when the processor excecutes the "iret" instruction, bochs panics with the message iret: return CS selector null. But, all the interrupt descriptors point to the correct CS descriptor.
Here's my C exception handler,
Code: Select all
void do_irq00(void)
{
PUSH_REGISTERS
print("Exception 0");
POP_REGISTERS
__asm__("iret");
}
Code: Select all
#define PUSH_REGISTERS { \
__asm__ ("pusha"); \
__asm__ ("push %ds"); \
__asm__ ("push %es"); \
__asm__ ("push %fs"); \
__asm__ ("push %gs"); \
}
#define POP_REGISTERS { \
__asm__ ("pop %gs"); \
__asm__ ("pop %fs"); \
__asm__ ("pop %es"); \
__asm__ ("pop %ds"); \
__asm__ ("popa"); \
}
Any help greatly appreciated.