diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/machdep.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/conf/GENERIC | 1 | ||||
-rw-r--r-- | sys/kern/kern_panic.c | 27 |
3 files changed, 29 insertions, 5 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 9b65d6e..af00c5a 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -44,6 +44,8 @@ #include <machine/intr.h> #include <machine/cdefs.h> #include <machine/isa/i8042var.h> +#include <dev/cons/cons.h> +#include <string.h> #define pr_trace(fmt, ...) kprintf("cpu: " fmt, ##__VA_ARGS__) #define pr_error(...) pr_trace(__VA_ARGS__) @@ -224,6 +226,7 @@ md_backtrace(void) uintptr_t rip; off_t off; const char *name; + char line[256]; __ASMV("mov %%rbp, %0" : "=r" (rbp) :: "memory"); while (1) { @@ -236,7 +239,8 @@ md_backtrace(void) if (name == NULL) name = "???"; - kprintf(OMIT_TIMESTAMP "%p @ <%s+0x%x>\n", rip, name, off); + snprintf(line, sizeof(line), "%p @ <%s+0x%x>\n", rip, name, off); + cons_putstr(&g_root_scr, line, strlen(line)); } } diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index 44ab8b5..95fe2e0 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -9,6 +9,7 @@ option SPECTRE_IBRS no // Enable the IBRS CPU feature option SERIAL_DEBUG yes // Enable kmsg serial logging option USER_KMSG no // Show kmsg in user consoles option CPU_SMEP yes // Supervisor Memory Exec Protection +option PANIC_SCR no // Clear screen on panic // Kernel constants setval SCHED_NQUEUE 4 // Number of scheduler queues (for MLFQ) diff --git a/sys/kern/kern_panic.c b/sys/kern/kern_panic.c index 099f620..13b4964 100644 --- a/sys/kern/kern_panic.c +++ b/sys/kern/kern_panic.c @@ -34,6 +34,22 @@ #include <dev/cons/cons.h> #include <machine/cdefs.h> #include <machine/cpu.h> +#include <string.h> + +#if defined(__PANIC_SCR) +#define PANIC_SCR __PANIC_SCR +#else +#define PANIC_SCR 0 +#endif + +static void +panic_puts(const char *str) +{ + size_t len; + + len = strlen(str); + cons_putstr(&g_root_scr, str, len); +} /* * Burn and sizzle - the core logic that really ends @@ -50,11 +66,11 @@ bas(bool do_trace, int reboot_type) spinlock_acquire(&lock); /* Never released */ if (do_trace) { - kprintf(OMIT_TIMESTAMP "** backtrace\n"); + panic_puts(" ** backtrace\n"); md_backtrace(); } - kprintf(OMIT_TIMESTAMP "\n-- ALL CORES HAVE BEEN HALTED --\n"); + panic_puts("\n-- ALL CORES HAVE BEEN HALTED --\n"); cpu_reboot(reboot_type); __builtin_unreachable(); } @@ -76,7 +92,8 @@ static void do_panic(const char *fmt, va_list *ap) { syslog_silence(false); - kprintf(OMIT_TIMESTAMP "panic: "); + spinlock_release(&g_root_scr.lock); + panic_puts("panic: "); vkprintf(fmt, ap); bas(true, REBOOT_HALT); @@ -101,7 +118,9 @@ panic(const char *fmt, ...) md_intoff(); cpu_halt_others(); - panic_screen(); + if (PANIC_SCR) { + panic_screen(); + } va_start(ap, fmt); do_panic(fmt, &ap); __builtin_unreachable(); |