iPXE
Functions
efi_wrap.h File Reference

EFI driver interface. More...

#include <ipxe/efi/efi.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
void efi_wrap (EFI_HANDLE handle)
 Wrap the calls made by a loaded image. More...
 

Detailed Description

EFI driver interface.

Definition in file efi_wrap.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_wrap()

void efi_wrap ( EFI_HANDLE  handle)

Wrap the calls made by a loaded image.

Parameters
handleImage handle

Definition at line 550 of file efi_wrap.c.

550  {
552  union {
554  void *intf;
555  } loaded;
556  EFI_STATUS efirc;
557  int rc;
558 
559  /* Do nothing unless debugging is enabled */
560  if ( ! DBG_LOG )
561  return;
562 
563  /* Populate table wrappers */
565  sizeof ( efi_systab_wrapper ) );
566  memcpy ( &efi_bs_wrapper, bs, sizeof ( efi_bs_wrapper ) );
593 
594  /* Open loaded image protocol */
595  if ( ( efirc = bs->OpenProtocol ( handle,
597  &loaded.intf, efi_image_handle, NULL,
599  rc = -EEFI ( efirc );
600  DBGC ( colour, "WRAP %s could not get loaded image protocol: "
601  "%s\n", efi_handle_name ( handle ), strerror ( rc ) );
602  return;
603  }
604 
605  /* Provide system table wrapper to image */
606  loaded.image->SystemTable = &efi_systab_wrapper;
607  DBGC ( colour, "WRAP %s at base %p has protocols:\n",
608  efi_handle_name ( handle ), loaded.image->ImageBase );
610  DBGC ( colour, "WRAP %s parent", efi_handle_name ( handle ) );
611  DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->ParentHandle ));
612  DBGC ( colour, "WRAP %s device", efi_handle_name ( handle ) );
613  DBGC ( colour, " %s\n", efi_handle_name ( loaded.image->DeviceHandle ));
614  DBGC ( colour, "WRAP %s file", efi_handle_name ( handle ) );
615  DBGC ( colour, " %s\n", efi_devpath_text ( loaded.image->FilePath ) );
616 
617  /* Close loaded image protocol */
620 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
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:159
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1914
static EFI_STATUS EFIAPI efi_reinstall_protocol_interface_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, VOID *old_interface, VOID *new_interface)
Wrap ReinstallProtocolInterface()
Definition: efi_wrap.c:141
static EFI_STATUS EFIAPI efi_locate_handle_wrapper(EFI_LOCATE_SEARCH_TYPE search_type, EFI_GUID *protocol, VOID *search_key, UINTN *buffer_size, EFI_HANDLE *buffer)
Wrap LocateHandle()
Definition: efi_wrap.c:202
#define DBGC_EFI_PROTOCOLS(...)
Definition: efi.h:264
EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface
Definition: UefiSpec.h:1871
EFI_EXIT_BOOT_SERVICES ExitBootServices
Definition: UefiSpec.h:1887
EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface
Definition: UefiSpec.h:1872
EFI_IMAGE_LOAD LoadImage
Definition: UefiSpec.h:1883
static EFI_STATUS EFIAPI efi_close_protocol_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, EFI_HANDLE agent_handle, EFI_HANDLE controller_handle)
Wrap CloseProtocol()
Definition: efi_wrap.c:447
static EFI_STATUS EFIAPI efi_protocols_per_handle_wrapper(EFI_HANDLE handle, EFI_GUID ***protocol_buffer, UINTN *protocol_buffer_count)
Wrap ProtocolsPerHandle()
Definition: efi_wrap.c:470
#define DBGC(...)
Definition: compiler.h:505
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:184
static EFI_STATUS EFIAPI efi_handle_protocol_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, VOID **interface)
Wrap HandleProtocol()
Definition: efi_wrap.c:183
EFI_LOCATE_HANDLE LocateHandle
Definition: UefiSpec.h:1876
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1886
An executable image.
Definition: image.h:24
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
void * memcpy(void *dest, const void *src, size_t len) __nonnull
Can be used on any image handle to obtain information about the loaded image.
Definition: LoadedImage.h:51
EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface
Definition: UefiSpec.h:1870
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1873
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:366
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1271
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
static EFI_STATUS EFIAPI efi_start_image_wrapper(EFI_HANDLE image_handle, UINTN *exit_data_size, CHAR16 **exit_data)
Wrap StartImage()
Definition: efi_wrap.c:288
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:32
static EFI_STATUS EFIAPI efi_install_protocol_interface_wrapper(EFI_HANDLE *handle, EFI_GUID *protocol, EFI_INTERFACE_TYPE interface_type, VOID *interface)
Wrap InstallProtocolInterface()
Definition: efi_wrap.c:119
static EFI_SYSTEM_TABLE efi_systab_wrapper
EFI system table wrapper.
Definition: efi_wrap.c:41
EFI_CONNECT_CONTROLLER ConnectController
Definition: UefiSpec.h:1899
static EFI_STATUS EFIAPI efi_connect_controller_wrapper(EFI_HANDLE controller_handle, EFI_HANDLE *driver_image_handle, EFI_DEVICE_PATH_PROTOCOL *remaining_path, BOOLEAN recursive)
Wrap ConnectController()
Definition: efi_wrap.c:369
static EFI_STATUS EFIAPI efi_locate_protocol_wrapper(EFI_GUID *protocol, VOID *registration, VOID **interface)
Wrap LocateProtocol()
Definition: efi_wrap.c:531
EFI_IMAGE_START StartImage
Definition: UefiSpec.h:1884
static EFI_STATUS EFIAPI efi_unload_image_wrapper(EFI_HANDLE image_handle)
Wrap UnloadImage()
Definition: efi_wrap.c:334
static EFI_BOOT_SERVICES efi_bs_wrapper
EFI boot services table wrapper.
Definition: efi_wrap.c:44
static EFI_STATUS EFIAPI efi_uninstall_protocol_interface_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, VOID *interface)
Wrap UninstallProtocolInterface()
Definition: efi_wrap.c:163
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:1912
static EFI_STATUS EFIAPI efi_locate_handle_buffer_wrapper(EFI_LOCATE_SEARCH_TYPE search_type, EFI_GUID *protocol, VOID *search_key, UINTN *no_handles, EFI_HANDLE **buffer)
Wrap LocateHandleBuffer()
Definition: efi_wrap.c:500
static EFI_STATUS EFIAPI efi_open_protocol_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, VOID **interface, EFI_HANDLE agent_handle, EFI_HANDLE controller_handle, UINT32 attributes)
Wrap OpenProtocol()
Definition: efi_wrap.c:423
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
static EFI_STATUS EFIAPI efi_load_image_wrapper(BOOLEAN boot_policy, EFI_HANDLE parent_image_handle, EFI_DEVICE_PATH_PROTOCOL *device_path, VOID *source_buffer, UINTN source_size, EFI_HANDLE *image_handle)
Wrap LoadImage()
Definition: efi_wrap.c:256
static EFI_STATUS EFIAPI efi_disconnect_controller_wrapper(EFI_HANDLE controller_handle, EFI_HANDLE driver_image_handle, EFI_HANDLE child_handle)
Wrap DisconnectController()
Definition: efi_wrap.c:400
static EFI_STATUS EFIAPI efi_locate_device_path_wrapper(EFI_GUID *protocol, EFI_DEVICE_PATH_PROTOCOL **device_path, EFI_HANDLE *device)
Wrap LocateDevicePath()
Definition: efi_wrap.c:235
static EFI_STATUS EFIAPI efi_exit_boot_services_wrapper(EFI_HANDLE image_handle, UINTN map_key)
Wrap ExitBootServices()
Definition: efi_wrap.c:351
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
static EFI_STATUS EFIAPI efi_exit_wrapper(EFI_HANDLE image_handle, EFI_STATUS exit_status, UINTN exit_data_size, CHAR16 *exit_data)
Wrap Exit()
Definition: efi_wrap.c:310
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
#define DBG_LOG
Definition: compiler.h:317
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1913
EFI_LOCATE_DEVICE_PATH LocateDevicePath
Definition: UefiSpec.h:1877
EFI_DISCONNECT_CONTROLLER DisconnectController
Definition: UefiSpec.h:1900

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, colour, EFI_BOOT_SERVICES::ConnectController, DBG_LOG, DBGC, DBGC_EFI_PROTOCOLS, EFI_BOOT_SERVICES::DisconnectController, EEFI, efi_bs_wrapper, efi_close_protocol_wrapper(), efi_connect_controller_wrapper(), efi_devpath_text(), efi_disconnect_controller_wrapper(), efi_exit_boot_services_wrapper(), efi_exit_wrapper(), efi_handle_name(), efi_handle_protocol_wrapper(), efi_image_handle, efi_install_protocol_interface_wrapper(), efi_load_image_wrapper(), efi_loaded_image_protocol_guid, efi_locate_device_path_wrapper(), efi_locate_handle_buffer_wrapper(), efi_locate_handle_wrapper(), efi_locate_protocol_wrapper(), EFI_OPEN_PROTOCOL_GET_PROTOCOL, efi_open_protocol_wrapper(), efi_protocols_per_handle_wrapper(), efi_reinstall_protocol_interface_wrapper(), efi_start_image_wrapper(), efi_systab, efi_systab_wrapper, efi_uninstall_protocol_interface_wrapper(), efi_unload_image_wrapper(), EFI_BOOT_SERVICES::Exit, EFI_BOOT_SERVICES::ExitBootServices, handle, EFI_BOOT_SERVICES::HandleProtocol, EFI_BOOT_SERVICES::InstallProtocolInterface, EFI_BOOT_SERVICES::LoadImage, EFI_BOOT_SERVICES::LocateDevicePath, EFI_BOOT_SERVICES::LocateHandle, EFI_BOOT_SERVICES::LocateHandleBuffer, EFI_BOOT_SERVICES::LocateProtocol, memcpy(), NULL, EFI_BOOT_SERVICES::OpenProtocol, EFI_BOOT_SERVICES::ProtocolsPerHandle, rc, EFI_BOOT_SERVICES::ReinstallProtocolInterface, EFI_BOOT_SERVICES::StartImage, strerror(), EFI_BOOT_SERVICES::UninstallProtocolInterface, and EFI_BOOT_SERVICES::UnloadImage.

Referenced by efi_image_exec(), and efi_load_image_wrapper().