From db555089dea369d9dd3010d1853077e7a4118b90 Mon Sep 17 00:00:00 2001 From: Fabian Imhof Date: Wed, 26 Mar 2025 10:08:40 +0000 Subject: add llm suggestion to idt creation --- .../interrupt_descriptor_table.cpp | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'arch') diff --git a/arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp b/arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp index 8bcce65..0555e4c 100644 --- a/arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp +++ b/arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp @@ -9,19 +9,22 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table { auto create_interrupt_descriptor_table() -> interrupt_descriptor_table { - // TODO: Fix offset and ist and selector index - uint64_t const offset = 0x0; - segment_selector const selector{0U, segment_selector::REQUEST_LEVEL_KERNEL}; - ist_offset const ist{0U}; - idt_flags const flags{idt_flags::DESCRIPTOR_LEVEL_KERNEL | idt_flags::INTERRUPT_GATE}; - gate_descriptor const interrupt_gate{selector, ist, flags, offset}; - - segment_selector const selector{0U, segment_selector::REQUEST_LEVEL_KERNEL}; - ist_offset const ist{0U}; - idt_flags const flags{idt_flags::DESCRIPTOR_LEVEL_KERNEL | idt_flags::TRAP_GATE}; - gate_descriptor const trap_gate{selector, ist, flags, offset}; - - return interrupt_descriptor_table{interrupt_gate, trap_gate}; + interrupt_descriptor_table idt{}; + + // Define basic exception handlers (at least for CPU exceptions 0x00-0x1F) + for (uint8_t vector = 0; vector < 32; ++vector) + { + uint64_t offset = reinterpret_cast(default_exception_handler); // Use a real handler function + segment_selector selector{0U, segment_selector::REQUEST_LEVEL_KERNEL}; + ist_offset ist{0U}; // Default stack offset (can be updated for IST) + idt_flags flags{idt_flags::DESCRIPTOR_LEVEL_KERNEL | idt_flags::TRAP_GATE}; + + idt.push_back(gate_descriptor{selector, ist, flags, offset}); + } + + // Additional entries for hardware interrupts (IRQs) and syscalls can be added here + + return idt; } } // namespace -- cgit v1.2.3