From 173cd9e73ad833bf479cc5b400de5ca738ef7510 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 7 Jan 2020 06:02:33 +0100 Subject: cmd: efidebug: simplify get_guid_text() When we hit a matching GUID we can directly return the text. There is no need for a check after the loop. efi_guid_t is defined as 8 byte aligned but GUIDs in packed structures do not follow this alignment. Do not require the argument of get_guid_text() to be correctly aligned. Signed-off-by: Heinrich Schuchardt --- cmd/efidebug.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'cmd/efidebug.c') diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 1fff4390dea..45ed5be8853 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -254,24 +254,27 @@ static const struct { }; /** - * get_guid_text - get string of protocol guid - * @guid: Protocol guid - * Return: String + * get_guid_text - get string of GUID * - * Return string for display to represent the protocol. + * Return description of GUID. + * + * @guid: GUID + * Return: description of GUID or NULL */ -static const char *get_guid_text(const efi_guid_t *guid) +static const char *get_guid_text(const void *guid) { int i; - for (i = 0; i < ARRAY_SIZE(guid_list); i++) + for (i = 0; i < ARRAY_SIZE(guid_list); i++) { + /* + * As guidcmp uses memcmp() we can safely accept unaligned + * GUIDs. + */ if (!guidcmp(&guid_list[i].guid, guid)) - break; + return guid_list[i].text; + } - if (i != ARRAY_SIZE(guid_list)) - return guid_list[i].text; - else - return NULL; + return NULL; } /** -- cgit v1.2.3 From 986e0648840710b55a93587fc166296365e03f24 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 7 Jan 2020 05:57:47 +0100 Subject: cmd: efidebug: new sub-command tables Provide sub-command for efidebug to list configuration tables. Signed-off-by: Heinrich Schuchardt --- cmd/efidebug.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'cmd/efidebug.c') diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 45ed5be8853..78fc6497827 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -251,6 +251,19 @@ static const struct { "PXE Base Code", EFI_PXE_BASE_CODE_PROTOCOL_GUID, }, + /* Configuration table GUIDs */ + { + "ACPI table", + EFI_ACPI_TABLE_GUID, + }, + { + "device tree", + EFI_FDT_GUID, + }, + { + "SMBIOS table", + SMBIOS_TABLE_GUID, + }, }; /** @@ -480,6 +493,34 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, return CMD_RET_SUCCESS; } +/** + * do_efi_show_tables() - show UEFI configuration tables + * + * @cmdtp: Command table + * @flag: Command flag + * @argc: Number of arguments + * @argv: Argument array + * Return: CMD_RET_SUCCESS on success, CMD_RET_RET_FAILURE on failure + * + * Implement efidebug "tables" sub-command. + * Show UEFI configuration tables. + */ +static int do_efi_show_tables(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + efi_uintn_t i; + const char *guid_str; + + for (i = 0; i < systab.nr_tables; ++i) { + guid_str = get_guid_text(&systab.tables[i].guid); + if (!guid_str) + guid_str = ""; + printf("%pUl %s\n", &systab.tables[i].guid, guid_str); + } + + return CMD_RET_SUCCESS; +} + /** * do_efi_boot_add() - set UEFI load option * @@ -1047,6 +1088,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = { "", ""), 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, + "", ""), }; /** @@ -1114,7 +1157,9 @@ static char efidebug_help_text[] = "efidebug images\n" " - show loaded images\n" "efidebug memmap\n" - " - show uefi memory map\n"; + " - show uefi memory map\n" + "efidebug tables\n" + " - show UEFI configuration tables\n"; #endif U_BOOT_CMD( -- cgit v1.2.3 From 07e2fe797115b1239c513ba12caa017978322da0 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 7 Jan 2020 07:48:15 +0100 Subject: cmd: efidebug: capitalize UEFI %s/uefi/UEFI/g Signed-off-by: Heinrich Schuchardt --- cmd/efidebug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cmd/efidebug.c') diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 78fc6497827..576e95b395d 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -1149,15 +1149,15 @@ static char efidebug_help_text[] = " - set/show UEFI boot order\n" "\n" "efidebug devices\n" - " - show uefi devices\n" + " - show UEFI devices\n" "efidebug drivers\n" - " - show uefi drivers\n" + " - show UEFI drivers\n" "efidebug dh\n" - " - show uefi handles\n" + " - show UEFI handles\n" "efidebug images\n" " - show loaded images\n" "efidebug memmap\n" - " - show uefi memory map\n" + " - show UEFI memory map\n" "efidebug tables\n" " - show UEFI configuration tables\n"; #endif -- cgit v1.2.3