From de94f0f3209e27ff36b264c58d5e6a8d54e07c65 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 18 Jan 2023 22:25:00 +0100 Subject: efi_loader: Set default console colors on efi_cout_clear_screen if needed Ensures a consistent background color of the whole screen for succeeding outputs as both demanded by the spec and implemented in EDK2 as well. Signed-off-by: Jan Kiszka Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/efi_loader/efi_console.c') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 4d08dd3763a..9316995073e 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -489,6 +489,12 @@ static efi_status_t EFIAPI efi_cout_clear_screen( { EFI_ENTRY("%p", this); + /* Set default colors if not done yet */ + if (efi_con_mode.attribute == 0) { + efi_con_mode.attribute = 0x07; + printf(ESC "[0;37;40m"); + } + efi_clear_screen(); return EFI_EXIT(EFI_SUCCESS); -- cgit v1.2.3 From e585b79ee4b1424f43dc7dbf66fc4f054255cb57 Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 18 Jan 2023 22:24:59 +0100 Subject: efi_loader: Avoid overwriting previous outputs on console screen clearing Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs. Tested regarding multi-output against qemu-x86_defconfig. Still, there were remaining concerns about side effects, so this is provided as an opt-in feature. Signed-off-by: Jan Kiszka Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/efi_loader/efi_console.c') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 9316995073e..1ed8c7aa36e 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -461,10 +461,21 @@ static efi_status_t EFIAPI efi_cout_set_attribute( } /** - * efi_cout_clear_screen() - clear screen + * efi_clear_screen() - clear screen */ static void efi_clear_screen(void) { + if (CONFIG_IS_ENABLED(EFI_SCROLL_ON_CLEAR_SCREEN)) { + unsigned int row, screen_rows, screen_columns; + + /* Avoid overwriting previous outputs on streaming consoles */ + screen_rows = efi_cout_modes[efi_con_mode.mode].rows; + screen_columns = efi_cout_modes[efi_con_mode.mode].columns; + printf(ESC "[%u;%uH", screen_rows, screen_columns); + for (row = 1; row < screen_rows; row++) + printf("\n"); + } + /* * The Linux console wants both a clear and a home command. The video * uclass does not support [H without coordinates, yet. -- cgit v1.2.3