summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efiprefix.c
diff options
context:
space:
mode:
authorMichael Brown2021-02-17 18:07:12 +0100
committerMichael Brown2021-02-17 18:14:19 +0100
commitd562339fcaf1bf5fb2e27f7c465e8633804c30b5 (patch)
treebc0a1335d1b2f8a99a97533e61a453ba58e6b484 /src/interface/efi/efiprefix.c
parent[efi] Split out autoexec script portions of efi_autoboot.c (diff)
downloadipxe-d562339fcaf1bf5fb2e27f7c465e8633804c30b5.tar.gz
ipxe-d562339fcaf1bf5fb2e27f7c465e8633804c30b5.tar.xz
ipxe-d562339fcaf1bf5fb2e27f7c465e8633804c30b5.zip
[efi] Defer autoboot link-layer address and autoexec script probing
The code to detect the autoboot link-layer address and to load the autoexec script currently runs before the call to initialise() and so has to function without a working heap. This requirement can be relaxed by deferring this code to run via an initialisation function. This gives the code a normal runtime environment, but still invokes it early enough to guarantee that the original loaded image device handle has not yet been invalidated. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efiprefix.c')
-rw-r--r--src/interface/efi/efiprefix.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/interface/efi/efiprefix.c b/src/interface/efi/efiprefix.c
index 928f41c7..47fbe79a 100644
--- a/src/interface/efi/efiprefix.c
+++ b/src/interface/efi/efiprefix.c
@@ -22,6 +22,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <stdlib.h>
#include <errno.h>
#include <ipxe/device.h>
+#include <ipxe/init.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_snp.h>
@@ -49,12 +50,6 @@ EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 )
goto err_init;
- /* Identify autoboot device, if any */
- efi_set_autoboot_ll_addr ( efi_loaded_image->DeviceHandle );
-
- /* Load autoexec script, if any */
- efi_autoexec_load ( efi_loaded_image->DeviceHandle );
-
/* Claim SNP devices for use by iPXE */
efi_snp_claim();
@@ -77,6 +72,25 @@ EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
}
/**
+ * Initialise EFI application
+ *
+ */
+static void efi_init_application ( void ) {
+ EFI_HANDLE device = efi_loaded_image->DeviceHandle;
+
+ /* Identify autoboot device, if any */
+ efi_set_autoboot_ll_addr ( device );
+
+ /* Load autoexec script, if any */
+ efi_autoexec_load ( device );
+}
+
+/** EFI application initialisation function */
+struct init_fn efi_init_application_fn __init_fn ( INIT_NORMAL ) = {
+ .initialise = efi_init_application,
+};
+
+/**
* Probe EFI root bus
*
* @v rootdev EFI root device