diff --git a/common/drivers/serial.h b/common/drivers/serial.h index 119ad476..af783298 100644 --- a/common/drivers/serial.h +++ b/common/drivers/serial.h @@ -1,12 +1,13 @@ #ifndef __DRIVERS__SERIAL_H__ #define __DRIVERS__SERIAL_H__ +#if defined (BIOS) + #include void serial_out(uint8_t b); - -#if defined (BIOS) int serial_in(void); + #endif #endif diff --git a/common/drivers/serial.s2.c b/common/drivers/serial.s2.c index 340cda0b..f2c885f3 100644 --- a/common/drivers/serial.s2.c +++ b/common/drivers/serial.s2.c @@ -1,38 +1,19 @@ +#if defined (BIOS) + #include #include #include #include #include #include -#if defined (UEFI) -# include -#endif static bool serial_initialised = false; -#if defined (UEFI) -static EFI_SERIAL_IO_PROTOCOL *serial_protocol; -#endif - static void serial_initialise(void) { if (serial_initialised) { return; } -#if defined (UEFI) - EFI_STATUS status; - - EFI_GUID serial_guid = EFI_SERIAL_IO_PROTOCOL_GUID; - - status = gBS->LocateProtocol(&serial_guid, NULL, (void **)&serial_protocol); - if (status) { - return; - } - - serial_protocol->Reset(serial_protocol); -#endif - -#if defined (BIOS) // Init com1 outb(0x3f8 + 3, 0x00); outb(0x3f8 + 1, 0x00); @@ -42,30 +23,17 @@ static void serial_initialise(void) { outb(0x3f8 + 3, 0x03); outb(0x3f8 + 2, 0xc7); outb(0x3f8 + 4, 0x0b); -#endif serial_initialised = true; } void serial_out(uint8_t b) { -#if defined (UEFI) - if (efi_boot_services_exited) { - return; - } -#endif - serial_initialise(); -#if defined (UEFI) - UINTN bsize = 1; - serial_protocol->Write(serial_protocol, &bsize, &b); -#elif defined (BIOS) while ((inb(0x3f8 + 5) & 0x20) == 0); outb(0x3f8, b); -#endif } -#if defined (BIOS) int serial_in(void) { serial_initialise(); @@ -74,4 +42,5 @@ int serial_in(void) { } return inb(0x3f8); } + #endif diff --git a/common/entry.s3.c b/common/entry.s3.c index edd136f9..d9d0d3a4 100644 --- a/common/entry.s3.c +++ b/common/entry.s3.c @@ -36,6 +36,8 @@ noreturn void uefi_entry(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) EFI_STATUS status; + gST->ConOut->EnableCursor(gST->ConOut, false); + term_fallback(); status = gBS->SetWatchdogTimer(0, 0x10000, 0, NULL); diff --git a/common/lib/gterm.c b/common/lib/gterm.c index d7551742..7a11da59 100644 --- a/common/lib/gterm.c +++ b/common/lib/gterm.c @@ -545,6 +545,17 @@ bool gterm_init(char *config, size_t width, size_t height) { return false; } +#if defined (UEFI) + if (serial || COM_OUTPUT) { + if (term != NULL) { + term->deinit(term, pmm_free); + term = NULL; + } + term_fallback(); + return true; + } +#endif + if (term != NULL && term_backend == GTERM && fbinfo.default_res == true diff --git a/common/lib/print.s2.c b/common/lib/print.s2.c index c6ba7294..5464958d 100644 --- a/common/lib/print.s2.c +++ b/common/lib/print.s2.c @@ -238,6 +238,7 @@ out: outb(0xe9, print_buf[i]); } #endif +#if defined (BIOS) if ((!quiet && serial) || COM_OUTPUT) { switch (print_buf[i]) { case '\n': @@ -253,5 +254,6 @@ out: } serial_out(print_buf[i]); } +#endif } } diff --git a/common/lib/term.c b/common/lib/term.c index 20640363..be72f5ea 100644 --- a/common/lib/term.c +++ b/common/lib/term.c @@ -182,7 +182,10 @@ static void fallback_scroll(struct term_context *ctx) { } static void fallback_raw_putchar(struct term_context *ctx, uint8_t c) { - (void)ctx; + if (!ctx->scroll_enabled && cursor_x == term->cols - 1 && cursor_y == term->rows - 1) { + return; + } + gST->ConOut->EnableCursor(gST->ConOut, true); CHAR16 string[2]; string[0] = c; string[1] = 0; @@ -229,9 +232,6 @@ void term_fallback(void) { if (!efi_boot_services_exited) { #endif fallback_clear(NULL, true); -#if defined (UEFI) - gST->ConOut->EnableCursor(gST->ConOut, false); -#endif term->raw_putchar = fallback_raw_putchar; term->clear = fallback_clear; term->set_cursor_pos = fallback_set_cursor_pos;