From: Jan Kiszka Date: Wed, 18 Jan 2023 21:24:59 +0000 (+0100) Subject: efi_loader: Avoid overwriting previous outputs on console screen clearing X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=e585b79ee4b1424f43dc7dbf66fc4f054255cb57;p=u-boot.git 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 --- diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index b630d88ef9..c56904afc2 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -124,6 +124,15 @@ config EFI_SET_TIME Provide the SetTime() runtime service at boottime. This service can be used by an EFI application to adjust the real time clock. +config EFI_SCROLL_ON_CLEAR_SCREEN + bool "Avoid overwriting previous output on clear screen" + help + Instead of erasing the screen content when the console screen should + be cleared, emit blank new lines so that previous output is scrolled + out of sight rather than overwritten. On serial consoles this allows + to capture complete boot logs (except for interactive menus etc.) + and can ease debugging related issues. + config EFI_HAVE_CAPSULE_SUPPORT bool diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 9316995073..1ed8c7aa36 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.