
From: Simon Glass <sjg@chromium.org> It is helpful to see the memory map in some cases, so enable this subcommand in the app. Unfortunately we cannot assume that desc_size is the same in the underlying EFI implementation, so use a variable for that. Signed-off-by: Simon Glass <sjg@chromium.org> --- cmd/efidebug.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 2e156fef525..d93fa43b779 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -659,15 +659,24 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, struct efi_mem_desc *memmap, *map; efi_uintn_t map_size; const char *type; - int i; - efi_status_t ret; + int desc_size, i; + efi_status_t eret; + int ret; - if (app_not_supported("memmap")) - return CMD_RET_FAILURE; + if (IS_ENABLED(CONFIG_EFI_APP)) { + uint key, version; + int size; - ret = efi_get_memory_map_alloc(&map_size, &memmap); - if (ret != EFI_SUCCESS) - return CMD_RET_FAILURE; + ret = efi_get_mmap(&memmap, &size, &key, &desc_size, &version); + if (ret) + return CMD_RET_FAILURE; + map_size = size; + } else { + eret = efi_get_memory_map_alloc(&map_size, &memmap); + if (eret) + return CMD_RET_FAILURE; + desc_size = sizeof(*map); + } printf("Type Start%.*s End%.*s Attributes\n", EFI_PHYS_ADDR_WIDTH - 5, spc, EFI_PHYS_ADDR_WIDTH - 3, spc); @@ -678,7 +687,8 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, * This is a false positive as memmap will always be * populated by allocate_pool() above. */ - for (i = 0, map = memmap; i < map_size / sizeof(*map); map++, i++) { + for (i = 0, map = memmap; i < map_size / desc_size; + map = (void *)map + desc_size, i++) { if (map->type < ARRAY_SIZE(efi_mem_type_string)) type = efi_mem_type_string[map->type]; else -- 2.43.0