From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: [PATCH 6/8] efi_loader: Update testapp to get memory map correctly
Date: Mon, 6 Jan 2025 07:47:53 -0700 [thread overview]
Message-ID: <20250106144755.3054780-7-sjg@chromium.org> (raw)
In-Reply-To: <20250106144755.3054780-1-sjg@chromium.org>
Allocate enough memory for the memory map so that it can be received
successfully.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
lib/efi_loader/testapp.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/lib/efi_loader/testapp.c b/lib/efi_loader/testapp.c
index 804ca7e4679..171ecdab043 100644
--- a/lib/efi_loader/testapp.c
+++ b/lib/efi_loader/testapp.c
@@ -28,7 +28,12 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
struct efi_system_table *systab)
{
struct efi_loaded_image *loaded_image;
+ struct efi_mem_desc *map;
efi_status_t ret;
+ efi_uintn_t map_size;
+ efi_uintn_t map_key;
+ efi_uintn_t desc_size;
+ u32 desc_version;
systable = systab;
boottime = systable->boottime;
@@ -48,6 +53,29 @@ efi_status_t EFIAPI efi_main(efi_handle_t handle,
con_out->output_string(con_out, u"U-Boot test app for EFI_LOADER\r\n");
out:
+ map_size = 0;
+ ret = boottime->get_memory_map(&map_size, NULL, &map_key, &desc_size,
+ &desc_version);
+ if (ret != EFI_BUFFER_TOO_SMALL) {
+ con_out->output_string(con_out, u"map error A\n");
+ return ret;
+ }
+
+ ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,
+ (void **)&map);
+ if (ret) {
+ con_out->output_string(con_out, u"map error B\n");
+ return ret;
+ }
+ /* Allocate extra space for newly allocated memory */
+ map_size += sizeof(struct efi_mem_desc);
+ ret = boottime->get_memory_map(&map_size, map, &map_key, &desc_size,
+ &desc_version);
+ if (ret) {
+ con_out->output_string(con_out, u"map error C\n");
+ return ret;
+ }
+
con_out->output_string(con_out, u"Exiting test app\n");
ret = boottime->exit(handle, ret, 0, NULL);
--
2.34.1
next prev parent reply other threads:[~2025-01-06 14:48 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-06 14:47 [PATCH 0/8] efi_loader: Complete the bootflow_efi() test Simon Glass
2025-01-06 14:47 ` [PATCH 1/8] sandbox: Make USB controller as having active DMA Simon Glass
2025-01-06 14:47 ` [PATCH 2/8] efi_loader: Fix display of addresses in log Simon Glass
2025-01-07 13:37 ` Ilias Apalodimas
2025-01-07 13:57 ` Simon Glass
2025-01-08 7:12 ` Ilias Apalodimas
2025-01-08 17:03 ` Simon Glass
2025-01-06 14:47 ` [PATCH 3/8] efi_loader: Return the memory map in pointer format Simon Glass
2025-01-06 14:47 ` [PATCH 4/8] efi_loader: Correct bounce-buffer setup Simon Glass
2025-01-17 10:33 ` Ilias Apalodimas
2025-01-18 4:35 ` Simon Glass
2025-01-06 14:47 ` [PATCH 5/8] efi_loader: Check memory allocations in bootflow_efi test() Simon Glass
2025-01-06 14:47 ` Simon Glass [this message]
2025-01-06 14:47 ` [PATCH 7/8] efi_loader: Check that the bootflow is not removed by app Simon Glass
2025-01-06 14:47 ` [PATCH 8/8] efi_loader: Test that active-DMA devices are removed Simon Glass
2025-01-06 17:00 ` [PATCH 0/8] efi_loader: Complete the bootflow_efi() test Heinrich Schuchardt
2025-01-07 12:15 ` Simon Glass
2025-01-07 13:11 ` Heinrich Schuchardt
2025-01-07 13:57 ` Simon Glass
2025-01-07 15:11 ` Tom Rini
2025-01-07 15:47 ` Heinrich Schuchardt
2025-01-08 13:39 ` Caleb Connolly
2025-01-08 17:02 ` Simon Glass
2025-01-08 17:02 ` Simon Glass
2025-01-08 19:14 ` Tom Rini
2025-01-09 15:02 ` Simon Glass
2025-01-09 16:51 ` Tom Rini
2025-01-10 13:40 ` Simon Glass
2025-01-10 16:48 ` Tom Rini
2025-01-13 19:01 ` Simon Glass
2025-01-13 20:20 ` Tom Rini
2025-01-18 4:35 ` Simon Glass
2025-01-18 17:03 ` Tom Rini
2025-01-18 17:15 ` Tom Rini
2025-01-31 0:10 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250106144755.3054780-7-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=ilias.apalodimas@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.