35 lines
No EOL
997 B
C
35 lines
No EOL
997 B
C
#include "int.h"
|
|
#include "../../print.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
int count = 0;
|
|
|
|
void exception_handler() {
|
|
print_str("I");
|
|
}
|
|
|
|
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() {
|
|
idtr.base = (uint32_t)&idt[0];
|
|
idtr.limit = (uint16_t)sizeof(idt_entry_t) * 256 - 1;
|
|
|
|
for (uint8_t vector = 0; vector < 32; vector++) {
|
|
idt_set_descriptor(vector, isr_stub_table[vector], 0x8E);
|
|
isr_stub_table[vector] = true;
|
|
}
|
|
|
|
__asm__ volatile ("lidt %0" : : "m"(idtr)); // load the new IDT
|
|
__asm__ volatile ("sti"); // set the interrupt flag
|
|
} |