diff options
author | Danny Holman <dholman@gymli.org> | 2024-02-24 14:44:38 -0600 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2024-02-24 14:44:38 -0600 |
commit | 2ce0f8af51dae9e7d591ff5fd038f89d6ca9dbbe (patch) | |
tree | 314f6105fc2996923070ed7f82c3acc8d5b2b20c /arch/i386/boot/idt.c | |
parent | arch: i386: move jump_userspace to its own file (diff) | |
download | box-2ce0f8af51dae9e7d591ff5fd038f89d6ca9dbbe.tar.gz box-2ce0f8af51dae9e7d591ff5fd038f89d6ca9dbbe.tar.zst box-2ce0f8af51dae9e7d591ff5fd038f89d6ca9dbbe.zip |
arch: i386: cleanup everything and reorganize
Clean up everything in the i386 arch directory. This code has been in
dire need of refactoring for a long while. All the inline assembly
functions and the data structures related to the architecture should be
placed into their own header file. Now the scheduler can access
registers and ISRs without having to deal with arch-specific code.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to '')
-rw-r--r-- | arch/i386/kernel/idt.c (renamed from arch/i386/boot/idt.c) | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/arch/i386/boot/idt.c b/arch/i386/kernel/idt.c index 7b9401d..5c0766c 100644 --- a/arch/i386/boot/idt.c +++ b/arch/i386/kernel/idt.c @@ -1,7 +1,8 @@ +#include <kernel/idt.h> #include <kernel/syscall.h> #include <kernel/panic.h> #include <kernel/gdt.h> -#include <kernel/isr.h> +#include <kernel/asm.h> #include <kernel/io.h> #include <kernel/pic.h> #include <kernel/string.h> @@ -44,51 +45,40 @@ const char* exceptions[] = { "RESERVED" }; -__attribute__((noreturn)) -void halt_catch_fire(struct isr_frame *frame) { - dump_reg(frame); - kprintf("ERRNO=%x\n", frame->errno); - __asm__ volatile("cli;hlt"); - while (1); -} - -void exception_handler(struct isr_frame *frame) { - switch (frame->vector) { +void exception_handler(struct regs *regs) { + switch (regs->isr_vector) { case 0x00: panic("Division by zero in kernel address space"); - halt_catch_fire(frame); + break; case 0x06: panic("Invalid opcode in kernel address space"); - halt_catch_fire(frame); + break; case 0x08: panic("Double fault in interrupt handler"); - halt_catch_fire(frame); + break; case 0x0D: panic("Protection fault in kernel address space"); - halt_catch_fire(frame); + break; case 0x0E: - page_fault_handler(frame); + page_fault_handler(regs); break; default: panic("Unhandled exception"); - halt_catch_fire(frame); } } -void interrupt_handler(struct isr_frame frame) { - if (frame.vector < 32) { - exception_handler(&frame); - } else if (frame.vector < 48) { - irq_dispatch(&frame); +void interrupt_handler(struct regs regs) { + if (regs.isr_vector < 32) { + exception_handler(®s); + } else if (regs.isr_vector < 48) { + irq_dispatch(®s); } else { - switch (frame.vector) { + switch (regs.isr_vector) { case 0x80: - handle_syscall(&frame); + handle_syscall(®s); break; default: panic("Unmapped interrupt"); - halt_catch_fire(&frame); - __asm__ volatile("cli;hlt"); } } } |