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 0042d6e8..1b894f9e 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -587,7 +587,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);
@@ -890,11 +896,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 f8fb9cbe..9a02c459 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -490,7 +490,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");
}
