diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Kconfig | 5 | ||||
-rw-r--r-- | lib/charset.c | 16 | ||||
-rw-r--r-- | lib/efi/Kconfig | 1 | ||||
-rw-r--r-- | lib/efi_loader/Kconfig | 1 | ||||
-rw-r--r-- | lib/efi_loader/efi_bootmgr.c | 51 | ||||
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 7 | ||||
-rw-r--r-- | lib/efi_loader/efi_console.c | 4 | ||||
-rw-r--r-- | lib/efi_selftest/Makefile | 4 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_tcg2.c | 8 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_unaligned.c | 9 |
10 files changed, 86 insertions, 20 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index e2697ab2ceb..acc0ac081a4 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -52,11 +52,6 @@ config CC_OPTIMIZE_LIBS_FOR_SPEED config CHARSET bool - default y if UT_UNICODE || EFI_LOADER || UFS || EFI_APP - help - Enables support for various conversions between different - character sets, such as between unicode representations and - different 'code pages'. config DYNAMIC_CRC_TABLE bool "Enable Dynamic tables for CRC" diff --git a/lib/charset.c b/lib/charset.c index de201cf3b9b..bece4985bfc 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -416,6 +416,22 @@ u16 *u16_strdup(const void *src) return new; } +size_t u16_strlcat(u16 *dest, const u16 *src, size_t count) +{ + size_t destlen = u16_strlen(dest); + size_t srclen = u16_strlen(src); + size_t ret = destlen + srclen + 1; + + if (destlen >= count) + return ret; + if (ret > count) + srclen -= ret - count; + memcpy(&dest[destlen], src, 2 * srclen); + dest[destlen + srclen] = 0x0000; + + return ret; +} + /* Convert UTF-16 to UTF-8. */ uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size) { diff --git a/lib/efi/Kconfig b/lib/efi/Kconfig index 15ce99e1a74..c2b9bb73f71 100644 --- a/lib/efi/Kconfig +++ b/lib/efi/Kconfig @@ -14,6 +14,7 @@ choice config EFI_APP bool "Support running as an EFI application" + select CHARSET help Build U-Boot as an application which can be started from EFI. This is useful for examining a platform in the early stages of porting diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 6b245f50a72..eb2d6fddc4f 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -14,6 +14,7 @@ config EFI_LOADER depends on DM_ETH || !NET depends on !EFI_APP default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 + select CHARSET select DM_EVENT select EVENT_DYNAMIC select LIB_UUID diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 52bea4d5411..631a25d76e9 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -11,6 +11,7 @@ #include <charset.h> #include <log.h> #include <malloc.h> +#include <efi_default_filename.h> #include <efi_loader.h> #include <efi_variable.h> #include <asm/unaligned.h> @@ -31,6 +32,51 @@ static const struct efi_runtime_services *rs; */ /** + * expand_media_path() - expand a device path for default file name + * @device_path: device path to check against + * + * If @device_path is a media or disk partition which houses a file + * system, this function returns a full device path which contains + * an architecture-specific default file name for removable media. + * + * Return: a newly allocated device path + */ +static +struct efi_device_path *expand_media_path(struct efi_device_path *device_path) +{ + struct efi_device_path *dp, *full_path; + efi_handle_t handle; + efi_status_t ret; + + if (!device_path) + return NULL; + + /* + * If device_path is a (removable) media or partition which provides + * simple file system protocol, append a default file name to support + * booting from removable media. + */ + dp = device_path; + ret = EFI_CALL(efi_locate_device_path( + &efi_simple_file_system_protocol_guid, + &dp, &handle)); + if (ret == EFI_SUCCESS) { + if (dp->type == DEVICE_PATH_TYPE_END) { + dp = efi_dp_from_file(NULL, 0, + "/EFI/BOOT/" BOOTEFI_NAME); + full_path = efi_dp_append(device_path, dp); + efi_free_pool(dp); + } else { + full_path = efi_dp_dup(device_path); + } + } else { + full_path = efi_dp_dup(device_path); + } + + return full_path; +} + +/** * try_load_entry() - try to load image for boot option * * Attempt to load load-option number 'n', returning device_path and file_path @@ -64,13 +110,16 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, } if (lo.attributes & LOAD_OPTION_ACTIVE) { + struct efi_device_path *file_path; u32 attributes; log_debug("trying to load \"%ls\" from %pD\n", lo.label, lo.file_path); - ret = EFI_CALL(efi_load_image(true, efi_root, lo.file_path, + file_path = expand_media_path(lo.file_path); + ret = EFI_CALL(efi_load_image(true, efi_root, file_path, NULL, 0, handle)); + efi_free_pool(file_path); if (ret != EFI_SUCCESS) { log_warning("Loading %ls '%ls' failed\n", varname, lo.label); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 5bcb8253edb..4da64b5d296 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1799,10 +1799,9 @@ failure: * * Return: status code */ -static efi_status_t EFIAPI efi_locate_device_path( - const efi_guid_t *protocol, - struct efi_device_path **device_path, - efi_handle_t *device) +efi_status_t EFIAPI efi_locate_device_path(const efi_guid_t *protocol, + struct efi_device_path **device_path, + efi_handle_t *device) { struct efi_device_path *dp; size_t i; diff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c index ba68a150172..60a3fc85ac4 100644 --- a/lib/efi_loader/efi_console.c +++ b/lib/efi_loader/efi_console.c @@ -522,11 +522,11 @@ static efi_status_t EFIAPI efi_cout_reset( { EFI_ENTRY("%p, %d", this, extended_verification); - /* Clear screen */ - EFI_CALL(efi_cout_clear_screen(this)); /* Set default colors */ efi_con_mode.attribute = 0x07; printf(ESC "[0;37;40m"); + /* Clear screen */ + EFI_CALL(efi_cout_clear_screen(this)); return EFI_EXIT(EFI_SUCCESS); } diff --git a/lib/efi_selftest/Makefile b/lib/efi_selftest/Makefile index be8040d1c7e..33536c9ec02 100644 --- a/lib/efi_selftest/Makefile +++ b/lib/efi_selftest/Makefile @@ -55,7 +55,9 @@ obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_selftest_devicepath.o obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += \ efi_selftest_unicode_collation.o -obj-$(CONFIG_CPU_V7) += efi_selftest_unaligned.o +ifeq ($(CONFIG_CPU_V7A)$(CONFIG_CPU_V7M)$(CONFIG_CPU_V7R),y) +obj-y += efi_selftest_unaligned.o +endif obj-$(CONFIG_EFI_LOADER_HII) += efi_selftest_hii.o obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_selftest_rng.o obj-$(CONFIG_EFI_GET_TIME) += efi_selftest_rtc.o diff --git a/lib/efi_selftest/efi_selftest_tcg2.c b/lib/efi_selftest/efi_selftest_tcg2.c index a2b4a79e9b2..67a886efaa8 100644 --- a/lib/efi_selftest/efi_selftest_tcg2.c +++ b/lib/efi_selftest/efi_selftest_tcg2.c @@ -631,8 +631,10 @@ static int efi_st_tcg2_setup(const efi_handle_t img_handle, sizeof(struct efi_tcg2_event) + sizeof(struct uefi_image_load_event), (void **)&efi_tcg2_event); - if (!efi_tcg2_event) + if (ret != EFI_SUCCESS) { + efi_st_error("Out of memory\n"); return EFI_ST_FAILURE; + } efi_tcg2_event->size = sizeof(struct efi_tcg2_event) + sizeof(struct uefi_image_load_event); @@ -659,8 +661,10 @@ static int efi_st_tcg2_setup(const efi_handle_t img_handle, (EFI_TCG2_MAX_PCR_INDEX + 1) * TPM2_SHA256_DIGEST_SIZE, (void **)&pcrs); - if (!pcrs) + if (ret != EFI_SUCCESS) { + efi_st_error("Out of memory\n"); return EFI_ST_FAILURE; + } boottime->set_mem(pcrs, (EFI_TCG2_MAX_PCR_INDEX + 1) * TPM2_SHA256_DIGEST_SIZE, 0); diff --git a/lib/efi_selftest/efi_selftest_unaligned.c b/lib/efi_selftest/efi_selftest_unaligned.c index 6fce110b76f..7c6bf2d6e8d 100644 --- a/lib/efi_selftest/efi_selftest_unaligned.c +++ b/lib/efi_selftest/efi_selftest_unaligned.c @@ -14,14 +14,14 @@ struct aligned_buffer { }; /* - * Return an u32 at a give address. + * Return an u32 at a given address. * If the address is not four byte aligned, an unaligned memory access * occurs. * * @addr: address to read * Return: value at the address */ -static inline u32 deref(u32 *addr) +static inline u32 deref(void *addr) { int ret; @@ -43,12 +43,11 @@ static int execute(void) { struct aligned_buffer buf = { {0, 1, 2, 3, 4, 5, 6, 7}, - }; - void *v = &buf; + }; u32 r = 0; /* Read an unaligned address */ - r = deref(v + 1); + r = deref(&buf.a[1]); /* UEFI only supports low endian systems */ if (r != 0x04030201) { |