diff options
| author | Fabian Imhof <fabian.imhof@ost.ch> | 2025-03-26 10:08:40 +0000 |
|---|---|---|
| committer | Fabian Imhof <fabian.imhof@ost.ch> | 2025-03-26 10:08:40 +0000 |
| commit | db555089dea369d9dd3010d1853077e7a4118b90 (patch) | |
| tree | 9925410344c36dc266b8a250b6ea8f13681f44bb /arch/x86_64/src | |
| parent | 96711d45ad7fb5b96cfd2b4fffda8756fe68fcd4 (diff) | |
| download | teachos-db555089dea369d9dd3010d1853077e7a4118b90.tar.xz teachos-db555089dea369d9dd3010d1853077e7a4118b90.zip | |
add llm suggestion to idt creation
Diffstat (limited to 'arch/x86_64/src')
| -rw-r--r-- | arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
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<uint64_t>(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 |
