
From: Simon Glass <sjg@chromium.org> Sometimes it is useful to see the device-path of the app itself. Add a new 'efi image' command for this. Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/efi.c | 15 +++++++++++++++ doc/usage/cmd/efi.rst | 14 ++++++++++++++ include/efi.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/cmd/efi.c b/cmd/efi.c index 91feec1c051..c59219ddf01 100644 --- a/cmd/efi.c +++ b/cmd/efi.c @@ -17,6 +17,19 @@ DECLARE_GLOBAL_DATA_PTR; +static int do_efi_image(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct efi_priv *priv = efi_get_priv(); + struct efi_loaded_image *lim = priv->loaded_image; + u16 *path; + + path = efi_dp_str(lim->file_path); + printf("Loaded-image path: %ls\n", path); + + return 0; +} + static int h_cmp_entry(const void *v1, const void *v2) { const struct efi_mem_desc *desc1 = v1; @@ -186,6 +199,7 @@ static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc, } static struct cmd_tbl efi_commands[] = { + U_BOOT_CMD_MKENT(image, 1, 1, do_efi_image, "", ""), U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""), U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""), }; @@ -211,6 +225,7 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) U_BOOT_CMD( efi, 3, 1, do_efi, "EFI access", + "image Dump loaded-image info\n" "mem [all] Dump memory information [include boot services]\n" "tables Dump tables" ); diff --git a/doc/usage/cmd/efi.rst b/doc/usage/cmd/efi.rst index b19d36188a9..e5d8913c94b 100644 --- a/doc/usage/cmd/efi.rst +++ b/doc/usage/cmd/efi.rst @@ -12,6 +12,7 @@ Synopsis :: + efi image efi mem [all] efi tables @@ -26,6 +27,16 @@ information. When running as an EFI payload, EFI boot services have been stopped, so it uses the information collected by the boot stub before that happened. +efi image +~~~~~~~~~ + +This shows the loaded image path information for the currently running EFI +application. The loaded image protocol provides access to the device path +from which the image was loaded. + +The output shows the file path in EFI device path format, displayed as a +human-readable Unicode string. + efi mem ~~~~~~~ @@ -71,6 +82,9 @@ Example :: + => efi image + Loaded-image path: u-boot-app.efi + => efi mem EFI table at 0, memory map 000000001ad38b60, size 1260, key a79, version 1, descr. size 0x30 # Type Physical Virtual Size Attributes diff --git a/include/efi.h b/include/efi.h index 2ca7cc30d52..530b127bde4 100644 --- a/include/efi.h +++ b/include/efi.h @@ -881,4 +881,6 @@ int efi_dp_from_bootdev(const struct udevice *dev, int efi_read_var(const u16 *name, const efi_guid_t *guid, u32 *attrp, struct abuf *buf, u64 *timep); +uint16_t *efi_dp_str(struct efi_device_path *dp); + #endif /* _LINUX_EFI_H */ -- 2.43.0