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') 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.3.1 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/Kconfig | 9 +++++++++ lib/efi_loader/efi_console.c | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index b630d88ef9e..c56904afc2e 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 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.3.1 From 90c420509ed66ef4cb8453b7e388beb168c34a97 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 19 Jan 2023 14:49:33 +0100 Subject: efi_loader: ensure that file ubootefi.var is created Currently file ubootefi.var is only created if the user sets a non-volatile EFI variable. If the file is missing, a warning is written. With the change PlatformLang is always persisted. So the file will exist on second boot. Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- lib/efi_loader/efi_variable.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 503a33ed65c..7c32adf6e5b 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -334,9 +334,11 @@ efi_status_t efi_set_variable_int(const u16 *variable_name, else ret = EFI_SUCCESS; - /* Write non-volatile EFI variables to file */ - if (attributes & EFI_VARIABLE_NON_VOLATILE && - ret == EFI_SUCCESS && efi_obj_list_initialized == EFI_SUCCESS) + /* + * Write non-volatile EFI variables to file + * TODO: check if a value change has occured to avoid superfluous writes + */ + if (attributes & EFI_VARIABLE_NON_VOLATILE) efi_var_to_file(); return EFI_SUCCESS; -- cgit v1.3.1 From cd63e2d26c7c080c8bdb4ea40b4bfc1320ce2aee Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Thu, 19 Jan 2023 16:29:15 +0200 Subject: efi_loader: update the error message of TCG protocol installation "Unable to find TPMv2 device" doesn't explain much with regards to the error origin. Update it to match what we have in the RNG protocol installation. Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_tcg2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index a525ebf75b5..918e9a26864 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -2417,7 +2417,7 @@ efi_status_t efi_tcg2_register(void) ret = platform_get_tpm2_device(&dev); if (ret != EFI_SUCCESS) { - log_warning("Unable to find TPMv2 device\n"); + log_warning("Missing TPMv2 device for EFI_TCG_PROTOCOL\n"); return EFI_SUCCESS; } -- cgit v1.3.1 From e10fffe8b56f4430e0e242977bfa67ab589b8235 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Fri, 20 Jan 2023 13:58:48 +0200 Subject: efi_loader: fix CapsuleMax variable reporting Currently the code that adds the CapsuleMax variable is under a Kconfig named 'EFI_HAVE_CAPSULE_UPDATE. Git history only shows a single occurrence of that. The IS_ENABLED should be checking for EFI_HAVE_CAPSULE_SUPPORT Reported-by: Heinrich Schuchardt Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index 54376411353..f0f01d3b1d5 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -128,7 +128,7 @@ static efi_status_t efi_init_capsule(void) { efi_status_t ret = EFI_SUCCESS; - if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_UPDATE)) { + if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT)) { ret = efi_set_variable_int(u"CapsuleMax", &efi_guid_capsule_report, EFI_VARIABLE_READ_ONLY | -- cgit v1.3.1