From bf03333d09669371ed2ee90a8ccddccc7d8aaa24 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 24 May 2024 14:54:26 +0200 Subject: efi_loader: allow concatenation with contained end node Allow appending a device-path to a device-path that contains an end node as separator. We need this feature for creating boot options specifying kernel, initrd, and dtb. Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/efi_loader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 9600941aa32..ddf2e41a95c 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -946,7 +946,7 @@ struct efi_device_path *efi_dp_from_lo(struct efi_load_option *lo, const efi_guid_t *guid); struct efi_device_path *efi_dp_concat(const struct efi_device_path *dp1, const struct efi_device_path *dp2, - bool split_end_node); + size_t split_end_node); struct efi_device_path *search_gpt_dp_node(struct efi_device_path *device_path); efi_status_t efi_deserialize_load_option(struct efi_load_option *lo, u8 *data, efi_uintn_t *size); -- cgit v1.2.3 From 58bef195f94eae4ae90bd5409a81a204c0cbbca3 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 26 Apr 2024 16:13:11 +0200 Subject: cmd: eficonfig: add support for setting fdt We already support creating a load option where the device-path field contains the concatenation of the binary device-path and optionally the device path of the initrd which we expose via the EFI_LOAD_FILE2_PROTOCOL. Allow to append another device-path pointing to the device-tree identified by the device-tree GUID. Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/efi_loader.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index ddf2e41a95c..1236eecff0f 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -1185,4 +1185,18 @@ efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int */ void efi_add_known_memory(void); +/** + * efi_load_option_dp_join() - join device-paths for load option + * + * @dp: in: binary device-path, out: joined device-path + * @dp_size: size of joined device-path + * @initrd_dp: initrd device-path or NULL + * @fdt_dp: device-tree device-path or NULL + * Return: status_code + */ +efi_status_t efi_load_option_dp_join(struct efi_device_path **dp, + size_t *dp_size, + struct efi_device_path *initrd_dp, + struct efi_device_path *fdt_dp); + #endif /* _EFI_LOADER_H */ -- cgit v1.2.3 From c9463859500c0db85a3e5a0a8e347fcb35e54aae Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 26 Apr 2024 16:13:18 +0200 Subject: efi_loader: move distro_efi_get_fdt_name() Move distro_efi_get_fdt_name() to a separate C module and rename it to efi_get_distro_fdt_name(). Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/efi_loader.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 1236eecff0f..1b4bc987a23 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -1199,4 +1199,6 @@ efi_status_t efi_load_option_dp_join(struct efi_device_path **dp, struct efi_device_path *initrd_dp, struct efi_device_path *fdt_dp); +int efi_get_distro_fdt_name(char *fname, int size, int seq); + #endif /* _EFI_LOADER_H */ -- cgit v1.2.3 From 8deb5d855b360b8e63b7230854ccd690fe1dd255 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 26 Apr 2024 16:13:20 +0200 Subject: efi_loader: export efi_load_image_from_path We can reuse this function to load the device-tree. Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/efi_loader.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 1b4bc987a23..ab7bed22971 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -664,6 +664,10 @@ efi_status_t EFIAPI efi_load_image(bool boot_policy, void *source_buffer, efi_uintn_t source_size, efi_handle_t *image_handle); +/* Load image from path */ +efi_status_t efi_load_image_from_path(bool boot_policy, + struct efi_device_path *file_path, + void **buffer, efi_uintn_t *size); /* Start image */ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle, efi_uintn_t *exit_data_size, -- cgit v1.2.3 From e91b68fd6b83d6e4c862000630d240b339cc5a7b Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 26 Apr 2024 16:13:21 +0200 Subject: efi_loader: load distro dtb in bootmgr If no device-tree is specified, try to load a device-tree from the boot device use the $fdtfile concatenated to either of the paths '/dtb/', '/', '/dtb/current/'. Signed-off-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- include/efi_loader.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index ab7bed22971..6c993e1a694 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -1205,4 +1205,6 @@ efi_status_t efi_load_option_dp_join(struct efi_device_path **dp, int efi_get_distro_fdt_name(char *fname, int size, int seq); +void efi_load_distro_fdt(void **fdt, efi_uintn_t *fdt_size); + #endif /* _EFI_LOADER_H */ -- cgit v1.2.3 From 535321c2ea76de44896330040d2e43aa4645d026 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 10 Jun 2024 10:00:01 +0200 Subject: efi_loader: rename struct efi_initrd_dp to efi_lo_dp_prefix As we now also store device-tree device-paths in load options rename struct efi_initrd_dp to efi_lo_dp_prefix. Signed-off-by: Heinrich Schuchardt --- include/efi_load_initrd.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/efi_load_initrd.h b/include/efi_load_initrd.h index be5d5a7acbe..9feafb18c86 100644 --- a/include/efi_load_initrd.h +++ b/include/efi_load_initrd.h @@ -18,7 +18,17 @@ 0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68) extern const efi_guid_t efi_lf2_initrd_guid; -struct efi_initrd_dp { +/** + * struct efi_lo_dp_prefix - separator device path used in load options + * + * We use vendor media device nodes in UEFI load options to separate + * the binary, initrd, and fdt device-paths. This structure contains + * the vendor media device node and an end node. + * + * @vendor: vendor media device node + * @end: end node + */ +struct efi_lo_dp_prefix { struct efi_device_path_vendor vendor; struct efi_device_path end; } __packed; -- cgit v1.2.3