#include "arch/x86_64/tables.h" #include "arch/x86_64/idt.h" __attribute__((aligned(0x10))) interrupt_gate_t s_idtd[256]; void isr_handle(ivt_state_t* state) { kpanic_state(state, "Unhandled interrupt %i", state->num); } void ivt_setup(void) { extern uintptr_t __ivt[256]; for(int i = 0; i < 256; i++) { uintptr_t base = __ivt[i]; s_idtd[i] = (interrupt_gate_t) { .base_0_15 = (base & 0xFFFF), .cs = GDT_OFFSET_KERNEL_CODE, .ist = 0, .type_flags = IDT_TYPE_INT_GATE | IDT_FLAG_DPL(0) | IDT_FLAG_P, .base_16_31 = (base >> 16) & 0xFFFF, .base_32_63 = (base >> 32) & 0xFFFFFFFF, .resv = 0 }; } } void idt_setup(processor_t *processor) { processor->idtr.base = (uintptr_t)&s_idtd; processor->idtr.length = sizeof(s_idtd) - 1; extern void idt_load(void* idtr); idt_load(&processor->idtr); }