diff options
author | Marvin Borner | 2019-10-18 22:28:39 +0200 |
---|---|---|
committer | Marvin Borner | 2019-10-18 22:28:39 +0200 |
commit | 00761c54b2a41007e611a2470669b334618152b9 (patch) | |
tree | 8aecb5d5d7203af4aad819803280a239daf60c98 /src/kernel/interrupts | |
parent | 17c6b30949ce7d4a293862ec8f9b873e17fe0cd8 (diff) |
Improved error logging and debugging possibilities
Diffstat (limited to 'src/kernel/interrupts')
-rw-r--r-- | src/kernel/interrupts/isr.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/kernel/interrupts/isr.c b/src/kernel/interrupts/isr.c index d4f2e3d..b615816 100644 --- a/src/kernel/interrupts/isr.c +++ b/src/kernel/interrupts/isr.c @@ -145,9 +145,28 @@ const char *exception_messages[] = { "Reserved" }; -// Master exception handler - halt via endless loop +// Master exception/interrupt/fault handler - halt via panic void fault_handler(struct regs *r) { if (r->int_no < 32) { + uint32_t faulting_address; + asm volatile("mov %%cr2, %0" : "=r" (faulting_address)); + + serial_write("\n[DEBUG]\nEIP: "); + serial_write_hex(r->eip); + serial_write("\nEAX: "); + serial_write_hex(r->eax); + serial_write("\nEBX: "); + serial_write_hex(r->ebx); + serial_write("\nECX: "); + serial_write_hex(r->ecx); + serial_write("\nEDX: "); + serial_write_hex(r->edx); + serial_write("\nFaulting address: "); + serial_write_hex(faulting_address); + serial_write("\nError flags: "); + serial_write_hex(r->eflags); + serial_write("\nError code: "); + serial_write_hex(r->err_code); char *message = (char *) exception_messages[r->int_no]; strcat(message, " Exception"); panic(message); |