diff options
Diffstat (limited to 'src/arch/amd64/idt.c')
-rw-r--r-- | src/arch/amd64/idt.c | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/src/arch/amd64/idt.c b/src/arch/amd64/idt.c index a2ee2a7..d33c795 100644 --- a/src/arch/amd64/idt.c +++ b/src/arch/amd64/idt.c @@ -1,7 +1,6 @@ #include <stdint.h> #include <stddef.h> #include <lib.h> -#include <serial.h> #include <panic.h> #include "debugger.h" @@ -74,48 +73,48 @@ void idt_init(void) { // Intel manual vol 3 ch 6.3.1 char *EXCEPTIONS[] = { - "0x00 Division Error", - "0x01 Debug", - "0x02 NMI", - "0x03 Breakpoint", - "0x04 Overflow", - "0x05 BOUND Range Exceeded", - "0x06 Invalid Opcode", - "0x07 Device Not Available", - "0x08 Double Fault", - "0x09 Coprocessor Segment Overrun", - "0x0A Invalid TSS", - "0x0B Segment Not Present", - "0x0C Stack-Segment Fault", - "0x0D General Protection Fault", - "0x0E Page Fault", - "0x0F Reserved", - "0x10 x87 Floating-Point Error", - "0x11 Alignment Check", - "0x12 Machine Check", - "0x13 SIMD Floaing-Point Exception", - "0x14 Virtualization Exception", - "0x15 Control Protection Exception", - "0x16 Reserved", - "0x17 Reserved", - "0x18 Reserved", - "0x19 Reserved", - "0x1A Reserved", - "0x1B Reserved", - "0x1C Hypervisor Injection Exception", - "0x1D VMM Communication Exception", - "0x1E Security Exception", - "0x1F Reserved", + "Division Error", + "Debug", + "NMI", + "Breakpoint", + "Overflow", + "BOUND Range Exceeded", + "Invalid Opcode", + "Device Not Available", + "Double Fault", + "Coprocessor Segment Overrun", + "Invalid TSS", + "Segment Not Present", + "Stack-Segment Fault", + "General Protection Fault", + "Page Fault", + "Reserved", + "x87 Floating-Point Error", + "Alignment Check", + "Machine Check", + "SIMD Floaing-Point Exception", + "Virtualization Exception", + "Control Protection Exception", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Reserved", + "Hypervisor Injection Exception", + "VMM Communication Exception", + "Security Exception", + "Reserved", }; void idt_exception_handler(uint64_t exception, uint64_t code, struct isr_regs *state) { - // breakpoint interrupt - if (exception == 0x03) { - debugger(state, DEBUG_INT3); - return; - } else if (exception == 0x01) { + switch (exception) { + case 0x01: // debug debugger(state, DEBUG_DBG); return; + case 0x03: // breakpoint + debugger(state, DEBUG_INT3); + return; } char custom[64]; @@ -124,12 +123,12 @@ void idt_exception_handler(uint64_t exception, uint64_t code, struct isr_regs *s // page faults store the offending address in cr2 if (exception == 0x0E) { strcat(custom, "\nPage fault address: 0x"); - void *addr; - __asm__ volatile ("mov %%cr2, %0" : "=r"(addr)); - ultoa((size_t)addr, custom + 23, 16); + uint64_t cr2; + __asm__ volatile ("mov %%cr2, %0" : "=r"(cr2)); + ultoa((size_t)cr2, custom + 23, 16); } - _panic_interrupt( + panic_interrupt( (void *)state->rip, (void *)state->rbp, "Exception %s\nError code 0x%lu%s", @@ -149,7 +148,7 @@ void idt_pic_timer(void) { // print a message once we know the timer works // but avoid spamming the logs if (counter == 3) { - serial_out_str("pic timer!\n"); + kputs("pic timer!\n"); } if (counter <= 3) { counter++; |