summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-01-05 20:26:01 +0300
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-01-07 00:27:30 +0300
commiteff444019545642a844431692dd51829aa52528c (patch)
treee52a108d870a0313f4f24a7f2f6a9e4acdfcfcdf /cmd
parentf4af97cdb4b9d702bf7d76d896e3b6d13a162bb3 (diff)
downloadu-boot-eff444019545642a844431692dd51829aa52528c.tar.xz
efi_loader: carve out efi_get_memory_map_alloc()
Carve out code from efidebug command used to read the memory map. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/efidebug.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 569003ae2e..e6959ede93 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -591,25 +591,15 @@ static void print_memory_attributes(u64 attributes)
static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
- struct efi_mem_desc *memmap = NULL, *map;
- efi_uintn_t map_size = 0;
+ struct efi_mem_desc *memmap, *map;
+ efi_uintn_t map_size;
const char *type;
int i;
efi_status_t ret;
- ret = efi_get_memory_map(&map_size, memmap, NULL, NULL, NULL);
- if (ret == EFI_BUFFER_TOO_SMALL) {
- map_size += sizeof(struct efi_mem_desc); /* for my own */
- ret = efi_allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,
- (void *)&memmap);
- if (ret != EFI_SUCCESS)
- return CMD_RET_FAILURE;
- ret = efi_get_memory_map(&map_size, memmap, NULL, NULL, NULL);
- }
- if (ret != EFI_SUCCESS) {
- efi_free_pool(memmap);
+ ret = efi_get_memory_map_alloc(&map_size, &memmap);
+ if (ret != EFI_SUCCESS)
return CMD_RET_FAILURE;
- }
printf("Type Start%.*s End%.*s Attributes\n",
EFI_PHYS_ADDR_WIDTH - 5, spc, EFI_PHYS_ADDR_WIDTH - 3, spc);