X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fefidebug.c;h=d4030fee645ae90ab3934f27bf86998d97bfbd95;hb=22b56f428d40c681c0bac1c4b042980b160d591d;hp=a40c4f4be286ba49142719a00cae482e22006e33;hpb=7d994067424776b6184872b82fcaf4c0b95528f9;p=oweals%2Fu-boot.git diff --git a/cmd/efidebug.c b/cmd/efidebug.c index a40c4f4be2..d4030fee64 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -9,9 +9,10 @@ #include #include #include -#include #include +#include #include +#include #include #include @@ -243,6 +244,10 @@ static const struct { "HII Config Routing", EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID, }, + { + "Load File2", + EFI_LOAD_FILE2_PROTOCOL_GUID, + }, { "Simple Network", EFI_SIMPLE_NETWORK_PROTOCOL_GUID, @@ -251,27 +256,47 @@ 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, + }, + { + "Runtime properties", + EFI_RT_PROPERTIES_TABLE_GUID, + }, }; /** - * 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; } /** @@ -370,6 +395,7 @@ static const char * const efi_mem_type_string[] = { [EFI_MMAP_IO] = "IO", [EFI_MMAP_IO_PORT] = "IO PORT", [EFI_PAL_CODE] = "PAL", + [EFI_PERSISTENT_MEMORY_TYPE] = "PERSISTENT", }; static const struct efi_mem_attrs { @@ -393,6 +419,7 @@ static const struct efi_mem_attrs { /** * print_memory_attributes() - print memory map attributes + * * @attributes: Attribute value * * Print memory map attributes @@ -456,16 +483,19 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, printf("================ %.*s %.*s ==========\n", EFI_PHYS_ADDR_WIDTH, sep, EFI_PHYS_ADDR_WIDTH, sep); for (i = 0, map = memmap; i < map_size / sizeof(*map); map++, i++) { - if (map->type < EFI_MAX_MEMORY_TYPE) + if (map->type < ARRAY_SIZE(efi_mem_type_string)) type = efi_mem_type_string[map->type]; else type = "(unknown)"; printf("%-16s %.*llx-%.*llx", type, EFI_PHYS_ADDR_WIDTH, - map->physical_start, + (u64)map_to_sysmem((void *)(uintptr_t) + map->physical_start), EFI_PHYS_ADDR_WIDTH, - map->physical_start + map->num_pages * EFI_PAGE_SIZE); + (u64)map_to_sysmem((void *)(uintptr_t) + (map->physical_start + + map->num_pages * EFI_PAGE_SIZE))); print_memory_attributes(map->attribute); putc('\n'); @@ -476,6 +506,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 * @@ -486,9 +544,9 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, * Return: CMD_RET_SUCCESS on success, * CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure * - * Implement efidebug "boot add" sub-command. - * Create or change UEFI load option. - * - boot add