mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-05 12:46:14 +02:00
efi_loader: Move the fallback code from efi_run_image()
This code is only needed if an invalid image/device path is passed in. Move the code out to a caller where this can be dealt with. The normal flow will provide these parameters. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
b9f42821af
commit
5f67c8800e
@ -165,37 +165,13 @@ static efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size,
|
||||
struct efi_device_path *dp_dev,
|
||||
struct efi_device_path *dp_img)
|
||||
{
|
||||
efi_handle_t mem_handle = NULL, handle;
|
||||
struct efi_device_path *file_path = NULL;
|
||||
struct efi_device_path *msg_path;
|
||||
efi_handle_t handle;
|
||||
struct efi_device_path *msg_path, *file_path;
|
||||
efi_status_t ret;
|
||||
u16 *load_options;
|
||||
|
||||
if (!dp_img || !dp_img) {
|
||||
log_debug("Not loaded from disk\n");
|
||||
/*
|
||||
* Special case for efi payload not loaded from disk,
|
||||
* such as 'bootefi hello' or for example payload
|
||||
* loaded directly into memory via JTAG, etc:
|
||||
*/
|
||||
file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
|
||||
(uintptr_t)source_buffer,
|
||||
source_size);
|
||||
/*
|
||||
* Make sure that device for device_path exist
|
||||
* in load_image(). Otherwise, shell and grub will fail.
|
||||
*/
|
||||
ret = efi_install_multiple_protocol_interfaces(&mem_handle,
|
||||
&efi_guid_device_path,
|
||||
file_path, NULL);
|
||||
if (ret != EFI_SUCCESS)
|
||||
goto out;
|
||||
msg_path = file_path;
|
||||
} else {
|
||||
file_path = efi_dp_concat(dp_img, dp_img, 0);
|
||||
msg_path = dp_img;
|
||||
log_debug("Loaded from disk\n");
|
||||
}
|
||||
file_path = efi_dp_concat(dp_dev, dp_img, 0);
|
||||
msg_path = dp_img;
|
||||
|
||||
log_info("Booting %pD\n", msg_path);
|
||||
|
||||
@ -214,15 +190,6 @@ static efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size,
|
||||
ret = do_bootefi_exec(handle, load_options);
|
||||
|
||||
out:
|
||||
if (mem_handle) {
|
||||
efi_status_t r;
|
||||
|
||||
r = efi_uninstall_multiple_protocol_interfaces(
|
||||
mem_handle, &efi_guid_device_path, file_path, NULL);
|
||||
if (r != EFI_SUCCESS)
|
||||
log_err("Uninstalling protocol interfaces failed\n");
|
||||
}
|
||||
efi_free_pool(file_path);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -241,9 +208,9 @@ out:
|
||||
*
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t efi_binary_run_dp(void *image, size_t size, void *fdt,
|
||||
struct efi_device_path *dp_dev,
|
||||
struct efi_device_path *dp_img)
|
||||
static efi_status_t efi_binary_run_dp(void *image, size_t size, void *fdt,
|
||||
struct efi_device_path *dp_dev,
|
||||
struct efi_device_path *dp_img)
|
||||
{
|
||||
efi_status_t ret;
|
||||
|
||||
@ -276,6 +243,44 @@ efi_status_t efi_binary_run_dp(void *image, size_t size, void *fdt,
|
||||
*/
|
||||
efi_status_t efi_binary_run(void *image, size_t size, void *fdt)
|
||||
{
|
||||
return efi_binary_run_dp(image, size, fdt, bootefi_device_path,
|
||||
bootefi_image_path);
|
||||
efi_handle_t mem_handle = NULL;
|
||||
struct efi_device_path *file_path = NULL;
|
||||
efi_status_t ret;
|
||||
|
||||
if (!bootefi_device_path || !bootefi_image_path) {
|
||||
log_debug("Not loaded from disk\n");
|
||||
/*
|
||||
* Special case for efi payload not loaded from disk,
|
||||
* such as 'bootefi hello' or for example payload
|
||||
* loaded directly into memory via JTAG, etc:
|
||||
*/
|
||||
file_path = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE,
|
||||
(uintptr_t)image, size);
|
||||
/*
|
||||
* Make sure that device for device_path exist
|
||||
* in load_image(). Otherwise, shell and grub will fail.
|
||||
*/
|
||||
ret = efi_install_multiple_protocol_interfaces(&mem_handle,
|
||||
&efi_guid_device_path,
|
||||
file_path, NULL);
|
||||
if (ret != EFI_SUCCESS)
|
||||
goto out;
|
||||
} else {
|
||||
log_debug("Loaded from disk\n");
|
||||
}
|
||||
|
||||
ret = efi_binary_run_dp(image, size, fdt, bootefi_device_path,
|
||||
bootefi_image_path);
|
||||
out:
|
||||
if (mem_handle) {
|
||||
efi_status_t r;
|
||||
|
||||
r = efi_uninstall_multiple_protocol_interfaces(mem_handle,
|
||||
&efi_guid_device_path, file_path, NULL);
|
||||
if (r != EFI_SUCCESS)
|
||||
log_err("Uninstalling protocol interfaces failed\n");
|
||||
}
|
||||
efi_free_pool(file_path);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user