From f4bbd7b9faa4c20e5b838d7ea609ebadc7305ba0 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 May 2025 11:28:21 -0600 Subject: efi_loader: Separate device path into its own header These functions are useful for the EFI app. As a first step towards making these available outside lib/efi_loader, create a separate header file and include it where needed. Add proper comments to the functions, since many are missing at present. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_bootmgr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/efi_loader/efi_bootmgr.c') diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index c0df5cb9acd..a2ab90030b4 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -527,7 +528,7 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp, * will be freed in return_to_efibootmgr event callback. */ loaded_dp = efi_dp_from_mem(EFI_RESERVED_MEMORY_TYPE, - (uintptr_t)image_addr, image_size); + image_addr, image_size); ret = efi_install_multiple_protocol_interfaces( &mem_handle, &efi_guid_device_path, loaded_dp, NULL); if (ret != EFI_SUCCESS) -- cgit v1.2.3 From 162a6b3df349295bf766c1d128d71b4547e8d56e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 May 2025 11:28:23 -0600 Subject: efi: Rename END to EFI_DP_END This exported symbol has a very generic name. Rename it to indicate that it relates to EFI and device-paths. Fix checkpatch warnings related to use of multiple assignments. Signed-off-by: Simon Glass Suggested-by: Heinrich Schuchardt Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_bootmgr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/efi_loader/efi_bootmgr.c') diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index a2ab90030b4..3ef0a9e73f3 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -856,7 +856,8 @@ efi_bootmgr_enumerate_boot_options(struct eficonfig_media_boot_option *opt, lo.label = dev_name; lo.attributes = LOAD_OPTION_ACTIVE; lo.file_path = device_path; - lo.file_path_length = efi_dp_size(device_path) + sizeof(END); + lo.file_path_length = efi_dp_size(device_path) + + sizeof(EFI_DP_END); /* * Set the dedicated guid to optional_data, it is used to identify * the boot option that automatically generated by the bootmenu. -- cgit v1.2.3 From f8949b1d1d0d4dc4d5abb458c59e831b9e2a0dca Mon Sep 17 00:00:00 2001 From: Ilias Apalodimas Date: Fri, 23 May 2025 16:04:04 +0300 Subject: efi_loader: Run dhcp if an http boot option is selected The EFI boot manager relies on having an IP address before trying to boot an EFI HTTP(s) boot entry. However, defining it as a boot or pre-boot command is not always the right answer since it will unconditionally add delay to the board boot, even if we don't boot over the network. So let's do a DHCP request from the boot manager, if 'ipaddr' is empty and fail early if we don't have an address. Signed-off-by: Ilias Apalodimas Tested-by: Michal Simek --- lib/efi_loader/efi_bootmgr.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/efi_loader/efi_bootmgr.c') diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 3ef0a9e73f3..1a3461f5a9d 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -480,6 +480,13 @@ static efi_status_t try_load_from_uri_path(struct efi_device_path_uri *uridp, if (!ctx) return EFI_OUT_OF_RESOURCES; + s = env_get("ipaddr"); + if (!s && dhcp_run(0, NULL, false)) { + log_err("Error: Can't find a valid IP address\n"); + ret = EFI_DEVICE_ERROR; + goto err; + } + s = env_get("loadaddr"); if (!s) { log_err("Error: loadaddr is not set\n"); -- cgit v1.2.3