diff options
author | Tom Rini | 2020-11-01 10:56:37 -0500 |
---|---|---|
committer | Tom Rini | 2020-11-01 10:56:37 -0500 |
commit | 41cab8edbcf38bce5cddf54957618dd4205d008f (patch) | |
tree | efe29a6e552133360d8303fc44b025ecf2cc1b95 /lib | |
parent | 2c31d7e746766f47a007f39c030706e493a9cc77 (diff) | |
parent | af11423eb06d68784647b879cac57d7b6619d095 (diff) |
Merge tag 'efi-2020-01-rc2-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2021-01-rc2 (2)
The series contains the following enhancements
* preparatory patches for UEFI capsule updates
* initialization of the emulated RTC using an environment variable
and a bug fix
* If DisconnectController() is called for a child controller that is the
only child of the driver, the driver must be disconnected.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/efi_loader/Kconfig | 4 | ||||
-rw-r--r-- | lib/efi_loader/Makefile | 1 | ||||
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 19 | ||||
-rw-r--r-- | lib/efi_loader/efi_string.c | 36 |
4 files changed, 52 insertions, 8 deletions
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index ab42f3ba75b..075481428cd 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -27,6 +27,10 @@ config EFI_LOADER if EFI_LOADER +config EFI_SETUP_EARLY + bool + default n + choice prompt "Store for non-volatile UEFI variables" default EFI_VARIABLE_FILE_STORE diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 9bad1d159b0..8892fb01e12 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -34,6 +34,7 @@ obj-y += efi_memory.o obj-y += efi_root_node.o obj-y += efi_runtime.o obj-y += efi_setup.o +obj-y += efi_string.o obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += efi_unicode_collation.o obj-y += efi_var_common.o obj-y += efi_var_mem.o diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index b26ac9fbfc7..dfa71b17743 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -3523,6 +3523,7 @@ static efi_status_t EFIAPI efi_disconnect_controller( size_t number_of_children = 0; efi_status_t r; struct efi_object *efiobj; + bool sole_child; EFI_ENTRY("%p, %p, %p", controller_handle, driver_image_handle, child_handle); @@ -3545,16 +3546,18 @@ static efi_status_t EFIAPI efi_disconnect_controller( } /* Create list of child handles */ + r = efi_get_child_controllers(efiobj, + driver_image_handle, + &number_of_children, + &child_handle_buffer); + if (r != EFI_SUCCESS) + return r; + sole_child = (number_of_children == 1); + if (child_handle) { number_of_children = 1; + free(child_handle_buffer); child_handle_buffer = &child_handle; - } else { - r = efi_get_child_controllers(efiobj, - driver_image_handle, - &number_of_children, - &child_handle_buffer); - if (r != EFI_SUCCESS) - return r; } /* Get the driver binding protocol */ @@ -3579,7 +3582,7 @@ static efi_status_t EFIAPI efi_disconnect_controller( } } /* Remove the driver */ - if (!child_handle) { + if (!child_handle || sole_child) { r = EFI_CALL(binding_protocol->stop(binding_protocol, controller_handle, 0, NULL)); diff --git a/lib/efi_loader/efi_string.c b/lib/efi_loader/efi_string.c new file mode 100644 index 00000000000..3de721f06c7 --- /dev/null +++ b/lib/efi_loader/efi_string.c @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * String functions + * + * Copyright (c) 2020 AKASHI Takahiro, Linaro Limited + */ + +#include <common.h> +#include <charset.h> + +/** + * efi_create_indexed_name - create a string name with an index + * @buffer: Buffer + * @name: Name string + * @index: Index + * + * Create a utf-16 string with @name, appending @index. + * For example, L"Capsule0001" + * + * The caller must ensure that the buffer has enough space for the resulting + * string including the trailing L'\0'. + * + * Return: A pointer to the next position after the created string + * in @buffer, or NULL otherwise + */ +u16 *efi_create_indexed_name(u16 *buffer, const char *name, unsigned int index) +{ + u16 *p = buffer; + char index_buf[5]; + + utf8_utf16_strcpy(&p, name); + sprintf(index_buf, "%04X", index); + utf8_utf16_strcpy(&p, index_buf); + + return p; +} |