
From: Simon Glass <sjg@chromium.org> This function is not called from the app at present. Even if it were, it would be called later, after stdio is working, so there is no need to use printhex2() and the like. Move the function into the stub. Signed-off-by: Simon Glass <sjg@chromium.org> --- include/efi.h | 11 --------- lib/efi_client/efi.c | 48 ------------------------------------ lib/efi_client/stub.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 59 deletions(-) diff --git a/include/efi.h b/include/efi.h index c7de1f82ac7..11966ffc417 100644 --- a/include/efi.h +++ b/include/efi.h @@ -666,17 +666,6 @@ void efi_puts(struct efi_priv *priv, const char *str); */ void efi_putc(struct efi_priv *priv, const char ch); -/** - * efi_store_memory_map() - Collect the memory-map info from EFI - * - * Collect the memory info and store it for later use, e.g. in calling - * exit_boot_services() - * - * @priv: Pointer to private EFI structure - * Returns: 0 if OK, non-zero on error - */ -int efi_store_memory_map(struct efi_priv *priv); - /** * efi_stub_exit_boot_services() - Handle the exit-boot-service procedure * diff --git a/lib/efi_client/efi.c b/lib/efi_client/efi.c index e670e1f7169..c5573dd67f9 100644 --- a/lib/efi_client/efi.c +++ b/lib/efi_client/efi.c @@ -191,51 +191,3 @@ void efi_free_pool(void *ptr) efi_free(priv, ptr); } - -int efi_store_memory_map(struct efi_priv *priv) -{ - struct efi_boot_services *boot = priv->sys_table->boottime; - efi_uintn_t size, desc_size; - efi_status_t ret; - - /* Get the memory map so we can switch off EFI */ - size = 0; - ret = boot->get_memory_map(&size, NULL, &priv->memmap_key, - &priv->memmap_desc_size, - &priv->memmap_version); - if (ret != EFI_BUFFER_TOO_SMALL) { - /* - * Note this function avoids using printf() since it is not - * available in the stub - */ - printhex2(EFI_BITS_PER_LONG); - putc(' '); - printhex2(ret); - puts(" No memory map\n"); - return ret; - } - /* - * Since doing a malloc() may change the memory map and also we want to - * be able to read the memory map in efi_call_exit_boot_services() - * below, after more changes have happened - */ - priv->memmap_alloc = size + 1024; - priv->memmap_size = priv->memmap_alloc; - priv->memmap_desc = efi_malloc(priv, size, &ret); - if (!priv->memmap_desc) { - printhex2(ret); - puts(" No memory for memory descriptor\n"); - return ret; - } - - ret = boot->get_memory_map(&priv->memmap_size, priv->memmap_desc, - &priv->memmap_key, &desc_size, - &priv->memmap_version); - if (ret) { - printhex2(ret); - puts(" Can't get memory map\n"); - return ret; - } - - return 0; -} diff --git a/lib/efi_client/stub.c b/lib/efi_client/stub.c index 27366937c18..01d62c3e5c9 100644 --- a/lib/efi_client/stub.c +++ b/lib/efi_client/stub.c @@ -127,6 +127,63 @@ static void efi_copy_code(struct efi_priv *priv) (ulong)_binary_u_boot_bin_start); } +/** + * efi_store_memory_map() - Collect the memory-map info from EFI + * + * Collect the memory info and store it for later use, e.g. in calling + * exit_boot_services() + * + * @priv: Pointer to private EFI structure + * Returns: 0 if OK, non-zero on error + */ +static int efi_store_memory_map(struct efi_priv *priv) +{ + struct efi_boot_services *boot = priv->sys_table->boottime; + efi_uintn_t size, desc_size; + efi_status_t ret; + + /* Get the memory map so we can switch off EFI */ + size = 0; + ret = boot->get_memory_map(&size, NULL, &priv->memmap_key, + &priv->memmap_desc_size, + &priv->memmap_version); + if (ret != EFI_BUFFER_TOO_SMALL) { + /* + * Note this function avoids using printf() since it is not + * available in the stub + */ + printhex2(EFI_BITS_PER_LONG); + putc(' '); + printhex2(ret); + puts(" No memory map\n"); + return ret; + } + /* + * Since doing a malloc() may change the memory map and also we want to + * be able to read the memory map in efi_call_exit_boot_services() + * below, after more changes have happened + */ + priv->memmap_alloc = size + 1024; + priv->memmap_size = priv->memmap_alloc; + priv->memmap_desc = efi_malloc(priv, size, &ret); + if (!priv->memmap_desc) { + printhex2(ret); + puts(" No memory for memory descriptor\n"); + return ret; + } + + ret = boot->get_memory_map(&priv->memmap_size, priv->memmap_desc, + &priv->memmap_key, &desc_size, + &priv->memmap_version); + if (ret) { + printhex2(ret); + puts(" Can't get memory map\n"); + return ret; + } + + return 0; +} + /** * efi_main() - Start an EFI image * -- 2.43.0