]> git.ameliathe1st.gay Git - voyage-au-centre-des-fichiers.git/commitdiff
Differentiated the interrupts between those that have error codes and those that...
authorAmelia Coutard <eliottulio.coutard@gmail.com>
Tue, 7 Jun 2022 01:19:34 +0000 (03:19 +0200)
committerAmelia Coutard <eliottulio.coutard@gmail.com>
Tue, 7 Jun 2022 01:19:34 +0000 (03:19 +0200)
src/interrupts.S
src/interrupts.cpp
src/kernel.cpp

index c9ee3edbd237538dc36a77445e06341d4d0dc9fa..679a7f1dcf99290a09069f7e3a3a18a6fb4a4afa 100644 (file)
@@ -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)
index 717667336746435b03ed899c343ad5f94edf0bf6..cd29ce976e9de21750ef16fa812424aaaf352a51 100644 (file)
@@ -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);
+}
index c8b780b12bf1bf234e460cc095e172b327577cde..7e1ab9381975e4dca0579b739cb7f8597c38ebd4 100644 (file)
@@ -33,10 +33,19 @@ os::paging::page_allocator page_allocator(os::phys_ptr<os::paging::page>(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<const multiboot2::info_start> info) {