diff --git a/common/lib/panic.s2.c b/common/lib/panic.s2.c index f7aaddd3..3781a292 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 c8b9e571..aeec7bb0 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 (;;) { @@ -222,15 +218,17 @@ 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 } -#endif for (size_t i = 0; i < print_buf_i; i++) { #if defined (__x86_64__) || defined (__i386__) @@ -238,7 +236,7 @@ out: outb(0xe9, print_buf[i]); } #endif - 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 7100163b..f6f6c490 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: { @@ -1026,7 +1028,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 1e86ea7c..04310176 100644 --- a/common/protos/limine.c +++ b/common/protos/limine.c @@ -738,7 +738,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 049a2fb4..1afcf38f 100644 --- a/common/protos/linux.c +++ b/common/protos/linux.c @@ -496,7 +496,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 78da218f..6dc8946b 100644 --- a/common/protos/multiboot1.c +++ b/common/protos/multiboot1.c @@ -303,7 +303,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 87131685..beb7f271 100644 --- a/common/protos/multiboot2.c +++ b/common/protos/multiboot2.c @@ -498,7 +498,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;