I have verified that the initial interrupt triggered is a General Protection Fault, however another interrupt is being triggered before the exception handler is executed.
This has been an issue for a while now, but I have only just been able to capture the event in a debugger.
On all other boots, this issue does not occur and everything is set up and working.
Relevant Code:
Setting up IDT & ISR Handlers
Code: Select all
void idt_set_descriptor(uint8_t vector, void* isr, uint8_t flags) {
idt_entry_t* descriptor = &idt[vector];
descriptor->isr_low = (uint32_t)isr & 0xFFFF;
descriptor->kernel_cs = 0x08; // this value can be whatever offset your kernel code selector is in your GDT
descriptor->attributes = flags;
descriptor->isr_high = (uint32_t)isr >> 16;
descriptor->reserved = 0;
}
void idt_init() {
__asm__ volatile("cli");
idtr.base = (uintptr_t)&idt[0];
idtr.limit = (uint16_t)sizeof(idt_entry_t) * IDT_MAX_DESCRIPTORS - 1;
memset((char*)idt, 0, sizeof(idt_entry_t) * 256);
__asm__ volatile ("lidt %0" : : "m"(idtr)); // load the new IDT
__asm__ volatile ("sti"); // set the interrupt flag
}
void isrs_install() {
__asm__ volatile("cli");
for (uint8_t vector = 0; vector < 32; vector++) {
idt_set_descriptor(vector, isr_stub_table[vector], 0x8E);
}
__asm__ volatile("sti");
}
Code: Select all
void _kmain(void) {
vga_init();
vga_puts("SOLKERN V0.1\n");
vga_puts("Setting up Interrupt Descriptor Table.....\n");
idt_init();
vga_puts("OK!\n");
vga_puts("Initializing Interrupt Service Routines.....\n");
isrs_install();
vga_puts("OK!\n");
// Fails here
while(1) {}
}