#include "idt.h" #include #define low_16(address) (uint16_t)((address) & 0xFFFF) #define high_16(address) (uint16_t)(((address) >> 16) & 0xFFFF) void set_idt_gate(int n,uint32_t handler) { idt[n].low_offset=low_16(handler); idt[n].sel=KERNEL_CS; idt[n].always0=0; idt[n].flags=0xEE; idt[n].high_offset=high_16(handler); } void set_idt() { idt_reg.base=(uint32_t) &idt; idt_reg.limit=IDT_ENTRIES * sizeof(idt_gate_t) - 1; /* Don't make the mistake of loading &idt -- always load &idt_reg */ asm volatile("lidtl (%0)":: "r" (&idt_reg)); }