:: commit d3c8a66918b585f49998d67cf3d7e14532ac627c

mintsuki <mintsuki@protonmail.com> — 2022-10-04 06:21

parents: b34954bb43

term: Misc fixes and improvements

diff --git a/common/drivers/vga_textmode.c b/common/drivers/vga_textmode.c
index 501d9006..9cabef49 100644
--- a/common/drivers/vga_textmode.c
+++ b/common/drivers/vga_textmode.c
@@ -255,7 +255,7 @@ static void text_deinit(struct term_context *_ctx, void (*_free)(void *, size_t)
 static struct textmode_context term_local_struct;
 
 void vga_textmode_init(bool managed) {
-    if (quiet || allocations_disallowed) {
+    if (quiet) {
         return;
     }
 
diff --git a/common/lib/gterm.c b/common/lib/gterm.c
index 6b9165c5..d61ace4c 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -536,14 +536,12 @@ static bool last_serial = false;
 static char *last_config = NULL;
 
 bool gterm_init(char *config, size_t width, size_t height) {
-    if (quiet || allocations_disallowed) {
+    if (quiet) {
         return false;
     }
 
-    if (current_video_mode >= 0
-#if defined (BIOS)
-     && current_video_mode != 0x03
-#endif
+    if (term != NULL
+     && term_backend == GTERM
      && fbinfo.default_res == true
      && width == 0
      && height == 0
@@ -554,10 +552,8 @@ bool gterm_init(char *config, size_t width, size_t height) {
         return true;
     }
 
-    if (current_video_mode >= 0
-#if defined (BIOS)
-     && current_video_mode != 0x03
-#endif
+    if (term != NULL
+     && term_backend == GTERM
      && fbinfo.framebuffer_width == width
      && fbinfo.framebuffer_height == height
      && fbinfo.framebuffer_bpp == 32
diff --git a/common/menu.c b/common/menu.c
index 33f99a1c..4dd07d41 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -564,7 +564,13 @@ static void menu_init_term(void) {
         if (menu_resolution != NULL)
             parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
 
-        gterm_init(NULL, req_width, req_height);
+        if (!gterm_init(NULL, req_width, req_height)) {
+#if defined (BIOS)
+            vga_textmode_init(true);
+#elif defined (UEFI)
+            panic(true, "menu: Failed to initialise terminal");
+#endif
+        }
     } else {
 #if defined (BIOS)
         vga_textmode_init(true);
@@ -847,11 +853,13 @@ timeout_aborted:
                 }
                 if (term_backend == FALLBACK) {
                     gterm_init(NULL, 0, 0);
+                    if (term == NULL) {
 #if defined (BIOS)
-                    if (term_backend == FALLBACK) {
                         vga_textmode_init(true);
-                    }
+#elif defined (UEFI)
+                        panic(true, "menu: Failed to initialise terminal");
 #endif
+                    }
                 } else {
                     reset_term();
                 }
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 1b67fee4..d23cbcf7 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -689,7 +689,7 @@ FEAT_START
         gterm_init(NULL, req_width, req_height);
     }
 
-    if (current_video_mode < 0) {
+    if (term == NULL) {
         panic(true, "limine: Failed to initialise terminal");
     }
 
tab: 248 wrap: offon