From 62469c529fad4377546b39f116d69fe359250845 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 22 Jan 2023 03:15:48 +0200 Subject: [PATCH] Kernel: IDT now allocates descriptors with kmalloc_eternal --- kernel/arch/i386/IDT.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/arch/i386/IDT.cpp b/kernel/arch/i386/IDT.cpp index 4d1806fd8c..7806dce841 100644 --- a/kernel/arch/i386/IDT.cpp +++ b/kernel/arch/i386/IDT.cpp @@ -1,8 +1,7 @@ #include #include +#include #include -#include -#include #define INTERRUPT_HANDLER____(i, msg) \ static void interrupt ## i () \ @@ -71,9 +70,9 @@ namespace IDT } __attribute((packed)); static IDTR s_idtr; - static GateDescriptor s_idt[0x100]; + static GateDescriptor* s_idt; - static void (*s_irq_handlers[0x100])() { nullptr }; + static void (**s_irq_handlers)(); INTERRUPT_HANDLER____(0x00, "Division Error") INTERRUPT_HANDLER____(0x01, "Debug") @@ -184,8 +183,14 @@ namespace IDT void initialize() { + s_idt = (GateDescriptor*)kmalloc_eternal(0x100 * sizeof(GateDescriptor)); + s_irq_handlers = (void(**)())kmalloc_eternal(0x100 * sizeof(void(*)())); + + for (uint32_t i = 0; i < 0x100; i++) + s_irq_handlers[i] = nullptr; + s_idtr.offset = s_idt; - s_idtr.size = sizeof(s_idt) - 1; + s_idtr.size = 0x100 * sizeof(GateDescriptor) - 1; for (uint8_t i = 0xFF; i > IRQ_VECTOR_BASE; i--) register_irq_handler(i, nullptr);