From: Amelia Coutard Date: Tue, 7 Jun 2022 01:19:34 +0000 (+0200) Subject: Differentiated the interrupts between those that have error codes and those that... X-Git-Url: https://git.ameliathe1st.gay/?a=commitdiff_plain;h=0c84d85616b57f4db9239d0c61a9ca596594ac09;p=voyage-au-centre-des-fichiers.git Differentiated the interrupts between those that have error codes and those that don't --- diff --git a/src/interrupts.S b/src/interrupts.S index c9ee3ed..679a7f1 100644 --- a/src/interrupts.S +++ b/src/interrupts.S @@ -1,41 +1,62 @@ -#define HANDLER(n) .globl handler_##n ;\ +#define PUSH_REGS pushq %rax; +#define POP_REGS popq %rax; + +#define HANDLER_ERRCODE(n, handler) \ +.globl handler_##n ;\ + handler_##n: ;\ + cli; \ + PUSH_REGS \ + movl 8(%rsp), %edi ;\ + call handler ;\ + movq $0xB0, %rdi;\ + movq $0, %rsi;\ + call set_APIC_reg_asm; \ + POP_REGS \ + sti; \ + addq 4, %rsp;\ + iretq +#define HANDLER_NOERRCODE(n, handler) \ +.globl handler_##n ;\ handler_##n: ;\ - mov $n, %rdi ;\ - call handler_impl ;\ - cli ;\ -1: hlt ;\ - jmp 1b ;\ + cli; \ + PUSH_REGS \ + call handler ;\ + movq $0xB0, %rdi;\ + movq $0, %rsi;\ + call set_APIC_reg_asm; \ + POP_REGS \ + sti; \ iretq -HANDLER(0x00) -HANDLER(0x01) -HANDLER(0x02) -HANDLER(0x03) -HANDLER(0x04) -HANDLER(0x05) -HANDLER(0x06) -HANDLER(0x07) -HANDLER(0x08) -HANDLER(0x09) -HANDLER(0x0a) -HANDLER(0x0b) -HANDLER(0x0c) -HANDLER(0x0d) -HANDLER(0x0e) -HANDLER(0x0f) -HANDLER(0x10) -HANDLER(0x11) -HANDLER(0x12) -HANDLER(0x13) -HANDLER(0x14) -HANDLER(0x15) -HANDLER(0x16) -HANDLER(0x17) -HANDLER(0x18) -HANDLER(0x19) -HANDLER(0x1a) -HANDLER(0x1b) -HANDLER(0x1c) -HANDLER(0x1d) -HANDLER(0x1e) -HANDLER(0x1f) +HANDLER_NOERRCODE(0x00, handler_impl_no_code) +HANDLER_NOERRCODE(0x01, handler_impl_no_code) +HANDLER_NOERRCODE(0x02, handler_impl_no_code) +HANDLER_NOERRCODE(0x03, handler_impl_no_code) +HANDLER_NOERRCODE(0x04, handler_impl_no_code) +HANDLER_NOERRCODE(0x05, handler_impl_no_code) +HANDLER_NOERRCODE(0x06, handler_impl_no_code) +HANDLER_NOERRCODE(0x07, handler_impl_no_code) +HANDLER_ERRCODE (0x08, handler_impl_code) +HANDLER_NOERRCODE(0x09, handler_impl_no_code) +HANDLER_ERRCODE (0x0a, handler_impl_code) +HANDLER_ERRCODE (0x0b, handler_impl_code) +HANDLER_ERRCODE (0x0c, handler_impl_code) +HANDLER_ERRCODE (0x0d, handler_impl_code) +HANDLER_ERRCODE (0x0e, handler_impl_code) +HANDLER_NOERRCODE(0x0f, handler_impl_no_code) +HANDLER_NOERRCODE(0x10, handler_impl_no_code) +HANDLER_ERRCODE (0x11, handler_impl_code) +HANDLER_NOERRCODE(0x12, handler_impl_no_code) +HANDLER_NOERRCODE(0x13, handler_impl_no_code) +HANDLER_NOERRCODE(0x14, handler_impl_no_code) +HANDLER_ERRCODE (0x15, handler_impl_code) +HANDLER_NOERRCODE(0x16, handler_impl_no_code) +HANDLER_NOERRCODE(0x17, handler_impl_no_code) +HANDLER_NOERRCODE(0x18, handler_impl_no_code) +HANDLER_NOERRCODE(0x19, handler_impl_no_code) +HANDLER_NOERRCODE(0x1a, handler_impl_no_code) +HANDLER_NOERRCODE(0x1b, handler_impl_no_code) +HANDLER_NOERRCODE(0x1c, handler_impl_no_code) +HANDLER_ERRCODE (0x1d, handler_impl_code) +HANDLER_ERRCODE (0x1e, handler_impl_code) +HANDLER_NOERRCODE(0x1f, handler_impl_no_code) diff --git a/src/interrupts.cpp b/src/interrupts.cpp index 7176673..cd29ce9 100644 --- a/src/interrupts.cpp +++ b/src/interrupts.cpp @@ -32,3 +32,6 @@ std::uint32_t os::get_APIC_reg(std::ptrdiff_t offset) { void os::set_APIC_reg(std::ptrdiff_t offset, std::uint32_t v) { get_APIC_base()[offset / 4] = v; } +extern "C" void set_APIC_reg_asm(std::ptrdiff_t offset, std::uint32_t v) { + os::set_APIC_reg(offset, v); +} diff --git a/src/kernel.cpp b/src/kernel.cpp index c8b780b..7e1ab93 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -33,10 +33,19 @@ os::paging::page_allocator page_allocator(os::phys_ptr(reinter os::idt<32> idt; -extern "C" void handler_impl(std::uint8_t id) { - os::print("Interrupt #"); - os::print(id); - os::print(" !\n"); +extern "C" void handler_impl_code(std::uint32_t err_code) { + os::println("Interrupt !"); + os::print("Err code: "); os::print(err_code); os::println("."); + while (true) { + os::hlt(); + } +} +extern "C" void handler_impl_no_code() { + os::println("Interrupt !"); + os::println("No error code."); + while (true) { + os::hlt(); + } } extern "C" void kmain(unsigned long magic, os::phys_ptr info) {