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)
 
EFI_BOOT_SERVICESefi_wrap_bs (void)
 Build boot services table wrapper. More...
 
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_bs()

EFI_BOOT_SERVICES* efi_wrap_bs ( void  )

Build boot services table wrapper.

Return values
bsWrapped boot services table

Definition at line 1180 of file efi_wrap.c.

1180  {
1181  static EFI_BOOT_SERVICES efi_bs_wrapper;
1183 
1184  /* Build boot services table wrapper */
1185  memcpy ( &efi_bs_wrapper, bs, sizeof ( efi_bs_wrapper ) );
1186  efi_bs_wrapper.RaiseTPL = efi_raise_tpl_wrapper;
1187  efi_bs_wrapper.RestoreTPL = efi_restore_tpl_wrapper;
1188  efi_bs_wrapper.AllocatePages = efi_allocate_pages_wrapper;
1189  efi_bs_wrapper.FreePages = efi_free_pages_wrapper;
1190  efi_bs_wrapper.GetMemoryMap = efi_get_memory_map_wrapper;
1191  efi_bs_wrapper.AllocatePool = efi_allocate_pool_wrapper;
1192  efi_bs_wrapper.FreePool = efi_free_pool_wrapper;
1193  efi_bs_wrapper.CreateEvent = efi_create_event_wrapper;
1194  efi_bs_wrapper.SetTimer = efi_set_timer_wrapper;
1195  efi_bs_wrapper.WaitForEvent = efi_wait_for_event_wrapper;
1196  efi_bs_wrapper.SignalEvent = efi_signal_event_wrapper;
1197  efi_bs_wrapper.CloseEvent = efi_close_event_wrapper;
1198  efi_bs_wrapper.CheckEvent = efi_check_event_wrapper;
1199  efi_bs_wrapper.InstallProtocolInterface
1201  efi_bs_wrapper.ReinstallProtocolInterface
1203  efi_bs_wrapper.UninstallProtocolInterface
1206  efi_bs_wrapper.RegisterProtocolNotify
1208  efi_bs_wrapper.LocateHandle = efi_locate_handle_wrapper;
1210  efi_bs_wrapper.InstallConfigurationTable
1212  efi_bs_wrapper.LoadImage = efi_load_image_wrapper;
1213  efi_bs_wrapper.StartImage = efi_start_image_wrapper;
1214  efi_bs_wrapper.Exit = efi_exit_wrapper;
1215  efi_bs_wrapper.UnloadImage = efi_unload_image_wrapper;
1217  efi_bs_wrapper.GetNextMonotonicCount
1219  efi_bs_wrapper.Stall = efi_stall_wrapper;
1221  efi_bs_wrapper.ConnectController
1223  efi_bs_wrapper.DisconnectController
1225  efi_bs_wrapper.OpenProtocol = efi_open_protocol_wrapper;
1226  efi_bs_wrapper.CloseProtocol = efi_close_protocol_wrapper;
1227  efi_bs_wrapper.OpenProtocolInformation
1229  efi_bs_wrapper.ProtocolsPerHandle
1231  efi_bs_wrapper.LocateHandleBuffer
1234  efi_bs_wrapper.InstallMultipleProtocolInterfaces
1238  efi_bs_wrapper.CreateEventEx = efi_create_event_ex_wrapper;
1239 
1240  return &efi_bs_wrapper;
1241 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static EFI_STATUS EFIAPI efi_set_timer_wrapper(EFI_EVENT event, EFI_TIMER_DELAY type, UINT64 trigger_time)
Wrap SetTimer()
Definition: efi_wrap.c:415
static VOID EFIAPI efi_restore_tpl_wrapper(EFI_TPL old_tpl)
Wrap RestoreTPL()
Definition: efi_wrap.c:260
EFI_SET_WATCHDOG_TIMER SetWatchdogTimer
Definition: UefiSpec.h:1894
EFI_RAISE_TPL RaiseTPL
Definition: UefiSpec.h:1845
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1914
EFI_STALL Stall
Definition: UefiSpec.h:1893
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:528
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:608
static EFI_STATUS EFIAPI efi_register_protocol_notify_wrapper(EFI_GUID *protocol, EFI_EVENT event, VOID **registration)
Wrap RegisterProtocolNotify()
Definition: efi_wrap.c:589
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:928
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:974
static EFI_STATUS EFIAPI efi_handle_protocol_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, VOID **interface)
Wrap HandleProtocol()
Definition: efi_wrap.c:570
EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1915
static EFI_STATUS EFIAPI efi_install_configuration_table_wrapper(EFI_GUID *guid, VOID *table)
Wrap InstallConfigurationTable()
Definition: efi_wrap.c:662
EFI_CLOSE_EVENT CloseEvent
Definition: UefiSpec.h:1864
EFI_SET_TIMER SetTimer
Definition: UefiSpec.h:1861
static EFI_STATUS EFIAPI efi_signal_event_wrapper(EFI_EVENT event)
Wrap SignalEvent()
Definition: efi_wrap.c:459
EFI_LOCATE_HANDLE LocateHandle
Definition: UefiSpec.h:1876
static EFI_STATUS EFIAPI efi_create_event_wrapper(UINT32 type, EFI_TPL notify_tpl, EFI_EVENT_NOTIFY notify_function, VOID *notify_context, EFI_EVENT *event)
Wrap CreateEvent()
Definition: efi_wrap.c:394
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1886
static EFI_STATUS EFIAPI efi_get_next_monotonic_count_wrapper(UINT64 *count)
Wrap GetNextMonotonicCount()
Definition: efi_wrap.c:795
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
EFI_CREATE_EVENT_EX CreateEventEx
Definition: UefiSpec.h:1928
static EFI_STATUS EFIAPI efi_create_event_ex_wrapper(UINT32 type, EFI_TPL notify_tpl, EFI_EVENT_NOTIFY notify_function, CONST VOID *notify_context, CONST EFI_GUID *event_group, EFI_EVENT *event)
Wrap CreateEventEx()
Definition: efi_wrap.c:1157
static EFI_STATUS EFIAPI efi_get_memory_map_wrapper(UINTN *memory_map_size, EFI_MEMORY_DESCRIPTOR *memory_map, UINTN *map_key, UINTN *descriptor_size, UINT32 *descriptor_version)
Wrap GetMemoryMap()
Definition: efi_wrap.c:314
void * memcpy(void *dest, const void *src, size_t len) __nonnull
EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface
Definition: UefiSpec.h:1870
EFI_CREATE_EVENT CreateEvent
Definition: UefiSpec.h:1860
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1873
EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify
Definition: UefiSpec.h:1875
static EFI_STATUS EFIAPI efi_free_pages_wrapper(EFI_PHYSICAL_ADDRESS memory, UINTN pages)
Wrap FreePages()
Definition: efi_wrap.c:296
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:711
EFI_SIGNAL_EVENT SignalEvent
Definition: UefiSpec.h:1863
EFI Boot Services Table.
Definition: UefiSpec.h:1836
static EFI_STATUS EFIAPI efi_set_watchdog_timer_wrapper(UINTN timeout, UINT64 watchdog_code, UINTN data_size, CHAR16 *watchdog_data)
Wrap SetWatchdogTimer()
Definition: efi_wrap.c:830
EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount
Definition: UefiSpec.h:1892
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:506
static EFI_STATUS EFIAPI efi_open_protocol_information_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **entry_buffer, UINTN *entry_count)
Wrap OpenProtocolInformation()
Definition: efi_wrap.c:951
static EFI_STATUS EFIAPI efi_wait_for_event_wrapper(UINTN number_of_events, EFI_EVENT *event, UINTN *index)
Wrap WaitForEvent()
Definition: efi_wrap.c:435
EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces
Definition: UefiSpec.h:1916
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:850
static EFI_STATUS EFIAPI efi_locate_protocol_wrapper(EFI_GUID *protocol, VOID *registration, VOID **interface)
Wrap LocateProtocol()
Definition: efi_wrap.c:1035
static EFI_STATUS EFIAPI efi_allocate_pages_wrapper(EFI_ALLOCATE_TYPE type, EFI_MEMORY_TYPE memory_type, UINTN pages, EFI_PHYSICAL_ADDRESS *memory)
Wrap AllocatePages()
Definition: efi_wrap.c:274
EFI_IMAGE_START StartImage
Definition: UefiSpec.h:1884
static EFI_TPL EFIAPI efi_raise_tpl_wrapper(EFI_TPL new_tpl)
Wrap RaiseTPL()
Definition: efi_wrap.c:244
static EFI_STATUS EFIAPI efi_install_multiple_protocol_interfaces_wrapper(EFI_HANDLE *handle,...)
Wrap InstallMultipleProtocolInterfaces()
Definition: efi_wrap.c:1057
static EFI_STATUS EFIAPI efi_unload_image_wrapper(EFI_HANDLE image_handle)
Wrap UnloadImage()
Definition: efi_wrap.c:757
EFI_WAIT_FOR_EVENT WaitForEvent
Definition: UefiSpec.h:1862
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1855
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:1907
static EFI_STATUS EFIAPI efi_uninstall_protocol_interface_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, VOID *interface)
Wrap UninstallProtocolInterface()
Definition: efi_wrap.c:550
EFI_GET_MEMORY_MAP GetMemoryMap
Definition: UefiSpec.h:1853
EFI_ALLOCATE_PAGES AllocatePages
Definition: UefiSpec.h:1851
static EFI_STATUS EFIAPI efi_allocate_pool_wrapper(EFI_MEMORY_TYPE pool_type, UINTN size, VOID **buffer)
Wrap AllocatePool()
Definition: efi_wrap.c:358
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:1004
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:904
EFI_CHECK_EVENT CheckEvent
Definition: UefiSpec.h:1865
static EFI_STATUS EFIAPI efi_close_event_wrapper(EFI_EVENT event)
Wrap CloseEvent()
Definition: efi_wrap.c:475
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:679
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:881
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:641
static EFI_STATUS EFIAPI efi_exit_boot_services_wrapper(EFI_HANDLE image_handle, UINTN map_key)
Wrap ExitBootServices()
Definition: efi_wrap.c:774
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:733
EFI_RESTORE_TPL RestoreTPL
Definition: UefiSpec.h:1846
static EFI_STATUS EFIAPI efi_stall_wrapper(UINTN microseconds)
Wrap Stall()
Definition: efi_wrap.c:812
static EFI_STATUS EFIAPI efi_uninstall_multiple_protocol_interfaces_wrapper(EFI_HANDLE handle,...)
Wrap UninstallMultipleProtocolInterfaces()
Definition: efi_wrap.c:1107
static EFI_STATUS EFIAPI efi_check_event_wrapper(EFI_EVENT event)
Wrap CheckEvent()
Definition: efi_wrap.c:490
EFI_FREE_PAGES FreePages
Definition: UefiSpec.h:1852
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1913
EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable
Definition: UefiSpec.h:1878
EFI_LOCATE_DEVICE_PATH LocateDevicePath
Definition: UefiSpec.h:1877
static EFI_STATUS EFIAPI efi_free_pool_wrapper(VOID *buffer)
Wrap FreePool()
Definition: efi_wrap.c:378
EFI_ALLOCATE_POOL AllocatePool
Definition: UefiSpec.h:1854
EFI_DISCONNECT_CONTROLLER DisconnectController
Definition: UefiSpec.h:1900

References EFI_BOOT_SERVICES::AllocatePages, EFI_BOOT_SERVICES::AllocatePool, EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CheckEvent, EFI_BOOT_SERVICES::CloseEvent, EFI_BOOT_SERVICES::CloseProtocol, EFI_BOOT_SERVICES::ConnectController, EFI_BOOT_SERVICES::CreateEvent, EFI_BOOT_SERVICES::CreateEventEx, EFI_BOOT_SERVICES::DisconnectController, efi_allocate_pages_wrapper(), efi_allocate_pool_wrapper(), efi_check_event_wrapper(), efi_close_event_wrapper(), efi_close_protocol_wrapper(), efi_connect_controller_wrapper(), efi_create_event_ex_wrapper(), efi_create_event_wrapper(), efi_disconnect_controller_wrapper(), efi_exit_boot_services_wrapper(), efi_exit_wrapper(), efi_free_pages_wrapper(), efi_free_pool_wrapper(), efi_get_memory_map_wrapper(), efi_get_next_monotonic_count_wrapper(), efi_handle_protocol_wrapper(), efi_install_configuration_table_wrapper(), efi_install_multiple_protocol_interfaces_wrapper(), efi_install_protocol_interface_wrapper(), efi_load_image_wrapper(), efi_locate_device_path_wrapper(), efi_locate_handle_buffer_wrapper(), efi_locate_handle_wrapper(), efi_locate_protocol_wrapper(), efi_open_protocol_information_wrapper(), efi_open_protocol_wrapper(), efi_protocols_per_handle_wrapper(), efi_raise_tpl_wrapper(), efi_register_protocol_notify_wrapper(), efi_reinstall_protocol_interface_wrapper(), efi_restore_tpl_wrapper(), efi_set_timer_wrapper(), efi_set_watchdog_timer_wrapper(), efi_signal_event_wrapper(), efi_stall_wrapper(), efi_start_image_wrapper(), efi_systab, efi_uninstall_multiple_protocol_interfaces_wrapper(), efi_uninstall_protocol_interface_wrapper(), efi_unload_image_wrapper(), efi_wait_for_event_wrapper(), EFI_BOOT_SERVICES::Exit, EFI_BOOT_SERVICES::ExitBootServices, EFI_BOOT_SERVICES::FreePages, EFI_BOOT_SERVICES::FreePool, EFI_BOOT_SERVICES::GetMemoryMap, EFI_BOOT_SERVICES::GetNextMonotonicCount, EFI_BOOT_SERVICES::HandleProtocol, EFI_BOOT_SERVICES::InstallConfigurationTable, EFI_BOOT_SERVICES::InstallMultipleProtocolInterfaces, 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(), EFI_BOOT_SERVICES::OpenProtocol, EFI_BOOT_SERVICES::OpenProtocolInformation, EFI_BOOT_SERVICES::ProtocolsPerHandle, EFI_BOOT_SERVICES::RaiseTPL, EFI_BOOT_SERVICES::RegisterProtocolNotify, EFI_BOOT_SERVICES::ReinstallProtocolInterface, EFI_BOOT_SERVICES::RestoreTPL, EFI_BOOT_SERVICES::SetTimer, EFI_BOOT_SERVICES::SetWatchdogTimer, EFI_BOOT_SERVICES::SignalEvent, EFI_BOOT_SERVICES::Stall, EFI_BOOT_SERVICES::StartImage, EFI_BOOT_SERVICES::UninstallMultipleProtocolInterfaces, EFI_BOOT_SERVICES::UninstallProtocolInterface, EFI_BOOT_SERVICES::UnloadImage, and EFI_BOOT_SERVICES::WaitForEvent.

Referenced by efi_wrap().

◆ efi_wrap()

void efi_wrap ( EFI_HANDLE  handle)

Wrap the calls made by a loaded image.

Parameters
handleImage handle

Definition at line 1248 of file efi_wrap.c.

1248  {
1249  static EFI_SYSTEM_TABLE efi_systab_copy;
1250 
1251  /* Do nothing unless debugging is enabled */
1252  if ( ! DBG_LOG )
1253  return;
1254 
1255  /* Construct modified system table */
1256  if ( efi_systab != &efi_systab_copy ) {
1257  memcpy ( &efi_systab_copy, efi_systab,
1258  sizeof ( efi_systab_copy ) );
1260  efi_systab = &efi_systab_copy;
1261  }
1262 
1263  /* Dump image information */
1264  efi_dump_image ( handle );
1265 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
EFI_BOOT_SERVICES * efi_wrap_bs(void)
Build boot services table wrapper.
Definition: efi_wrap.c:1180
static void efi_dump_image(EFI_HANDLE handle)
Dump information about a loaded image.
Definition: efi_wrap.c:203
void * memcpy(void *dest, const void *src, size_t len) __nonnull
EFI System Table.
Definition: UefiSpec.h:1949
EFI_SYSTEM_TABLE * efi_systab
#define DBG_LOG
Definition: compiler.h:317
uint16_t handle
Handle.
Definition: smbios.h:16

References EFI_SYSTEM_TABLE::BootServices, DBG_LOG, efi_dump_image(), efi_systab, efi_wrap_bs(), handle, and memcpy().

Referenced by efi_image_exec().