stivale2: Ensure serial off before starting runtime term
diff --git a/common/lib/gterm.c b/common/lib/gterm.c
index ce685547..2586dd77 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -592,13 +592,16 @@ void gterm_putchar(uint8_t c) {
}
}
+static bool last_serial = false;
+
bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
if (current_video_mode >= 0
&& fbinfo.default_res == true
&& width == 0
&& height == 0
&& fbinfo.framebuffer_bpp == 32
- && !early_term) {
+ && !early_term
+ && serial == last_serial) {
*_rows = rows;
*_cols = cols;
gterm_clear(true);
@@ -609,7 +612,8 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
&& fbinfo.framebuffer_width == width
&& fbinfo.framebuffer_height == height
&& fbinfo.framebuffer_bpp == 32
- && !early_term) {
+ && !early_term
+ && serial == last_serial) {
*_rows = rows;
*_cols = cols;
gterm_clear(true);
@@ -622,6 +626,8 @@ bool gterm_init(size_t *_rows, size_t *_cols, size_t width, size_t height) {
if (!fb_init(&fbinfo, width, height, 32))
return false;
+ last_serial = serial;
+
cursor_status = true;
scroll_enabled = true;
diff --git a/common/lib/print.s2.c b/common/lib/print.s2.c
index 06f3ac0e..ec0aec61 100644
--- a/common/lib/print.s2.c
+++ b/common/lib/print.s2.c
@@ -213,7 +213,7 @@ out:
if (E9_OUTPUT) {
outb(0xe9, print_buf[i]);
}
- if (serial || COM_OUTPUT) {
+ if ((term_backend != NOT_READY && serial) || COM_OUTPUT) {
switch (print_buf[i]) {
case '\n':
serial_out('\r');
diff --git a/common/protos/stivale2.c b/common/protos/stivale2.c
index 95c7555d..5035c390 100644
--- a/common/protos/stivale2.c
+++ b/common/protos/stivale2.c
@@ -527,6 +527,7 @@ failed_to_load_header_section:
if (bits == 64 && terminal_hdr_tag != NULL) {
quiet = false;
+ serial = false;
if (bios &&
((avtag == NULL && hdrtag == NULL) || (avtag != NULL && preference == 1))) {
