]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Added handlers for each one of the exceptions, instead of having generic ones, put...
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Sun, 12 Jun 2022 11:00:07 +0000 (13:00 +0200)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Sun, 12 Jun 2022 11:00:07 +0000 (13:00 +0200)
src/interrupts.S
src/interrupts.cpp
src/kernel.cpp

index 679a7f1dcf99290a09069f7e3a3a18a6fb4a4afa..3ef34473af18f6afd87289b373e95c2e95c27da2 100644 (file)
@@ -1,18 +1,36 @@
-#define PUSH_REGS pushq %rax;
-#define POP_REGS popq %rax;
+#define PUSH_REGS  \
+       pushq %rax; \
+       pushq %rcx; \
+       pushq %rdx; \
+       pushq %rsi; \
+       pushq %rdi; \
+       pushq %r8;  \
+       pushq %r9;  \
+       pushq %r10; \
+       pushq %r11;
+#define POP_REGS   \
+       popq %r11; \
+       popq %r10; \
+       popq %r9;  \
+       popq %r8;  \
+       popq %rdi; \
+       popq %rsi; \
+       popq %rdx; \
+       popq %rcx; \
+       popq %rax;
 
 #define HANDLER_ERRCODE(n, handler) \
 .globl handler_##n ;\
        handler_##n: ;\
        cli; \
        PUSH_REGS \
-       movl 8(%rsp), %edi ;\
+       movl 72(%rsp), %edi ;\
        call handler ;\
        movq $0xB0, %rdi;\
        movq $0, %rsi;\
        call set_APIC_reg_asm; \
-       POP_REGS \
        sti; \
+       POP_REGS \
        addq 4, %rsp;\
        iretq
 #define HANDLER_NOERRCODE(n, handler) \
        sti; \
        iretq
 
-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)
+HANDLER_NOERRCODE(0x00, int_div_by_0)
+HANDLER_NOERRCODE(0x01, int_debug)
+HANDLER_NOERRCODE(0x02, int_NMI)
+HANDLER_NOERRCODE(0x03, int_breakpoint)
+HANDLER_NOERRCODE(0x04, int_overflow)
+HANDLER_NOERRCODE(0x05, int_bound_range_exceeded)
+HANDLER_NOERRCODE(0x06, int_invalid_opcode)
+HANDLER_NOERRCODE(0x07, int_device_not_available)
+HANDLER_ERRCODE  (0x08, int_double_fault)
+HANDLER_NOERRCODE(0x09, int_coprocessor_segment_overrun)
+HANDLER_ERRCODE  (0x0a, int_invalid_TSS)
+HANDLER_ERRCODE  (0x0b, int_segment_not_present)
+HANDLER_ERRCODE  (0x0c, int_stack_segment_fault)
+HANDLER_ERRCODE  (0x0d, int_general_protection_fault)
+HANDLER_ERRCODE  (0x0e, int_page_fault)
+HANDLER_NOERRCODE(0x0f, int_default)
+HANDLER_NOERRCODE(0x10, int_x87_floating_point_exception)
+HANDLER_ERRCODE  (0x11, int_alignment_check)
+HANDLER_NOERRCODE(0x12, int_machine_check)
+HANDLER_NOERRCODE(0x13, int_SIMD_floating_point_exception)
+HANDLER_NOERRCODE(0x14, int_virtualization_exception)
+HANDLER_ERRCODE  (0x15, int_control_protection_exception)
+HANDLER_NOERRCODE(0x16, int_default)
+HANDLER_NOERRCODE(0x17, int_default)
+HANDLER_NOERRCODE(0x18, int_default)
+HANDLER_NOERRCODE(0x19, int_default)
+HANDLER_NOERRCODE(0x1a, int_default)
+HANDLER_NOERRCODE(0x1b, int_default)
+HANDLER_NOERRCODE(0x1c, int_hypervisor_injection_exception)
+HANDLER_ERRCODE  (0x1d, int_VMM_communication_exception)
+HANDLER_ERRCODE  (0x1e, int_security_exception)
+HANDLER_NOERRCODE(0x1f, int_default)
index cd29ce976e9de21750ef16fa812424aaaf352a51..c80d7d19d6dcd526b224202970ac689cafeaee3f 100644 (file)
@@ -35,3 +35,115 @@ void os::set_APIC_reg(std::ptrdiff_t offset, std::uint32_t v) {
 extern "C" void set_APIC_reg_asm(std::ptrdiff_t offset, std::uint32_t v) {
        os::set_APIC_reg(offset, v);
 }
+
+
+extern "C" void int_div_by_0() {
+       os::print("Interrupt: Divide-by-0 error.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_debug() {
+       os::print("Interrupt: Debug.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_NMI() {
+       os::print("Interrupt: Non-maskable interrupt.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_breakpoint() {
+       os::print("Interrupt: Breakpoint.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_overflow() {
+       os::print("Interrupt: Overflow.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_bound_range_exceeded() {
+       os::print("Interrupt: Bound Range Exceeded.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_invalid_opcode() {
+       os::print("Interrupt: Invalid Opcode.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_device_not_available() {
+       os::print("Interrupt: Device Not Available.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_double_fault(std::uint32_t err_code) {
+       os::print("Interrupt: Double Fault.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_coprocessor_segment_overrun() {
+       os::print("Interrupt: Coprocessor Segment Overrun.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_invalid_TSS(std::uint32_t err_code) {
+       os::print("Interrupt: Invalid TSS.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_segment_not_present(std::uint32_t err_code) {
+       os::print("Interrupt: Segment Not Present.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_stack_segment_fault(std::uint32_t err_code) {
+       os::print("Interrupt: Stack-Segment Fault.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_general_protection_fault(std::uint32_t err_code) {
+       os::print("Interrupt: General Protection Fault.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_page_fault(std::uint32_t err_code) {
+       os::print("Interrupt: Page Fault.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_x87_floating_point_exception() {
+       os::print("Interrupt: x87 Floating-Point Exception.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_alignment_check(std::uint32_t err_code) {
+       os::print("Interrupt: Alignment Check.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_machine_check() {
+       os::print("Interrupt: Machine Check.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_SIMD_floating_point_exception() {
+       os::print("Interrupt: SIMD Floating-Point Exception.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_virtualization_exception() {
+       os::print("Interrupt: Virtualization Exception.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_control_protection_exception(std::uint32_t err_code) {
+       os::print("Interrupt: Control Protection Exception.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_hypervisor_injection_exception() {
+       os::print("Interrupt: Hypervisor Injection Exception.\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_VMM_communication_exception(std::uint32_t err_code) {
+       os::print("Interrupt: VMM Communication Exception.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_security_exception(std::uint32_t err_code) {
+       os::print("Interrupt: Security Exception.\n");
+       os::print("Err code: "); os::print(err_code); os::print(".\n");
+       while (true) { os::hlt(); }
+}
+extern "C" void int_default() {
+       os::print("Interrupt: Unknown interrupt.\n");
+       while (true) { os::hlt(); }
+}
index 3994028a90a67b651ffed4a8acb84a1c37f5dc72..fe6a38c0e6e8afb4bb39226c303a346ca33ce934 100644 (file)
@@ -29,20 +29,6 @@ void remove_some_mem(os::phys_ptr<os::paging::page> mem_start,
 }
 
 os::idt<32> idt;
-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<const multiboot2::info_start> info) {
        os::assert(magic == 0x36D76289, "Incorrect magic number: wasn't booted with multiboot2.");