@@ -470,6 +470,120 @@ static int do_efi_show_drivers(cmd_tbl_t *cmdtp, int flag,
return CMD_RET_SUCCESS;
}
+static const struct {
+ const char *text;
+ const efi_guid_t guid;
+} guid_list[] = {
+ {
+ "Device Path",
+ DEVICE_PATH_GUID,
+ },
+ {
+ "Device Path To Text",
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID,
+ },
+ {
+ "Device Path Utilities",
+ EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID,
+ },
+ {
+ "Unicode Collation 2",
+ EFI_UNICODE_COLLATION_PROTOCOL2_GUID,
+ },
+ {
+ "Driver Binding",
+ EFI_DRIVER_BINDING_PROTOCOL_GUID,
+ },
+ {
+ "Simple Text Input",
+ EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID,
+ },
+ {
+ "Simple Text Input Ex",
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID,
+ },
+ {
+ "Simple Text Output",
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID,
+ },
+ {
+ "Block IO",
+ BLOCK_IO_GUID,
+ },
+ {
+ "Simple File System",
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
+ },
+ {
+ "Loaded Image",
+ LOADED_IMAGE_PROTOCOL_GUID,
+ },
+ {
+ "GOP",
+ EFI_GOP_GUID,
+ },
+};
+
+static const char *get_guid_text(const efi_guid_t *guid)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(guid_list); i++)
+ if (!guidcmp(&guid_list[i].guid, guid))
+ break;
+
+ if (i != ARRAY_SIZE(guid_list))
+ return guid_list[i].text;
+ else
+ return NULL;
+}
+
+static int do_efi_show_handles(cmd_tbl_t *cmdtp, int flag,
+ int argc, char * const argv[])
+{
+ efi_handle_t *handles;
+ efi_guid_t **guid;
+ efi_uintn_t count;
+ const char *guid_text;
+ int num, i, j;
+ 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++) {
+ if (j)
+ printf(", ");
+ else
+ putc(' ');
+
+ guid_text = get_guid_text(guid[j]);
+ if (guid_text)
+ puts(guid_text);
+ else
+ printf("%pUl", guid[j]);
+ }
+ putc('\n');
+ }
+
+ free(handles);
+
+ return CMD_RET_SUCCESS;
+}
+
static int do_efi_boot_add(cmd_tbl_t *cmdtp, int flag,
int argc, char * const argv[])
{
@@ -867,6 +981,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = {
"", ""),
U_BOOT_CMD_MKENT(drivers, CONFIG_SYS_MAXARGS, 1, do_efi_show_drivers,
"", ""),
+ U_BOOT_CMD_MKENT(dh, CONFIG_SYS_MAXARGS, 1, do_efi_show_handles,
+ "", ""),
};
/* Interpreter command to configure UEFI environment */
@@ -921,7 +1037,9 @@ static char efidebug_help_text[] =
"efidebug devices\n"
" - show uefi devices\n"
"efidebug drivers\n"
- " - show uefi drivers\n";
+ " - show uefi drivers\n"
+ "efidebug dh\n"
+ " - show uefi handles\n";
#endif
U_BOOT_CMD(
"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@linaro.org> --- cmd/efidebug.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-)