:: commit 18d8598e576ce28bccb51d4242fccd3e1780c650

mintsuki <mintsuki@protonmail.com> — 2022-09-15 11:31

parents: e645f83efd

efi: Ensure panics are (hopefully) always visible

diff --git a/common/lib/panic.s2.c b/common/lib/panic.s2.c
index 114e1ca6..8f869682 100644
--- a/common/lib/panic.s2.c
+++ b/common/lib/panic.s2.c
@@ -29,14 +29,22 @@ noreturn void panic(bool allow_menu, const char *fmt, ...) {
 
     is_nested = true;
 
-    if (
 #if defined (BIOS)
-      stage3_loaded == true &&
-#endif
-      term_backend == NOT_READY) {
+    if (stage3_loaded == true && term_backend == NOT_READY) {
         early_term = true;
         term_vbe(NULL, 0, 0);
     }
+#endif
+
+#if defined (UEFI)
+    if (term_backend == NOT_READY) {
+        if (term_enabled_once) {
+            term_vbe(NULL, 0, 0);
+        } else {
+            term_fallback();
+        }
+    }
+#endif
 
 nested:
     if (term_backend == NOT_READY) {
diff --git a/common/lib/term.c b/common/lib/term.c
index ba80a061..97e222ab 100644
--- a/common/lib/term.c
+++ b/common/lib/term.c
@@ -109,6 +109,8 @@ void term_vbe(char *config, size_t width, size_t height) {
     term_context_restore = gterm_context_restore;
     term_full_refresh = gterm_full_refresh;
 
+    term_enabled_once = true;
+
     term_backend = VBE;
 }
 
@@ -220,6 +222,8 @@ void term_textmode(void) {
     term_context_restore = text_context_restore;
     term_full_refresh = text_full_refresh;
 
+    term_enabled_once = true;
+
     term_backend = TEXTMODE;
 }
 #endif
diff --git a/common/lib/term.h b/common/lib/term.h
index 4305ab77..abf39136 100644
--- a/common/lib/term.h
+++ b/common/lib/term.h
@@ -50,6 +50,7 @@ extern int term_backend;
 extern size_t term_rows, term_cols;
 extern bool term_runtime;
 extern bool early_term;
+extern bool term_enabled_once;
 
 void term_fallback(void);
 
diff --git a/common/lib/term.s2.c b/common/lib/term.s2.c
index 7da107d1..2c6081d6 100644
--- a/common/lib/term.s2.c
+++ b/common/lib/term.s2.c
@@ -11,6 +11,7 @@ no_unwind int current_video_mode = -1;
 int term_backend = NOT_READY;
 size_t term_rows, term_cols;
 bool term_runtime = false;
+bool term_enabled_once = false;
 
 void (*raw_putchar)(uint8_t c);
 void (*clear)(bool move);
tab: 248 wrap: offon