misc: Fix bugs introduced in 3181293a
diff --git a/common/lib/panic.s2.c b/common/lib/panic.s2.c
index b062bd2b..2ea7d4b3 100644
--- a/common/lib/panic.s2.c
+++ b/common/lib/panic.s2.c
@@ -21,6 +21,10 @@ noreturn void panic(bool allow_menu, const char *fmt, ...) {
quiet = false;
+ if (term_backend == _NOT_READY) {
+ term_fallback();
+ }
+
if (term_backend != FALLBACK) {
print("\033[31mPANIC\033[37;1m\033[0m: ");
} else {
diff --git a/common/lib/print.s2.c b/common/lib/print.s2.c
index 4d62417b..8c3d2620 100644
--- a/common/lib/print.s2.c
+++ b/common/lib/print.s2.c
@@ -142,10 +142,6 @@ void print(const char *fmt, ...) {
static char print_buf[PRINT_BUF_MAX];
void vprint(const char *fmt, va_list args) {
- if (quiet) {
- return;
- }
-
size_t print_buf_i = 0;
for (;;) {
@@ -203,21 +199,23 @@ void vprint(const char *fmt, va_list args) {
}
out:
+ if (!quiet) {
#if defined (BIOS)
- if (stage3_loaded) {
+ if (stage3_loaded) {
#endif
- term_write((uint64_t)(uintptr_t)print_buf, print_buf_i);
+ term_write((uint64_t)(uintptr_t)print_buf, print_buf_i);
#if defined (BIOS)
- } else {
- s2_print(print_buf, print_buf_i);
- }
+ } else {
+ s2_print(print_buf, print_buf_i);
+ }
#endif
+ }
for (size_t i = 0; i < print_buf_i; i++) {
if (E9_OUTPUT) {
outb(0xe9, print_buf[i]);
}
- if (serial || COM_OUTPUT) {
+ if ((!quiet && serial) || COM_OUTPUT) {
switch (print_buf[i]) {
case '\n':
serial_out('\r');
diff --git a/common/lib/term.c b/common/lib/term.c
index 9a5b2528..b027148d 100644
--- a/common/lib/term.c
+++ b/common/lib/term.c
@@ -52,7 +52,7 @@ void term_deinit(void) {
gterm_deinit();
}
- term_fallback();
+ term_notready();
}
void term_vbe(char *config, size_t width, size_t height) {
@@ -253,6 +253,8 @@ static uint8_t xfer_buf[TERM_XFER_CHUNK];
bool term_autoflush = true;
+static void term_putchar(uint8_t c);
+
void term_write(uint64_t buf, uint64_t count) {
switch (count) {
case TERM_CTX_SIZE: {
@@ -1024,7 +1026,7 @@ static uint8_t dec_special_to_cp437(uint8_t c) {
return c;
}
-void term_putchar(uint8_t c) {
+static void term_putchar(uint8_t c) {
if (discard_next || (term_runtime == true && (c == 0x18 || c == 0x1a))) {
discard_next = false;
escape = false;
diff --git a/common/lib/term.h b/common/lib/term.h
index e40b28bb..82ff658d 100644
--- a/common/lib/term.h
+++ b/common/lib/term.h
@@ -50,13 +50,13 @@ extern int term_backend;
extern size_t term_rows, term_cols;
extern bool term_runtime;
+void term_notready(void);
void term_fallback(void);
void term_reinit(void);
void term_deinit(void);
void term_vbe(char *config, size_t width, size_t height);
void term_textmode(void);
-void term_putchar(uint8_t c);
void term_write(uint64_t buf, uint64_t count);
extern void (*raw_putchar)(uint8_t c);
diff --git a/common/lib/term.s2.c b/common/lib/term.s2.c
index ea594975..132b1a5b 100644
--- a/common/lib/term.s2.c
+++ b/common/lib/term.s2.c
@@ -136,8 +136,6 @@ static void fallback_get_cursor_pos(size_t *x, size_t *y) {
}
#endif
-static void term_notready(void);
-
void term_fallback(void) {
#if defined (UEFI)
if (!efi_boot_services_exited) {
@@ -193,7 +191,7 @@ static void notready_uint64_t(uint64_t n) {
(void)n;
}
-static void term_notready(void) {
+void term_notready(void) {
raw_putchar = notready_raw_putchar;
clear = notready_clear;
enable_cursor = notready_void;
@@ -224,4 +222,6 @@ static void term_notready(void) {
term_cols = 80;
term_rows = 24;
+
+ term_backend = _NOT_READY;
}
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 9da5bb2e..c0e43fb2 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -535,7 +535,6 @@ FEAT_START
FEAT_END
term_deinit();
- quiet = true;
if (!fb_init(&fb, req_width, req_height, req_bpp)) {
panic(true, "limine: Could not acquire framebuffer");
diff --git a/common/protos/linux.c b/common/protos/linux.c
index f0ecc62b..f5092d9b 100644
--- a/common/protos/linux.c
+++ b/common/protos/linux.c
@@ -494,7 +494,6 @@ noreturn void linux_load(char *config, char *cmdline) {
///////////////////////////////////////
term_deinit();
- quiet = true;
struct screen_info *screen_info = &boot_params->screen_info;
diff --git a/common/protos/multiboot1.c b/common/protos/multiboot1.c
index 2915b4d4..f006d570 100644
--- a/common/protos/multiboot1.c
+++ b/common/protos/multiboot1.c
@@ -298,7 +298,6 @@ noreturn void multiboot1_load(char *config, char *cmdline) {
multiboot1_info->flags |= (1 << 9);
term_deinit();
- quiet = true;
if (header.flags & (1 << 2)) {
size_t req_width = header.fb_width;
diff --git a/common/protos/multiboot2.c b/common/protos/multiboot2.c
index 64f53708..b0d5ce59 100644
--- a/common/protos/multiboot2.c
+++ b/common/protos/multiboot2.c
@@ -493,7 +493,6 @@ noreturn void multiboot2_load(char *config, char* cmdline) {
tag->common.size = sizeof(struct multiboot_tag_framebuffer);
term_deinit();
- quiet = true;
if (fbtag) {
size_t req_width = fbtag->width;
diff --git a/common/protos/stivale.c b/common/protos/stivale.c
index 9adf5a09..b91fba00 100644
--- a/common/protos/stivale.c
+++ b/common/protos/stivale.c
@@ -309,7 +309,6 @@ noreturn void stivale_load(char *config, char *cmdline) {
printv("stivale: Current epoch: %U\n", stivale_struct->epoch);
term_deinit();
- quiet = true;
if (stivale_hdr.flags & (1 << 0)) {
size_t req_width = stivale_hdr.framebuffer_width;
diff --git a/common/protos/stivale2.c b/common/protos/stivale2.c
index 33fc6f30..fb8d7ee6 100644
--- a/common/protos/stivale2.c
+++ b/common/protos/stivale2.c
@@ -629,7 +629,6 @@ failed_to_load_header_section:
}
term_deinit();
- quiet = true;
if (hdrtag != NULL
#if defined (UEFI)
@@ -637,7 +636,6 @@ failed_to_load_header_section:
#endif
|| (avtag != NULL && preference == 0)) {
term_deinit();
- quiet = true;
#if defined (UEFI)
gop_force_16 = true;
