iPXE
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)
 FILE_SECBOOT (PERMITTED)
EFI_STATUS EFIAPI _efi_start (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
 EFI entry point.
static void efi_init_application (void)
 Initialise EFI application.
struct init_fn efi_init_application_fn __init_fn (INIT_NORMAL)
 EFI application initialisation function.
static int efi_probe (struct root_device *rootdev __unused)
 Probe EFI root bus.
static void efi_remove (struct root_device *rootdev __unused)
 Remove EFI root bus.

Variables

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

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ _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 45 of file efiprefix.c.

46 {
47 EFI_STATUS efirc;
48 int rc;
49
50 /* Initialise stack cookie */
51 efi_init_stack_guard ( image_handle );
52
53 /* Initialise EFI environment */
54 if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 )
55 goto err_init;
56
57 /* Claim SNP devices for use by iPXE */
59
60 /* Start watchdog holdoff timer */
62
63 /* Call to main() */
64 if ( ( rc = main() ) != 0 ) {
65 efirc = EFIRC ( rc );
66 goto err_main;
67 }
68
69 err_main:
72 efi_loaded_image->Unload ( image_handle );
74 err_init:
75 return efirc;
76}
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
void efi_driver_reconnect_all(void)
Reconnect original EFI drivers to all possible devices.
Definition efi_driver.c:659
EFI_STATUS efi_init(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
Initialise EFI environment.
Definition efi_init.c:155
EFI_LOADED_IMAGE_PROTOCOL * efi_loaded_image
Loaded image protocol for this image.
Definition efi_init.c:39
static void efi_snp_claim(void)
Claim network devices for use by iPXE.
Definition efi_snp.h:92
static void efi_snp_release(void)
Release network devices for use via SNP.
Definition efi_snp.h:100
static void efi_watchdog_start(void)
Start EFI watchdog holdoff timer.
static void efi_watchdog_stop(void)
Stop EFI watchdog holdoff timer.
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition efi.h:167
static void efi_init_stack_guard(EFI_HANDLE handle)
Initialise stack cookie.
Definition efi.h:387
__asmcall int main(void)
Main entry point.
Definition main.c:29

References efi_driver_reconnect_all(), EFI_HANDLE, efi_init(), efi_init_stack_guard(), efi_loaded_image, efi_snp_claim(), efi_snp_release(), efi_watchdog_start(), efi_watchdog_stop(), EFIAPI, EFIRC, main(), and rc.

◆ efi_init_application()

void efi_init_application ( void )
static

Initialise EFI application.

Definition at line 82 of file efiprefix.c.

82 {
83 EFI_HANDLE device = efi_loaded_image->DeviceHandle;
86 struct uri *uri;
87
88 /* Set current working URI from device path, if present */
89 bootpath = efi_current_boot_path();
90 DBGC ( device, "EFI has loaded image device path %s\n",
91 efi_devpath_text ( devpath ) );
92 DBGC ( device, "EFI has boot option device path %s\n",
93 efi_devpath_text ( bootpath ) );
94 uri = efi_path_uri ( devpath );
95 if ( bootpath && ( ! uri ) )
96 uri = efi_path_uri ( bootpath );
97 if ( uri )
98 churi ( uri );
99 uri_put ( uri );
100 free ( bootpath );
101
102 /* Identify autoboot device, if any */
103 efi_set_autoboot_ll_addr ( device, devpath );
104
105 /* Store cached DHCP packet, if any */
106 efi_cachedhcp_record ( device, devpath );
107}
void churi(struct uri *uri)
Change working URI.
Definition cwuri.c:46
int efi_set_autoboot_ll_addr(EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path)
Identify autoboot device.
int efi_cachedhcp_record(EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *path)
Record cached DHCP packet.
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition efi_debug.c:247
EFI_DEVICE_PATH_PROTOCOL * efi_loaded_image_path
Device path for the loaded image's device handle.
Definition efi_init.c:42
EFI_DEVICE_PATH_PROTOCOL * efi_current_boot_path(void)
Get EFI device path for current boot option.
Definition efi_path.c:887
struct uri * efi_path_uri(EFI_DEVICE_PATH_PROTOCOL *path)
Parse URI from device path.
Definition efi_path.c:301
#define DBGC(...)
Definition compiler.h:505
#define EFI_HANDLE
Definition efi.h:53
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition DevicePath.h:46
A hardware device.
Definition device.h:77
A Uniform Resource Identifier.
Definition uri.h:65
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition uri.h:206

References churi(), DBGC, efi_cachedhcp_record(), efi_current_boot_path(), efi_devpath_text(), EFI_HANDLE, efi_loaded_image, efi_loaded_image_path, efi_path_uri(), efi_set_autoboot_ll_addr(), free, and uri_put().

Referenced by __init_fn().

◆ __init_fn()

struct init_fn efi_init_application_fn __init_fn ( INIT_NORMAL )

EFI application initialisation function.

References __init_fn, efi_init_application(), and INIT_NORMAL.

◆ efi_probe()

int efi_probe ( struct root_device *rootdev __unused)
static

Probe EFI root bus.

Parameters
rootdevEFI root device

Definition at line 120 of file efiprefix.c.

120 {
121
122 /* Try loading autoexec script */
124
125 /* Remove any vetoed drivers */
126 efi_veto();
127
128 /* Connect our drivers */
129 return efi_driver_connect_all();
130}
int efi_autoexec_load(void)
Load autoexec script.
int efi_driver_connect_all(void)
Connect EFI driver to all possible devices.
Definition efi_driver.c:637
void efi_veto(void)
Remove any vetoed drivers.
Definition efi_veto.c:615

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

◆ efi_remove()

void efi_remove ( struct root_device *rootdev __unused)
static

Remove EFI root bus.

Parameters
rootdevEFI root device

Definition at line 137 of file efiprefix.c.

137 {
138
139 /* Disconnect our drivers */
141}
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition efi_driver.c:648

References __unused, and 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.
static int efi_probe(struct root_device *rootdev __unused)
Probe EFI root bus.

EFI root device driver.

Definition at line 144 of file efiprefix.c.

144 {
145 .probe = efi_probe,
146 .remove = efi_remove,
147};

◆ __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.

EFI root device.

Definition at line 150 of file efiprefix.c.

150 {
151 .dev = { .name = "EFI" },
152 .driver = &efi_root_driver,
153};