iPXE
efi_debug.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 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 debugging utilities
30  *
31  */
32 
33 #include <stdio.h>
34 #include <string.h>
35 #include <errno.h>
36 #include <ipxe/uuid.h>
37 #include <ipxe/base16.h>
38 #include <ipxe/vsprintf.h>
39 #include <ipxe/efi/efi.h>
40 #include <ipxe/efi/efi_utils.h>
45 
46 /** Device path to text protocol */
49 
50 /** Iscsi4Dxe module GUID */
52  0x4579b72d, 0x7ec4, 0x4dd4,
53  { 0x84, 0x86, 0x08, 0x3c, 0x86, 0xb1, 0x82, 0xa7 }
54 };
55 
56 /** VlanConfigDxe module GUID */
58  0xe4f61863, 0xfe2c, 0x4b56,
59  { 0xa8, 0xf4, 0x08, 0x51, 0x9b, 0xc4, 0x39, 0xdf }
60 };
61 
62 /** A well-known GUID */
64  /** GUID */
66  /** Name */
67  const char *name;
68 };
69 
70 /** Well-known GUIDs */
73  "AbsolutePointer" },
75  "AcpiTable" },
77  "AppleNetBoot" },
79  "Arp" },
81  "ArpSb" },
83  "BlockIo" },
85  "BlockIo2" },
87  "BusSpecificDriverOverride" },
89  "ComponentName" },
91  "ComponentName2" },
93  "ConsoleControl" },
95  "DevicePath" },
97  "DriverBinding" },
99  "Dhcp4" },
101  "Dhcp4Sb" },
103  "DiskIo" },
105  "GraphicsOutput" },
107  "HiiConfigAccess" },
109  "HiiFont" },
111  "Ip4" },
113  "Ip4Config" },
115  "Ip4Sb" },
117  "IScsi4Dxe" },
119  "LoadFile" },
121  "LoadFile2" },
123  "LoadedImage" },
125  "LoadedImageDevicePath"},
127  "ManagedNetwork" },
129  "ManagedNetworkSb" },
131  "Mtftp4" },
133  "Mtftp4Sb" },
135  "Nii" },
137  "Nii31" },
139  "PciIo" },
141  "PciRootBridgeIo" },
143  "PxeBaseCode" },
145  "SerialIo" },
147  "SimpleFileSystem" },
149  "SimpleNetwork" },
151  "SimplePointer" },
153  "SimpleTextInput" },
155  "SimpleTextInputEx" },
157  "SimpleTextOutput" },
159  "Tcg" },
161  "Tcp4" },
163  "Tcp4Sb" },
165  "TrEE" },
167  "Udp4" },
169  "Udp4Sb" },
171  "UgaDraw" },
173  "UnicodeCollation" },
175  "UsbHc" },
177  "Usb2Hc" },
179  "UsbIo" },
181  "VlanConfig" },
183  "VlanConfigDxe" },
184 };
185 
186 /**
187  * Convert GUID to a printable string
188  *
189  * @v guid GUID
190  * @ret string Printable string
191  */
192 const __attribute__ (( pure )) char * efi_guid_ntoa ( EFI_GUID *guid ) {
193  union {
194  union uuid uuid;
195  EFI_GUID guid;
196  } u;
197  unsigned int i;
198 
199  /* Sanity check */
200  if ( ! guid )
201  return NULL;
202 
203  /* Check for a match against well-known GUIDs */
204  for ( i = 0 ; i < ( sizeof ( efi_well_known_guids ) /
205  sizeof ( efi_well_known_guids[0] ) ) ; i++ ) {
207  sizeof ( *guid ) ) == 0 ) {
208  return efi_well_known_guids[i].name;
209  }
210  }
211 
212  /* Convert GUID to standard endianness */
213  memcpy ( &u.guid, guid, sizeof ( u.guid ) );
214  uuid_mangle ( &u.uuid );
215  return uuid_ntoa ( &u.uuid );
216 }
217 
218 /**
219  * Name locate search type
220  *
221  * @v search_type Locate search type
222  * @ret name Locate search type name
223  */
224 const __attribute__ (( pure )) char *
226  static char buf[16];
227 
228  switch ( search_type ) {
229  case AllHandles : return "AllHandles";
230  case ByRegisterNotify: return "ByRegisterNotify";
231  case ByProtocol: return "ByProtocol";
232  default:
233  snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", search_type );
234  return buf;
235  }
236 }
237 
238 /**
239  * Name protocol open attributes
240  *
241  * @v attributes Protocol open attributes
242  * @ret name Protocol open attributes name
243  *
244  * Returns a (static) string with characters for each set bit
245  * corresponding to BY_(H)ANDLE_PROTOCOL, (G)ET_PROTOCOL,
246  * (T)EST_PROTOCOL, BY_(C)HILD_CONTROLLER, BY_(D)RIVER, and
247  * E(X)CLUSIVE.
248  */
249 const __attribute__ (( pure )) char *
250 efi_open_attributes_name ( unsigned int attributes ) {
251  static char attribute_chars[] = "HGTCDX";
252  static char name[ sizeof ( attribute_chars ) ];
253  char *tmp = name;
254  unsigned int i;
255 
256  for ( i = 0 ; i < ( sizeof ( attribute_chars ) - 1 ) ; i++ ) {
257  if ( attributes & ( 1 << i ) )
258  *(tmp++) = attribute_chars[i];
259  }
260  *tmp = '\0';
261 
262  return name;
263 }
264 
265 /**
266  * Print list of openers of a given protocol on a given handle
267  *
268  * @v handle EFI handle
269  * @v protocol Protocol GUID
270  */
275  UINTN count;
276  unsigned int i;
277  EFI_STATUS efirc;
278  int rc;
279 
280  /* Sanity check */
281  if ( ( ! handle ) || ( ! protocol ) ) {
282  printf ( "HANDLE %s could not retrieve openers for %s\n",
284  efi_guid_ntoa ( protocol ) );
285  return;
286  }
287 
288  /* Retrieve list of openers */
289  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
290  &count ) ) != 0 ) {
291  rc = -EEFI ( efirc );
292  printf ( "HANDLE %s could not retrieve openers for %s: %s\n",
294  efi_guid_ntoa ( protocol ), strerror ( rc ) );
295  return;
296  }
297 
298  /* Dump list of openers */
299  for ( i = 0 ; i < count ; i++ ) {
300  opener = &openers[i];
301  printf ( "HANDLE %s %s opened %dx (%s)",
303  efi_guid_ntoa ( protocol ), opener->OpenCount,
304  efi_open_attributes_name ( opener->Attributes ) );
305  printf ( " by %s", efi_handle_name ( opener->AgentHandle ) );
306  if ( opener->ControllerHandle == handle ) {
307  printf ( "\n" );
308  } else {
309  printf ( " for %s\n",
310  efi_handle_name ( opener->ControllerHandle ) );
311  }
312  }
313 
314  /* Free list */
315  bs->FreePool ( openers );
316 }
317 
318 /**
319  * Print list of protocol handlers attached to a handle
320  *
321  * @v handle EFI handle
322  */
325  EFI_GUID **protocols;
327  UINTN count;
328  unsigned int i;
329  EFI_STATUS efirc;
330  int rc;
331 
332  /* Sanity check */
333  if ( ! handle ) {
334  printf ( "HANDLE %p could not retrieve protocols\n", handle );
335  return;
336  }
337 
338  /* Retrieve list of protocols */
339  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
340  &count ) ) != 0 ) {
341  rc = -EEFI ( efirc );
342  printf ( "HANDLE %s could not retrieve protocols: %s\n",
343  efi_handle_name ( handle ), strerror ( rc ) );
344  return;
345  }
346 
347  /* Dump list of protocols */
348  for ( i = 0 ; i < count ; i++ ) {
349  protocol = protocols[i];
350  printf ( "HANDLE %s %s supported\n", efi_handle_name ( handle ),
351  efi_guid_ntoa ( protocol ) );
353  }
354 
355  /* Free list */
356  bs->FreePool ( protocols );
357 }
358 
359 /**
360  * Get textual representation of device path
361  *
362  * @v path Device path
363  * @ret text Textual representation of device path, or NULL
364  */
365 const __attribute__ (( pure )) char *
368  static char text[256];
369  size_t len;
370  CHAR16 *wtext;
371 
372  /* Sanity checks */
373  if ( ! path ) {
374  DBG ( "[NULL DevicePath]" );
375  return NULL;
376  }
377 
378  /* If we have no DevicePathToText protocol then use a raw hex string */
379  if ( ! efidpt ) {
380  DBG ( "[No DevicePathToText]" );
381  len = efi_devpath_len ( path );
382  base16_encode ( path, len, text, sizeof ( text ) );
383  return text;
384  }
385 
386  /* Convert path to a textual representation */
387  wtext = efidpt->ConvertDevicePathToText ( path, TRUE, FALSE );
388  if ( ! wtext )
389  return NULL;
390 
391  /* Store path in buffer */
392  snprintf ( text, sizeof ( text ), "%ls", wtext );
393 
394  /* Free path */
395  bs->FreePool ( wtext );
396 
397  return text;
398 }
399 
400 /**
401  * Get driver name
402  *
403  * @v wtf Component name protocol
404  * @ret name Driver name, or NULL
405  */
406 static const char * efi_driver_name ( EFI_COMPONENT_NAME_PROTOCOL *wtf ) {
407  static char name[64];
408  CHAR16 *driver_name;
409  EFI_STATUS efirc;
410 
411  /* Sanity check */
412  if ( ! wtf ) {
413  DBG ( "[NULL ComponentName]" );
414  return NULL;
415  }
416 
417  /* Try "eng" first; if that fails then try the first language */
418  if ( ( ( efirc = wtf->GetDriverName ( wtf, "eng",
419  &driver_name ) ) != 0 ) &&
420  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
421  &driver_name ) ) != 0 ) ) {
422  return NULL;
423  }
424 
425  /* Convert name from CHAR16 to char */
426  snprintf ( name, sizeof ( name ), "%ls", driver_name );
427  return name;
428 }
429 
430 /**
431  * Get driver name
432  *
433  * @v wtf Component name protocol
434  * @ret name Driver name, or NULL
435  */
436 static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) {
437  static char name[64];
438  CHAR16 *driver_name;
439  EFI_STATUS efirc;
440 
441  /* Sanity check */
442  if ( ! wtf ) {
443  DBG ( "[NULL ComponentName2]" );
444  return NULL;
445  }
446 
447  /* Try "en" first; if that fails then try the first language */
448  if ( ( ( efirc = wtf->GetDriverName ( wtf, "en",
449  &driver_name ) ) != 0 ) &&
450  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
451  &driver_name ) ) != 0 ) ) {
452  return NULL;
453  }
454 
455  /* Convert name from CHAR16 to char */
456  snprintf ( name, sizeof ( name ), "%ls", driver_name );
457  return name;
458 }
459 
460 /**
461  * Get PE/COFF debug filename
462  *
463  * @v loaded Loaded image
464  * @ret name PE/COFF debug filename, or NULL
465  */
466 static const char *
468  static char buf[32];
473  EFI_IMAGE_DATA_DIRECTORY *datadir;
478  uint16_t dos_magic;
479  uint32_t pe_magic;
480  uint16_t opt_magic;
481  uint32_t codeview_magic;
482  size_t max_len;
483  char *name;
484  char *tmp;
485 
486  /* Sanity check */
487  if ( ! loaded ) {
488  DBG ( "[NULL LoadedImage]" );
489  return NULL;
490  }
491 
492  /* Parse DOS header */
493  dos = loaded->ImageBase;
494  if ( ! dos ) {
495  DBG ( "[Missing DOS header]" );
496  return NULL;
497  }
498  dos_magic = dos->e_magic;
499  if ( dos_magic != EFI_IMAGE_DOS_SIGNATURE ) {
500  DBG ( "[Bad DOS signature %#04x]", dos_magic );
501  return NULL;
502  }
503  pe = ( loaded->ImageBase + dos->e_lfanew );
504 
505  /* Parse PE header */
506  pe_magic = pe->Pe32.Signature;
507  if ( pe_magic != EFI_IMAGE_NT_SIGNATURE ) {
508  DBG ( "[Bad PE signature %#08x]", pe_magic );
509  return NULL;
510  }
511  opt32 = &pe->Pe32.OptionalHeader;
512  opt64 = &pe->Pe32Plus.OptionalHeader;
513  opt_magic = opt32->Magic;
514  if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ) {
515  datadir = opt32->DataDirectory;
516  } else if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC ) {
517  datadir = opt64->DataDirectory;
518  } else {
519  DBG ( "[Bad optional header signature %#04x]", opt_magic );
520  return NULL;
521  }
522 
523  /* Parse data directory entry */
524  if ( ! datadir[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress ) {
525  DBG ( "[Empty debug directory entry]" );
526  return NULL;
527  }
528  debug = ( loaded->ImageBase +
530 
531  /* Parse debug directory entry */
532  if ( debug->Type != EFI_IMAGE_DEBUG_TYPE_CODEVIEW ) {
533  DBG ( "[Not a CodeView debug directory entry (type %d)]",
534  debug->Type );
535  return NULL;
536  }
537  codeview_nb10 = ( loaded->ImageBase + debug->RVA );
538  codeview_rsds = ( loaded->ImageBase + debug->RVA );
539  codeview_mtoc = ( loaded->ImageBase + debug->RVA );
540  codeview_magic = codeview_nb10->Signature;
541 
542  /* Parse CodeView entry */
543  if ( codeview_magic == CODEVIEW_SIGNATURE_NB10 ) {
544  name = ( ( void * ) ( codeview_nb10 + 1 ) );
545  } else if ( codeview_magic == CODEVIEW_SIGNATURE_RSDS ) {
546  name = ( ( void * ) ( codeview_rsds + 1 ) );
547  } else if ( codeview_magic == CODEVIEW_SIGNATURE_MTOC ) {
548  name = ( ( void * ) ( codeview_mtoc + 1 ) );
549  } else {
550  DBG ( "[Bad CodeView signature %#08x]", codeview_magic );
551  return NULL;
552  }
553 
554  /* Sanity check - avoid scanning endlessly through memory */
555  max_len = EFI_PAGE_SIZE; /* Reasonably sane */
556  if ( strnlen ( name, max_len ) == max_len ) {
557  DBG ( "[Excessively long or invalid CodeView name]" );
558  return NULL;
559  }
560 
561  /* Skip any directory components. We cannot modify this data
562  * or create a temporary buffer, so do not use basename().
563  */
564  while ( ( ( tmp = strchr ( name, '/' ) ) != NULL ) ||
565  ( ( tmp = strchr ( name, '\\' ) ) != NULL ) ) {
566  name = ( tmp + 1 );
567  }
568 
569  /* Copy base name to buffer */
570  snprintf ( buf, sizeof ( buf ), "%s", name );
571 
572  /* Strip file suffix, if present */
573  if ( ( tmp = strrchr ( name, '.' ) ) != NULL )
574  *tmp = '\0';
575 
576  return name;
577 }
578 
579 /**
580  * Get initial loaded image name
581  *
582  * @v loaded Loaded image
583  * @ret name Initial loaded image name, or NULL
584  */
585 static const char *
587 
588  /* Sanity check */
589  if ( ! loaded ) {
590  DBG ( "[NULL LoadedImage]" );
591  return NULL;
592  }
593 
594  return ( ( loaded->ParentHandle == NULL ) ? "DxeCore(?)" : NULL );
595 }
596 
597 /**
598  * Get loaded image name from file path
599  *
600  * @v loaded Loaded image
601  * @ret name Loaded image name, or NULL
602  */
603 static const char *
605 
606  /* Sanity check */
607  if ( ! loaded ) {
608  DBG ( "[NULL LoadedImage]" );
609  return NULL;
610  }
611 
612  return efi_devpath_text ( loaded->FilePath );
613 }
614 
615 /**
616  * Get console input handle name
617  *
618  * @v input Simple text input protocol
619  * @ret name Console input handle name, or NULL
620  */
621 static const char *
623 
624  /* Check for match against ConIn */
625  if ( input == efi_systab->ConIn )
626  return "ConIn";
627 
628  return NULL;
629 }
630 
631 /**
632  * Get console output handle name
633  *
634  * @v output Simple text output protocol
635  * @ret name Console output handle name, or NULL
636  */
637 static const char *
639 
640  /* Check for match against ConOut */
641  if ( output == efi_systab->ConOut )
642  return "ConOut";
643 
644  /* Check for match against StdErr (if different from ConOut) */
645  if ( output == efi_systab->StdErr )
646  return "StdErr";
647 
648  return NULL;
649 }
650 
651 /** An EFI handle name type */
653  /** Protocol */
655  /**
656  * Get name
657  *
658  * @v interface Protocol interface
659  * @ret name Name of handle, or NULL on failure
660  */
661  const char * ( * name ) ( void *interface );
662 };
663 
664 /**
665  * Define an EFI handle name type
666  *
667  * @v protocol Protocol interface
668  * @v name Method to get name
669  * @ret type EFI handle name type
670  */
671 #define EFI_HANDLE_NAME_TYPE( protocol, name ) { \
672  (protocol), \
673  ( const char * ( * ) ( void * ) ) (name), \
674  }
675 
676 /** EFI handle name types */
678  /* Device path */
681  /* Driver name (for driver image handles) */
684  /* Driver name (via obsolete original ComponentName protocol) */
686  efi_driver_name ),
687  /* PE/COFF debug filename (for image handles) */
690  /* Loaded image device path (for image handles) */
693  /* First loaded image name (for the DxeCore image) */
696  /* Handle's loaded image file path (for image handles) */
699  /* Our standard input file handle */
701  efi_conin_name ),
702  /* Our standard output and standard error file handles */
704  efi_conout_name ),
705 };
706 
707 /**
708  * Get name of an EFI handle
709  *
710  * @v handle EFI handle
711  * @ret text Name of handle, or NULL
712  */
713 const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) {
715  struct efi_handle_name_type *type;
716  static char buf[256];
717  size_t used = 0;
718  EFI_GUID **protocols;
719  UINTN count;
720  unsigned int i;
721  void *interface;
722  const char *name;
723  EFI_STATUS efirc;
724 
725  /* Fail immediately for NULL handles */
726  if ( ! handle )
727  return NULL;
728 
729  /* Try each name type in turn */
730  for ( i = 0 ; i < ( sizeof ( efi_handle_name_types ) /
731  sizeof ( efi_handle_name_types[0] ) ) ; i++ ) {
733  DBG2 ( "<%d", i );
734 
735  /* Try to open the applicable protocol */
736  efirc = bs->OpenProtocol ( handle, type->protocol, &interface,
739  if ( efirc != 0 ) {
740  DBG2 ( ">" );
741  continue;
742  }
743 
744  /* Try to get name from this protocol */
745  DBG2 ( "-" );
746  name = type->name ( interface );
747  DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );
748 
749  /* Close protocol */
750  bs->CloseProtocol ( handle, type->protocol,
752  DBG2 ( ">" );
753 
754  /* Use this name, if possible */
755  if ( name && name[0] )
756  return name;
757  }
758 
759  /* If no name is found, then use the raw handle value and a
760  * list of installed protocols.
761  */
762  used = ssnprintf ( buf, sizeof ( buf ), "UNKNOWN<%p", handle );
763  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
764  &count ) ) == 0 ) {
765  for ( i = 0 ; i < count ; i++ ) {
766  used += ssnprintf ( ( buf + used ),
767  ( sizeof ( buf ) - used ), ",%s",
768  efi_guid_ntoa ( protocols[i] ) );
769  }
770  bs->FreePool ( protocols );
771  }
772  used += ssnprintf ( ( buf + used ), ( sizeof ( buf ) - used ), ">" );
773  return buf;
774 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:212
static EFI_GUID efi_iscsi4_dxe_guid
Iscsi4Dxe module GUID.
Definition: efi_debug.c:51
#define __attribute__(x)
Definition: compiler.h:10
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2000
#define EFI_PAGE_SIZE
Definition: UefiBaseType.h:191
EFI_GUID efi_ip4_config_protocol_guid
IPv4 configuration protocol GUID.
Definition: efi_guid.c:168
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
unsigned short uint16_t
Definition: stdint.h:11
EFI_GUID efi_dhcp4_service_binding_protocol_guid
DHCPv4 service binding protocol GUID.
Definition: efi_guid.c:140
EFI Oprn Protocol Information Entry.
Definition: UefiSpec.h:1349
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
EFI_GUID efi_hii_font_protocol_guid
HII font protocol GUID.
Definition: efi_guid.c:160
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:159
int printf(const char *fmt,...)
Write a formatted string to the console.
Definition: vsprintf.c:464
void dbg_efi_openers(EFI_HANDLE handle, EFI_GUID *protocol)
Print list of openers of a given protocol on a given handle.
Definition: efi_debug.c:271
EFI_GUID efi_tcg_protocol_guid
TCG protocol GUID.
Definition: efi_guid.c:256
EFI_GUID efi_block_io2_protocol_guid
Block I/O version 2 protocol GUID.
Definition: efi_guid.c:112
EFI_HANDLE ControllerHandle
Definition: UefiSpec.h:1351
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
EFI_HANDLE AgentHandle
Definition: UefiSpec.h:1350
const char * name
Name.
Definition: efi_debug.c:67
static const char * efi_loaded_image_filepath_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get loaded image name from file path.
Definition: efi_debug.c:604
char * strrchr(const char *src, int character)
Find rightmost character within a string.
Definition: string.c:274
128 bit buffer containing a unique identifier value.
Definition: Base.h:263
static void size_t size_t max_len
Definition: entropy.h:153
Error codes.
A universally unique ID.
Definition: uuid.h:15
static const char * efi_conin_name(EFI_SIMPLE_TEXT_INPUT_PROTOCOL *input)
Get console input handle name.
Definition: efi_debug.c:622
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1439
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
Definition: efi_guid.c:216
The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
Definition: SimpleTextIn.h:124
EFI_GUID efi_arp_service_binding_protocol_guid
ARP service binding protocol GUID.
Definition: efi_guid.c:104
EFI_GUID efi_usb_hc_protocol_guid
USB host controller protocol GUID.
Definition: efi_guid.c:288
static const char * efi_driver_name(EFI_COMPONENT_NAME_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:406
EFI_GUID efi_usb2_hc_protocol_guid
USB2 host controller protocol GUID.
Definition: efi_guid.c:292
EFI_GUID efi_graphics_output_protocol_guid
Graphics output protocol GUID.
Definition: efi_guid.c:152
uint8_t type
Type.
Definition: ena.h:16
printf() and friends
EFI_GUID efi_simple_pointer_protocol_guid
Simple pointer protocol GUID.
Definition: efi_guid.c:240
EFI_GUID efi_loaded_image_device_path_protocol_guid
Loaded image device path protocol GUID.
Definition: efi_guid.c:188
EFI_GUID efi_dhcp4_protocol_guid
DHCPv4 protocol GUID.
Definition: efi_guid.c:136
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
Definition: efi_guid.c:236
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:184
EFI_COMPONENT_NAME_GET_DRIVER_NAME GetDriverName
EFI_DEVICE_PATH_PROTOCOL * FilePath
A pointer to the file path portion specific to DeviceHandle that the EFI Image was loaded from.
Definition: LoadedImage.h:62
Retrieve the next handle fron a RegisterProtocolNotify() event.
Definition: UefiSpec.h:1443
Union of PE32, PE32+, and TE headers.
Definition: PeImage.h:745
Definition: bnxt_hsi.h:68
EFI_GUID efi_tcp4_protocol_guid
TCPv4 protocol GUID.
Definition: efi_guid.c:260
Universally unique IDs.
size_t efi_devpath_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_utils.c:59
Definition: PeImage.h:625
#define EFI_HANDLE_NAME_TYPE(protocol, name)
Define an EFI handle name type.
Definition: efi_debug.c:671
unsigned short CHAR16
Definition: ProcessorBind.h:59
#define EFI_IMAGE_DOS_SIGNATURE
Definition: PeImage.h:49
Optional Header Standard Fields for PE32+.
Definition: PeImage.h:199
EFI_GUID efi_pxe_base_code_protocol_guid
PXE base code protocol GUID.
Definition: efi_guid.c:224
Optional Header Standard Fields for PE32.
Definition: PeImage.h:148
VOID * ImageBase
The base address at which the image was loaded.
Definition: LoadedImage.h:75
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:51
EFI_GUID efi_managed_network_service_binding_protocol_guid
Managed network service binding protocol GUID.
Definition: efi_guid.c:196
static struct efi_well_known_guid efi_well_known_guids[]
Well-known GUIDs.
Definition: efi_debug.c:71
EFI Component Name Protocol as defined in the EFI 1.1 specification.
EFI_IMAGE_NT_HEADERS32 Pe32
Definition: PeImage.h:746
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:1906
static const char * efi_driver_name2(EFI_COMPONENT_NAME2_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:436
EFI_GUID efi_disk_io_protocol_guid
Disk I/O protocol GUID.
Definition: efi_guid.c:144
EFI_GUID efi_hii_config_access_protocol_guid
HII configuration access protocol GUID.
Definition: efi_guid.c:156
EFI utilities.
EFI_GUID efi_console_control_protocol_guid
Console control protocol GUID.
Definition: efi_guid.c:128
EFI_GUID efi_simple_text_output_protocol_guid
Simple text output protocol GUID.
Definition: efi_guid.c:252
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
EFI_GUID efi_mtftp4_service_binding_protocol_guid
MTFTPv4 service binding protocol GUID.
Definition: efi_guid.c:204
EFI_GUID * guid
GUID.
Definition: efi_debug.c:65
static void uuid_mangle(union uuid *uuid)
Change UUID endianness.
Definition: uuid.h:43
int ssnprintf(char *buf, ssize_t ssize, const char *fmt,...)
Version of vsnprintf() that accepts a signed buffer size.
Definition: vsprintf.c:420
static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL * efidpt
Device path to text protocol.
Definition: efi_debug.c:47
#define EFI_IMAGE_NT_SIGNATURE
Definition: PeImage.h:52
EFI_GUID efi_uga_draw_protocol_guid
UGA draw protocol GUID.
Definition: efi_guid.c:280
void * memcpy(void *dest, const void *src, size_t len) __nonnull
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
Definition: PeImage.h:656
UINT32 Type
Definition: PeImage.h:613
Can be used on any image handle to obtain information about the loaded image.
Definition: LoadedImage.h:51
This protocol converts device paths and device nodes to text.
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with ConsoleOutHandle.
Definition: UefiSpec.h:1982
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL as defined in UEFI 2.0.
#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG
Definition: PeImage.h:129
EFI_GUID efi_tcp4_service_binding_protocol_guid
TCPv4 service binding protocol GUID.
Definition: efi_guid.c:264
EFI_GUID efi_tree_protocol_guid
TrEE protocol GUID.
Definition: efi_guid.c:268
An object interface.
Definition: interface.h:109
#define CODEVIEW_SIGNATURE_RSDS
Debug Data Structure defined in Microsoft C++.
Definition: PeImage.h:638
EFI_GUID efi_simple_file_system_protocol_guid
Simple file system protocol GUID.
Definition: efi_guid.c:232
EFI_GUID efi_ip4_service_binding_protocol_guid
IPv4 service binding protocol GUID.
Definition: efi_guid.c:172
EFI_GUID efi_acpi_table_protocol_guid
ACPI table protocol GUID.
Definition: efi_guid.c:92
UEFI Component Name 2 Protocol as defined in the UEFI 2.1 specification.
EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName
UINT32 OpenCount
Definition: UefiSpec.h:1353
UINT32 Attributes
Definition: UefiSpec.h:1352
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is associated with ConsoleInHandle.
Definition: UefiSpec.h:1973
const char * efi_locate_search_type_name(EFI_LOCATE_SEARCH_TYPE search_type)
Name locate search type.
Definition: efi_debug.c:225
EFI_GUID efi_vlan_config_protocol_guid
VLAN configuration protocol GUID.
Definition: efi_guid.c:300
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 struct efi_handle_name_type efi_handle_name_types[]
EFI handle name types.
Definition: efi_debug.c:677
CHAR8 * SupportedLanguages
A Null-terminated ASCII string that contains one or more ISO 639-2 language codes.
UINT16 Magic
Standard fields.
Definition: PeImage.h:152
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI_GUID efi_usb_io_protocol_guid
USB I/O protocol GUID.
Definition: efi_guid.c:296
EFI_GUID efi_load_file2_protocol_guid
Load file 2 protocol GUID.
Definition: efi_guid.c:180
EFI Boot Services Table.
Definition: UefiSpec.h:1836
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:33
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:256
A well-known GUID.
Definition: efi_debug.c:63
EFI_GUID efi_serial_io_protocol_guid
Serial I/O protocol GUID.
Definition: efi_guid.c:228
UINT32 Signature
"NB10"
Definition: PeImage.h:626
#define CODEVIEW_SIGNATURE_MTOC
Debug Data Structure defined by Apple Mach-O to Coff utility.
Definition: PeImage.h:655
static EFI_GUID efi_vlan_config_dxe_guid
VlanConfigDxe module GUID.
Definition: efi_debug.c:57
uint8_t * tmp
Definition: entropy.h:156
Header Data Directories.
Definition: PeImage.h:115
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition: PeImage.h:235
UINT64 UINTN
Unsigned value of native width.
Definition: ProcessorBind.h:71
static const char * efi_pecoff_debug_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get PE/COFF debug filename.
Definition: efi_debug.c:467
size_t strnlen(const char *src, size_t max)
Get length of string.
Definition: string.c:240
EFI image format for PE32, PE32+ and TE.
EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader
Definition: PeImage.h:258
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:132
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:124
Definition: PeImage.h:639
unsigned int uint32_t
Definition: stdint.h:12
EFI_GUID efi_simple_text_input_ex_protocol_guid
Simple text input extension protocol GUID.
Definition: efi_guid.c:248
void dbg_efi_protocols(EFI_HANDLE handle)
Print list of protocol handlers attached to a handle.
Definition: efi_debug.c:323
const char * uuid_ntoa(const union uuid *uuid)
Convert UUID to printable string.
Definition: uuid.c:43
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1855
Debug Directory Format.
Definition: PeImage.h:608
EFI_GUID efi_simple_text_input_protocol_guid
Simple text input protocol GUID.
Definition: efi_guid.c:244
#define TRUE
Definition: tlan.h:46
EFI_GUID efi_bus_specific_driver_override_protocol_guid
Bus specific driver override protocol GUID.
Definition: efi_guid.c:116
EFI_GUID efi_mtftp4_protocol_guid
MTFTPv4 protocol GUID.
Definition: efi_guid.c:200
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:1907
#define CODEVIEW_SIGNATURE_NB10
Debug Data Structure defined in Microsoft C++.
Definition: PeImage.h:624
EFI API.
uint64_t guid
GUID.
Definition: edd.h:30
static const char * efi_conout_name(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *output)
Get console output handle name.
Definition: efi_debug.c:638
EFI_GUID efi_nii_protocol_guid
Network interface identifier protocol GUID (old version)
Definition: efi_guid.c:208
EFI_GUID efi_absolute_pointer_protocol_guid
Absolute pointer protocol GUID.
Definition: efi_guid.c:88
const char * efi_guid_ntoa(EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
EFI_GUID efi_arp_protocol_guid
ARP protocol GUID.
Definition: efi_guid.c:100
UINT32 e_lfanew
File address of new exe header.
Definition: PeImage.h:77
EFI_GUID efi_apple_net_boot_protocol_guid
Apple NetBoot protocol GUID.
Definition: efi_guid.c:96
static const char * efi_first_loaded_image_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get initial loaded image name.
Definition: efi_debug.c:586
UINT16 e_magic
Magic number.
Definition: PeImage.h:59
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:1912
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition: PeImage.h:185
uint32_t len
Length.
Definition: ena.h:14
CHAR8 * SupportedLanguages
A Null-terminated ASCII string array that contains one or more supported language codes.
EFI_GUID efi_block_io_protocol_guid
Block I/O protocol GUID.
Definition: efi_guid.c:108
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_GUID * protocol
Protocol.
Definition: efi_debug.c:654
uint16_t count
Number of entries.
Definition: ena.h:22
PE images can start with an optional DOS header, so if an image is run under DOS it can print an erro...
Definition: PeImage.h:58
EFI_GUID efi_pci_root_bridge_io_protocol_guid
PCI root bridge I/O protocol GUID.
Definition: efi_guid.c:220
union @17 u
An EFI handle name type.
Definition: efi_debug.c:652
const char * efi_open_attributes_name(unsigned int attributes)
Name protocol open attributes.
Definition: efi_debug.c:250
#define FALSE
Definition: tlan.h:45
EFI_GUID efi_ip4_protocol_guid
IPv4 protocol GUID.
Definition: efi_guid.c:164
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
Retrieve the set of handles from the handle database that support a specified protocol.
Definition: UefiSpec.h:1448
EFI_IMAGE_NT_HEADERS64 Pe32Plus
Definition: PeImage.h:747
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1905
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition: efi_guid.c:120
uint16_t protocol
Protocol ID.
Definition: stp.h:18
EFI_LOCATE_SEARCH_TYPE
Enumeration of EFI Locate Search Types.
Definition: UefiSpec.h:1435
#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: PeImage.h:143
EFI_GUID efi_unicode_collation_protocol_guid
Unicode collation protocol GUID.
Definition: efi_guid.c:284
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
UINT32 RVA
The address of the debug data when loaded, relative to the image base.
Definition: PeImage.h:615
EFI_GUID efi_load_file_protocol_guid
Load file protocol GUID.
Definition: efi_guid.c:176
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: PeImage.h:194
EFI_GUID efi_udp4_protocol_guid
UDPv4 protocol GUID.
Definition: efi_guid.c:272
EFI_GUID efi_udp4_service_binding_protocol_guid
UDPv4 service binding protocol GUID.
Definition: efi_guid.c:276
EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText
uint16_t handle
Handle.
Definition: smbios.h:16
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:113
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:148
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
String functions.
EFI_REQUEST_PROTOCOL(EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt)
EFI_HANDLE ParentHandle
Parent image's image handle.
Definition: LoadedImage.h:54
#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW
The Visual C++ debug information.
Definition: PeImage.h:619
Definition: efi.h:55
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * StdErr
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with StandardErrorHandl...
Definition: UefiSpec.h:1992
EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: PeImage.h:246
#define DBG2(...)
Definition: compiler.h:515
Base16 encoding.
EFI_GUID efi_managed_network_protocol_guid
Managed network protocol GUID.
Definition: efi_guid.c:192