Make kprintf_internal so panic.h can use it.

This commit is contained in:
Liam Kerr 2026-02-10 13:22:12 +00:00
parent b4d5f8f6eb
commit 663c2712fd
6 changed files with 75 additions and 63 deletions

View file

@ -1,5 +1,6 @@
#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <drivers/uart.h>
#include <syscon/syscon.h>
#include <kernel/plic.h>
@ -21,11 +22,14 @@ void interrupt_init()
kputs("OK");
}
void kpanic(const char *reason)
void kpanic(const char *reason, ...)
{
va_list args;
va_start(args, reason);
kputs("\n!!! PANIC !!!\n");
kputs(reason);
kprintf_internal(reason, args);
kputs("\n!!! PANIC !!!\n");
va_end(args);
poweroff();
}
@ -80,7 +84,7 @@ void handle_trap()
kpanic("Reason: Illegal Instruction\n");
break;
case 3:
kpanic("Reason: Breakpoint (ebreak)\n");
kpanic("Reason: Breakpoint (ebreak) %s\n", "woo!");
break;
case 4:
kpanic("Reason: Load Address Misaligned\n");
@ -96,7 +100,7 @@ void handle_trap()
break;
default:
break;
// kpanic("Reason: Unknown Exception Code %d\n", cause);
kpanic("Reason: Unknown Exception Code %d\n", cause);
}
kprintf("Faulting Address (if applicable): %x\n", mtval);
}

View file

@ -2,7 +2,7 @@
#define PANIC_H
void interrupt_init();
void kpanic(const char *);
void kpanic(const char *, ...);
void kpanic_force();
void handle_interrupt(unsigned long code);

View file

@ -16,4 +16,6 @@ void kmain()
uart_init();
page_init();
interrupt_init();
kpanic_force();
}