diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-03-31 15:20:27 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-03-31 15:20:27 +0000 |
| commit | 40cfa485cc2c9e344a0386419ed55c123312ec32 (patch) | |
| tree | da745d26684556b19a38d4a9186820d093fe0b5a /arch/x86_64/src | |
| parent | e8fb1d771d9aa4d1cb5b18cd0483c7e5731aeecc (diff) | |
| download | teachos-40cfa485cc2c9e344a0386419ed55c123312ec32.tar.xz teachos-40cfa485cc2c9e344a0386419ed55c123312ec32.zip | |
Add missing flag to idt entry.
Diffstat (limited to 'arch/x86_64/src')
| -rw-r--r-- | arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp | 21 |
1 files changed, 13 insertions, 8 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 db3351e..b520a57 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 @@ -10,15 +10,20 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table { auto create_interrupt_descriptor_table() -> interrupt_descriptor_table { - // @MTO: This address resolution is most certainly wrong -> numbers in dbg seem off (offset_3 = 0) - uint64_t offset = reinterpret_cast<uint64_t>(&interrupt_handling::generic_interrupt_handler); - segment_selector selector{0U, segment_selector::REQUEST_LEVEL_KERNEL}; + // TODO: See 7.14 Vol. 3A Page 3299 Intel Manual, still crashes from time to time on setting interrupt flag? + // Probably an interrupt is generated but the interrupt descriptor table is not in a valid form and does not + // handle the interrupt. + interrupt_descriptor_table interrupt_descriptor_table{256}; + + uint64_t offset = 0U; + segment_selector selector{1U, segment_selector::REQUEST_LEVEL_KERNEL}; ist_offset ist{0U}; - idt_flags flags{idt_flags::DESCRIPTOR_LEVEL_KERNEL | idt_flags::PRESENT}; - gate_descriptor descriptor{selector, ist, flags, offset}; + idt_flags flags{idt_flags::DESCRIPTOR_LEVEL_KERNEL | idt_flags::INTERRUPT_GATE | idt_flags::PRESENT}; - // Interrupt Descriptor Table needs to be kept alive - static interrupt_descriptor_table interrupt_descriptor_table{descriptor}; + for (std::size_t i = 0; i < 256; i++) + { + interrupt_descriptor_table.at(i) = {selector, ist, flags, offset}; + } return interrupt_descriptor_table; } } // namespace @@ -32,7 +37,7 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table auto update_interrupt_descriptor_table_register() -> void { - static auto idt = get_or_create_interrupt_descriptor_table(); + decltype(auto) idt = get_or_create_interrupt_descriptor_table(); interrupt_descriptor_table_pointer idt_pointer{static_cast<uint16_t>((idt.size() * sizeof(gate_descriptor)) - 1), idt.data()}; |
