From 2d544e5993f120ff2ad2ec86fbc9d844bcb9b9e2 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Sun, 7 Jan 2024 14:02:16 +0100 Subject: [PATCH] Set defaukt colors before clearing console screen --- xtldr/console.c | 59 +++++++++++++++++++++--------------------- xtldr/includes/xtldr.h | 8 +++--- xtldr/xtldr.c | 2 +- 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/xtldr/console.c b/xtldr/console.c index e41b8ce..8d7bca3 100644 --- a/xtldr/console.c +++ b/xtldr/console.c @@ -138,6 +138,36 @@ BlConsoleWrite(IN PUSHORT String) EfiSystemTable->ConOut->OutputString(EfiSystemTable->ConOut, String); } +/** + * This routine initializes the EFI console. + * + * @return This routine returns status code. + * + * @since XT 1.0 + */ +XTCDECL +VOID +BlInitializeConsole() +{ + /* Clear console buffers */ + EfiSystemTable->ConIn->Reset(EfiSystemTable->ConIn, TRUE); + EfiSystemTable->ConOut->Reset(EfiSystemTable->ConOut, TRUE); + EfiSystemTable->StdErr->Reset(EfiSystemTable->StdErr, TRUE); + + /* Make sure that current console mode is 80x25 characters, as some broken EFI implementations might + * set different mode that do not fit on the screen, causing a text to be displayed offscreen */ + if(EfiSystemTable->ConOut->Mode->Mode != 0) + { + /* Set console mode to 0, which is standard, 80x25 text mode */ + BlSetConsoleMode(0); + } + + /* Clear screen and enable cursor */ + BlSetConsoleAttributes(EFI_TEXT_BGCOLOR_BLACK | EFI_TEXT_FGCOLOR_LIGHTGRAY); + BlClearConsoleScreen(); + BlEnableConsoleCursor(); +} + /** * Queries information concerning the output device’s supported text mode. * @@ -266,32 +296,3 @@ BlpConsolePrintChar(IN USHORT Character) Buffer[1] = 0; EfiSystemTable->ConOut->OutputString(EfiSystemTable->ConOut, Buffer); } - -/** - * This routine initializes the EFI console. - * - * @return This routine returns status code. - * - * @since XT 1.0 - */ -XTCDECL -VOID -BlpInitializeConsole() -{ - /* Clear console buffers */ - EfiSystemTable->ConIn->Reset(EfiSystemTable->ConIn, TRUE); - EfiSystemTable->ConOut->Reset(EfiSystemTable->ConOut, TRUE); - EfiSystemTable->StdErr->Reset(EfiSystemTable->StdErr, TRUE); - - /* Make sure that current console mode is 80x25 characters, as some broken EFI implementations might - * set different mode that do not fit on the screen, causing a text to be displayed offscreen */ - if(EfiSystemTable->ConOut->Mode->Mode != 0) - { - /* Set console mode to 0, which is standard, 80x25 text mode */ - BlSetConsoleMode(0); - } - - /* Clear screen and enable cursor */ - BlClearConsoleScreen(); - BlEnableConsoleCursor(); -} diff --git a/xtldr/includes/xtldr.h b/xtldr/includes/xtldr.h index b7aaaf3..ea52a22 100644 --- a/xtldr/includes/xtldr.h +++ b/xtldr/includes/xtldr.h @@ -131,6 +131,10 @@ BlInitializeBootMenuList(OUT PXTBL_BOOTMENU_ITEM MenuEntries, OUT PULONG EntriesCount, OUT PULONG DefaultId); +XTCDECL +VOID +BlInitializeConsole(); + XTCDECL EFI_STATUS BlInvokeBootProtocol(IN PLIST_ENTRY OptionsList); @@ -254,10 +258,6 @@ XTCDECL EFI_STATUS BlpActivateSerialIOController(); -XTCDECL -VOID -BlpInitializeConsole(); - XTCDECL VOID BlpConsolePrintChar(IN USHORT Character); diff --git a/xtldr/xtldr.c b/xtldr/xtldr.c index 85e7902..c6d4608 100644 --- a/xtldr/xtldr.c +++ b/xtldr/xtldr.c @@ -28,7 +28,7 @@ BlInitializeBootLoader() BlpStatus.BootServices = TRUE; /* Initialize console */ - BlpInitializeConsole(); + BlInitializeConsole(); /* Print XTLDR version */ BlConsolePrint(L"XTLDR boot loader v%s\n", XTOS_VERSION);