iPXE
Macros | Functions | Variables
efi_wrap.c File Reference

EFI image wrapping. More...

#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/LoadedImage.h>
#include <ipxe/efi/efi_wrap.h>

Go to the source code of this file.

Macros

#define colour   &efi_systab_wrapper
 Colour for debug messages. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static const char * efi_status (EFI_STATUS efirc)
 Convert EFI status code to text. More...
 
static const char * efi_boolean (BOOLEAN boolean)
 Convert EFI boolean to text. More...
 
static EFI_STATUS EFIAPI efi_install_protocol_interface_wrapper (EFI_HANDLE *handle, EFI_GUID *protocol, EFI_INTERFACE_TYPE interface_type, VOID *interface)
 Wrap InstallProtocolInterface() More...
 
static EFI_STATUS EFIAPI efi_reinstall_protocol_interface_wrapper (EFI_HANDLE handle, EFI_GUID *protocol, VOID *old_interface, VOID *new_interface)
 Wrap ReinstallProtocolInterface() More...
 
static EFI_STATUS EFIAPI efi_uninstall_protocol_interface_wrapper (EFI_HANDLE handle, EFI_GUID *protocol, VOID *interface)
 Wrap UninstallProtocolInterface() More...
 
static EFI_STATUS EFIAPI efi_handle_protocol_wrapper (EFI_HANDLE handle, EFI_GUID *protocol, VOID **interface)
 Wrap HandleProtocol() More...
 
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() More...
 
static EFI_STATUS EFIAPI efi_locate_device_path_wrapper (EFI_GUID *protocol, EFI_DEVICE_PATH_PROTOCOL **device_path, EFI_HANDLE *device)
 Wrap LocateDevicePath() More...
 
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() More...
 
static EFI_STATUS EFIAPI efi_start_image_wrapper (EFI_HANDLE image_handle, UINTN *exit_data_size, CHAR16 **exit_data)
 Wrap StartImage() More...
 
static EFI_STATUS EFIAPI efi_exit_wrapper (EFI_HANDLE image_handle, EFI_STATUS exit_status, UINTN exit_data_size, CHAR16 *exit_data)
 Wrap Exit() More...
 
static EFI_STATUS EFIAPI efi_unload_image_wrapper (EFI_HANDLE image_handle)
 Wrap UnloadImage() More...
 
static EFI_STATUS EFIAPI efi_exit_boot_services_wrapper (EFI_HANDLE image_handle, UINTN map_key)
 Wrap ExitBootServices() More...
 
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() More...
 
static EFI_STATUS EFIAPI efi_disconnect_controller_wrapper (EFI_HANDLE controller_handle, EFI_HANDLE driver_image_handle, EFI_HANDLE child_handle)
 Wrap DisconnectController() More...
 
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() More...
 
static EFI_STATUS EFIAPI efi_close_protocol_wrapper (EFI_HANDLE handle, EFI_GUID *protocol, EFI_HANDLE agent_handle, EFI_HANDLE controller_handle)
 Wrap CloseProtocol() More...
 
static EFI_STATUS EFIAPI efi_protocols_per_handle_wrapper (EFI_HANDLE handle, EFI_GUID ***protocol_buffer, UINTN *protocol_buffer_count)
 Wrap ProtocolsPerHandle() More...
 
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() More...
 
static EFI_STATUS EFIAPI efi_locate_protocol_wrapper (EFI_GUID *protocol, VOID *registration, VOID **interface)
 Wrap LocateProtocol() More...
 
void efi_wrap (EFI_HANDLE handle)
 Wrap the calls made by a loaded image. More...
 

Variables

static EFI_SYSTEM_TABLE efi_systab_wrapper
 EFI system table wrapper. More...
 
static EFI_BOOT_SERVICES efi_bs_wrapper
 EFI boot services table wrapper. More...
 

Detailed Description

EFI image wrapping.

Definition in file efi_wrap.c.

Macro Definition Documentation

◆ colour

#define colour   &efi_systab_wrapper

Colour for debug messages.

Definition at line 47 of file efi_wrap.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ efi_status()

static const char* efi_status ( EFI_STATUS  efirc)
static

Convert EFI status code to text.

Parameters
efircEFI status code
Return values
textEFI status code text

Definition at line 55 of file efi_wrap.c.

55  {
56  static char buf[ 19 /* "0xXXXXXXXXXXXXXXXX" + NUL */ ];
57 
58  switch ( efirc ) {
59  case EFI_SUCCESS : return "0";
60  case EFI_LOAD_ERROR : return "LOAD_ERROR";
61  case EFI_INVALID_PARAMETER : return "INVALID_PARAMETER";
62  case EFI_UNSUPPORTED : return "UNSUPPORTED";
63  case EFI_BAD_BUFFER_SIZE : return "BAD_BUFFER_SIZE";
64  case EFI_BUFFER_TOO_SMALL : return "BUFFER_TOO_SMALL";
65  case EFI_NOT_READY : return "NOT_READY";
66  case EFI_DEVICE_ERROR : return "DEVICE_ERROR";
67  case EFI_WRITE_PROTECTED : return "WRITE_PROTECTED";
68  case EFI_OUT_OF_RESOURCES : return "OUT_OF_RESOURCES";
69  case EFI_VOLUME_CORRUPTED : return "VOLUME_CORRUPTED";
70  case EFI_VOLUME_FULL : return "VOLUME_FULL";
71  case EFI_NO_MEDIA : return "NO_MEDIA";
72  case EFI_MEDIA_CHANGED : return "MEDIA_CHANGED";
73  case EFI_NOT_FOUND : return "NOT_FOUND";
74  case EFI_ACCESS_DENIED : return "ACCESS_DENIED";
75  case EFI_NO_RESPONSE : return "NO_RESPONSE";
76  case EFI_NO_MAPPING : return "NO_MAPPING";
77  case EFI_TIMEOUT : return "TIMEOUT";
78  case EFI_NOT_STARTED : return "NOT_STARTED";
79  case EFI_ALREADY_STARTED : return "ALREADY_STARTED";
80  case EFI_ABORTED : return "ABORTED";
81  case EFI_ICMP_ERROR : return "ICMP_ERROR";
82  case EFI_TFTP_ERROR : return "TFTP_ERROR";
83  case EFI_PROTOCOL_ERROR : return "PROTOCOL_ERROR";
84  case EFI_INCOMPATIBLE_VERSION : return "INCOMPATIBLE_VERSION";
85  case EFI_SECURITY_VIOLATION : return "SECURITY_VIOLATION";
86  case EFI_CRC_ERROR : return "CRC_ERROR";
87  case EFI_END_OF_MEDIA : return "END_OF_MEDIA";
88  case EFI_END_OF_FILE : return "END_OF_FILE";
89  case EFI_INVALID_LANGUAGE : return "INVALID_LANGUAGE";
90  case EFI_COMPROMISED_DATA : return "COMPROMISED_DATA";
91  case EFI_WARN_UNKNOWN_GLYPH : return "WARN_UNKNOWN_GLYPH";
92  case EFI_WARN_DELETE_FAILURE : return "WARN_DELETE_FAILURE";
93  case EFI_WARN_WRITE_FAILURE : return "WARN_WRITE_FAILURE";
94  case EFI_WARN_BUFFER_TOO_SMALL : return "WARN_BUFFER_TOO_SMALL";
95  case EFI_WARN_STALE_DATA : return "WARN_STALE_DATA";
96  default:
97  snprintf ( buf, sizeof ( buf ), "%#lx",
98  ( unsigned long ) efirc );
99  return buf;
100  }
101 }
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
#define EFI_VOLUME_CORRUPTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:130
#define EFI_WARN_BUFFER_TOO_SMALL
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:157
#define EFI_ICMP_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:142
#define EFI_NO_RESPONSE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:136
#define EFI_ALREADY_STARTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:140
#define EFI_CRC_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:147
#define EFI_BAD_BUFFER_SIZE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:124
#define EFI_PROTOCOL_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:144
#define EFI_BUFFER_TOO_SMALL
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:125
#define EFI_NO_MEDIA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:132
#define EFI_OUT_OF_RESOURCES
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:129
#define EFI_DEVICE_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:127
#define EFI_LOAD_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:121
#define EFI_VOLUME_FULL
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:131
#define EFI_ACCESS_DENIED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:135
#define EFI_COMPROMISED_DATA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:151
#define EFI_NOT_STARTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:139
#define EFI_WRITE_PROTECTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:128
#define EFI_NOT_READY
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:126
#define EFI_INVALID_PARAMETER
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:122
#define EFI_END_OF_FILE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:149
#define EFI_INVALID_LANGUAGE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:150
#define EFI_WARN_STALE_DATA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:158
#define EFI_WARN_DELETE_FAILURE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:155
#define EFI_SECURITY_VIOLATION
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:146
#define EFI_MEDIA_CHANGED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:133
#define EFI_NOT_FOUND
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:134
#define EFI_INCOMPATIBLE_VERSION
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:145
#define EFI_SUCCESS
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:120
#define EFI_WARN_UNKNOWN_GLYPH
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:154
#define EFI_NO_MAPPING
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:137
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
#define EFI_WARN_WRITE_FAILURE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:156
#define EFI_END_OF_MEDIA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:148
#define EFI_ABORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:141
#define EFI_TFTP_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:143
#define EFI_TIMEOUT
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:138

References EFI_ABORTED, EFI_ACCESS_DENIED, EFI_ALREADY_STARTED, EFI_BAD_BUFFER_SIZE, EFI_BUFFER_TOO_SMALL, EFI_COMPROMISED_DATA, EFI_CRC_ERROR, EFI_DEVICE_ERROR, EFI_END_OF_FILE, EFI_END_OF_MEDIA, EFI_ICMP_ERROR, EFI_INCOMPATIBLE_VERSION, EFI_INVALID_LANGUAGE, EFI_INVALID_PARAMETER, EFI_LOAD_ERROR, EFI_MEDIA_CHANGED, EFI_NO_MAPPING, EFI_NO_MEDIA, EFI_NO_RESPONSE, EFI_NOT_FOUND, EFI_NOT_READY, EFI_NOT_STARTED, EFI_OUT_OF_RESOURCES, EFI_PROTOCOL_ERROR, EFI_SECURITY_VIOLATION, EFI_SUCCESS, EFI_TFTP_ERROR, EFI_TIMEOUT, EFI_UNSUPPORTED, EFI_VOLUME_CORRUPTED, EFI_VOLUME_FULL, EFI_WARN_BUFFER_TOO_SMALL, EFI_WARN_DELETE_FAILURE, EFI_WARN_STALE_DATA, EFI_WARN_UNKNOWN_GLYPH, EFI_WARN_WRITE_FAILURE, EFI_WRITE_PROTECTED, and snprintf().

Referenced by efi_close_protocol_wrapper(), efi_connect_controller_wrapper(), efi_disconnect_controller_wrapper(), efi_exit_boot_services_wrapper(), efi_exit_wrapper(), efi_handle_protocol_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_wrapper(), efi_protocols_per_handle_wrapper(), efi_reinstall_protocol_interface_wrapper(), efi_start_image_wrapper(), efi_uninstall_protocol_interface_wrapper(), and efi_unload_image_wrapper().

◆ efi_boolean()

static const char* efi_boolean ( BOOLEAN  boolean)
static

Convert EFI boolean to text.

Parameters
booleanBoolean value
Return values
textBoolean value text

Definition at line 109 of file efi_wrap.c.

109  {
110 
111  return ( boolean ? "TRUE" : "FALSE" );
112 }

Referenced by efi_connect_controller_wrapper(), and efi_load_image_wrapper().

◆ efi_install_protocol_interface_wrapper()

static EFI_STATUS EFIAPI efi_install_protocol_interface_wrapper ( EFI_HANDLE handle,
EFI_GUID protocol,
EFI_INTERFACE_TYPE  interface_type,
VOID interface 
)
static

Wrap InstallProtocolInterface()

Definition at line 119 of file efi_wrap.c.

121  {
123  void *retaddr = __builtin_return_address ( 0 );
124  EFI_STATUS efirc;
125 
126  DBGC ( colour, "InstallProtocolInterface ( %s, %s, %d, %p ) ",
130  interface );
131  DBGC ( colour, "= %s ( %s ) -> %p\n",
132  efi_status ( efirc ), efi_handle_name ( *handle ), retaddr );
133  return efirc;
134 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
An object interface.
Definition: interface.h:109
EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface
Definition: UefiSpec.h:1870
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
struct edd_interface_type interface_type
Interface type.
Definition: edd.h:20
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
uint16_t handle
Handle.
Definition: smbios.h:16

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_status(), efi_systab, handle, EFI_BOOT_SERVICES::InstallProtocolInterface, interface_type, and protocol.

Referenced by efi_wrap().

◆ efi_reinstall_protocol_interface_wrapper()

static EFI_STATUS EFIAPI efi_reinstall_protocol_interface_wrapper ( EFI_HANDLE  handle,
EFI_GUID protocol,
VOID old_interface,
VOID new_interface 
)
static

Wrap ReinstallProtocolInterface()

Definition at line 141 of file efi_wrap.c.

144  {
146  void *retaddr = __builtin_return_address ( 0 );
147  EFI_STATUS efirc;
148 
149  DBGC ( colour, "ReinstallProtocolInterface ( %s, %s, %p, %p ) ",
151  old_interface, new_interface );
153  old_interface, new_interface );
154  DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
155  return efirc;
156 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface
Definition: UefiSpec.h:1871
#define DBGC(...)
Definition: compiler.h:505
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
uint16_t handle
Handle.
Definition: smbios.h:16

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_status(), efi_systab, handle, protocol, and EFI_BOOT_SERVICES::ReinstallProtocolInterface.

Referenced by efi_wrap().

◆ efi_uninstall_protocol_interface_wrapper()

static EFI_STATUS EFIAPI efi_uninstall_protocol_interface_wrapper ( EFI_HANDLE  handle,
EFI_GUID protocol,
VOID interface 
)
static

Wrap UninstallProtocolInterface()

Definition at line 163 of file efi_wrap.c.

165  {
167  void *retaddr = __builtin_return_address ( 0 );
168  EFI_STATUS efirc;
169 
170  DBGC ( colour, "UninstallProtocolInterface ( %s, %s, %p ) ",
172  interface );
174  DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
175  return efirc;
176 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface
Definition: UefiSpec.h:1872
#define DBGC(...)
Definition: compiler.h:505
An object interface.
Definition: interface.h:109
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
uint16_t handle
Handle.
Definition: smbios.h:16

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_status(), efi_systab, handle, protocol, and EFI_BOOT_SERVICES::UninstallProtocolInterface.

Referenced by efi_wrap().

◆ efi_handle_protocol_wrapper()

static EFI_STATUS EFIAPI efi_handle_protocol_wrapper ( EFI_HANDLE  handle,
EFI_GUID protocol,
VOID **  interface 
)
static

Wrap HandleProtocol()

Definition at line 183 of file efi_wrap.c.

184  {
186  void *retaddr = __builtin_return_address ( 0 );
187  EFI_STATUS efirc;
188 
189  DBGC ( colour, "HandleProtocol ( %s, %s ) ",
191  efirc = bs->HandleProtocol ( handle, protocol, interface );
192  DBGC ( colour, "= %s ( %p ) -> %p\n",
193  efi_status ( efirc ), *interface, retaddr );
194  return efirc;
195 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
An object interface.
Definition: interface.h:109
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1873
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
uint16_t handle
Handle.
Definition: smbios.h:16

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_status(), efi_systab, handle, EFI_BOOT_SERVICES::HandleProtocol, and protocol.

Referenced by efi_wrap().

◆ efi_locate_handle_wrapper()

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 
)
static

Wrap LocateHandle()

Definition at line 202 of file efi_wrap.c.

204  {
206  void *retaddr = __builtin_return_address ( 0 );
207  unsigned int i;
208  EFI_STATUS efirc;
209 
210  DBGC ( colour, "LocateHandle ( %s, %s, %p, %zd ) ",
211  efi_locate_search_type_name ( search_type ),
212  efi_guid_ntoa ( protocol ), search_key,
213  ( ( size_t ) *buffer_size ) );
214  efirc = bs->LocateHandle ( search_type, protocol, search_key,
215  buffer_size, buffer );
216  DBGC ( colour, "= %s ( %zd", efi_status ( efirc ),
217  ( ( size_t ) *buffer_size ) );
218  if ( efirc == 0 ) {
219  DBGC ( colour, ", {" );
220  for ( i = 0; i < ( *buffer_size / sizeof ( buffer[0] ) ); i++ ){
221  DBGC ( colour, "%s%s", ( i ? ", " : " " ),
222  efi_handle_name ( buffer[i] ) );
223  }
224  DBGC ( colour, " }" );
225  }
226  DBGC ( colour, " ) -> %p\n", retaddr );
227  return efirc;
228 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
EFI_LOCATE_HANDLE LocateHandle
Definition: UefiSpec.h:1876
const char * efi_locate_search_type_name(EFI_LOCATE_SEARCH_TYPE search_type)
Name locate search type.
Definition: efi_debug.c:225
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
UINT16_t buffer_size
UDP payload buffer size.
Definition: pxe_api.h:62

References EFI_SYSTEM_TABLE::BootServices, buffer, buffer_size, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_locate_search_type_name(), efi_status(), efi_systab, EFI_BOOT_SERVICES::LocateHandle, and protocol.

Referenced by efi_wrap().

◆ efi_locate_device_path_wrapper()

static EFI_STATUS EFIAPI efi_locate_device_path_wrapper ( EFI_GUID protocol,
EFI_DEVICE_PATH_PROTOCOL **  device_path,
EFI_HANDLE device 
)
static

Wrap LocateDevicePath()

Definition at line 235 of file efi_wrap.c.

237  {
239  void *retaddr = __builtin_return_address ( 0 );
240  EFI_STATUS efirc;
241 
242  DBGC ( colour, "LocateDevicePath ( %s, %s ) ",
244  efirc = bs->LocateDevicePath ( protocol, device_path, device );
245  DBGC ( colour, "= %s ( %s, ",
246  efi_status ( efirc ), efi_devpath_text ( *device_path ) );
247  DBGC ( colour, "%s ) -> %p\n", efi_handle_name ( *device ), retaddr );
248  return efirc;
249 }
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:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
A hardware device.
Definition: device.h:73
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:366
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
EFI_LOCATE_DEVICE_PATH LocateDevicePath
Definition: UefiSpec.h:1877

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, device_path, efi_devpath_text(), efi_guid_ntoa(), efi_handle_name(), efi_status(), efi_systab, EFI_BOOT_SERVICES::LocateDevicePath, and protocol.

Referenced by efi_wrap().

◆ efi_load_image_wrapper()

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 
)
static

Wrap LoadImage()

Definition at line 256 of file efi_wrap.c.

259  {
261  void *retaddr = __builtin_return_address ( 0 );
262  EFI_STATUS efirc;
263 
264  DBGC ( colour, "LoadImage ( %s, %s, ", efi_boolean ( boot_policy ),
265  efi_handle_name ( parent_image_handle ) );
266  DBGC ( colour, "%s, %p, %#llx ) ",
267  efi_devpath_text ( device_path ), source_buffer,
268  ( ( unsigned long long ) source_size ) );
269  efirc = bs->LoadImage ( boot_policy, parent_image_handle, device_path,
270  source_buffer, source_size, image_handle );
271  DBGC ( colour, "= %s ( ", efi_status ( efirc ) );
272  if ( efirc == 0 )
273  DBGC ( colour, "%s ", efi_handle_name ( *image_handle ) );
274  DBGC ( colour, ") -> %p\n", retaddr );
275 
276  /* Wrap the new image */
277  if ( efirc == 0 )
278  efi_wrap ( *image_handle );
279 
280  return efirc;
281 }
union edd_device_path device_path
Device path.
Definition: edd.h:24
static const char * efi_boolean(BOOLEAN boolean)
Convert EFI boolean to text.
Definition: efi_wrap.c:109
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
EFI_IMAGE_LOAD LoadImage
Definition: UefiSpec.h:1883
#define DBGC(...)
Definition: compiler.h:505
void efi_wrap(EFI_HANDLE handle)
Wrap the calls made by a loaded image.
Definition: efi_wrap.c:550
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:366
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
static unsigned int source_size
Definition: bigint.h:240
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, device_path, efi_boolean(), efi_devpath_text(), efi_handle_name(), efi_status(), efi_systab, efi_wrap(), EFI_BOOT_SERVICES::LoadImage, and source_size.

Referenced by efi_wrap().

◆ efi_start_image_wrapper()

static EFI_STATUS EFIAPI efi_start_image_wrapper ( EFI_HANDLE  image_handle,
UINTN exit_data_size,
CHAR16 **  exit_data 
)
static

Wrap StartImage()

Definition at line 288 of file efi_wrap.c.

289  {
291  void *retaddr = __builtin_return_address ( 0 );
292  EFI_STATUS efirc;
293 
294  DBGC ( colour, "StartImage ( %s ) ", efi_handle_name ( image_handle ) );
295  efirc = bs->StartImage ( image_handle, exit_data_size, exit_data );
296  DBGC ( colour, "= %s", efi_status ( efirc ) );
297  if ( ( efirc != 0 ) && exit_data && *exit_data_size )
298  DBGC ( colour, " ( \"%ls\" )", *exit_data );
299  DBGC ( colour, " -> %p\n", retaddr );
300  if ( ( efirc != 0 ) && exit_data && *exit_data_size )
301  DBGC_HD ( colour, *exit_data, *exit_data_size );
302  return efirc;
303 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
#define DBGC_HD(...)
Definition: compiler.h:507
EFI_IMAGE_START StartImage
Definition: UefiSpec.h:1884
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, DBGC_HD, efi_handle_name(), efi_status(), efi_systab, and EFI_BOOT_SERVICES::StartImage.

Referenced by efi_wrap().

◆ efi_exit_wrapper()

static EFI_STATUS EFIAPI efi_exit_wrapper ( EFI_HANDLE  image_handle,
EFI_STATUS  exit_status,
UINTN  exit_data_size,
CHAR16 exit_data 
)
static

Wrap Exit()

Definition at line 310 of file efi_wrap.c.

311  {
313  void *retaddr = __builtin_return_address ( 0 );
314  EFI_STATUS efirc;
315 
316  if ( ( exit_status != 0 ) && exit_data && exit_data_size )
317  DBGC_HD ( colour, exit_data, exit_data_size );
318  DBGC ( colour, "Exit ( %s, %s",
319  efi_handle_name ( image_handle ), efi_status ( exit_status ) );
320  if ( ( exit_status != 0 ) && exit_data && exit_data_size )
321  DBGC ( colour, ", \"%ls\"", exit_data );
322  DBGC ( colour, " ) " );
323  efirc = bs->Exit ( image_handle, exit_status, exit_data_size,
324  exit_data );
325  DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
326  return efirc;
327 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
#define DBGC_HD(...)
Definition: compiler.h:507
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, DBGC_HD, efi_handle_name(), efi_status(), efi_systab, and EFI_BOOT_SERVICES::Exit.

Referenced by efi_wrap().

◆ efi_unload_image_wrapper()

static EFI_STATUS EFIAPI efi_unload_image_wrapper ( EFI_HANDLE  image_handle)
static

Wrap UnloadImage()

Definition at line 334 of file efi_wrap.c.

334  {
336  void *retaddr = __builtin_return_address ( 0 );
337  EFI_STATUS efirc;
338 
339  DBGC ( colour, "UnloadImage ( %s ) ",
340  efi_handle_name ( image_handle ) );
341  efirc = bs->UnloadImage ( image_handle );
342  DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
343  return efirc;
344 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1886
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_handle_name(), efi_status(), efi_systab, and EFI_BOOT_SERVICES::UnloadImage.

Referenced by efi_wrap().

◆ efi_exit_boot_services_wrapper()

static EFI_STATUS EFIAPI efi_exit_boot_services_wrapper ( EFI_HANDLE  image_handle,
UINTN  map_key 
)
static

Wrap ExitBootServices()

Definition at line 351 of file efi_wrap.c.

351  {
353  void *retaddr = __builtin_return_address ( 0 );
354  EFI_STATUS efirc;
355 
356  DBGC ( colour, "ExitBootServices ( %s, %#llx ) ",
357  efi_handle_name ( image_handle ),
358  ( ( unsigned long long ) map_key ) );
359  efirc = bs->ExitBootServices ( image_handle, map_key );
360  DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
361  return efirc;
362 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
EFI_EXIT_BOOT_SERVICES ExitBootServices
Definition: UefiSpec.h:1887
#define DBGC(...)
Definition: compiler.h:505
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_handle_name(), efi_status(), efi_systab, and EFI_BOOT_SERVICES::ExitBootServices.

Referenced by efi_wrap().

◆ efi_connect_controller_wrapper()

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 
)
static

Wrap ConnectController()

Definition at line 369 of file efi_wrap.c.

372  {
374  void *retaddr = __builtin_return_address ( 0 );
375  EFI_HANDLE *tmp;
376  EFI_STATUS efirc;
377 
378  DBGC ( colour, "ConnectController ( %s, {",
379  efi_handle_name ( controller_handle ) );
380  if ( driver_image_handle ) {
381  for ( tmp = driver_image_handle ; *tmp ; tmp++ ) {
382  DBGC ( colour, "%s%s",
383  ( ( tmp == driver_image_handle ) ? " " : ", " ),
384  efi_handle_name ( *tmp ) );
385  }
386  }
387  DBGC ( colour, " }, %s, %s ) ", efi_devpath_text ( remaining_path ),
388  efi_boolean ( recursive ) );
389  efirc = bs->ConnectController ( controller_handle, driver_image_handle,
390  remaining_path, recursive );
391  DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
392  return efirc;
393 }
static const char * efi_boolean(BOOLEAN boolean)
Convert EFI boolean to text.
Definition: efi_wrap.c:109
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:366
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
uint8_t * tmp
Definition: entropy.h:156
EFI_CONNECT_CONTROLLER ConnectController
Definition: UefiSpec.h:1899
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
Definition: efi.h:55

References EFI_SYSTEM_TABLE::BootServices, colour, EFI_BOOT_SERVICES::ConnectController, DBGC, efi_boolean(), efi_devpath_text(), efi_handle_name(), efi_status(), efi_systab, and tmp.

Referenced by efi_wrap().

◆ efi_disconnect_controller_wrapper()

static EFI_STATUS EFIAPI efi_disconnect_controller_wrapper ( EFI_HANDLE  controller_handle,
EFI_HANDLE  driver_image_handle,
EFI_HANDLE  child_handle 
)
static

Wrap DisconnectController()

Definition at line 400 of file efi_wrap.c.

402  {
404  void *retaddr = __builtin_return_address ( 0 );
405  EFI_STATUS efirc;
406 
407  DBGC ( colour, "DisconnectController ( %s",
408  efi_handle_name ( controller_handle ) );
409  DBGC ( colour, ", %s", efi_handle_name ( driver_image_handle ) );
410  DBGC ( colour, ", %s ) ", efi_handle_name ( child_handle ) );
411  efirc = bs->DisconnectController ( controller_handle,
412  driver_image_handle,
413  child_handle );
414  DBGC ( colour, "= %s -> %p\n", efi_status ( efirc ), retaddr );
415  return efirc;
416 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
EFI_DISCONNECT_CONTROLLER DisconnectController
Definition: UefiSpec.h:1900

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, EFI_BOOT_SERVICES::DisconnectController, efi_handle_name(), efi_status(), and efi_systab.

Referenced by efi_wrap().

◆ efi_open_protocol_wrapper()

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 
)
static

Wrap OpenProtocol()

Definition at line 423 of file efi_wrap.c.

425  {
427  void *retaddr = __builtin_return_address ( 0 );
428  EFI_STATUS efirc;
429 
430  DBGC ( colour, "OpenProtocol ( %s, %s, ",
432  DBGC ( colour, "%s, ", efi_handle_name ( agent_handle ) );
433  DBGC ( colour, "%s, %s ) ", efi_handle_name ( controller_handle ),
434  efi_open_attributes_name ( attributes ) );
435  efirc = bs->OpenProtocol ( handle, protocol, interface, agent_handle,
436  controller_handle, attributes );
437  DBGC ( colour, "= %s ( %p ) -> %p\n",
438  efi_status ( efirc ), *interface, retaddr );
439  return efirc;
440 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
An object interface.
Definition: interface.h:109
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
const char * efi_open_attributes_name(unsigned int attributes)
Name protocol open attributes.
Definition: efi_debug.c:250
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
uint16_t handle
Handle.
Definition: smbios.h:16

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_open_attributes_name(), efi_status(), efi_systab, handle, EFI_BOOT_SERVICES::OpenProtocol, and protocol.

Referenced by efi_wrap().

◆ efi_close_protocol_wrapper()

static EFI_STATUS EFIAPI efi_close_protocol_wrapper ( EFI_HANDLE  handle,
EFI_GUID protocol,
EFI_HANDLE  agent_handle,
EFI_HANDLE  controller_handle 
)
static

Wrap CloseProtocol()

Definition at line 447 of file efi_wrap.c.

449  {
451  void *retaddr = __builtin_return_address ( 0 );
452  EFI_STATUS efirc;
453 
454  DBGC ( colour, "CloseProtocol ( %s, %s, ",
456  DBGC ( colour, "%s, ", efi_handle_name ( agent_handle ) );
457  DBGC ( colour, "%s ) ", efi_handle_name ( controller_handle ) );
458  efirc = bs->CloseProtocol ( handle, protocol, agent_handle,
459  controller_handle );
460  DBGC ( colour, "= %s -> %p\n",
461  efi_status ( efirc ), retaddr );
462  return efirc;
463 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
uint16_t handle
Handle.
Definition: smbios.h:16

References EFI_SYSTEM_TABLE::BootServices, EFI_BOOT_SERVICES::CloseProtocol, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_status(), efi_systab, handle, and protocol.

Referenced by efi_wrap().

◆ efi_protocols_per_handle_wrapper()

static EFI_STATUS EFIAPI efi_protocols_per_handle_wrapper ( EFI_HANDLE  handle,
EFI_GUID ***  protocol_buffer,
UINTN protocol_buffer_count 
)
static

Wrap ProtocolsPerHandle()

Definition at line 470 of file efi_wrap.c.

472  {
474  void *retaddr = __builtin_return_address ( 0 );
475  unsigned int i;
476  EFI_STATUS efirc;
477 
478  DBGC ( colour, "ProtocolsPerHandle ( %s ) ",
479  efi_handle_name ( handle ) );
480  efirc = bs->ProtocolsPerHandle ( handle, protocol_buffer,
481  protocol_buffer_count );
482  DBGC ( colour, "= %s", efi_status ( efirc ) );
483  if ( efirc == 0 ) {
484  DBGC ( colour, " ( {" );
485  for ( i = 0 ; i < *protocol_buffer_count ; i++ ) {
486  DBGC ( colour, "%s%s", ( i ? ", " : " " ),
487  efi_guid_ntoa ( (*protocol_buffer)[i] ) );
488  }
489  DBGC ( colour, " } )" );
490  }
491  DBGC ( colour, " -> %p\n", retaddr );
492  return efirc;
493 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:1912
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
uint16_t handle
Handle.
Definition: smbios.h:16

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_status(), efi_systab, handle, and EFI_BOOT_SERVICES::ProtocolsPerHandle.

Referenced by efi_wrap().

◆ efi_locate_handle_buffer_wrapper()

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 
)
static

Wrap LocateHandleBuffer()

Definition at line 500 of file efi_wrap.c.

502  {
504  void *retaddr = __builtin_return_address ( 0 );
505  unsigned int i;
506  EFI_STATUS efirc;
507 
508  DBGC ( colour, "LocateHandleBuffer ( %s, %s, %p ) ",
509  efi_locate_search_type_name ( search_type ),
510  efi_guid_ntoa ( protocol ), search_key );
511  efirc = bs->LocateHandleBuffer ( search_type, protocol, search_key,
512  no_handles, buffer );
513  DBGC ( colour, "= %s", efi_status ( efirc ) );
514  if ( efirc == 0 ) {
515  DBGC ( colour, " ( %d, {", ( ( unsigned int ) *no_handles ) );
516  for ( i = 0 ; i < *no_handles ; i++ ) {
517  DBGC ( colour, "%s%s", ( i ? ", " : " " ),
518  efi_handle_name ( (*buffer)[i] ) );
519  }
520  DBGC ( colour, " } )" );
521  }
522  DBGC ( colour, " -> %p\n", retaddr );
523  return efirc;
524 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
#define DBGC(...)
Definition: compiler.h:505
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
const char * efi_locate_search_type_name(EFI_LOCATE_SEARCH_TYPE search_type)
Name locate search type.
Definition: efi_debug.c:225
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:713
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1913

References EFI_SYSTEM_TABLE::BootServices, buffer, colour, DBGC, efi_guid_ntoa(), efi_handle_name(), efi_locate_search_type_name(), efi_status(), efi_systab, EFI_BOOT_SERVICES::LocateHandleBuffer, and protocol.

Referenced by efi_wrap().

◆ efi_locate_protocol_wrapper()

static EFI_STATUS EFIAPI efi_locate_protocol_wrapper ( EFI_GUID protocol,
VOID registration,
VOID **  interface 
)
static

Wrap LocateProtocol()

Definition at line 531 of file efi_wrap.c.

532  {
534  void *retaddr = __builtin_return_address ( 0 );
535  EFI_STATUS efirc;
536 
537  DBGC ( colour, "LocateProtocol ( %s, %p ) ",
538  efi_guid_ntoa ( protocol ), registration );
539  efirc = bs->LocateProtocol ( protocol, registration, interface );
540  DBGC ( colour, "= %s ( %p ) -> %p\n",
541  efi_status ( efirc ), *interface, retaddr );
542  return efirc;
543 }
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
static const char * efi_status(EFI_STATUS efirc)
Convert EFI status code to text.
Definition: efi_wrap.c:55
EFI_LOCATE_PROTOCOL LocateProtocol
Definition: UefiSpec.h:1914
#define DBGC(...)
Definition: compiler.h:505
An object interface.
Definition: interface.h:109
EFI Boot Services Table.
Definition: UefiSpec.h:1836
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_SYSTEM_TABLE * efi_systab
uint16_t protocol
Protocol ID.
Definition: stp.h:18
#define colour
Colour for debug messages.
Definition: efi_wrap.c:47

References EFI_SYSTEM_TABLE::BootServices, colour, DBGC, efi_guid_ntoa(), efi_status(), efi_systab, EFI_BOOT_SERVICES::LocateProtocol, and protocol.

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 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().

Variable Documentation

◆ efi_systab_wrapper

EFI_SYSTEM_TABLE efi_systab_wrapper
static

EFI system table wrapper.

Definition at line 41 of file efi_wrap.c.

Referenced by efi_wrap().

◆ efi_bs_wrapper

EFI_BOOT_SERVICES efi_bs_wrapper
static

EFI boot services table wrapper.

Definition at line 44 of file efi_wrap.c.

Referenced by efi_wrap().