diff options
Diffstat (limited to 'lib/efi_loader')
-rw-r--r-- | lib/efi_loader/Kconfig | 4 | ||||
-rw-r--r-- | lib/efi_loader/efi_bootmgr.c | 6 | ||||
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 42 |
3 files changed, 32 insertions, 20 deletions
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index d2b6327119..827c267b60 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -1,6 +1,10 @@ config EFI_LOADER bool "Support running EFI Applications in U-Boot" depends on (ARM || X86) && OF_LIBFDT + # We need EFI_STUB_64BIT to be set on x86_64 with EFI_STUB + depends on !EFI_STUB || !X86_64 || EFI_STUB_64BIT + # We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB + depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT default y help Select this option if you want to run EFI applications (like grub2) diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 857d88a879..c96b9d48c5 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -120,11 +120,9 @@ static void *try_load_entry(uint16_t n, struct efi_device_path **device_path, if (lo.attributes & LOAD_OPTION_ACTIVE) { efi_status_t ret; - u16 *str = NULL; - debug("%s: trying to load \"%ls\" from: %ls\n", __func__, - lo.label, (str = efi_dp_str(lo.file_path))); - efi_free_pool(str); + debug("%s: trying to load \"%ls\" from %pD\n", + __func__, lo.label, lo.file_path); ret = efi_load_image_from_path(lo.file_path, &image); diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 39d8511fe3..da93498b36 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -111,8 +111,11 @@ void efi_restore_gd(void) } /* - * Two spaces per indent level, maxing out at 10.. which ought to be - * enough for anyone ;-) + * Return a string for indenting with two spaces per level. A maximum of ten + * indent levels is supported. Higher indent levels will be truncated. + * + * @level indent level + * @return indent string */ static const char *indent_string(int level) { @@ -1364,16 +1367,18 @@ efi_status_t efi_setup_loaded_image( obj->handle = info; info->file_path = file_path; - if (device_path) - info->device_handle = efi_dp_find_obj(device_path, NULL); - /* - * When asking for the device path interface, return - * bootefi_device_path - */ - ret = efi_add_protocol(obj->handle, &efi_guid_device_path, device_path); - if (ret != EFI_SUCCESS) - goto failure; + if (device_path) { + info->device_handle = efi_dp_find_obj(device_path, NULL); + /* + * When asking for the device path interface, return + * bootefi_device_path + */ + ret = efi_add_protocol(obj->handle, &efi_guid_device_path, + device_path); + if (ret != EFI_SUCCESS) + goto failure; + } /* * When asking for the loaded_image interface, just @@ -1456,7 +1461,7 @@ error: * for details. * * @boot_policy true for request originating from the boot manager - * @parent_image the calles's image handle + * @parent_image the caller's image handle * @file_path the path of the image to load * @source_buffer memory location from which the image is installed * @source_size size of the memory area from which the image is @@ -1534,8 +1539,8 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, unsigned long *exit_data_size, s16 **exit_data) { - asmlinkage ulong (*entry)(efi_handle_t image_handle, - struct efi_system_table *st); + EFIAPI efi_status_t (*entry)(efi_handle_t image_handle, + struct efi_system_table *st); struct efi_loaded_image *info = image_handle; efi_status_t ret; @@ -1575,8 +1580,13 @@ static efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, ret = EFI_CALL(entry(image_handle, &systab)); - /* Should usually never get here */ - return EFI_EXIT(ret); + /* + * Usually UEFI applications call Exit() instead of returning. + * But because the world doesn not consist of ponies and unicorns, + * we're happy to emulate that behavior on behalf of a payload + * that forgot. + */ + return EFI_CALL(systab.boottime->exit(image_handle, ret, 0, NULL)); } /* |