diff options
Diffstat (limited to 'src/arch/amd64/idt.c')
-rw-r--r-- | src/arch/amd64/idt.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/arch/amd64/idt.c b/src/arch/amd64/idt.c index c0ea5a8..a2ee2a7 100644 --- a/src/arch/amd64/idt.c +++ b/src/arch/amd64/idt.c @@ -118,26 +118,25 @@ void idt_exception_handler(uint64_t exception, uint64_t code, struct isr_regs *s return; } - // TODO don't just panic - char buf[24]; - char msg[256] = "Exception "; - - strcat(msg, EXCEPTIONS[exception]); - - strcat(msg, "\nError code 0x"); - ultoa(code, buf, 16); - strcat(msg, buf); + char custom[64]; + *custom = '\0'; // page faults store the offending address in cr2 if (exception == 0x0E) { - strcat(msg, "\nPage fault address: 0x"); + strcat(custom, "\nPage fault address: 0x"); void *addr; __asm__ volatile ("mov %%cr2, %0" : "=r"(addr)); - ultoa((size_t)addr, buf, 16); - strcat(msg, buf); + ultoa((size_t)addr, custom + 23, 16); } - panic_interrupt((void *)state->rip, (void *)state->rbp, msg); + _panic_interrupt( + (void *)state->rip, + (void *)state->rbp, + "Exception %s\nError code 0x%lu%s", + EXCEPTIONS[exception], + code, + custom + ); } void idt_pic_eoi(uint8_t exception) { |