diff options
author | Ian Moffett <ian@osmora.org> | 2025-06-29 03:35:39 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-06-29 03:35:39 -0400 |
commit | c1fa9c578fa6c6b329aeb7118afb55306134a301 (patch) | |
tree | bf9c85eb22b88c3dc5abb4b0fc392ad043ae6fd5 /sys | |
parent | c5c72e3906eb4ea73b0df1e63ab8b2c0fb0c1d45 (diff) |
kernel: panic: Implement fresh panic screenexpt
Clear the screen and tweak console foreground/background to urgent
looking colors during a system panic
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_panic.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/sys/kern/kern_panic.c b/sys/kern/kern_panic.c index 703dba9..099f620 100644 --- a/sys/kern/kern_panic.c +++ b/sys/kern/kern_panic.c @@ -31,6 +31,7 @@ #include <sys/spinlock.h> #include <sys/syslog.h> #include <sys/reboot.h> +#include <dev/cons/cons.h> #include <machine/cdefs.h> #include <machine/cpu.h> @@ -53,10 +54,35 @@ bas(bool do_trace, int reboot_type) md_backtrace(); } + kprintf(OMIT_TIMESTAMP "\n-- ALL CORES HAVE BEEN HALTED --\n"); cpu_reboot(reboot_type); __builtin_unreachable(); } +static void +panic_screen(void) +{ + struct cons_screen *scr = &g_root_scr; + + if (scr->fb_mem != NULL) { + scr->bg = 0x8B0000; + scr->fg = 0xAABBAA; + cons_reset_cursor(scr); + cons_clear_scr(scr, 0x393B39); + } +} + +static void +do_panic(const char *fmt, va_list *ap) +{ + syslog_silence(false); + kprintf(OMIT_TIMESTAMP "panic: "); + vkprintf(fmt, ap); + bas(true, REBOOT_HALT); + + __builtin_unreachable(); +} + /* * Tells the user something terribly wrong happened then * halting the system as soon as possible. @@ -75,11 +101,9 @@ panic(const char *fmt, ...) md_intoff(); cpu_halt_others(); + panic_screen(); va_start(ap, fmt); - kprintf(OMIT_TIMESTAMP "\npanic: "); - vkprintf(fmt, &ap); - bas(true, REBOOT_HALT); - + do_panic(fmt, &ap); __builtin_unreachable(); } |