iPXE
Functions | Variables
efiprefix.c File Reference
#include <stdlib.h>
#include <errno.h>
#include <ipxe/device.h>
#include <ipxe/uri.h>
#include <ipxe/init.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_snp.h>
#include <ipxe/efi/efi_autoboot.h>
#include <ipxe/efi/efi_autoexec.h>
#include <ipxe/efi/efi_cachedhcp.h>
#include <ipxe/efi/efi_watchdog.h>
#include <ipxe/efi/efi_path.h>
#include <ipxe/efi/efi_veto.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
EFI_STATUS EFIAPI _efi_start (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
 EFI entry point. More...
 
static void efi_init_application (void)
 Initialise EFI application. More...
 
struct init_fn efi_init_application_fn __init_fn (INIT_NORMAL)
 EFI application initialisation function. More...
 
static int efi_probe (struct root_device *rootdev __unused)
 Probe EFI root bus. More...
 
static void efi_remove (struct root_device *rootdev __unused)
 Remove EFI root bus. More...
 

Variables

static struct root_driver efi_root_driver
 EFI root device driver. More...
 
struct root_device efi_root_device __root_device
 EFI root device. More...
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ _efi_start()

EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE  image_handle,
EFI_SYSTEM_TABLE systab 
)

EFI entry point.

Parameters
image_handleImage handle
systabSystem table
Return values
efircEFI return status code

Definition at line 44 of file efiprefix.c.

45  {
46  EFI_STATUS efirc;
47  int rc;
48 
49  /* Initialise stack cookie */
50  efi_init_stack_guard ( image_handle );
51 
52  /* Initialise EFI environment */
53  if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 )
54  goto err_init;
55 
56  /* Claim SNP devices for use by iPXE */
57  efi_snp_claim();
58 
59  /* Start watchdog holdoff timer */
61 
62  /* Call to main() */
63  if ( ( rc = main() ) != 0 ) {
64  efirc = EFIRC ( rc );
65  goto err_main;
66  }
67 
68  err_main:
71  efi_loaded_image->Unload ( image_handle );
73  err_init:
74  return efirc;
75 }
EFI_LOADED_IMAGE_PROTOCOL * efi_loaded_image
Loaded image protocol for this image.
Definition: efi_init.c:37
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void efi_init_stack_guard(EFI_HANDLE handle)
Initialise stack cookie.
Definition: efi.h:363
static void efi_snp_claim(void)
Claim network devices for use by iPXE.
Definition: efi_snp.h:91
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
Definition: efi_driver.c:624
static void efi_watchdog_start(void)
Start EFI watchdog holdoff timer.
Definition: efi_watchdog.h:17
static void efi_watchdog_stop(void)
Stop EFI watchdog holdoff timer.
Definition: efi_watchdog.h:26
EFI_IMAGE_UNLOAD Unload
Definition: LoadedImage.h:73
static void efi_snp_release(void)
Release network devices for use via SNP.
Definition: efi_snp.h:99
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_STATUS efi_init(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
Initialise EFI environment.
Definition: efi_init.c:171
__asmcall int main(void)
Main entry point.
Definition: main.c:28
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:163

References efi_driver_reconnect_all(), efi_init(), efi_init_stack_guard(), efi_loaded_image, efi_snp_claim(), efi_snp_release(), efi_watchdog_start(), efi_watchdog_stop(), EFIRC, main(), rc, and EFI_LOADED_IMAGE_PROTOCOL::Unload.

◆ efi_init_application()

static void efi_init_application ( void  )
static

Initialise EFI application.

Definition at line 81 of file efiprefix.c.

81  {
84  struct uri *uri;
85 
86  /* Set current working URI from device path, if present */
87  uri = efi_path_uri ( devpath );
88  if ( uri )
89  churi ( uri );
90  uri_put ( uri );
91 
92  /* Identify autoboot device, if any */
93  efi_set_autoboot_ll_addr ( device, devpath );
94 
95  /* Store cached DHCP packet, if any */
96  efi_cachedhcp_record ( device, devpath );
97 }
EFI_LOADED_IMAGE_PROTOCOL * efi_loaded_image
Loaded image protocol for this image.
Definition: efi_init.c:37
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:45
A hardware device.
Definition: device.h:73
EFI_DEVICE_PATH_PROTOCOL * efi_loaded_image_path
Device path for the loaded image's device handle.
Definition: efi_init.c:40
void churi(struct uri *uri)
Change working URI.
Definition: cwuri.c:45
int efi_set_autoboot_ll_addr(EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path)
Identify autoboot device.
Definition: efi_autoboot.c:49
int efi_cachedhcp_record(EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path)
Record cached DHCP packet.
Definition: efi_cachedhcp.c:47
struct uri * efi_path_uri(EFI_DEVICE_PATH_PROTOCOL *path)
Parse URI from device path.
Definition: efi_path.c:244
A Uniform Resource Identifier.
Definition: uri.h:64
Definition: efi.h:59
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
Definition: LoadedImage.h:55

References churi(), EFI_LOADED_IMAGE_PROTOCOL::DeviceHandle, efi_cachedhcp_record(), efi_loaded_image, efi_loaded_image_path, efi_path_uri(), efi_set_autoboot_ll_addr(), and uri_put().

◆ __init_fn()

struct init_fn efi_init_application_fn __init_fn ( INIT_NORMAL  )

EFI application initialisation function.

◆ efi_probe()

static int efi_probe ( struct root_device *rootdev  __unused)
static

Probe EFI root bus.

Parameters
rootdevEFI root device

Definition at line 109 of file efiprefix.c.

109  {
110 
111  /* Try loading autoexec script */
113 
114  /* Remove any vetoed drivers */
115  efi_veto();
116 
117  /* Connect our drivers */
118  return efi_driver_connect_all();
119 }
int efi_driver_connect_all(void)
Connect EFI driver to all possible devices.
Definition: efi_driver.c:602
void efi_veto(void)
Remove any vetoed drivers.
Definition: efi_veto.c:660
int efi_autoexec_load(void)
Load autoexec script.
Definition: efi_autoexec.c:165

References efi_autoexec_load(), efi_driver_connect_all(), and efi_veto().

◆ efi_remove()

static void efi_remove ( struct root_device *rootdev  __unused)
static

Remove EFI root bus.

Parameters
rootdevEFI root device

Definition at line 126 of file efiprefix.c.

126  {
127 
128  /* Disconnect our drivers */
130 }
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition: efi_driver.c:613

References efi_driver_disconnect_all().

Variable Documentation

◆ efi_root_driver

struct root_driver efi_root_driver
static
Initial value:
= {
.probe = efi_probe,
.remove = efi_remove,
}
static void efi_remove(struct root_device *rootdev __unused)
Remove EFI root bus.
Definition: efiprefix.c:126
static int efi_probe(struct root_device *rootdev __unused)
Probe EFI root bus.
Definition: efiprefix.c:109

EFI root device driver.

Definition at line 133 of file efiprefix.c.

◆ __root_device

struct root_device efi_root_device __root_device
Initial value:
= {
.dev = { .name = "EFI" },
.driver = &efi_root_driver,
}
static struct root_driver efi_root_driver
EFI root device driver.
Definition: efiprefix.c:133

EFI root device.

Definition at line 139 of file efiprefix.c.