efi: Add an efi subcommand to show the loaded image
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>
This commit is contained in:
30
cmd/efi.c
30
cmd/efi.c
@@ -17,6 +17,34 @@
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
static bool is_app(void)
|
||||
{
|
||||
if (!IS_ENABLED(CONFIG_EFI_APP)) {
|
||||
printf("This command is only available in the app\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int do_efi_image(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||
char *const argv[])
|
||||
{
|
||||
struct efi_loaded_image *lim;
|
||||
struct efi_priv *priv;
|
||||
u16 *path;
|
||||
|
||||
if (!is_app())
|
||||
return CMD_RET_FAILURE;
|
||||
|
||||
priv = efi_get_priv();
|
||||
lim = priv->loaded_image;
|
||||
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 +214,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 +240,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"
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user