diff options
6 files changed, 19 insertions, 16 deletions
diff --git a/arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp b/arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp index 9f33fa0..d828c50 100644 --- a/arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp +++ b/arch/x86_64/include/arch/interrupt_handling/generic_interrupt_handler.hpp @@ -13,11 +13,12 @@ namespace teachos::arch::interrupt_handling */ struct interrupt_frame { - uint64_t ip; ///< Dummy - uint64_t cs; ///< Dummy - uint64_t flags; ///< Dummy - uint64_t sp; ///< Dummy - uint64_t ss; ///< Dummy + uint64_t error_code; ///< Error Code (TODO: Potential mistake -> some interrupts contain this field and some dont?) + uint64_t ip; ///< Instruction pointer + uint64_t cs; ///< Code segment + uint64_t flags; ///< RFLAGS + uint64_t sp; ///< Stack pointer + uint64_t ss; ///< Stack segment }; [[gnu::interrupt]] diff --git a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp index 730bcaf..0a25ca9 100644 --- a/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp +++ b/arch/x86_64/include/arch/memory/multiboot/elf_symbols_section.hpp @@ -20,7 +20,7 @@ namespace teachos::arch::memory::multiboot INACTIVE, ///< (SHT_NULL) Unused, meaning all values are zeroed out. PROGRAMM, ///< (SHT_PROGBITS) Program data (DATA, CODE). SYMBOL_TABLE, ///< (SHT_SYMBTAB) Contains actual entries pointed to in symbol hash table. - STRING_TABLE, ///< (SHT_STRTAB) Contains symbols, section and deubbging null-terminated strings. + STRING_TABLE, ///< (SHT_STRTAB) Contains symbols, section and debugging null-terminated strings. RELOCATION_ENTRY_WITH_ADDENDS, ///< (SHT_RELA) Only used on 64 bit systems. SYMBOL_HASH_TABLE, ///< (SHT_HASH) Hash table used by dynamic linker to locate symbols. DYNAMIC, ///< (SHT_DYNAMIC) Contains dynamic linking information. diff --git a/arch/x86_64/scripts/kernel.ld b/arch/x86_64/scripts/kernel.ld index cc07896..806adb5 100644 --- a/arch/x86_64/scripts/kernel.ld +++ b/arch/x86_64/scripts/kernel.ld @@ -90,6 +90,11 @@ SECTIONS *(.text*) } + .interrupt_text ALIGN(4K) : AT(ADDR (.interrupt_text)) + { + *(.interrupt_text) + } + .rodata ALIGN(4K) : AT (ADDR (.rodata)) { *(.rodata) 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 b520a57..82114b4 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,20 +10,19 @@ namespace teachos::arch::context_switching::interrupt_descriptor_table { auto create_interrupt_descriptor_table() -> interrupt_descriptor_table { - // 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}; + // Only account for the reserved Vectors for now (0 - 31) + interrupt_descriptor_table interrupt_descriptor_table{32}; - uint64_t offset = 0U; - segment_selector selector{1U, segment_selector::REQUEST_LEVEL_KERNEL}; + uint64_t offset = reinterpret_cast<uint64_t>(interrupt_handling::generic_interrupt_handler); + segment_selector selector{2U, segment_selector::REQUEST_LEVEL_KERNEL}; ist_offset ist{0U}; idt_flags flags{idt_flags::DESCRIPTOR_LEVEL_KERNEL | idt_flags::INTERRUPT_GATE | idt_flags::PRESENT}; - for (std::size_t i = 0; i < 256; i++) + for (std::size_t i = 0; i < 32; i++) { interrupt_descriptor_table.at(i) = {selector, ist, flags, offset}; } + return interrupt_descriptor_table; } } // namespace diff --git a/arch/x86_64/src/context_switching/main.cpp b/arch/x86_64/src/context_switching/main.cpp index 2b853ec..ac53735 100644 --- a/arch/x86_64/src/context_switching/main.cpp +++ b/arch/x86_64/src/context_switching/main.cpp @@ -22,8 +22,6 @@ namespace teachos::arch::context_switching segment_descriptor_table::update_task_state_segment_register(); - // FIXME: We currently cannot enable interrupts, since for some reason, we will later run into what looks like a GP - // and triple fault. kernel::cpu::set_interrupt_flag(); descriptor_tables tables = {segment_descriptor_table::get_or_create_global_descriptor_table(), diff --git a/arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp b/arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp index 2f599e5..4392b04 100644 --- a/arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp +++ b/arch/x86_64/src/interrupt_handling/generic_interrupt_handler.cpp @@ -5,7 +5,7 @@ namespace teachos::arch::interrupt_handling { - [[gnu::interrupt]] + [[gnu::interrupt]] [[gnu::section(".interrupt_text")]] auto generic_interrupt_handler(interrupt_frame * frame) -> void { (void)frame; |
