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_path.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 ( CONST 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 opened protocol information
267  *
268  * @v handle EFI handle
269  * @V protocol Protocol GUID
270  * @v opener Opened protocol information
271  */
274 
275  printf ( "HANDLE %s %s opened %dx (%s)", efi_handle_name ( handle ),
276  efi_guid_ntoa ( protocol ), opener->OpenCount,
277  efi_open_attributes_name ( opener->Attributes ) );
278  printf ( " by %s", efi_handle_name ( opener->AgentHandle ) );
279  if ( opener->ControllerHandle == handle ) {
280  printf ( "\n" );
281  } else {
282  printf ( " for %s\n",
283  efi_handle_name ( opener->ControllerHandle ) );
284  }
285 }
286 
287 /**
288  * Print list of openers of a given protocol on a given handle
289  *
290  * @v handle EFI handle
291  * @v protocol Protocol GUID
292  */
296  UINTN count;
297  unsigned int i;
298  EFI_STATUS efirc;
299  int rc;
300 
301  /* Sanity check */
302  if ( ( ! handle ) || ( ! protocol ) ) {
303  printf ( "HANDLE %s could not retrieve openers for %s\n",
305  efi_guid_ntoa ( protocol ) );
306  return;
307  }
308 
309  /* Retrieve list of openers */
310  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
311  &count ) ) != 0 ) {
312  rc = -EEFI ( efirc );
313  printf ( "HANDLE %s could not retrieve openers for %s: %s\n",
315  efi_guid_ntoa ( protocol ), strerror ( rc ) );
316  return;
317  }
318 
319  /* Dump list of openers */
320  for ( i = 0 ; i < count ; i++ )
321  dbg_efi_opener ( handle, protocol, &openers[i] );
322 
323  /* Free list */
324  bs->FreePool ( openers );
325 }
326 
327 /**
328  * Print list of protocol handlers attached to a handle
329  *
330  * @v handle EFI handle
331  */
334  EFI_GUID **protocols;
336  UINTN count;
337  unsigned int i;
338  EFI_STATUS efirc;
339  int rc;
340 
341  /* Sanity check */
342  if ( ! handle ) {
343  printf ( "HANDLE %p could not retrieve protocols\n", handle );
344  return;
345  }
346 
347  /* Retrieve list of protocols */
348  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
349  &count ) ) != 0 ) {
350  rc = -EEFI ( efirc );
351  printf ( "HANDLE %s could not retrieve protocols: %s\n",
352  efi_handle_name ( handle ), strerror ( rc ) );
353  return;
354  }
355 
356  /* Dump list of protocols */
357  for ( i = 0 ; i < count ; i++ ) {
358  protocol = protocols[i];
359  printf ( "HANDLE %s %s supported\n", efi_handle_name ( handle ),
360  efi_guid_ntoa ( protocol ) );
362  }
363 
364  /* Free list */
365  bs->FreePool ( protocols );
366 }
367 
368 /**
369  * Get textual representation of device path
370  *
371  * @v path Device path
372  * @ret text Textual representation of device path, or NULL
373  */
374 const __attribute__ (( pure )) char *
377  static char text[256];
378  size_t len;
379  CHAR16 *wtext;
380 
381  /* Sanity checks */
382  if ( ! path ) {
383  DBG ( "[NULL DevicePath]" );
384  return NULL;
385  }
386 
387  /* If we have no DevicePathToText protocol then use a raw hex string */
388  if ( ! efidpt ) {
389  DBG ( "[No DevicePathToText]" );
390  len = efi_path_len ( path );
391  base16_encode ( path, len, text, sizeof ( text ) );
392  return text;
393  }
394 
395  /* Convert path to a textual representation */
396  wtext = efidpt->ConvertDevicePathToText ( path, TRUE, FALSE );
397  if ( ! wtext )
398  return NULL;
399 
400  /* Store path in buffer */
401  snprintf ( text, sizeof ( text ), "%ls", wtext );
402 
403  /* Free path */
404  bs->FreePool ( wtext );
405 
406  return text;
407 }
408 
409 /**
410  * Get driver name
411  *
412  * @v wtf Component name protocol
413  * @ret name Driver name, or NULL
414  */
415 static const char * efi_driver_name ( EFI_COMPONENT_NAME_PROTOCOL *wtf ) {
416  static char name[64];
417  CHAR16 *driver_name;
418  EFI_STATUS efirc;
419 
420  /* Sanity check */
421  if ( ! wtf ) {
422  DBG ( "[NULL ComponentName]" );
423  return NULL;
424  }
425 
426  /* Try "eng" first; if that fails then try the first language */
427  if ( ( ( efirc = wtf->GetDriverName ( wtf, "eng",
428  &driver_name ) ) != 0 ) &&
429  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
430  &driver_name ) ) != 0 ) ) {
431  return NULL;
432  }
433 
434  /* Convert name from CHAR16 to char */
435  snprintf ( name, sizeof ( name ), "%ls", driver_name );
436  return name;
437 }
438 
439 /**
440  * Get driver name
441  *
442  * @v wtf Component name protocol
443  * @ret name Driver name, or NULL
444  */
445 static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) {
446  static char name[64];
447  CHAR16 *driver_name;
448  EFI_STATUS efirc;
449 
450  /* Sanity check */
451  if ( ! wtf ) {
452  DBG ( "[NULL ComponentName2]" );
453  return NULL;
454  }
455 
456  /* Try "en" first; if that fails then try the first language */
457  if ( ( ( efirc = wtf->GetDriverName ( wtf, "en",
458  &driver_name ) ) != 0 ) &&
459  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
460  &driver_name ) ) != 0 ) ) {
461  return NULL;
462  }
463 
464  /* Convert name from CHAR16 to char */
465  snprintf ( name, sizeof ( name ), "%ls", driver_name );
466  return name;
467 }
468 
469 /**
470  * Get PE/COFF debug filename
471  *
472  * @v loaded Loaded image
473  * @ret name PE/COFF debug filename, or NULL
474  */
475 static const char *
477  static char buf[32];
482  EFI_IMAGE_DATA_DIRECTORY *datadir;
487  uint16_t dos_magic;
488  uint32_t pe_magic;
489  uint16_t opt_magic;
490  uint32_t codeview_magic;
491  size_t max_len;
492  char *name;
493  char *tmp;
494 
495  /* Sanity check */
496  if ( ! loaded ) {
497  DBG ( "[NULL LoadedImage]" );
498  return NULL;
499  }
500 
501  /* Parse DOS header */
502  dos = loaded->ImageBase;
503  if ( ! dos ) {
504  DBG ( "[Missing DOS header]" );
505  return NULL;
506  }
507  dos_magic = dos->e_magic;
508  if ( dos_magic != EFI_IMAGE_DOS_SIGNATURE ) {
509  DBG ( "[Bad DOS signature %#04x]", dos_magic );
510  return NULL;
511  }
512  pe = ( loaded->ImageBase + dos->e_lfanew );
513 
514  /* Parse PE header */
515  pe_magic = pe->Pe32.Signature;
516  if ( pe_magic != EFI_IMAGE_NT_SIGNATURE ) {
517  DBG ( "[Bad PE signature %#08x]", pe_magic );
518  return NULL;
519  }
520  opt32 = &pe->Pe32.OptionalHeader;
521  opt64 = &pe->Pe32Plus.OptionalHeader;
522  opt_magic = opt32->Magic;
523  if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ) {
524  datadir = opt32->DataDirectory;
525  } else if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC ) {
526  datadir = opt64->DataDirectory;
527  } else {
528  DBG ( "[Bad optional header signature %#04x]", opt_magic );
529  return NULL;
530  }
531 
532  /* Parse data directory entry */
533  if ( ! datadir[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress ) {
534  DBG ( "[Empty debug directory entry]" );
535  return NULL;
536  }
537  debug = ( loaded->ImageBase +
539 
540  /* Parse debug directory entry */
541  if ( debug->Type != EFI_IMAGE_DEBUG_TYPE_CODEVIEW ) {
542  DBG ( "[Not a CodeView debug directory entry (type %d)]",
543  debug->Type );
544  return NULL;
545  }
546  codeview_nb10 = ( loaded->ImageBase + debug->RVA );
547  codeview_rsds = ( loaded->ImageBase + debug->RVA );
548  codeview_mtoc = ( loaded->ImageBase + debug->RVA );
549  codeview_magic = codeview_nb10->Signature;
550 
551  /* Parse CodeView entry */
552  if ( codeview_magic == CODEVIEW_SIGNATURE_NB10 ) {
553  name = ( ( void * ) ( codeview_nb10 + 1 ) );
554  } else if ( codeview_magic == CODEVIEW_SIGNATURE_RSDS ) {
555  name = ( ( void * ) ( codeview_rsds + 1 ) );
556  } else if ( codeview_magic == CODEVIEW_SIGNATURE_MTOC ) {
557  name = ( ( void * ) ( codeview_mtoc + 1 ) );
558  } else {
559  DBG ( "[Bad CodeView signature %#08x]", codeview_magic );
560  return NULL;
561  }
562 
563  /* Sanity check - avoid scanning endlessly through memory */
564  max_len = EFI_PAGE_SIZE; /* Reasonably sane */
565  if ( strnlen ( name, max_len ) == max_len ) {
566  DBG ( "[Excessively long or invalid CodeView name]" );
567  return NULL;
568  }
569 
570  /* Skip any directory components. We cannot modify this data
571  * or create a temporary buffer, so do not use basename().
572  */
573  while ( ( ( tmp = strchr ( name, '/' ) ) != NULL ) ||
574  ( ( tmp = strchr ( name, '\\' ) ) != NULL ) ) {
575  name = ( tmp + 1 );
576  }
577 
578  /* Copy base name to buffer */
579  snprintf ( buf, sizeof ( buf ), "%s", name );
580 
581  /* Strip file suffix, if present */
582  if ( ( tmp = strrchr ( name, '.' ) ) != NULL )
583  *tmp = '\0';
584 
585  return name;
586 }
587 
588 /**
589  * Get initial loaded image name
590  *
591  * @v loaded Loaded image
592  * @ret name Initial loaded image name, or NULL
593  */
594 static const char *
596 
597  /* Sanity check */
598  if ( ! loaded ) {
599  DBG ( "[NULL LoadedImage]" );
600  return NULL;
601  }
602 
603  return ( ( loaded->ParentHandle == NULL ) ? "DxeCore(?)" : NULL );
604 }
605 
606 /**
607  * Get loaded image name from file path
608  *
609  * @v loaded Loaded image
610  * @ret name Loaded image name, or NULL
611  */
612 static const char *
614 
615  /* Sanity check */
616  if ( ! loaded ) {
617  DBG ( "[NULL LoadedImage]" );
618  return NULL;
619  }
620 
621  return efi_devpath_text ( loaded->FilePath );
622 }
623 
624 /**
625  * Get console input handle name
626  *
627  * @v input Simple text input protocol
628  * @ret name Console input handle name, or NULL
629  */
630 static const char *
632 
633  /* Check for match against ConIn */
634  if ( input == efi_systab->ConIn )
635  return "ConIn";
636 
637  return NULL;
638 }
639 
640 /**
641  * Get console output handle name
642  *
643  * @v output Simple text output protocol
644  * @ret name Console output handle name, or NULL
645  */
646 static const char *
648 
649  /* Check for match against ConOut */
650  if ( output == efi_systab->ConOut )
651  return "ConOut";
652 
653  /* Check for match against StdErr (if different from ConOut) */
654  if ( output == efi_systab->StdErr )
655  return "StdErr";
656 
657  return NULL;
658 }
659 
660 /** An EFI handle name type */
662  /** Protocol */
664  /**
665  * Get name
666  *
667  * @v interface Protocol interface
668  * @ret name Name of handle, or NULL on failure
669  */
670  const char * ( * name ) ( void *interface );
671 };
672 
673 /**
674  * Define an EFI handle name type
675  *
676  * @v protocol Protocol interface
677  * @v name Method to get name
678  * @ret type EFI handle name type
679  */
680 #define EFI_HANDLE_NAME_TYPE( protocol, name ) { \
681  (protocol), \
682  ( const char * ( * ) ( void * ) ) (name), \
683  }
684 
685 /** EFI handle name types */
687  /* Device path */
690  /* Driver name (for driver image handles) */
693  /* Driver name (via obsolete original ComponentName protocol) */
695  efi_driver_name ),
696  /* PE/COFF debug filename (for image handles) */
699  /* Loaded image device path (for image handles) */
702  /* First loaded image name (for the DxeCore image) */
705  /* Handle's loaded image file path (for image handles) */
708  /* Our standard input file handle */
710  efi_conin_name ),
711  /* Our standard output and standard error file handles */
713  efi_conout_name ),
714 };
715 
716 /**
717  * Get name of an EFI handle
718  *
719  * @v handle EFI handle
720  * @ret text Name of handle, or NULL
721  */
722 const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) {
724  struct efi_handle_name_type *type;
725  static char buf[256];
726  size_t used = 0;
727  EFI_GUID **protocols;
728  UINTN count;
729  unsigned int i;
730  void *interface;
731  const char *name;
732  EFI_STATUS efirc;
733 
734  /* Fail immediately for NULL handles */
735  if ( ! handle )
736  return NULL;
737 
738  /* Try each name type in turn */
739  for ( i = 0 ; i < ( sizeof ( efi_handle_name_types ) /
740  sizeof ( efi_handle_name_types[0] ) ) ; i++ ) {
742  DBG2 ( "<%d", i );
743 
744  /* Try to open the applicable protocol */
745  efirc = bs->OpenProtocol ( handle, type->protocol, &interface,
748  if ( efirc != 0 ) {
749  DBG2 ( ">" );
750  continue;
751  }
752 
753  /* Try to get name from this protocol */
754  DBG2 ( "-" );
755  name = type->name ( interface );
756  DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );
757 
758  /* Close protocol */
759  bs->CloseProtocol ( handle, type->protocol,
761  DBG2 ( ">" );
762 
763  /* Use this name, if possible */
764  if ( name && name[0] )
765  return name;
766  }
767 
768  /* If no name is found, then use the raw handle value and a
769  * list of installed protocols.
770  */
771  used = ssnprintf ( buf, sizeof ( buf ), "UNKNOWN<%p", handle );
772  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
773  &count ) ) == 0 ) {
774  for ( i = 0 ; i < count ; i++ ) {
775  used += ssnprintf ( ( buf + used ),
776  ( sizeof ( buf ) - used ), ",%s",
777  efi_guid_ntoa ( protocols[i] ) );
778  }
779  bs->FreePool ( protocols );
780  }
781  used += ssnprintf ( ( buf + used ), ( sizeof ( buf ) - used ), ">" );
782  return buf;
783 }
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:167
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:293
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:613
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:631
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:415
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_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:67
Definition: PeImage.h:625
#define EFI_HANDLE_NAME_TYPE(protocol, name)
Define an EFI handle name type.
Definition: efi_debug.c:680
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
void dbg_efi_opener(EFI_HANDLE handle, EFI_GUID *protocol, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener)
Print opened protocol information.
Definition: efi_debug.c:272
static const char * efi_driver_name2(EFI_COMPONENT_NAME2_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:445
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_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:124
#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:375
#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:722
static struct efi_handle_name_type efi_handle_name_types[]
EFI handle name types.
Definition: efi_debug.c:686
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
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:192
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
EFI device paths.
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:476
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:332
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:647
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
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:595
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
#define CONST
Datum is read-only.
Definition: Base.h:309
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:35
EFI_GUID * protocol
Protocol.
Definition: efi_debug.c:663
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:661
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