iPXE
Functions | Variables
efi_init.c File Reference
#include <string.h>
#include <errno.h>
#include <endian.h>
#include <ipxe/init.h>
#include <ipxe/rotate.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_path.h>
#include <ipxe/efi/efi_cmdline.h>
#include <ipxe/efi/Protocol/LoadedImage.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 
EFI_SYSTEM_TABLE_C2 (PLATFORM, _systab)
 System table passed to entry point. More...
 
static EFI_STATUS EFIAPI efi_unload (EFI_HANDLE image_handle __unused)
 Shut down EFI environment. More...
 
static EFIAPI void efi_shutdown_hook (EFI_EVENT event __unused, void *context __unused)
 Shut down in preparation for booting an OS. More...
 
static void * efi_find_table (EFI_GUID *guid)
 Look up EFI configuration table. More...
 
unsigned long efi_stack_cookie (EFI_HANDLE handle)
 Construct a stack cookie value. More...
 
EFI_STATUS efi_init (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *systab)
 Initialise EFI environment. More...
 
void __stack_chk_fail (void)
 Abort on stack check failure. More...
 
void efi_raise_tpl (struct efi_saved_tpl *tpl)
 Raise task priority level to internal level. More...
 
void efi_restore_tpl (struct efi_saved_tpl *tpl)
 Restore task priority level. More...
 

Variables

EFI_HANDLE efi_image_handle
 Image handle passed to entry point. More...
 
EFI_LOADED_IMAGE_PROTOCOLefi_loaded_image
 Loaded image protocol for this image. More...
 
EFI_DEVICE_PATH_PROTOCOLefi_loaded_image_path
 Device path for the loaded image's device handle. More...
 
EFI_TPL efi_internal_tpl = TPL_CALLBACK
 Internal task priority level. More...
 
EFI_TPL efi_external_tpl = TPL_APPLICATION
 External task priority level. More...
 
int efi_shutdown_in_progress
 EFI shutdown is in progress. More...
 
static EFI_EVENT efi_shutdown_event
 Event used to signal shutdown. More...
 
unsigned long __stack_chk_guard
 Stack cookie. More...
 
static EFI_EXIT efi_exit
 Exit function. More...
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER  )

◆ _C2()

EFI_SYSTEM_TABLE* _C2 ( PLATFORM  ,
_systab   
)

System table passed to entry point.

We construct the symbol name efi_systab via the PLATFORM macro. This ensures that the symbol is defined only in EFI builds, and so prevents EFI code from being incorrectly linked in to a non-EFI build.

◆ efi_unload()

static EFI_STATUS EFIAPI efi_unload ( EFI_HANDLE image_handle  __unused)
static

Shut down EFI environment.

Parameters
image_handleImage handle

Definition at line 335 of file efi_init.c.

335  {
337  EFI_SYSTEM_TABLE *systab = efi_systab;
338  struct efi_saved_tpl tpl;
339 
340  DBGC ( systab, "EFI image unloading\n" );
341 
342  /* Raise TPL */
343  efi_raise_tpl ( &tpl );
344 
345  /* Shut down */
346  shutdown_exit();
347 
348  /* Disconnect any remaining devices */
350 
351  /* Uninstall driver binding protocol */
353 
354  /* Uninstall exit boot services event */
356 
357  /* Free copy of loaded image's device handle's device path */
359 
360  DBGC ( systab, "EFI image unloaded\n" );
361 
362  /* Restore TPL */
363  efi_restore_tpl ( &tpl );
364 
365  return 0;
366 }
void efi_driver_uninstall(void)
Uninstall EFI driver.
Definition: efi_driver.c:447
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
void efi_raise_tpl(struct efi_saved_tpl *tpl)
Raise task priority level to internal level.
Definition: efi_init.c:399
#define DBGC(...)
Definition: compiler.h:505
EFI_CLOSE_EVENT CloseEvent
Definition: UefiSpec.h:1945
EFI_DEVICE_PATH_PROTOCOL * efi_loaded_image_path
Device path for the loaded image's device handle.
Definition: efi_init.c:40
static EFI_EVENT efi_shutdown_event
Event used to signal shutdown.
Definition: efi_init.c:61
static void shutdown_exit(void)
Shut down system for exit back to firmware.
Definition: init.h:84
EFI Boot Services Table.
Definition: UefiSpec.h:1917
void efi_driver_disconnect_all(void)
Disconnect EFI driver from all possible devices.
Definition: efi_driver.c:613
EFI System Table.
Definition: UefiSpec.h:2030
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
An EFI saved task priority level.
Definition: efi.h:76
EFI_SYSTEM_TABLE * efi_systab
void efi_restore_tpl(struct efi_saved_tpl *tpl)
Restore task priority level.
Definition: efi_init.c:415

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseEvent, DBGC, efi_driver_disconnect_all(), efi_driver_uninstall(), efi_loaded_image_path, efi_raise_tpl(), efi_restore_tpl(), efi_shutdown_event, efi_systab, EFI_BOOT_SERVICES::FreePool, and shutdown_exit().

Referenced by efi_init().

◆ efi_shutdown_hook()

static EFIAPI void efi_shutdown_hook ( EFI_EVENT event  __unused,
void *context  __unused 
)
static

Shut down in preparation for booting an OS.

This hook gets called at ExitBootServices time in order to make sure that everything is properly shut down before the OS takes over.

Definition at line 83 of file efi_init.c.

84  {
85 
86  /* This callback is invoked at TPL_NOTIFY in order to ensure
87  * that we have an opportunity to shut down cleanly before
88  * other shutdown hooks perform destructive operations such as
89  * disabling the IOMMU.
90  *
91  * Modify the internal task priority level so that no code
92  * attempts to raise from TPL_NOTIFY to TPL_CALLBACK (which
93  * would trigger a fatal exception).
94  */
96 
97  /* Mark shutdown as being in progress, to indicate that large
98  * parts of the system (e.g. timers) are no longer functional.
99  */
101 
102  /* Shut down iPXE */
103  shutdown_boot();
104 }
EFI_TPL efi_internal_tpl
Internal task priority level.
Definition: efi_init.c:52
#define TPL_NOTIFY
Definition: UefiSpec.h:639
static void shutdown_boot(void)
Shut down system for OS boot.
Definition: init.h:76
int efi_shutdown_in_progress
EFI shutdown is in progress.
Definition: efi_init.c:58

References efi_internal_tpl, efi_shutdown_in_progress, shutdown_boot(), and TPL_NOTIFY.

Referenced by efi_init().

◆ efi_find_table()

static void* efi_find_table ( EFI_GUID guid)
static

Look up EFI configuration table.

Parameters
guidConfiguration table GUID
Return values
tableConfiguration table, or NULL

Definition at line 112 of file efi_init.c.

112  {
113  unsigned int i;
114 
115  for ( i = 0 ; i < efi_systab->NumberOfTableEntries ; i++ ) {
117  guid, sizeof ( *guid ) ) == 0 )
119  }
120 
121  return NULL;
122 }
EFI_GUID VendorGuid
The 128-bit GUID value that uniquely identifies the system configuration table.
Definition: UefiSpec.h:2020
uint64_t guid
GUID.
Definition: edd.h:30
UINTN NumberOfTableEntries
The number of system configuration tables in the buffer ConfigurationTable.
Definition: UefiSpec.h:2085
EFI_SYSTEM_TABLE * efi_systab
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
EFI_CONFIGURATION_TABLE * ConfigurationTable
A pointer to the system configuration tables.
Definition: UefiSpec.h:2090
VOID * VendorTable
A pointer to the table associated with VendorGuid.
Definition: UefiSpec.h:2024

References EFI_SYSTEM_TABLE::ConfigurationTable, efi_systab, guid, memcmp(), NULL, EFI_SYSTEM_TABLE::NumberOfTableEntries, EFI_CONFIGURATION_TABLE::VendorGuid, and EFI_CONFIGURATION_TABLE::VendorTable.

Referenced by efi_init().

◆ efi_stack_cookie()

unsigned long efi_stack_cookie ( EFI_HANDLE  handle)

Construct a stack cookie value.

Parameters
handleImage handle
Return values
cookieStack cookie

Definition at line 131 of file efi_init.c.

131  {
132  unsigned long cookie = 0;
133  unsigned int rotation = ( 8 * sizeof ( cookie ) / 4 );
134 
135  /* There is no viable source of entropy available at this
136  * point. Construct a value that is at least likely to vary
137  * between platforms and invocations.
138  */
139  cookie ^= ( ( unsigned long ) handle );
140  cookie = roll ( cookie, rotation );
141  cookie ^= ( ( unsigned long ) &handle );
142  cookie = roll ( cookie, rotation );
143  cookie ^= profile_timestamp();
144  cookie = roll ( cookie, rotation );
145  cookie ^= build_id;
146 
147  /* Ensure that the value contains a NUL byte, to act as a
148  * runaway string terminator. Construct the NUL using a shift
149  * rather than a mask, to avoid losing valuable entropy in the
150  * lower-order bits.
151  */
152  cookie <<= 8;
153 
154  /* Ensure that the NUL byte is placed at the bottom of the
155  * stack cookie, to avoid potential disclosure via an
156  * unterminated string.
157  */
158  if ( __BYTE_ORDER == __BIG_ENDIAN )
159  cookie >>= 8;
160 
161  return cookie;
162 }
#define __BYTE_ORDER
Definition: endian.h:6
unsigned long build_id
Build ID.
Definition: version.c:61
#define __BIG_ENDIAN
Constant representing big-endian byte order.
Definition: endian.h:21
static unsigned int rotation
Definition: rotate.h:22
uint16_t handle
Handle.
Definition: smbios.h:16

References __BIG_ENDIAN, __BYTE_ORDER, build_id, handle, and rotation.

Referenced by efi_init_stack_guard().

◆ efi_init()

EFI_STATUS efi_init ( EFI_HANDLE  image_handle,
EFI_SYSTEM_TABLE systab 
)

Initialise EFI environment.

Parameters
image_handleImage handle
systabSystem table
Return values
efircEFI return status code

Definition at line 171 of file efi_init.c.

172  {
173  EFI_BOOT_SERVICES *bs;
174  struct efi_protocol *prot;
175  struct efi_config_table *tab;
176  void *loaded_image;
177  void *device_path;
178  void *device_path_copy;
179  size_t device_path_len;
180  EFI_STATUS efirc;
181  int rc;
182 
183  /* Store image handle and system table pointer for future use */
184  efi_image_handle = image_handle;
185  efi_systab = systab;
186 
187  /* Sanity checks */
188  if ( ! systab ) {
189  efirc = EFI_NOT_AVAILABLE_YET;
190  goto err_sanity;
191  }
192  if ( ! systab->ConOut ) {
193  efirc = EFI_NOT_AVAILABLE_YET;
194  goto err_sanity;
195  }
196  if ( ! systab->BootServices ) {
197  DBGC ( systab, "EFI provided no BootServices entry point\n" );
198  efirc = EFI_NOT_AVAILABLE_YET;
199  goto err_sanity;
200  }
201  if ( ! systab->RuntimeServices ) {
202  DBGC ( systab, "EFI provided no RuntimeServices entry "
203  "point\n" );
204  efirc = EFI_NOT_AVAILABLE_YET;
205  goto err_sanity;
206  }
207  DBGC ( systab, "EFI handle %p systab %p\n", image_handle, systab );
208  bs = systab->BootServices;
209 
210  /* Store abort function pointer */
211  efi_exit = bs->Exit;
212 
213  /* Look up used protocols */
215  if ( ( efirc = bs->LocateProtocol ( &prot->guid, NULL,
216  prot->protocol ) ) == 0 ) {
217  DBGC ( systab, "EFI protocol %s is at %p\n",
218  efi_guid_ntoa ( &prot->guid ),
219  *(prot->protocol) );
220  } else {
221  DBGC ( systab, "EFI does not provide protocol %s\n",
222  efi_guid_ntoa ( &prot->guid ) );
223  /* Fail if protocol is required */
224  if ( prot->required )
225  goto err_missing_protocol;
226  }
227  }
228 
229  /* Look up used configuration tables */
231  if ( ( *(tab->table) = efi_find_table ( &tab->guid ) ) ) {
232  DBGC ( systab, "EFI configuration table %s is at %p\n",
233  efi_guid_ntoa ( &tab->guid ), *(tab->table) );
234  } else {
235  DBGC ( systab, "EFI does not provide configuration "
236  "table %s\n", efi_guid_ntoa ( &tab->guid ) );
237  if ( tab->required ) {
238  efirc = EFI_NOT_AVAILABLE_YET;
239  goto err_missing_table;
240  }
241  }
242  }
243 
244  /* Get loaded image protocol */
245  if ( ( efirc = bs->OpenProtocol ( image_handle,
247  &loaded_image, image_handle, NULL,
248  EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
249  rc = -EEFI ( efirc );
250  DBGC ( systab, "EFI could not get loaded image protocol: %s",
251  strerror ( rc ) );
252  goto err_no_loaded_image;
253  }
254  efi_loaded_image = loaded_image;
255  DBGC ( systab, "EFI image base address %p\n",
257 
258  /* Record command line */
261 
262  /* Get loaded image's device handle's device path */
263  if ( ( efirc = bs->OpenProtocol ( efi_loaded_image->DeviceHandle,
265  &device_path, image_handle, NULL,
266  EFI_OPEN_PROTOCOL_GET_PROTOCOL ) ) != 0 ) {
267  rc = -EEFI ( efirc );
268  DBGC ( systab, "EFI could not get loaded image's device path: "
269  "%s", strerror ( rc ) );
270  goto err_no_device_path;
271  }
272 
273  /* Make a copy of the loaded image's device handle's device
274  * path, since the device handle itself may become invalidated
275  * when we load our own drivers.
276  */
277  device_path_len = ( efi_path_len ( device_path ) +
278  sizeof ( EFI_DEVICE_PATH_PROTOCOL ) );
279  if ( ( efirc = bs->AllocatePool ( EfiBootServicesData, device_path_len,
280  &device_path_copy ) ) != 0 ) {
281  rc = -EEFI ( efirc );
282  goto err_alloc_device_path;
283  }
284  memcpy ( device_path_copy, device_path, device_path_len );
285  efi_loaded_image_path = device_path_copy;
286  DBGC ( systab, "EFI image device path %s\n",
288 
289  /* EFI is perfectly capable of gracefully shutting down any
290  * loaded devices if it decides to fall back to a legacy boot.
291  * For no particularly comprehensible reason, it doesn't
292  * bother doing so when ExitBootServices() is called.
293  */
294  if ( ( efirc = bs->CreateEvent ( EVT_SIGNAL_EXIT_BOOT_SERVICES,
296  NULL, &efi_shutdown_event ) ) != 0 ) {
297  rc = -EEFI ( efirc );
298  DBGC ( systab, "EFI could not create ExitBootServices event: "
299  "%s\n", strerror ( rc ) );
300  goto err_create_event;
301  }
302 
303  /* Install driver binding protocol */
304  if ( ( rc = efi_driver_install() ) != 0 ) {
305  DBGC ( systab, "EFI could not install driver: %s\n",
306  strerror ( rc ) );
307  efirc = EFIRC ( rc );
308  goto err_driver_install;
309  }
310 
311  /* Install image unload method */
313 
314  return 0;
315 
317  err_driver_install:
319  err_create_event:
321  err_alloc_device_path:
322  err_no_device_path:
323  err_no_loaded_image:
324  err_missing_table:
325  err_missing_protocol:
326  err_sanity:
327  return efirc;
328 }
void efi_driver_uninstall(void)
Uninstall EFI driver.
Definition: efi_driver.c:447
union edd_device_path device_path
Device path.
Definition: edd.h:24
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
void ** protocol
Variable containing pointer to protocol structure.
Definition: efi.h:88
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
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
const wchar_t * efi_cmdline
EFI command line (may not be wNUL-terminated.
Definition: efi_cmdline.c:43
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1995
EFI_GUID guid
GUID.
Definition: efi.h:86
#define DBGC(...)
Definition: compiler.h:505
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:243
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:144
EFI_CLOSE_EVENT CloseEvent
Definition: UefiSpec.h:1945
VOID * ImageBase
The base address at which the image was loaded.
Definition: LoadedImage.h:69
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:45
#define TPL_NOTIFY
Definition: UefiSpec.h:639
#define EFI_PROTOCOLS
EFI protocol table.
Definition: efi.h:94
#define EVT_SIGNAL_EXIT_BOOT_SERVICES
Definition: UefiSpec.h:445
#define EFI_CONFIG_TABLES
EFI configuration table table.
Definition: efi.h:138
An EFI configuration table used by iPXE.
Definition: efi.h:128
EFI_DEVICE_PATH_PROTOCOL * efi_loaded_image_path
Device path for the loaded image's device handle.
Definition: efi_init.c:40
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define EFI_NOT_AVAILABLE_YET
If this value is returned by an API, it means the capability is not yet installed/available/ready to ...
Definition: PiMultiPhase.h:49
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
Definition: UefiSpec.h:2063
static EFI_EVENT efi_shutdown_event
Event used to signal shutdown.
Definition: efi_init.c:61
static EFIAPI void efi_shutdown_hook(EFI_EVENT event __unused, void *context __unused)
Shut down in preparation for booting an OS.
Definition: efi_init.c:83
EFI_CREATE_EVENT CreateEvent
Definition: UefiSpec.h:1941
static void * efi_find_table(EFI_GUID *guid)
Look up EFI configuration table.
Definition: efi_init.c:112
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:461
VOID * LoadOptions
A pointer to the image's binary load options.
Definition: LoadedImage.h:64
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1344
An EFI protocol used by iPXE.
Definition: efi.h:84
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:254
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:34
EFI_IMAGE_UNLOAD Unload
Definition: LoadedImage.h:73
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition: tables.h:385
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:143
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
void ** table
Variable containing pointer to configuration table.
Definition: efi.h:132
UINT32 LoadOptionsSize
The size in bytes of LoadOptions.
Definition: LoadedImage.h:63
int required
Protocol is required.
Definition: efi.h:90
EFI_RUNTIME_SERVICES * RuntimeServices
A pointer to the EFI Runtime Services Table.
Definition: UefiSpec.h:2077
EFI_GUID guid
GUID.
Definition: efi.h:130
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
static EFI_EXIT efi_exit
Exit function.
Definition: efi_init.c:71
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1986
size_t efi_cmdline_len
Length of EFI command line (in bytes)
Definition: efi_cmdline.c:46
The data portions of a loaded Boot Serves Driver, and the default data allocation type used by a Boot...
int required
Table is required for operation.
Definition: efi.h:134
static EFI_STATUS EFIAPI efi_unload(EFI_HANDLE image_handle)
Shut down EFI environment.
Definition: efi_init.c:335
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
int efi_driver_install(void)
Install EFI driver.
Definition: efi_driver.c:414
#define EFIRC(rc)
Convert an iPXE status code to an EFI status code.
Definition: efi.h:163
EFI_HANDLE DeviceHandle
The device handle that the EFI Image was loaded from.
Definition: LoadedImage.h:55
EFI_ALLOCATE_POOL AllocatePool
Definition: UefiSpec.h:1935

References EFI_BOOT_SERVICES::AllocatePool, EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseEvent, EFI_SYSTEM_TABLE::ConOut, EFI_BOOT_SERVICES::CreateEvent, DBGC, device_path, EFI_LOADED_IMAGE_PROTOCOL::DeviceHandle, EEFI, efi_cmdline, efi_cmdline_len, EFI_CONFIG_TABLES, efi_device_path_protocol_guid, efi_devpath_text(), efi_driver_install(), efi_driver_uninstall(), efi_exit, efi_find_table(), efi_guid_ntoa(), efi_image_handle, efi_loaded_image, efi_loaded_image_path, efi_loaded_image_protocol_guid, EFI_NOT_AVAILABLE_YET, EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_path_len(), EFI_PROTOCOLS, efi_shutdown_event, efi_shutdown_hook(), efi_systab, efi_unload(), EfiBootServicesData, EFIRC, EVT_SIGNAL_EXIT_BOOT_SERVICES, EFI_BOOT_SERVICES::Exit, for_each_table_entry, EFI_BOOT_SERVICES::FreePool, efi_protocol::guid, efi_config_table::guid, EFI_LOADED_IMAGE_PROTOCOL::ImageBase, EFI_LOADED_IMAGE_PROTOCOL::LoadOptions, EFI_LOADED_IMAGE_PROTOCOL::LoadOptionsSize, EFI_BOOT_SERVICES::LocateProtocol, memcpy(), NULL, EFI_BOOT_SERVICES::OpenProtocol, efi_protocol::protocol, rc, efi_protocol::required, efi_config_table::required, EFI_SYSTEM_TABLE::RuntimeServices, strerror(), efi_config_table::table, TPL_NOTIFY, and EFI_LOADED_IMAGE_PROTOCOL::Unload.

Referenced by _efi_start(), and _efidrv_start().

◆ __stack_chk_fail()

void __stack_chk_fail ( void  )

Abort on stack check failure.

Definition at line 372 of file efi_init.c.

372  {
373  EFI_STATUS efirc;
374  int rc;
375 
376  /* Report failure (when debugging) */
377  DBGC ( efi_systab, "EFI stack check failed (cookie %#lx); aborting\n",
379 
380  /* Attempt to exit cleanly with an error status */
381  if ( efi_exit ) {
383  0, NULL );
384  rc = -EEFI ( efirc );
385  DBGC ( efi_systab, "EFI stack check exit failed: %s\n",
386  strerror ( rc ) );
387  }
388 
389  /* If the exit fails for any reason, lock the system */
390  while ( 1 ) {}
391 
392 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
#define DBGC(...)
Definition: compiler.h:505
#define EFI_COMPROMISED_DATA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:145
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:34
unsigned long __stack_chk_guard
Stack cookie.
Definition: efi_init.c:64
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
static EFI_EXIT efi_exit
Exit function.
Definition: efi_init.c:71
EFI_SYSTEM_TABLE * efi_systab
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References __stack_chk_guard, DBGC, EEFI, EFI_COMPROMISED_DATA, efi_exit, efi_image_handle, efi_systab, NULL, rc, and strerror().

◆ efi_raise_tpl()

void efi_raise_tpl ( struct efi_saved_tpl tpl)

Raise task priority level to internal level.

Parameters
tplSaved TPL

Definition at line 399 of file efi_init.c.

399  {
401 
402  /* Record current external TPL */
403  tpl->previous = efi_external_tpl;
404 
405  /* Raise TPL and record previous TPL as new external TPL */
406  tpl->current = bs->RaiseTPL ( efi_internal_tpl );
407  efi_external_tpl = tpl->current;
408 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1926
EFI_TPL efi_internal_tpl
Internal task priority level.
Definition: efi_init.c:52
EFI_TPL current
Current external TPL.
Definition: efi.h:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
EFI_TPL previous
Previous external TPL.
Definition: efi.h:80
EFI_SYSTEM_TABLE * efi_systab
EFI_TPL efi_external_tpl
External task priority level.
Definition: efi_init.c:55

References EFI_SYSTEM_TABLE::BootServices, efi_saved_tpl::current, efi_external_tpl, efi_internal_tpl, efi_systab, efi_saved_tpl::previous, and EFI_BOOT_SERVICES::RaiseTPL.

Referenced by _efidrv_start(), efi_driver_start(), efi_driver_stop(), efi_snp_add_claim(), efi_snp_get_status(), efi_snp_initialize(), efi_snp_receive(), efi_snp_reset(), efi_snp_shutdown(), efi_snp_transmit(), efi_snp_wait_for_packet(), efi_unload(), efi_usb_async_interrupt_transfer(), efi_usb_bulk_transfer(), efi_usb_control_transfer(), efi_usb_get_string_descriptor(), efi_usb_sync_interrupt_transfer(), efi_vlan_find(), efi_vlan_remove(), and efi_vlan_set().

◆ efi_restore_tpl()

void efi_restore_tpl ( struct efi_saved_tpl tpl)

Restore task priority level.

Parameters
tplSaved TPL

Definition at line 415 of file efi_init.c.

415  {
417 
418  /* Restore external TPL */
419  efi_external_tpl = tpl->previous;
420 
421  /* Restore TPL */
422  bs->RestoreTPL ( tpl->current );
423 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2081
EFI_TPL current
Current external TPL.
Definition: efi.h:78
EFI Boot Services Table.
Definition: UefiSpec.h:1917
EFI_TPL previous
Previous external TPL.
Definition: efi.h:80
EFI_SYSTEM_TABLE * efi_systab
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1927
EFI_TPL efi_external_tpl
External task priority level.
Definition: efi_init.c:55

References EFI_SYSTEM_TABLE::BootServices, efi_saved_tpl::current, efi_external_tpl, efi_systab, efi_saved_tpl::previous, and EFI_BOOT_SERVICES::RestoreTPL.

Referenced by _efidrv_start(), efi_driver_start(), efi_driver_stop(), efi_snp_add_claim(), efi_snp_get_status(), efi_snp_initialize(), efi_snp_receive(), efi_snp_reset(), efi_snp_shutdown(), efi_snp_transmit(), efi_snp_wait_for_packet(), efi_unload(), efi_usb_async_interrupt_transfer(), efi_usb_bulk_transfer(), efi_usb_control_transfer(), efi_usb_get_string_descriptor(), efi_usb_sync_interrupt_transfer(), efi_vlan_find(), efi_vlan_remove(), and efi_vlan_set().

Variable Documentation

◆ efi_image_handle

EFI_HANDLE efi_image_handle

◆ efi_loaded_image

EFI_LOADED_IMAGE_PROTOCOL* efi_loaded_image

◆ efi_loaded_image_path

EFI_DEVICE_PATH_PROTOCOL* efi_loaded_image_path

Device path for the loaded image's device handle.

Definition at line 40 of file efi_init.c.

Referenced by efi_init(), efi_init_application(), efi_local_open_volume(), efi_path_net_probe(), and efi_unload().

◆ efi_internal_tpl

EFI_TPL efi_internal_tpl = TPL_CALLBACK

Internal task priority level.

Definition at line 52 of file efi_init.c.

Referenced by efi_currticks(), efi_entropy_disable(), efi_raise_tpl(), efi_shutdown_hook(), and nii_issue_cpb_db().

◆ efi_external_tpl

EFI_TPL efi_external_tpl = TPL_APPLICATION

External task priority level.

Definition at line 55 of file efi_init.c.

Referenced by efi_currticks(), efi_entropy_enable(), efi_raise_tpl(), and efi_restore_tpl().

◆ efi_shutdown_in_progress

int efi_shutdown_in_progress

◆ efi_shutdown_event

EFI_EVENT efi_shutdown_event
static

Event used to signal shutdown.

Definition at line 61 of file efi_init.c.

Referenced by efi_init(), and efi_unload().

◆ __stack_chk_guard

unsigned long __stack_chk_guard

Stack cookie.

Definition at line 64 of file efi_init.c.

Referenced by __stack_chk_fail(), and efi_init_stack_guard().

◆ efi_exit

EFI_EXIT efi_exit
static

Exit function.

Cached to minimise external dependencies when a stack check failure is triggered.

Definition at line 71 of file efi_init.c.

Referenced by __stack_chk_fail(), and efi_init().