Improved panic messaging

This commit is contained in:
Liam Kerr 2026-02-09 02:48:27 +00:00
parent cee1760a5b
commit 6208ae369d

View file

@ -10,10 +10,17 @@ void handle_trap() {
unsigned long cause;
__asm__ volatile("csrr %0, mcause" : "=r"(cause));
if (cause == 3) { // 3 is the code for 'breakpoint' (ebreak)
kprint("Reason: ebreak (Breakpoint)\n");
} else {
kprint("Reason: Other Exception\n");
switch(cause) {
case 0: kprint("Reason: Instruction Address Misaligned\n"); break;
case 1: kprint("Reason: Instruction Access Fault\n"); break;
case 2: kprint("Reason: Illegal Instruction\n"); break;
case 3: kprint("Reason: Breakpoint (ebreak)\n"); break;
case 4: kprint("Reason: Load Address Misaligned\n"); break;
case 5: kprint("Reason: Load Access Fault\n"); break;
case 6: kprint("Reason: Store/AMO Address Misaligned\n"); break;
case 7: kprint("Reason: Store/AMO Access Fault\n"); break;
default:
kprintf("Reason: Unknown Exception Code %d\n", cause);
}
poweroff();