aboutsummaryrefslogtreecommitdiff
path: root/lib/efi/efi_app.c
diff options
context:
space:
mode:
authorSimon Glass2022-01-04 03:51:12 -0700
committerHeinrich Schuchardt2022-01-15 10:57:22 +0100
commit25a326b0066b3c449a0a91889b0ce19cb7320237 (patch)
tree215cd3419424c42bcdea7c8ccbeac63103ea4416 /lib/efi/efi_app.c
parentce1dc0cc17e94a0bf1c17bd1465cb0afd5bfb214 (diff)
efi: Support the efi command in the app
At present the 'efi' command only works in the EFI payload. Update it to work in the app too, so the memory map can be examined. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Diffstat (limited to 'lib/efi/efi_app.c')
-rw-r--r--lib/efi/efi_app.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 5c2593bc4d9..6980933d7ea 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -32,6 +32,39 @@ int efi_info_get(enum efi_entry_t type, void **datap, int *sizep)
return -ENOSYS;
}
+int efi_get_mmap(struct efi_mem_desc **descp, int *sizep, uint *keyp,
+ int *desc_sizep, uint *versionp)
+{
+ struct efi_priv *priv = efi_get_priv();
+ struct efi_boot_services *boot = priv->sys_table->boottime;
+ efi_uintn_t size, desc_size, key;
+ struct efi_mem_desc *desc;
+ efi_status_t ret;
+ u32 version;
+
+ /* Get the memory map so we can switch off EFI */
+ size = 0;
+ ret = boot->get_memory_map(&size, NULL, &key, &desc_size, &version);
+ if (ret != EFI_BUFFER_TOO_SMALL)
+ return log_msg_ret("get", -ENOMEM);
+
+ desc = malloc(size);
+ if (!desc)
+ return log_msg_ret("mem", -ENOMEM);
+
+ ret = boot->get_memory_map(&size, desc, &key, &desc_size, &version);
+ if (ret)
+ return log_msg_ret("get", -EINVAL);
+
+ *descp = desc;
+ *sizep = size;
+ *desc_sizep = desc_size;
+ *versionp = version;
+ *keyp = key;
+
+ return 0;
+}
+
/**
* efi_bind_block() - bind a new block device to an EFI device
*