term: Tidy up gterm wrapper code
diff --git a/common/lib/gterm.c b/common/lib/gterm.c
index 8f250c1f..3244b4fb 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -193,6 +193,14 @@ static bool last_serial = false;
static char *last_config = NULL;
bool gterm_init(char *config, size_t width, size_t height) {
+ if (term_backend != GTERM) {
+ term->deinit(term, pmm_free);
+ }
+
+ if (quiet || allocations_disallowed) {
+ return false;
+ }
+
if (current_video_mode >= 0
#if defined (BIOS)
&& current_video_mode != 0x03
@@ -422,5 +430,16 @@ no_load_font:;
font_scale_x, font_scale_y,
margin);
+ if (serial) {
+ term->cols = term->cols > 80 ? 80 : term->cols;
+ term->rows = term->rows > 24 ? 24 : term->rows;
+ }
+
+ term_context_reinit(term);
+
+ term_backend = GTERM;
+
+ term->in_bootloader = true;
+
return true;
}
diff --git a/common/lib/term.c b/common/lib/term.c
index 5fd4334f..d6e42279 100644
--- a/common/lib/term.c
+++ b/common/lib/term.c
@@ -259,33 +259,6 @@ void term_fallback(void) {
extern void reset_term(void);
extern void set_cursor_pos_helper(size_t x, size_t y);
-void term_vbe(char *config, size_t width, size_t height) {
- if (term_backend != VBE) {
- term->deinit(term, pmm_free);
- }
-
- if (quiet || allocations_disallowed) {
- return;
- }
-
- if (!gterm_init(config, width, height)) {
-#if defined (BIOS)
- // Failed to set VBE properly, default to text mode
- term_textmode();
-#endif
- return;
- }
-
- if (serial) {
- term->cols = term->cols > 80 ? 80 : term->cols;
- term->rows = term->rows > 24 ? 24 : term->rows;
- }
-
- term_backend = VBE;
-
- term->in_bootloader = true;
-}
-
#if defined (BIOS)
void term_textmode(void) {
term_notready();
diff --git a/common/lib/term.h b/common/lib/term.h
index f7fdbf11..96d0d25b 100644
--- a/common/lib/term.h
+++ b/common/lib/term.h
@@ -10,7 +10,7 @@
enum {
_NOT_READY,
- VBE,
+ GTERM,
TEXTMODE,
FALLBACK
};
@@ -37,7 +37,6 @@ inline void set_cursor_pos_helper(size_t x, size_t y) {
}
void term_fallback(void);
-void term_vbe(char *config, size_t width, size_t height);
void term_textmode(void);
void _term_write(uint64_t buf, uint64_t count);
diff --git a/common/menu.c b/common/menu.c
index 6bc8f3e2..19bcf960 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -563,7 +563,7 @@ static void menu_init_term(void) {
if (menu_resolution != NULL)
parse_resolution(&req_width, &req_height, &req_bpp, menu_resolution);
- term_vbe(NULL, req_width, req_height);
+ gterm_init(NULL, req_width, req_height);
} else {
#if defined (BIOS)
term_textmode();
@@ -842,7 +842,7 @@ timeout_aborted:
goto refresh;
}
if (term_backend == FALLBACK) {
- term_vbe(NULL, 0, 0);
+ gterm_init(NULL, 0, 0);
#if defined (BIOS)
if (term_backend == FALLBACK) {
term_textmode();
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 77a079b9..a7466947 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -684,9 +684,9 @@ FEAT_START
char *term_conf_override_s = config_get_value(config, 0, "TERM_CONFIG_OVERRIDE");
if (term_conf_override_s != NULL && strcmp(term_conf_override_s, "yes") == 0) {
- term_vbe(config, req_width, req_height);
+ gterm_init(config, req_width, req_height);
} else {
- term_vbe(NULL, req_width, req_height);
+ gterm_init(NULL, req_width, req_height);
}
if (current_video_mode < 0) {
