
From: Simon Glass <sjg@chromium.org> When the app is booting a kernel without using EFI, it must first exit the boot services provided by EFI. Add a hook for this, using bootm_final() Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) board/efi/efi-arm_app/board.c | 30 ++++++++++++++++++++++++++++++ include/efi.h | 11 +++++++++++ lib/efi_client/efi_app.c | 12 ++++++++++++ 3 files changed, 53 insertions(+) diff --git a/board/efi/efi-arm_app/board.c b/board/efi/efi-arm_app/board.c index 239e1fbaba4..ce6c3e78ebc 100644 --- a/board/efi/efi-arm_app/board.c +++ b/board/efi/efi-arm_app/board.c @@ -3,6 +3,9 @@ * Copyright (c) 2015 Google, Inc */ +#include <bootm.h> +#include <efi.h> +#include <event.h> #include <init.h> struct mm_region *mem_map; @@ -16,3 +19,30 @@ int board_init(void) { return 0; } + +int board_exit_boot_services(void *ctx, struct event *evt) +{ + struct efi_priv *priv = efi_get_priv(); + struct efi_mem_desc *desc; + int desc_size; + uint version; + int size; + uint key; + int ret; + + printf("Exiting EFI\n"); + ret = efi_get_mmap(&desc, &size, &key, &desc_size, &version); + if (ret) { + printf("efi: Failed to get memory map\n"); + return -EFAULT; + } + + ret = efi_app_exit_boot_services(priv, key); + if (ret) + return ret; + + /* no console output after here as there are no EFI drivers! */ + + return 0; +} +EVENT_SPY_FULL(EVT_BOOTM_FINAL, board_exit_boot_services); diff --git a/include/efi.h b/include/efi.h index e558c1f6a38..9ff945ae1c3 100644 --- a/include/efi.h +++ b/include/efi.h @@ -675,6 +675,17 @@ void efi_putc(struct efi_priv *priv, const char ch); */ int efi_stub_exit_boot_services(void); +/** + * efi_app_exit_boot_services() - Handle the exit-boot-service procedure + * + * Tell EFI we don't want their boot services anymore + * + * This is only available in the app + * + * Return: 0 if OK, non-zero on error + */ +int efi_app_exit_boot_services(struct efi_priv *priv, uint key); + /** * efi_get_mmap() - Get the memory map from EFI * diff --git a/lib/efi_client/efi_app.c b/lib/efi_client/efi_app.c index 9b895f144aa..ea53c3c1678 100644 --- a/lib/efi_client/efi_app.c +++ b/lib/efi_client/efi_app.c @@ -276,6 +276,18 @@ int board_fixup_os(void *ctx, struct event *evt) } EVENT_SPY_FULL(EVT_BOOT_OS_ADDR, board_fixup_os); +int efi_app_exit_boot_services(struct efi_priv *priv, uint key) +{ + const struct efi_boot_services *boot = priv->boot; + int ret; + + ret = boot->exit_boot_services(priv->parent_image, key); + if (ret) + return ret; + + return 0; +} + static const struct udevice_id efi_sysreset_ids[] = { { .compatible = "efi,reset" }, { } -- 2.43.0