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 /** HttpBootDxe module GUID */
52  0xecebcb00, 0xd9c8, 0x11e4,
53  { 0xaf, 0x3d, 0x8c, 0xdc, 0xd4, 0x26, 0xc9, 0x73 }
54 };
55 
56 /** IScsiDxe module GUID */
58  0x86cddf93, 0x4872, 0x4597,
59  { 0x8a, 0xf9, 0xa3, 0x5a, 0xe4, 0xd3, 0x72, 0x5f }
60 };
61 
62 /** Old IScsi4Dxe module GUID */
64  0x4579b72d, 0x7ec4, 0x4dd4,
65  { 0x84, 0x86, 0x08, 0x3c, 0x86, 0xb1, 0x82, 0xa7 }
66 };
67 
68 /** UefiPxeBcDxe module GUID */
70  0xb95e9fda, 0x26de, 0x48d2,
71  { 0x88, 0x07, 0x1f, 0x91, 0x07, 0xac, 0x5e, 0x3a }
72 };
73 
74 /** VlanConfigDxe module GUID */
76  0xe4f61863, 0xfe2c, 0x4b56,
77  { 0xa8, 0xf4, 0x08, 0x51, 0x9b, 0xc4, 0x39, 0xdf }
78 };
79 
80 /** A well-known GUID */
82  /** GUID */
84  /** Name */
85  const char *name;
86 };
87 
88 /** Well-known GUIDs */
91  "AbsolutePointer" },
93  "AcpiTable" },
95  "AppleNetBoot" },
97  "Arp" },
99  "ArpSb" },
101  "BlockIo" },
103  "BlockIo2" },
105  "BusSpecificDriverOverride" },
107  "ComponentName" },
109  "ComponentName2" },
111  "ConsoleControl" },
113  "DevicePath" },
115  "DriverBinding" },
117  "Dhcp4" },
119  "Dhcp4Sb" },
121  "Dhcp6" },
123  "Dhcp6Sb" },
125  "DiskIo" },
127  "Dns4" },
129  "Dns4Sb" },
131  "Dns6" },
133  "Dns6Sb" },
135  "GraphicsOutput" },
137  "HiiConfigAccess" },
139  "HiiFont" },
141  "HttpBootDxe" },
143  "Http" },
145  "HttpSb" },
147  "Ip4" },
149  "Ip4Config" },
151  "Ip4Config2" },
153  "Ip4Sb" },
155  "Ip6" },
157  "Ip6Config" },
159  "Ip6Sb" },
161  "IScsiDxe" },
163  "IScsi4Dxe" },
165  "LoadFile" },
167  "LoadFile2" },
169  "LoadedImage" },
171  "LoadedImageDevicePath"},
173  "ManagedNetwork" },
175  "ManagedNetworkSb" },
177  "Mtftp4" },
179  "Mtftp4Sb" },
181  "Mtftp6" },
183  "Mtftp6Sb" },
185  "Nii" },
187  "Nii31" },
189  "PciIo" },
191  "PciRootBridgeIo" },
193  "PxeBaseCode" },
195  "SerialIo" },
197  "ShimLock" },
199  "SimpleFileSystem" },
201  "SimpleNetwork" },
203  "SimplePointer" },
205  "SimpleTextInput" },
207  "SimpleTextInputEx" },
209  "SimpleTextOutput" },
211  "Tcg" },
213  "Tcg2" },
215  "Tcp4" },
217  "Tcp4Sb" },
219  "Tcp6" },
221  "Tcp6Sb" },
223  "TrEE" },
225  "Udp4" },
227  "Udp4Sb" },
229  "Udp6" },
231  "Udp6Sb" },
233  "UefiPxeBcDxe" },
235  "UgaDraw" },
237  "UnicodeCollation" },
239  "UsbHc" },
241  "Usb2Hc" },
243  "UsbIo" },
245  "VlanConfig" },
247  "VlanConfigDxe" },
248 };
249 
250 /**
251  * Convert GUID to a printable string
252  *
253  * @v guid GUID
254  * @ret string Printable string
255  */
256 const __attribute__ (( pure )) char * efi_guid_ntoa ( CONST EFI_GUID *guid ) {
257  union {
258  union uuid uuid;
259  EFI_GUID guid;
260  } u;
261  unsigned int i;
262 
263  /* Sanity check */
264  if ( ! guid )
265  return NULL;
266 
267  /* Check for a match against well-known GUIDs */
268  for ( i = 0 ; i < ( sizeof ( efi_well_known_guids ) /
269  sizeof ( efi_well_known_guids[0] ) ) ; i++ ) {
271  sizeof ( *guid ) ) == 0 ) {
272  return efi_well_known_guids[i].name;
273  }
274  }
275 
276  /* Convert GUID to standard endianness */
277  memcpy ( &u.guid, guid, sizeof ( u.guid ) );
278  uuid_mangle ( &u.uuid );
279  return uuid_ntoa ( &u.uuid );
280 }
281 
282 /**
283  * Name locate search type
284  *
285  * @v search_type Locate search type
286  * @ret name Locate search type name
287  */
288 const __attribute__ (( pure )) char *
290  static char buf[16];
291 
292  switch ( search_type ) {
293  case AllHandles : return "AllHandles";
294  case ByRegisterNotify: return "ByRegisterNotify";
295  case ByProtocol: return "ByProtocol";
296  default:
297  snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", search_type );
298  return buf;
299  }
300 }
301 
302 /**
303  * Name protocol open attributes
304  *
305  * @v attributes Protocol open attributes
306  * @ret name Protocol open attributes name
307  *
308  * Returns a (static) string with characters for each set bit
309  * corresponding to BY_(H)ANDLE_PROTOCOL, (G)ET_PROTOCOL,
310  * (T)EST_PROTOCOL, BY_(C)HILD_CONTROLLER, BY_(D)RIVER, and
311  * E(X)CLUSIVE.
312  */
313 const __attribute__ (( pure )) char *
314 efi_open_attributes_name ( unsigned int attributes ) {
315  static char attribute_chars[] = "HGTCDX";
316  static char name[ sizeof ( attribute_chars ) ];
317  char *tmp = name;
318  unsigned int i;
319 
320  for ( i = 0 ; i < ( sizeof ( attribute_chars ) - 1 ) ; i++ ) {
321  if ( attributes & ( 1 << i ) )
322  *(tmp++) = attribute_chars[i];
323  }
324  *tmp = '\0';
325 
326  return name;
327 }
328 
329 /**
330  * Print opened protocol information
331  *
332  * @v handle EFI handle
333  * @V protocol Protocol GUID
334  * @v opener Opened protocol information
335  */
338 
339  printf ( "HANDLE %s %s opened %dx (%s)", efi_handle_name ( handle ),
340  efi_guid_ntoa ( protocol ), opener->OpenCount,
341  efi_open_attributes_name ( opener->Attributes ) );
342  printf ( " by %s", efi_handle_name ( opener->AgentHandle ) );
343  if ( opener->ControllerHandle == handle ) {
344  printf ( "\n" );
345  } else {
346  printf ( " for %s\n",
347  efi_handle_name ( opener->ControllerHandle ) );
348  }
349 }
350 
351 /**
352  * Print list of openers of a given protocol on a given handle
353  *
354  * @v handle EFI handle
355  * @v protocol Protocol GUID
356  */
360  UINTN count;
361  unsigned int i;
362  EFI_STATUS efirc;
363  int rc;
364 
365  /* Sanity check */
366  if ( ( ! handle ) || ( ! protocol ) ) {
367  printf ( "HANDLE %s could not retrieve openers for %s\n",
369  efi_guid_ntoa ( protocol ) );
370  return;
371  }
372 
373  /* Retrieve list of openers */
374  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
375  &count ) ) != 0 ) {
376  rc = -EEFI ( efirc );
377  printf ( "HANDLE %s could not retrieve openers for %s: %s\n",
379  efi_guid_ntoa ( protocol ), strerror ( rc ) );
380  return;
381  }
382 
383  /* Dump list of openers */
384  for ( i = 0 ; i < count ; i++ )
385  dbg_efi_opener ( handle, protocol, &openers[i] );
386 
387  /* Free list */
388  bs->FreePool ( openers );
389 }
390 
391 /**
392  * Print protocol information on a given handle
393  *
394  * @v handle EFI handle
395  * @v protocol Protocol GUID
396  */
399  VOID *interface;
400  EFI_STATUS efirc;
401  int rc;
402 
403  /* Get protocol instance */
404  if ( ( efirc = bs->HandleProtocol ( handle, protocol,
405  &interface ) ) != 0 ) {
406  rc = -EEFI ( efirc );
407  printf ( "HANDLE %s could not identify %s: %s\n",
409  efi_guid_ntoa ( protocol ), strerror ( rc ) );
410  return;
411  }
412  printf ( "HANDLE %s %s at %p\n", efi_handle_name ( handle ),
414 
415  /* Dump list of openers */
417 }
418 
419 /**
420  * Print list of protocol handlers attached to a handle
421  *
422  * @v handle EFI handle
423  */
426  EFI_GUID **protocols;
427  UINTN count;
428  unsigned int i;
429  EFI_STATUS efirc;
430  int rc;
431 
432  /* Sanity check */
433  if ( ! handle ) {
434  printf ( "HANDLE %p could not retrieve protocols\n", handle );
435  return;
436  }
437 
438  /* Retrieve list of protocols */
439  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
440  &count ) ) != 0 ) {
441  rc = -EEFI ( efirc );
442  printf ( "HANDLE %s could not retrieve protocols: %s\n",
443  efi_handle_name ( handle ), strerror ( rc ) );
444  return;
445  }
446 
447  /* Dump list of protocols */
448  for ( i = 0 ; i < count ; i++ ) {
449  dbg_efi_protocol ( handle, protocols[i] );
450  }
451 
452  /* Free list */
453  bs->FreePool ( protocols );
454 }
455 
456 /**
457  * Get textual representation of device path
458  *
459  * @v path Device path
460  * @ret text Textual representation of device path, or NULL
461  */
462 const __attribute__ (( pure )) char *
465  static char text[512];
466  size_t len;
467  CHAR16 *wtext;
468 
469  /* Sanity checks */
470  if ( ! path ) {
471  DBG ( "[NULL DevicePath]" );
472  return NULL;
473  }
474 
475  /* If we have no DevicePathToText protocol then use a raw hex string */
476  if ( ! efidpt ) {
477  DBG ( "[No DevicePathToText]" );
478  len = efi_path_len ( path );
479  base16_encode ( path, len, text, sizeof ( text ) );
480  return text;
481  }
482 
483  /* Convert path to a textual representation */
484  wtext = efidpt->ConvertDevicePathToText ( path, FALSE, FALSE );
485  if ( ! wtext )
486  return NULL;
487 
488  /* Store path in buffer */
489  snprintf ( text, sizeof ( text ), "%ls", wtext );
490 
491  /* Free path */
492  bs->FreePool ( wtext );
493 
494  return text;
495 }
496 
497 /**
498  * Get driver name
499  *
500  * @v wtf Component name protocol
501  * @ret name Driver name, or NULL
502  */
504  static char name[64];
505  CHAR16 *driver_name;
506  EFI_STATUS efirc;
507 
508  /* Sanity check */
509  if ( ! wtf ) {
510  DBG ( "[NULL ComponentName]" );
511  return NULL;
512  }
513 
514  /* Try "eng" first; if that fails then try the first language */
515  if ( ( ( efirc = wtf->GetDriverName ( wtf, "eng",
516  &driver_name ) ) != 0 ) &&
517  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
518  &driver_name ) ) != 0 ) ) {
519  return NULL;
520  }
521 
522  /* Convert name from CHAR16 to char */
523  snprintf ( name, sizeof ( name ), "%ls", driver_name );
524  return name;
525 }
526 
527 /**
528  * Get driver name
529  *
530  * @v wtf Component name protocol
531  * @ret name Driver name, or NULL
532  */
534  static char name[64];
535  CHAR16 *driver_name;
536  EFI_STATUS efirc;
537 
538  /* Sanity check */
539  if ( ! wtf ) {
540  DBG ( "[NULL ComponentName2]" );
541  return NULL;
542  }
543 
544  /* Try "en" first; if that fails then try the first language */
545  if ( ( ( efirc = wtf->GetDriverName ( wtf, "en",
546  &driver_name ) ) != 0 ) &&
547  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
548  &driver_name ) ) != 0 ) ) {
549  return NULL;
550  }
551 
552  /* Convert name from CHAR16 to char */
553  snprintf ( name, sizeof ( name ), "%ls", driver_name );
554  return name;
555 }
556 
557 /**
558  * Get PE/COFF debug filename
559  *
560  * @v loaded Loaded image
561  * @ret name PE/COFF debug filename, or NULL
562  */
563 static const char *
565  static char buf[32];
570  EFI_IMAGE_DATA_DIRECTORY *datadir;
575  uint16_t dos_magic;
576  uint32_t pe_magic;
577  uint16_t opt_magic;
578  uint32_t codeview_magic;
579  size_t max_len;
580  char *name;
581  char *tmp;
582 
583  /* Sanity check */
584  if ( ! loaded ) {
585  DBG ( "[NULL LoadedImage]" );
586  return NULL;
587  }
588 
589  /* Parse DOS header */
590  dos = loaded->ImageBase;
591  if ( ! dos ) {
592  DBG ( "[Missing DOS header]" );
593  return NULL;
594  }
595  dos_magic = dos->e_magic;
596  if ( dos_magic != EFI_IMAGE_DOS_SIGNATURE ) {
597  DBG ( "[Bad DOS signature %#04x]", dos_magic );
598  return NULL;
599  }
600  pe = ( loaded->ImageBase + dos->e_lfanew );
601 
602  /* Parse PE header */
603  pe_magic = pe->Pe32.Signature;
604  if ( pe_magic != EFI_IMAGE_NT_SIGNATURE ) {
605  DBG ( "[Bad PE signature %#08x]", pe_magic );
606  return NULL;
607  }
608  opt32 = &pe->Pe32.OptionalHeader;
609  opt64 = &pe->Pe32Plus.OptionalHeader;
610  opt_magic = opt32->Magic;
611  if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ) {
612  datadir = opt32->DataDirectory;
613  } else if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC ) {
614  datadir = opt64->DataDirectory;
615  } else {
616  DBG ( "[Bad optional header signature %#04x]", opt_magic );
617  return NULL;
618  }
619 
620  /* Parse data directory entry */
621  if ( ! datadir[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress ) {
622  DBG ( "[Empty debug directory entry]" );
623  return NULL;
624  }
625  debug = ( loaded->ImageBase +
627 
628  /* Parse debug directory entry */
629  if ( debug->Type != EFI_IMAGE_DEBUG_TYPE_CODEVIEW ) {
630  DBG ( "[Not a CodeView debug directory entry (type %d)]",
631  debug->Type );
632  return NULL;
633  }
634  codeview_nb10 = ( loaded->ImageBase + debug->RVA );
635  codeview_rsds = ( loaded->ImageBase + debug->RVA );
636  codeview_mtoc = ( loaded->ImageBase + debug->RVA );
637  codeview_magic = codeview_nb10->Signature;
638 
639  /* Parse CodeView entry */
640  if ( codeview_magic == CODEVIEW_SIGNATURE_NB10 ) {
641  name = ( ( void * ) ( codeview_nb10 + 1 ) );
642  } else if ( codeview_magic == CODEVIEW_SIGNATURE_RSDS ) {
643  name = ( ( void * ) ( codeview_rsds + 1 ) );
644  } else if ( codeview_magic == CODEVIEW_SIGNATURE_MTOC ) {
645  name = ( ( void * ) ( codeview_mtoc + 1 ) );
646  } else {
647  DBG ( "[Bad CodeView signature %#08x]", codeview_magic );
648  return NULL;
649  }
650 
651  /* Sanity check - avoid scanning endlessly through memory */
652  max_len = EFI_PAGE_SIZE; /* Reasonably sane */
653  if ( strnlen ( name, max_len ) == max_len ) {
654  DBG ( "[Excessively long or invalid CodeView name]" );
655  return NULL;
656  }
657 
658  /* Skip any directory components. We cannot modify this data
659  * or create a temporary buffer, so do not use basename().
660  */
661  while ( ( ( tmp = strchr ( name, '/' ) ) != NULL ) ||
662  ( ( tmp = strchr ( name, '\\' ) ) != NULL ) ) {
663  name = ( tmp + 1 );
664  }
665 
666  /* Copy base name to buffer */
667  snprintf ( buf, sizeof ( buf ), "%s", name );
668 
669  /* Strip file suffix, if present */
670  if ( ( tmp = strrchr ( buf, '.' ) ) != NULL )
671  *tmp = '\0';
672 
673  return buf;
674 }
675 
676 /**
677  * Get initial loaded image name
678  *
679  * @v loaded Loaded image
680  * @ret name Initial loaded image name, or NULL
681  */
682 static const char *
684 
685  /* Sanity check */
686  if ( ! loaded ) {
687  DBG ( "[NULL LoadedImage]" );
688  return NULL;
689  }
690 
691  return ( ( loaded->ParentHandle == NULL ) ? "DxeCore(?)" : NULL );
692 }
693 
694 /**
695  * Get loaded image name from file path
696  *
697  * @v loaded Loaded image
698  * @ret name Loaded image name, or NULL
699  */
700 static const char *
702 
703  /* Sanity check */
704  if ( ! loaded ) {
705  DBG ( "[NULL LoadedImage]" );
706  return NULL;
707  }
708 
709  return efi_devpath_text ( loaded->FilePath );
710 }
711 
712 /**
713  * Get console input handle name
714  *
715  * @v input Simple text input protocol
716  * @ret name Console input handle name, or NULL
717  */
718 static const char *
720 
721  /* Check for match against ConIn */
722  if ( input == efi_systab->ConIn )
723  return "ConIn";
724 
725  return NULL;
726 }
727 
728 /**
729  * Get console output handle name
730  *
731  * @v output Simple text output protocol
732  * @ret name Console output handle name, or NULL
733  */
734 static const char *
736 
737  /* Check for match against ConOut */
738  if ( output == efi_systab->ConOut )
739  return "ConOut";
740 
741  /* Check for match against StdErr (if different from ConOut) */
742  if ( output == efi_systab->StdErr )
743  return "StdErr";
744 
745  return NULL;
746 }
747 
748 /** An EFI handle name type */
750  /** Protocol */
752  /**
753  * Get name
754  *
755  * @v interface Protocol interface
756  * @ret name Name of handle, or NULL on failure
757  */
758  const char * ( * name ) ( void *interface );
759 };
760 
761 /**
762  * Define an EFI handle name type
763  *
764  * @v protocol Protocol interface
765  * @v name Method to get name
766  * @ret type EFI handle name type
767  */
768 #define EFI_HANDLE_NAME_TYPE( protocol, name ) { \
769  (protocol), \
770  ( const char * ( * ) ( void * ) ) (name), \
771  }
772 
773 /** EFI handle name types */
775  /* Device path */
778  /* Driver name (for driver image handles) */
781  /* Driver name (via obsolete original ComponentName protocol) */
783  efi_driver_name ),
784  /* PE/COFF debug filename (for image handles) */
787  /* Loaded image device path (for image handles) */
790  /* First loaded image name (for the DxeCore image) */
793  /* Handle's loaded image file path (for image handles) */
796  /* Our standard input file handle */
798  efi_conin_name ),
799  /* Our standard output and standard error file handles */
801  efi_conout_name ),
802 };
803 
804 /**
805  * Get name of an EFI handle
806  *
807  * @v handle EFI handle
808  * @ret text Name of handle, or NULL
809  */
810 const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) {
812  struct efi_handle_name_type *type;
813  static char buf[256];
814  size_t used = 0;
815  EFI_GUID **protocols;
816  UINTN count;
817  unsigned int i;
818  void *interface;
819  const char *name;
820  EFI_STATUS efirc;
821 
822  /* Fail immediately for NULL handles */
823  if ( ! handle )
824  return NULL;
825 
826  /* Try each name type in turn */
827  for ( i = 0 ; i < ( sizeof ( efi_handle_name_types ) /
828  sizeof ( efi_handle_name_types[0] ) ) ; i++ ) {
830  DBG2 ( "<%d", i );
831 
832  /* Try to open the applicable protocol */
833  efirc = bs->OpenProtocol ( handle, type->protocol, &interface,
836  if ( efirc != 0 ) {
837  DBG2 ( ">" );
838  continue;
839  }
840 
841  /* Try to get name from this protocol */
842  DBG2 ( "-" );
843  name = type->name ( interface );
844  DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );
845 
846  /* Close protocol */
847  bs->CloseProtocol ( handle, type->protocol,
849  DBG2 ( ">" );
850 
851  /* Use this name, if possible */
852  if ( name && name[0] )
853  return name;
854  }
855 
856  /* If no name is found, then use the raw handle value and a
857  * list of installed protocols.
858  */
859  used = ssnprintf ( buf, sizeof ( buf ), "UNKNOWN<%p", handle );
860  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
861  &count ) ) == 0 ) {
862  for ( i = 0 ; i < count ; i++ ) {
863  used += ssnprintf ( ( buf + used ),
864  ( sizeof ( buf ) - used ), ",%s",
865  efi_guid_ntoa ( protocols[i] ) );
866  }
867  bs->FreePool ( protocols );
868  }
869  used += ssnprintf ( ( buf + used ), ( sizeof ( buf ) - used ), ">" );
870  return buf;
871 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:280
EFI_GUID efi_mtftp6_service_binding_protocol_guid
MTFTPv6 service binding protocol GUID.
Definition: efi_guid.c:272
static EFI_GUID efi_iscsi4_dxe_guid
Old IScsi4Dxe module GUID.
Definition: efi_debug.c:63
#define __attribute__(x)
Definition: compiler.h:10
EFI_BOOT_SERVICES * BootServices
A pointer to the EFI Boot Services Table.
Definition: UefiSpec.h:2098
#define EFI_PAGE_SIZE
Definition: UefiBaseType.h:187
EFI_GUID efi_ip4_config_protocol_guid
IPv4 configuration protocol GUID.
Definition: efi_guid.c:212
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
EFI_GUID efi_dns4_service_binding_protocol_guid
DNSv4 service binding protocol GUID.
Definition: efi_guid.c:172
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:152
EFI Oprn Protocol Information Entry.
Definition: UefiSpec.h:1431
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:196
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:171
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:357
EFI_GUID efi_tcg_protocol_guid
TCG protocol GUID.
Definition: efi_guid.c:328
EFI_GUID efi_block_io2_protocol_guid
Block I/O version 2 protocol GUID.
Definition: efi_guid.c:124
EFI_HANDLE ControllerHandle
Definition: UefiSpec.h:1433
This protocol is used to retrieve user readable names of drivers and controllers managed by UEFI Driv...
EFI_GUID efi_ip6_protocol_guid
IPv6 protocol GUID.
Definition: efi_guid.c:224
EFI_GUID efi_udp6_service_binding_protocol_guid
UDPv6 service binding protocol GUID.
Definition: efi_guid.c:368
EFI_HANDLE AgentHandle
Definition: UefiSpec.h:1432
const char * name
Name.
Definition: efi_debug.c:85
static const char * efi_loaded_image_filepath_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get loaded image name from file path.
Definition: efi_debug.c:701
char * strrchr(const char *src, int character)
Find rightmost character within a string.
Definition: string.c:289
128 bit buffer containing a unique identifier value.
Definition: Base.h:215
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:719
EFI_GUID efi_dhcp6_service_binding_protocol_guid
DHCPv6 service binding protocol GUID.
Definition: efi_guid.c:160
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1521
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
Definition: efi_guid.c:284
The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
Definition: SimpleTextIn.h:119
EFI_GUID efi_arp_service_binding_protocol_guid
ARP service binding protocol GUID.
Definition: efi_guid.c:116
EFI_GUID efi_usb_hc_protocol_guid
USB host controller protocol GUID.
Definition: efi_guid.c:380
static const char * efi_driver_name(EFI_COMPONENT_NAME_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:503
EFI_GUID efi_usb2_hc_protocol_guid
USB2 host controller protocol GUID.
Definition: efi_guid.c:384
EFI_GUID efi_graphics_output_protocol_guid
Graphics output protocol GUID.
Definition: efi_guid.c:188
uint32_t type
Operating system type.
Definition: ena.h:12
static EFI_GUID efi_http_boot_dxe_guid
HttpBootDxe module GUID.
Definition: efi_debug.c:51
printf() and friends
EFI_GUID efi_simple_pointer_protocol_guid
Simple pointer protocol GUID.
Definition: efi_guid.c:312
EFI_GUID efi_loaded_image_device_path_protocol_guid
Loaded image device path protocol GUID.
Definition: efi_guid.c:248
EFI_GUID efi_dhcp4_protocol_guid
DHCPv4 protocol GUID.
Definition: efi_guid.c:148
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
Definition: efi_guid.c:308
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:244
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:56
Retrieve the next handle fron a RegisterProtocolNotify() event.
Definition: UefiSpec.h:1525
Union of PE32, PE32+, and TE headers.
Definition: PeImage.h:805
Definition: bnxt_hsi.h:68
void dbg_efi_protocol(EFI_HANDLE handle, EFI_GUID *protocol)
Print protocol information on a given handle.
Definition: efi_debug.c:397
EFI_GUID efi_tcp4_protocol_guid
TCPv4 protocol GUID.
Definition: efi_guid.c:336
Universally unique IDs.
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:144
Definition: PeImage.h:660
#define EFI_HANDLE_NAME_TYPE(protocol, name)
Define an EFI handle name type.
Definition: efi_debug.c:768
unsigned short CHAR16
#define EFI_IMAGE_DOS_SIGNATURE
Definition: PeImage.h:50
Optional Header Standard Fields for PE32+.
Definition: PeImage.h:201
EFI_GUID efi_pxe_base_code_protocol_guid
PXE base code protocol GUID.
Definition: efi_guid.c:292
EFI_GUID efi_ip4_config2_protocol_guid
IPv4 configuration 2 protocol GUID.
Definition: efi_guid.c:216
Optional Header Standard Fields for PE32.
Definition: PeImage.h:150
VOID * ImageBase
The base address at which the image was loaded.
Definition: LoadedImage.h:69
This protocol can be used on any device handle to obtain generic path/location information concerning...
Definition: DevicePath.h:45
EFI_GUID efi_managed_network_service_binding_protocol_guid
Managed network service binding protocol GUID.
Definition: efi_guid.c:256
EFI_GUID efi_ip6_service_binding_protocol_guid
IPv6 service binding protocol GUID.
Definition: efi_guid.c:232
static struct efi_well_known_guid efi_well_known_guids[]
Well-known GUIDs.
Definition: efi_debug.c:89
EFI Component Name Protocol as defined in the EFI 1.1 specification.
EFI_IMAGE_NT_HEADERS32 Pe32
Definition: PeImage.h:806
EFI_CLOSE_PROTOCOL CloseProtocol
Definition: UefiSpec.h:2000
void dbg_efi_opener(EFI_HANDLE handle, EFI_GUID *protocol, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener)
Print opened protocol information.
Definition: efi_debug.c:336
static const char * efi_driver_name2(EFI_COMPONENT_NAME2_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:533
EFI_GUID efi_disk_io_protocol_guid
Disk I/O protocol GUID.
Definition: efi_guid.c:164
EFI_GUID efi_hii_config_access_protocol_guid
HII configuration access protocol GUID.
Definition: efi_guid.c:192
EFI_GUID efi_console_control_protocol_guid
Console control protocol GUID.
Definition: efi_guid.c:140
EFI_GUID efi_simple_text_output_protocol_guid
Simple text output protocol GUID.
Definition: efi_guid.c:324
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:264
EFI_GUID * guid
GUID.
Definition: efi_debug.c:83
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
unsigned long tmp
Definition: linux_pci.h:63
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:53
EFI_GUID efi_uga_draw_protocol_guid
UGA draw protocol GUID.
Definition: efi_guid.c:372
void * memcpy(void *dest, const void *src, size_t len) __nonnull
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
Definition: PeImage.h:690
Can be used on any image handle to obtain information about the loaded image.
Definition: LoadedImage.h:45
EFI_GUID efi_tcp6_protocol_guid
TCPv6 protocol GUID.
Definition: efi_guid.c:344
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:2079
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL as defined in UEFI 2.0.
#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG
Definition: PeImage.h:131
EFI_GUID efi_tcp4_service_binding_protocol_guid
TCPv4 service binding protocol GUID.
Definition: efi_guid.c:340
EFI_GUID efi_tree_protocol_guid
TrEE protocol GUID.
Definition: efi_guid.c:352
char wtf[42]
Authenticator response string.
Definition: mschapv2.h:18
An object interface.
Definition: interface.h:124
#define CODEVIEW_SIGNATURE_RSDS
Debug Data Structure defined in Microsoft C++.
Definition: PeImage.h:673
EFI_GUID efi_dhcp6_protocol_guid
DHCPv6 protocol GUID.
Definition: efi_guid.c:156
EFI_GUID efi_simple_file_system_protocol_guid
Simple file system protocol GUID.
Definition: efi_guid.c:304
EFI_GUID efi_ip4_service_binding_protocol_guid
IPv4 service binding protocol GUID.
Definition: efi_guid.c:220
EFI_GUID efi_acpi_table_protocol_guid
ACPI table protocol GUID.
Definition: efi_guid.c:104
UEFI Component Name 2 Protocol as defined in the UEFI 2.1 specification.
UINT32 OpenCount
Definition: UefiSpec.h:1435
static EFI_GUID efi_iscsi_dxe_guid
IScsiDxe module GUID.
Definition: efi_debug.c:57
UINT32 Attributes
Definition: UefiSpec.h:1434
uint16_t count
Number of entries.
Definition: ena.h:22
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is associated with ConsoleInHandle.
Definition: UefiSpec.h:2068
const char * efi_locate_search_type_name(EFI_LOCATE_SEARCH_TYPE search_type)
Name locate search type.
Definition: efi_debug.c:289
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1967
EFI_GUID efi_vlan_config_protocol_guid
VLAN configuration protocol GUID.
Definition: efi_guid.c:392
EFI_GUID efi_ip6_config_protocol_guid
IPv6 configuration protocol GUID.
Definition: efi_guid.c:228
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:463
uint64_t debug
Debug area base address.
Definition: ena.h:14
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1354
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:810
static struct efi_handle_name_type efi_handle_name_types[]
EFI handle name types.
Definition: efi_debug.c:774
UINT16 Magic
Standard fields.
Definition: PeImage.h:154
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_debug.c:256
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:388
EFI_GUID efi_load_file2_protocol_guid
Load file 2 protocol GUID.
Definition: efi_guid.c:240
EFI Boot Services Table.
Definition: UefiSpec.h:1930
EFI_HANDLE efi_image_handle
Image handle passed to entry point.
Definition: efi_init.c:34
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:271
A well-known GUID.
Definition: efi_debug.c:81
EFI_GUID efi_serial_io_protocol_guid
Serial I/O protocol GUID.
Definition: efi_guid.c:296
UINT32 Signature
"NB10"
Definition: PeImage.h:661
#define CODEVIEW_SIGNATURE_MTOC
Debug Data Structure defined by Apple Mach-O to Coff utility.
Definition: PeImage.h:689
static EFI_GUID efi_vlan_config_dxe_guid
VlanConfigDxe module GUID.
Definition: efi_debug.c:75
Header Data Directories.
Definition: PeImage.h:117
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition: PeImage.h:237
EFI device paths.
UINT64 UINTN
Unsigned value of native width.
static const char * efi_pecoff_debug_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get PE/COFF debug filename.
Definition: efi_debug.c:564
size_t strnlen(const char *src, size_t max)
Get length of string.
Definition: string.c:255
EFI image format for PE32, PE32+ and TE.
EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader
Definition: PeImage.h:259
EFI_GUID efi_udp6_protocol_guid
UDPv6 protocol GUID.
Definition: efi_guid.c:364
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:144
static EFI_GUID efi_uefi_pxe_bc_dxe_guid
UefiPxeBcDxe module GUID.
Definition: efi_debug.c:69
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:136
#define VOID
Undeclared type.
Definition: Base.h:271
Definition: PeImage.h:674
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:320
void dbg_efi_protocols(EFI_HANDLE handle)
Print list of protocol handlers attached to a handle.
Definition: efi_debug.c:424
const char * uuid_ntoa(const union uuid *uuid)
Convert UUID to printable string.
Definition: uuid.c:45
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
Debug Directory Format.
Definition: PeImage.h:642
EFI_GUID efi_simple_text_input_protocol_guid
Simple text input protocol GUID.
Definition: efi_guid.c:316
EFI_GUID efi_bus_specific_driver_override_protocol_guid
Bus specific driver override protocol GUID.
Definition: efi_guid.c:128
EFI_GUID efi_mtftp4_protocol_guid
MTFTPv4 protocol GUID.
Definition: efi_guid.c:260
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:2001
#define CODEVIEW_SIGNATURE_NB10
Debug Data Structure defined in Microsoft C++.
Definition: PeImage.h:659
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:735
EFI_GUID efi_tcp6_service_binding_protocol_guid
TCPv6 service binding protocol GUID.
Definition: efi_guid.c:348
EFI_GUID efi_nii_protocol_guid
Network interface identifier protocol GUID (old version)
Definition: efi_guid.c:276
EFI_GUID efi_dns4_protocol_guid
DNSv4 protocol GUID.
Definition: efi_guid.c:168
EFI_GUID efi_absolute_pointer_protocol_guid
Absolute pointer protocol GUID.
Definition: efi_guid.c:100
EFI_GUID efi_arp_protocol_guid
ARP protocol GUID.
Definition: efi_guid.c:112
UINT32 e_lfanew
File address of new exe header.
Definition: PeImage.h:78
EFI_GUID efi_apple_net_boot_protocol_guid
Apple NetBoot protocol GUID.
Definition: efi_guid.c:108
static const char * efi_first_loaded_image_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get initial loaded image name.
Definition: efi_debug.c:683
UINT16 e_magic
Magic number.
Definition: PeImage.h:60
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:2006
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition: PeImage.h:187
EFI_GUID efi_block_io_protocol_guid
Block I/O protocol GUID.
Definition: efi_guid.c:120
#define CONST
Datum is read-only.
Definition: Base.h:261
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_GUID * protocol
Protocol.
Definition: efi_debug.c:751
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:59
EFI_GUID efi_pci_root_bridge_io_protocol_guid
PCI root bridge I/O protocol GUID.
Definition: efi_guid.c:288
union @17 u
An EFI handle name type.
Definition: efi_debug.c:749
const char * efi_open_attributes_name(unsigned int attributes)
Name protocol open attributes.
Definition: efi_debug.c:314
EFI_GUID efi_http_protocol_guid
HTTP protocol GUID.
Definition: efi_guid.c:200
#define FALSE
Definition: tlan.h:45
EFI_GUID efi_ip4_protocol_guid
IPv4 protocol GUID.
Definition: efi_guid.c:208
EFI_GUID efi_shim_lock_protocol_guid
Shim lock protocol GUID.
Definition: efi_guid.c:300
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
EFI_GUID efi_http_service_binding_protocol_guid
HTTP service binding protocol GUID.
Definition: efi_guid.c:204
Retrieve the set of handles from the handle database that support a specified protocol.
Definition: UefiSpec.h:1530
EFI_GUID efi_dns6_service_binding_protocol_guid
DNSv6 service binding protocol GUID.
Definition: efi_guid.c:180
EFI_IMAGE_NT_HEADERS64 Pe32Plus
Definition: PeImage.h:807
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1999
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition: efi_guid.c:132
EFI_GUID efi_dns6_protocol_guid
DNSv6 protocol GUID.
Definition: efi_guid.c:176
uint16_t protocol
Protocol ID.
Definition: stp.h:18
EFI_LOCATE_SEARCH_TYPE
Enumeration of EFI Locate Search Types.
Definition: UefiSpec.h:1517
#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
Definition: PeImage.h:145
EFI_GUID efi_unicode_collation_protocol_guid
Unicode collation protocol GUID.
Definition: efi_guid.c:376
EFI_GUID efi_mtftp6_protocol_guid
MTFTPv6 protocol GUID.
Definition: efi_guid.c:268
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
EFI_GUID efi_tcg2_protocol_guid
TCG2 protocol GUID.
Definition: efi_guid.c:332
EFI_GUID efi_load_file_protocol_guid
Load file protocol GUID.
Definition: efi_guid.c:236
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: PeImage.h:196
EFI_GUID efi_udp4_protocol_guid
UDPv4 protocol GUID.
Definition: efi_guid.c:356
EFI_GUID efi_udp4_service_binding_protocol_guid
UDPv4 service binding protocol GUID.
Definition: efi_guid.c:360
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:114
uint32_t len
Length.
Definition: ena.h:14
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:184
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
String functions.
EFI_REQUEST_PROTOCOL(EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt)
EFI_HANDLE ParentHandle
Parent image's image handle.
Definition: LoadedImage.h:48
#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW
The Visual C++ debug information.
Definition: PeImage.h:653
Definition: efi.h:59
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * StdErr
A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface that is associated with StandardErrorHandl...
Definition: UefiSpec.h:2090
EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: PeImage.h:247
#define DBG2(...)
Definition: compiler.h:515
Base16 encoding.
EFI_GUID efi_managed_network_protocol_guid
Managed network protocol GUID.
Definition: efi_guid.c:252