:: commit 56d50b80b47fc2bc61e26e68587f896ccb556463

mintsuki <mintsuki@protonmail.com> — 2021-10-29 23:58

parents: 04f30a48cb

panic: Initialise a terminal backend if term is not ready

diff --git a/stage23/lib/panic.s2.c b/stage23/lib/panic.s2.c
index 1094b99e..d444523d 100644
--- a/stage23/lib/panic.s2.c
+++ b/stage23/lib/panic.s2.c
@@ -7,6 +7,7 @@
 #include <lib/blib.h>
 #include <lib/readline.h>
 #include <lib/gterm.h>
+#include <lib/term.h>
 #include <mm/pmm.h>
 
 __attribute__((noreturn)) void panic(const char *fmt, ...) {
@@ -14,6 +15,14 @@ __attribute__((noreturn)) void panic(const char *fmt, ...) {
 
     va_start(args, fmt);
 
+    if (term_backend == NOT_READY) {
+#if bios == 1
+        term_textmode();
+#elif uefi == 1
+        term_vbe(0, 0);
+#endif
+    }
+
     print("\033[31mPANIC\033[37;1m\033[0m: ");
     vprint(fmt, args);
 
tab: 248 wrap: offon