From f32723663b464ab82285b22af57bf58bd32f759f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 15 Oct 2022 11:13:59 +0200 Subject: efi_loader: avoid EFI_CALL() for clearing screen Carve out function efi_clear_screen. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 3354b217a9a..6d4784e1408 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -460,6 +460,20 @@ static efi_status_t EFIAPI efi_cout_set_attribute( return EFI_EXIT(EFI_SUCCESS); } +/** + * efi_cout_clear_screen() - clear screen + */ +static void efi_clear_screen(void) +{ + /* + * The Linux console wants both a clear and a home command. The video + * uclass does not support [H without coordinates, yet. + */ + printf(ESC "[2J" ESC "[1;1H"); + efi_con_mode.cursor_column = 0; + efi_con_mode.cursor_row = 0; +} + /** * efi_cout_clear_screen() - clear screen * @@ -475,13 +489,7 @@ static efi_status_t EFIAPI efi_cout_clear_screen( { EFI_ENTRY("%p", this); - /* - * The Linux console wants both a clear and a home command. The video - * uclass does not support [H without coordinates, yet. - */ - printf(ESC "[2J" ESC "[1;1H"); - efi_con_mode.cursor_column = 0; - efi_con_mode.cursor_row = 0; + efi_clear_screen(); return EFI_EXIT(EFI_SUCCESS); } @@ -510,7 +518,7 @@ static efi_status_t EFIAPI efi_cout_set_mode( return EFI_EXIT(EFI_UNSUPPORTED); efi_con_mode.mode = mode_number; - EFI_CALL(efi_cout_clear_screen(this)); + efi_clear_screen(); return EFI_EXIT(EFI_SUCCESS); } @@ -536,7 +544,7 @@ static efi_status_t EFIAPI efi_cout_reset( efi_con_mode.attribute = 0x07; printf(ESC "[0;37;40m"); /* Clear screen */ - EFI_CALL(efi_cout_clear_screen(this)); + efi_clear_screen(); return EFI_EXIT(EFI_SUCCESS); } -- cgit v1.3.1 From 7831d36f5bd8c321a9054912c1675c840978314d Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 15 Oct 2022 12:22:37 +0200 Subject: efi_loader: avoid EFI_CALL() when draining console Use internal function. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_console.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index 6d4784e1408..ab83f8bf828 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -1359,9 +1359,7 @@ efi_status_t efi_console_get_u16_string(struct efi_simple_text_input_protocol *c ANSI_CLEAR_LINE_TO_END ANSI_CURSOR_SHOW, row, col); - ret = EFI_CALL(cin->reset(cin, false)); - if (ret != EFI_SUCCESS) - return ret; + efi_cin_empty_buffer(); for (;;) { do { -- cgit v1.3.1 From 70089c13a73f58315547982573be2016e7a70958 Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Sun, 16 Oct 2022 11:36:32 +0300 Subject: efi_loader: remove efi_delete_handle on loadfile2 Loadfile2 code is installing two protocols on it's own handle and uses efi_delete_handle() to clean it up on failure(s). However commit 05c4c9e21ae6 ("efi_loader: define internal implementations of install/uninstallmultiple") prepares the ground for us to clean up efi_delete_handle() used in favor of Install/UninstallMultipleProtocol. While at it clean up the non needed void casts to (void *) on the protolcol installation. Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- cmd/bootefi.c | 6 ++++-- include/efi_loader.h | 2 +- lib/efi_loader/efi_load_initrd.c | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/cmd/bootefi.c b/cmd/bootefi.c index b93c0d3d4c0..2a7d42925d6 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -394,8 +394,10 @@ static efi_status_t do_bootefi_exec(efi_handle_t handle, void *load_options) out: free(load_options); - if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) - efi_initrd_deregister(); + if (IS_ENABLED(CONFIG_EFI_LOAD_FILE2_INITRD)) { + if (efi_initrd_deregister() != EFI_SUCCESS) + log_err("Failed to remove loadfile2 for initrd\n"); + } /* Control is returned to U-Boot, disable EFI watchdog */ efi_set_watchdog(0); diff --git a/include/efi_loader.h b/include/efi_loader.h index 1bac3f49a3e..0c6c95ba464 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -570,7 +570,7 @@ efi_status_t efi_net_register(void); /* Called by bootefi to make the watchdog available */ efi_status_t efi_watchdog_register(void); efi_status_t efi_initrd_register(void); -void efi_initrd_deregister(void); +efi_status_t efi_initrd_deregister(void); /* Called by bootefi to make SMBIOS tables available */ /** * efi_acpi_register() - write out ACPI tables diff --git a/lib/efi_loader/efi_load_initrd.c b/lib/efi_loader/efi_load_initrd.c index 87fde3f88c2..193433782c2 100644 --- a/lib/efi_loader/efi_load_initrd.c +++ b/lib/efi_loader/efi_load_initrd.c @@ -213,7 +213,7 @@ efi_status_t efi_initrd_register(void) &efi_guid_device_path, &dp_lf2_handle, /* LOAD_FILE2 */ &efi_guid_load_file2_protocol, - (void *)&efi_lf2_protocol, + &efi_lf2_protocol, NULL); return ret; @@ -227,11 +227,22 @@ efi_status_t efi_initrd_register(void) * * Return: status code */ -void efi_initrd_deregister(void) +efi_status_t efi_initrd_deregister(void) { + efi_status_t ret; + if (!efi_initrd_handle) - return; + return EFI_SUCCESS; - efi_delete_handle(efi_initrd_handle); + ret = efi_uninstall_multiple_protocol_interfaces(efi_initrd_handle, + /* initramfs */ + &efi_guid_device_path, + &dp_lf2_handle, + /* LOAD_FILE2 */ + &efi_guid_load_file2_protocol, + &efi_lf2_protocol, + NULL); efi_initrd_handle = NULL; + + return ret; } -- cgit v1.3.1