[U-Boot] [PATCH v4 5/9] cmd: efitool: add dh command
AKASHI Takahiro
takahiro.akashi at linaro.org
Tue Jan 15 02:55:18 UTC 2019
"dh" command prints all the uefi handles used in the system.
=> efi dh
7ef3bfa0: Device Path, Device Path To Text, Device Path Utilities,
Unicode Collation 2
7ef31d30: Driver Binding
7ef31da0: Simple Text Output
7ef31e10: Simple Text Input, Simple Text Input Ex
7ef3cca0: Block IO, Device Path
7ef3d070: Block IO, Device Path
7ef3d1b0: Block IO, Device Path, Simple File System
7ef3d3e0: Block IO, Device Path, Simple File System
Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
cmd/efitool.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 102 insertions(+), 1 deletion(-)
diff --git a/cmd/efitool.c b/cmd/efitool.c
index 4d46721fbf91..4bd6367b4bd9 100644
--- a/cmd/efitool.c
+++ b/cmd/efitool.c
@@ -436,6 +436,103 @@ static int do_efi_show_drivers(int argc, char * const argv[])
return CMD_RET_SUCCESS;
}
+static struct {
+ u16 *name;
+ efi_guid_t guid;
+} guid_list[] = {
+ {
+ L"Device Path",
+ DEVICE_PATH_GUID,
+ },
+ {
+ L"Device Path To Text",
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID,
+ },
+ {
+ L"Device Path Utilities",
+ EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID,
+ },
+ {
+ L"Unicode Collation 2",
+ EFI_UNICODE_COLLATION_PROTOCOL2_GUID,
+ },
+ {
+ L"Driver Binding",
+ EFI_DRIVER_BINDING_PROTOCOL_GUID,
+ },
+ {
+ L"Simple Text Input",
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID,
+ },
+ {
+ L"Simple Text Input Ex",
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID,
+ },
+ {
+ L"Simple Text Output",
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID,
+ },
+ {
+ L"Block IO",
+ BLOCK_IO_GUID,
+ },
+ {
+ L"Simple File System",
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
+ },
+ {
+ NULL,
+ {{0,},},
+ },
+};
+
+static int do_efi_show_handles(int argc, char * const argv[])
+{
+ efi_handle_t *handles;
+ efi_guid_t **guid;
+ efi_uintn_t count;
+ int num, i, j, k;
+ efi_status_t ret;
+
+ handles = NULL;
+ num = 0;
+ if (efi_get_handles_by_proto(NULL, &handles, &num))
+ return CMD_RET_FAILURE;
+
+ if (!num)
+ return CMD_RET_SUCCESS;
+
+ for (i = 0; i < num; i++) {
+ printf("%16p:", handles[i]);
+ ret = BS->protocols_per_handle(handles[i], &guid, &count);
+ if (ret || !count) {
+ putc('\n');
+ continue;
+ }
+
+ for (j = 0; j < count; j++) {
+ for (k = 0; guid_list[k].name; k++)
+ if (!guidcmp(&guid_list[k].guid, guid[j]))
+ break;
+
+ if (j)
+ printf(", ");
+ else
+ putc(' ');
+
+ if (guid[j])
+ printf("%ls", guid_list[k].name);
+ else
+ printf("%pUl", guid[j]);
+ }
+ putc('\n');
+ }
+
+ free(handles);
+
+ return CMD_RET_SUCCESS;
+}
+
static int do_efi_boot_add(int argc, char * const argv[])
{
int id;
@@ -847,6 +944,8 @@ static int do_efitool(cmd_tbl_t *cmdtp, int flag,
return do_efi_show_devices(argc, argv);
else if (!strcmp(command, "drivers"))
return do_efi_show_drivers(argc, argv);
+ else if (!strcmp(command, "dh"))
+ return do_efi_show_handles(argc, argv);
else
return CMD_RET_USAGE;
}
@@ -875,7 +974,9 @@ static char efitool_help_text[] =
"efitool devices\n"
" - show uefi devices\n"
"efitool drivers\n"
- " - show uefi drivers\n";
+ " - show uefi drivers\n"
+ "efitool dh\n"
+ " - show uefi handles\n";
#endif
U_BOOT_CMD(
--
2.19.1
More information about the U-Boot
mailing list