
From: Simon Glass <sjg@chromium.org> Add a new 'efidebug media' subcommand to show media devices and their device-paths. Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/efidebug.c | 43 ++++++++++++++++++++++++++++++++++++++ doc/usage/cmd/efidebug.rst | 21 ++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 1515a508e2d..1d943113054 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -8,6 +8,8 @@ #include <charset.h> #include <command.h> #include <dm/device.h> +#include <dm/uclass.h> +#include <efi.h> #include <efi_device_path.h> #include <efi_dt_fixup.h> #include <efi_load_initrd.h> @@ -1604,6 +1606,43 @@ static int do_efi_test(struct cmd_tbl *cmdtp, int flag, return cp->cmd(cmdtp, flag, argc, argv); } +/** + * do_efi_show_media() - show EFI media devices + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, CMD_RET_FAILURE on failure + * + * Implement efidebug "media" sub-command. + * Show all EFI media devices and their device paths. + */ +static int do_efi_show_media(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) +{ + struct udevice *dev; + struct uclass *uc; + int ret; + + ret = uclass_get(UCLASS_EFI_MEDIA, &uc); + if (ret) { + printf("Cannot get EFI media uclass: (err=%dE)\n", ret); + return CMD_RET_FAILURE; + } + + printf("Device Device Path\n"); + printf("------------------- -----------\n"); + + uclass_foreach_dev(dev, uc) { + struct efi_media_plat *plat = dev_get_plat(dev); + + printf("%-20s %pD\n", dev->name, plat->device_path); + } + + return CMD_RET_SUCCESS; +} + /** * do_efi_query_info() - QueryVariableInfo EFI service * @@ -1670,6 +1709,8 @@ static struct cmd_tbl cmd_efidebug_sub[] = { U_BOOT_CMD_MKENT(images, CONFIG_SYS_MAXARGS, 1, do_efi_show_images, "", ""), U_BOOT_CMD_MKENT(log, CONFIG_SYS_MAXARGS, 1, do_efi_show_log, "", ""), + U_BOOT_CMD_MKENT(media, CONFIG_SYS_MAXARGS, 1, do_efi_show_media, + "", ""), U_BOOT_CMD_MKENT(memmap, CONFIG_SYS_MAXARGS, 1, do_efi_show_memmap, "", ""), U_BOOT_CMD_MKENT(tables, CONFIG_SYS_MAXARGS, 1, do_efi_show_tables, @@ -1772,6 +1813,8 @@ U_BOOT_LONGHELP(efidebug, " - show loaded images\n" "efidebug log\n" " - show UEFI log\n" + "efidebug media\n" + " - show EFI media devices\n" "efidebug memmap\n" " - show UEFI memory map\n" "efidebug tables\n" diff --git a/doc/usage/cmd/efidebug.rst b/doc/usage/cmd/efidebug.rst index 5eca4079f82..90e0b9c4546 100644 --- a/doc/usage/cmd/efidebug.rst +++ b/doc/usage/cmd/efidebug.rst @@ -14,6 +14,7 @@ Synopsis :: efidebug log + efidebug media Description ----------- @@ -21,7 +22,7 @@ Description The *efidebug* command provides access to debugging features for the EFI-loader subsystem. -Only one of the subcommands are documented at present. +Only two of the subcommands are documented at present. efidebug log ~~~~~~~~~~~~ @@ -30,10 +31,28 @@ This shows a log of EFI boot-services calls which have been handled since U-Boot started. This can be useful to see what the app is doing, or even what U-Boot itself has called. +efidebug media +~~~~~~~~~~~~~~ + +This shows a list of all EFI media devices and their corresponding device paths. +Each EFI media device represents a block device that was discovered through EFI +boot services, such as hard drives, USB storage, or other bootable media. The +device path shows the EFI device path for each device, which can be useful for +debugging boot issues or understanding the system topology. + Example ------- +This shows checking the EFI media devices:: + + => efidebug media + Device Device Path + ------ ----------- + efi_media_1 PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) + efi_media_2 PciRoot(0x0)/Pci(0x5,0x0) + + This shows checking the log, then using 'efidebug tables' to fully set up the EFI-loader subsystem, then checking the log again:: -- 2.43.0