aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/x86_64/src/context_switching/interrupt_descriptor_table/interrupt_descriptor_table.cpp21
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()};