diff options
Diffstat (limited to 'src/kernel/interrupts/idt.c')
-rw-r--r-- | src/kernel/interrupts/idt.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/kernel/interrupts/idt.c b/src/kernel/interrupts/idt.c index 026b23c..7c762b3 100644 --- a/src/kernel/interrupts/idt.c +++ b/src/kernel/interrupts/idt.c @@ -2,16 +2,16 @@ #include <kernel/system.h> struct idt_entry { - uint16_t base_low; - uint16_t sel; // Kernel segment - uint8_t always0; // Always 0 - uint8_t flags; - uint16_t base_high; + uint16_t base_low; + uint16_t sel; // Kernel segment + uint8_t always0; // Always 0 + uint8_t flags; + uint16_t base_high; } __attribute__((packed)); struct idt_ptr { - unsigned short limit; - void *base; + unsigned short limit; + void *base; } __attribute__((packed)); // Initialize IDT with 256 entries @@ -23,26 +23,26 @@ extern void idt_load(); void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags) { - // Specify the interrupt routine's base address - idt[num].base_low = (uint16_t) (base & 0xFFFF); - idt[num].base_high = (uint16_t) ((base >> 16) & 0xFFFF); - - // Set selector/segment of IDT entry - idt[num].sel = sel; - idt[num].always0 = 0; - idt[num].flags = (uint8_t) (flags | 0x60); + // Specify the interrupt routine's base address + idt[num].base_low = (uint16_t)(base & 0xFFFF); + idt[num].base_high = (uint16_t)((base >> 16) & 0xFFFF); + + // Set selector/segment of IDT entry + idt[num].sel = sel; + idt[num].always0 = 0; + idt[num].flags = (uint8_t)(flags | 0x60); } // Install IDT void idt_install() { - // Set IDT pointer and limit - idtp.limit = (sizeof(struct idt_entry) * 256) - 1; - idtp.base = &idt; + // Set IDT pointer and limit + idtp.limit = (sizeof(struct idt_entry) * 256) - 1; + idtp.base = &idt; - // Clear IDT by setting memory cells to 0 - memset(&idt, 0, sizeof(struct idt_entry) * 256); + // Clear IDT by setting memory cells to 0 + memset(&idt, 0, sizeof(struct idt_entry) * 256); - idt_load(); - vga_log("Installed Interrupt Descriptor Table"); + idt_load(); + vga_log("Installed Interrupt Descriptor Table"); }
\ No newline at end of file |