iPXE
efi_wrap.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301, USA.
18  *
19  * You can also choose to distribute this program under the terms of
20  * the Unmodified Binary Distribution Licence (as given in the file
21  * COPYING.UBDL), provided that you have satisfied its requirements.
22  */
23 
24 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
25 
26 /**
27  * @file
28  *
29  * EFI image wrapping
30  *
31  */
32 
33 #include <string.h>
34 #include <stdio.h>
35 #include <errno.h>
36 #include <ipxe/efi/efi.h>
38 #include <ipxe/efi/efi_wrap.h>
39 
40 /** EFI system table wrapper */
42 
43 /** EFI boot services table wrapper */
45 
46 /** Colour for debug messages */
47 #define colour &efi_systab_wrapper
48 
49 /**
50  * Convert EFI status code to text
51  *
52  * @v efirc EFI status code
53  * @ret text EFI status code text
54  */
55 static const char * efi_status ( EFI_STATUS efirc ) {
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 }
102 
103 /**
104  * Convert EFI boolean to text
105  *
106  * @v boolean Boolean value
107  * @ret text Boolean value text
108  */
109 static const char * efi_boolean ( BOOLEAN boolean ) {
110 
111  return ( boolean ? "TRUE" : "FALSE" );
112 }
113 
114 /**
115  * Wrap InstallProtocolInterface()
116  *
117  */
118 static EFI_STATUS EFIAPI
121  VOID *interface ) {
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 }
135 
136 /**
137  * Wrap ReinstallProtocolInterface()
138  *
139  */
140 static EFI_STATUS EFIAPI
143  VOID *old_interface,
144  VOID *new_interface ) {
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 }
157 
158 /**
159  * Wrap UninstallProtocolInterface()
160  *
161  */
162 static EFI_STATUS EFIAPI
165  VOID *interface ) {
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 }
177 
178 /**
179  * Wrap HandleProtocol()
180  *
181  */
182 static EFI_STATUS EFIAPI
184  VOID **interface ) {
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 }
196 
197 /**
198  * Wrap LocateHandle()
199  *
200  */
201 static EFI_STATUS EFIAPI
203  EFI_GUID *protocol, VOID *search_key,
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 }
229 
230 /**
231  * Wrap LocateDevicePath()
232  *
233  */
234 static EFI_STATUS EFIAPI
237  EFI_HANDLE *device ) {
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 }
250 
251 /**
252  * Wrap LoadImage()
253  *
254  */
255 static EFI_STATUS EFIAPI
256 efi_load_image_wrapper ( BOOLEAN boot_policy, EFI_HANDLE parent_image_handle,
258  VOID *source_buffer, UINTN source_size,
259  EFI_HANDLE *image_handle ) {
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 }
282 
283 /**
284  * Wrap StartImage()
285  *
286  */
287 static EFI_STATUS EFIAPI
288 efi_start_image_wrapper ( EFI_HANDLE image_handle, UINTN *exit_data_size,
289  CHAR16 **exit_data ) {
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 }
304 
305 /**
306  * Wrap Exit()
307  *
308  */
309 static EFI_STATUS EFIAPI
310 efi_exit_wrapper ( EFI_HANDLE image_handle, EFI_STATUS exit_status,
311  UINTN exit_data_size, CHAR16 *exit_data ) {
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 }
328 
329 /**
330  * Wrap UnloadImage()
331  *
332  */
333 static EFI_STATUS EFIAPI
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 }
345 
346 /**
347  * Wrap ExitBootServices()
348  *
349  */
350 static EFI_STATUS EFIAPI
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 }
363 
364 /**
365  * Wrap ConnectController()
366  *
367  */
368 static EFI_STATUS EFIAPI
370  EFI_HANDLE *driver_image_handle,
371  EFI_DEVICE_PATH_PROTOCOL *remaining_path,
372  BOOLEAN recursive ) {
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 }
394 
395 /**
396  * Wrap DisconnectController()
397  *
398  */
399 static EFI_STATUS EFIAPI
401  EFI_HANDLE driver_image_handle,
402  EFI_HANDLE child_handle ) {
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 }
417 
418 /**
419  * Wrap OpenProtocol()
420  *
421  */
422 static EFI_STATUS EFIAPI
424  VOID **interface, EFI_HANDLE agent_handle,
425  EFI_HANDLE controller_handle, UINT32 attributes ) {
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 }
441 
442 /**
443  * Wrap CloseProtocol()
444  *
445  */
446 static EFI_STATUS EFIAPI
448  EFI_HANDLE agent_handle,
449  EFI_HANDLE controller_handle ) {
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 }
464 
465 /**
466  * Wrap ProtocolsPerHandle()
467  *
468  */
469 static EFI_STATUS EFIAPI
471  EFI_GUID ***protocol_buffer,
472  UINTN *protocol_buffer_count ) {
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 }
494 
495 /**
496  * Wrap LocateHandleBuffer()
497  *
498  */
499 static EFI_STATUS EFIAPI
501  EFI_GUID *protocol, VOID *search_key,
502  UINTN *no_handles, EFI_HANDLE **buffer ) {
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 }
525 
526 /**
527  * Wrap LocateProtocol()
528  *
529  */
530 static EFI_STATUS EFIAPI
532  VOID **interface ) {
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 }
544 
545 /**
546  * Wrap the calls made by a loaded image
547  *
548  * @v handle Image handle
549  */
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 }
union edd_device_path device_path
Device path.
Definition: edd.h:24
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
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
#define EFI_UNSUPPORTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:123
#define EFI_VOLUME_CORRUPTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:130
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#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 EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:157
#define EFI_ALREADY_STARTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:140
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
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
#define EFI_CRC_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:147
128 bit buffer containing a unique identifier value.
Definition: Base.h:263
#define EFI_BAD_BUFFER_SIZE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:124
Error codes.
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:262
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
unsigned char BOOLEAN
Definition: ProcessorBind.h:61
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 EFI_PROTOCOL_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:144
#define DBGC(...)
Definition: compiler.h:505
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:184
unsigned int UINT32
Definition: ProcessorBind.h:56
static EFI_STATUS EFIAPI efi_handle_protocol_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, VOID **interface)
Wrap HandleProtocol()
Definition: efi_wrap.c:183
unsigned short CHAR16
Definition: ProcessorBind.h:59
uint32_t buffer
Buffer index (or NETVSC_RNDIS_NO_BUFFER)
Definition: netvsc.h:16
EFI_LOCATE_HANDLE LocateHandle
Definition: UefiSpec.h:1876
EFI_IMAGE_UNLOAD UnloadImage
Definition: UefiSpec.h:1886
An executable image.
Definition: image.h:24
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
#define EFI_BUFFER_TOO_SMALL
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:125
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
#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
UEFI 2.0 Loaded image protocol definition.
#define EFI_LOAD_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:121
A hardware device.
Definition: device.h:73
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
#define EFI_VOLUME_FULL
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:131
#define EFI_ACCESS_DENIED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:135
An object interface.
Definition: interface.h:109
#define EFI_COMPROMISED_DATA
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:151
EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface
Definition: UefiSpec.h:1870
void efi_wrap(EFI_HANDLE handle)
Wrap the calls made by a loaded image.
Definition: efi_wrap.c:550
const char * efi_locate_search_type_name(EFI_LOCATE_SEARCH_TYPE search_type)
Name locate search type.
Definition: efi_debug.c:225
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
#define EFI_NOT_STARTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:139
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
#define EFI_WRITE_PROTECTED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:128
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
#define EFIAPI
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:30
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
uint8_t * tmp
Definition: entropy.h:156
static EFI_SYSTEM_TABLE efi_systab_wrapper
EFI system table wrapper.
Definition: efi_wrap.c:41
#define DBGC_HD(...)
Definition: compiler.h:507
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
UINT64 UINTN
Unsigned value of native width.
Definition: ProcessorBind.h:71
EFI System Table.
Definition: UefiSpec.h:1949
#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
static EFI_STATUS EFIAPI efi_unload_image_wrapper(EFI_HANDLE image_handle)
Wrap UnloadImage()
Definition: efi_wrap.c:334
#define VOID
Undeclared type.
Definition: Base.h:319
#define EFI_INVALID_LANGUAGE
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:150
static EFI_BOOT_SERVICES efi_bs_wrapper
EFI boot services table wrapper.
Definition: efi_wrap.c:44
#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
EFI API.
static EFI_STATUS EFIAPI efi_uninstall_protocol_interface_wrapper(EFI_HANDLE handle, EFI_GUID *protocol, VOID *interface)
Wrap UninstallProtocolInterface()
Definition: efi_wrap.c:163
#define EFI_SECURITY_VIOLATION
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:146
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
#define EFI_MEDIA_CHANGED
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:133
static unsigned int source_size
Definition: bigint.h:249
#define EFI_NOT_FOUND
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:134
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
#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
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
#define EFI_NO_MAPPING
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:137
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
const char * efi_open_attributes_name(unsigned int attributes)
Name protocol open attributes.
Definition: efi_debug.c:250
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
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
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
uint16_t protocol
Protocol ID.
Definition: stp.h:18
EFI_LOCATE_SEARCH_TYPE
Enumeration of EFI Locate Search Types.
Definition: UefiSpec.h:1435
EFI_INTERFACE_TYPE
Enumeration of EFI Interface Types.
Definition: UefiSpec.h:1118
#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 colour
Colour for debug messages.
Definition: efi_wrap.c:47
#define DBG_LOG
Definition: compiler.h:317
#define EFI_TFTP_ERROR
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:143
uint16_t handle
Handle.
Definition: smbios.h:16
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
UINT16_t buffer_size
UDP payload buffer size.
Definition: pxe_api.h:62
String functions.
EFI driver interface.
Definition: efi.h:55
EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer
Definition: UefiSpec.h:1913
EFI_LOCATE_DEVICE_PATH LocateDevicePath
Definition: UefiSpec.h:1877
#define EFI_TIMEOUT
Enumeration of EFI_STATUS.
Definition: UefiBaseType.h:138
EFI_DISCONNECT_CONTROLLER DisconnectController
Definition: UefiSpec.h:1900