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  "Tcp4" },
215  "Tcp4Sb" },
217  "Tcp6" },
219  "Tcp6Sb" },
221  "TrEE" },
223  "Udp4" },
225  "Udp4Sb" },
227  "Udp6" },
229  "Udp6Sb" },
231  "UefiPxeBcDxe" },
233  "UgaDraw" },
235  "UnicodeCollation" },
237  "UsbHc" },
239  "Usb2Hc" },
241  "UsbIo" },
243  "VlanConfig" },
245  "VlanConfigDxe" },
246 };
247 
248 /**
249  * Convert GUID to a printable string
250  *
251  * @v guid GUID
252  * @ret string Printable string
253  */
254 const __attribute__ (( pure )) char * efi_guid_ntoa ( CONST EFI_GUID *guid ) {
255  union {
256  union uuid uuid;
257  EFI_GUID guid;
258  } u;
259  unsigned int i;
260 
261  /* Sanity check */
262  if ( ! guid )
263  return NULL;
264 
265  /* Check for a match against well-known GUIDs */
266  for ( i = 0 ; i < ( sizeof ( efi_well_known_guids ) /
267  sizeof ( efi_well_known_guids[0] ) ) ; i++ ) {
269  sizeof ( *guid ) ) == 0 ) {
270  return efi_well_known_guids[i].name;
271  }
272  }
273 
274  /* Convert GUID to standard endianness */
275  memcpy ( &u.guid, guid, sizeof ( u.guid ) );
276  uuid_mangle ( &u.uuid );
277  return uuid_ntoa ( &u.uuid );
278 }
279 
280 /**
281  * Name locate search type
282  *
283  * @v search_type Locate search type
284  * @ret name Locate search type name
285  */
286 const __attribute__ (( pure )) char *
288  static char buf[16];
289 
290  switch ( search_type ) {
291  case AllHandles : return "AllHandles";
292  case ByRegisterNotify: return "ByRegisterNotify";
293  case ByProtocol: return "ByProtocol";
294  default:
295  snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", search_type );
296  return buf;
297  }
298 }
299 
300 /**
301  * Name protocol open attributes
302  *
303  * @v attributes Protocol open attributes
304  * @ret name Protocol open attributes name
305  *
306  * Returns a (static) string with characters for each set bit
307  * corresponding to BY_(H)ANDLE_PROTOCOL, (G)ET_PROTOCOL,
308  * (T)EST_PROTOCOL, BY_(C)HILD_CONTROLLER, BY_(D)RIVER, and
309  * E(X)CLUSIVE.
310  */
311 const __attribute__ (( pure )) char *
312 efi_open_attributes_name ( unsigned int attributes ) {
313  static char attribute_chars[] = "HGTCDX";
314  static char name[ sizeof ( attribute_chars ) ];
315  char *tmp = name;
316  unsigned int i;
317 
318  for ( i = 0 ; i < ( sizeof ( attribute_chars ) - 1 ) ; i++ ) {
319  if ( attributes & ( 1 << i ) )
320  *(tmp++) = attribute_chars[i];
321  }
322  *tmp = '\0';
323 
324  return name;
325 }
326 
327 /**
328  * Print opened protocol information
329  *
330  * @v handle EFI handle
331  * @V protocol Protocol GUID
332  * @v opener Opened protocol information
333  */
336 
337  printf ( "HANDLE %s %s opened %dx (%s)", efi_handle_name ( handle ),
338  efi_guid_ntoa ( protocol ), opener->OpenCount,
339  efi_open_attributes_name ( opener->Attributes ) );
340  printf ( " by %s", efi_handle_name ( opener->AgentHandle ) );
341  if ( opener->ControllerHandle == handle ) {
342  printf ( "\n" );
343  } else {
344  printf ( " for %s\n",
345  efi_handle_name ( opener->ControllerHandle ) );
346  }
347 }
348 
349 /**
350  * Print list of openers of a given protocol on a given handle
351  *
352  * @v handle EFI handle
353  * @v protocol Protocol GUID
354  */
358  UINTN count;
359  unsigned int i;
360  EFI_STATUS efirc;
361  int rc;
362 
363  /* Sanity check */
364  if ( ( ! handle ) || ( ! protocol ) ) {
365  printf ( "HANDLE %s could not retrieve openers for %s\n",
367  efi_guid_ntoa ( protocol ) );
368  return;
369  }
370 
371  /* Retrieve list of openers */
372  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
373  &count ) ) != 0 ) {
374  rc = -EEFI ( efirc );
375  printf ( "HANDLE %s could not retrieve openers for %s: %s\n",
377  efi_guid_ntoa ( protocol ), strerror ( rc ) );
378  return;
379  }
380 
381  /* Dump list of openers */
382  for ( i = 0 ; i < count ; i++ )
383  dbg_efi_opener ( handle, protocol, &openers[i] );
384 
385  /* Free list */
386  bs->FreePool ( openers );
387 }
388 
389 /**
390  * Print protocol information on a given handle
391  *
392  * @v handle EFI handle
393  * @v protocol Protocol GUID
394  */
397  VOID *interface;
398  EFI_STATUS efirc;
399  int rc;
400 
401  /* Get protocol instance */
402  if ( ( efirc = bs->HandleProtocol ( handle, protocol,
403  &interface ) ) != 0 ) {
404  rc = -EEFI ( efirc );
405  printf ( "HANDLE %s could not identify %s: %s\n",
407  efi_guid_ntoa ( protocol ), strerror ( rc ) );
408  return;
409  }
410  printf ( "HANDLE %s %s at %p\n", efi_handle_name ( handle ),
412 
413  /* Dump list of openers */
415 }
416 
417 /**
418  * Print list of protocol handlers attached to a handle
419  *
420  * @v handle EFI handle
421  */
424  EFI_GUID **protocols;
425  UINTN count;
426  unsigned int i;
427  EFI_STATUS efirc;
428  int rc;
429 
430  /* Sanity check */
431  if ( ! handle ) {
432  printf ( "HANDLE %p could not retrieve protocols\n", handle );
433  return;
434  }
435 
436  /* Retrieve list of protocols */
437  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
438  &count ) ) != 0 ) {
439  rc = -EEFI ( efirc );
440  printf ( "HANDLE %s could not retrieve protocols: %s\n",
441  efi_handle_name ( handle ), strerror ( rc ) );
442  return;
443  }
444 
445  /* Dump list of protocols */
446  for ( i = 0 ; i < count ; i++ ) {
447  dbg_efi_protocol ( handle, protocols[i] );
448  }
449 
450  /* Free list */
451  bs->FreePool ( protocols );
452 }
453 
454 /**
455  * Get textual representation of device path
456  *
457  * @v path Device path
458  * @ret text Textual representation of device path, or NULL
459  */
460 const __attribute__ (( pure )) char *
463  static char text[512];
464  size_t len;
465  CHAR16 *wtext;
466 
467  /* Sanity checks */
468  if ( ! path ) {
469  DBG ( "[NULL DevicePath]" );
470  return NULL;
471  }
472 
473  /* If we have no DevicePathToText protocol then use a raw hex string */
474  if ( ! efidpt ) {
475  DBG ( "[No DevicePathToText]" );
476  len = efi_path_len ( path );
477  base16_encode ( path, len, text, sizeof ( text ) );
478  return text;
479  }
480 
481  /* Convert path to a textual representation */
482  wtext = efidpt->ConvertDevicePathToText ( path, FALSE, FALSE );
483  if ( ! wtext )
484  return NULL;
485 
486  /* Store path in buffer */
487  snprintf ( text, sizeof ( text ), "%ls", wtext );
488 
489  /* Free path */
490  bs->FreePool ( wtext );
491 
492  return text;
493 }
494 
495 /**
496  * Get driver name
497  *
498  * @v wtf Component name protocol
499  * @ret name Driver name, or NULL
500  */
502  static char name[64];
503  CHAR16 *driver_name;
504  EFI_STATUS efirc;
505 
506  /* Sanity check */
507  if ( ! wtf ) {
508  DBG ( "[NULL ComponentName]" );
509  return NULL;
510  }
511 
512  /* Try "eng" first; if that fails then try the first language */
513  if ( ( ( efirc = wtf->GetDriverName ( wtf, "eng",
514  &driver_name ) ) != 0 ) &&
515  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
516  &driver_name ) ) != 0 ) ) {
517  return NULL;
518  }
519 
520  /* Convert name from CHAR16 to char */
521  snprintf ( name, sizeof ( name ), "%ls", driver_name );
522  return name;
523 }
524 
525 /**
526  * Get driver name
527  *
528  * @v wtf Component name protocol
529  * @ret name Driver name, or NULL
530  */
532  static char name[64];
533  CHAR16 *driver_name;
534  EFI_STATUS efirc;
535 
536  /* Sanity check */
537  if ( ! wtf ) {
538  DBG ( "[NULL ComponentName2]" );
539  return NULL;
540  }
541 
542  /* Try "en" first; if that fails then try the first language */
543  if ( ( ( efirc = wtf->GetDriverName ( wtf, "en",
544  &driver_name ) ) != 0 ) &&
545  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
546  &driver_name ) ) != 0 ) ) {
547  return NULL;
548  }
549 
550  /* Convert name from CHAR16 to char */
551  snprintf ( name, sizeof ( name ), "%ls", driver_name );
552  return name;
553 }
554 
555 /**
556  * Get PE/COFF debug filename
557  *
558  * @v loaded Loaded image
559  * @ret name PE/COFF debug filename, or NULL
560  */
561 static const char *
563  static char buf[32];
568  EFI_IMAGE_DATA_DIRECTORY *datadir;
573  uint16_t dos_magic;
574  uint32_t pe_magic;
575  uint16_t opt_magic;
576  uint32_t codeview_magic;
577  size_t max_len;
578  char *name;
579  char *tmp;
580 
581  /* Sanity check */
582  if ( ! loaded ) {
583  DBG ( "[NULL LoadedImage]" );
584  return NULL;
585  }
586 
587  /* Parse DOS header */
588  dos = loaded->ImageBase;
589  if ( ! dos ) {
590  DBG ( "[Missing DOS header]" );
591  return NULL;
592  }
593  dos_magic = dos->e_magic;
594  if ( dos_magic != EFI_IMAGE_DOS_SIGNATURE ) {
595  DBG ( "[Bad DOS signature %#04x]", dos_magic );
596  return NULL;
597  }
598  pe = ( loaded->ImageBase + dos->e_lfanew );
599 
600  /* Parse PE header */
601  pe_magic = pe->Pe32.Signature;
602  if ( pe_magic != EFI_IMAGE_NT_SIGNATURE ) {
603  DBG ( "[Bad PE signature %#08x]", pe_magic );
604  return NULL;
605  }
606  opt32 = &pe->Pe32.OptionalHeader;
607  opt64 = &pe->Pe32Plus.OptionalHeader;
608  opt_magic = opt32->Magic;
609  if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ) {
610  datadir = opt32->DataDirectory;
611  } else if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC ) {
612  datadir = opt64->DataDirectory;
613  } else {
614  DBG ( "[Bad optional header signature %#04x]", opt_magic );
615  return NULL;
616  }
617 
618  /* Parse data directory entry */
619  if ( ! datadir[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress ) {
620  DBG ( "[Empty debug directory entry]" );
621  return NULL;
622  }
623  debug = ( loaded->ImageBase +
625 
626  /* Parse debug directory entry */
627  if ( debug->Type != EFI_IMAGE_DEBUG_TYPE_CODEVIEW ) {
628  DBG ( "[Not a CodeView debug directory entry (type %d)]",
629  debug->Type );
630  return NULL;
631  }
632  codeview_nb10 = ( loaded->ImageBase + debug->RVA );
633  codeview_rsds = ( loaded->ImageBase + debug->RVA );
634  codeview_mtoc = ( loaded->ImageBase + debug->RVA );
635  codeview_magic = codeview_nb10->Signature;
636 
637  /* Parse CodeView entry */
638  if ( codeview_magic == CODEVIEW_SIGNATURE_NB10 ) {
639  name = ( ( void * ) ( codeview_nb10 + 1 ) );
640  } else if ( codeview_magic == CODEVIEW_SIGNATURE_RSDS ) {
641  name = ( ( void * ) ( codeview_rsds + 1 ) );
642  } else if ( codeview_magic == CODEVIEW_SIGNATURE_MTOC ) {
643  name = ( ( void * ) ( codeview_mtoc + 1 ) );
644  } else {
645  DBG ( "[Bad CodeView signature %#08x]", codeview_magic );
646  return NULL;
647  }
648 
649  /* Sanity check - avoid scanning endlessly through memory */
650  max_len = EFI_PAGE_SIZE; /* Reasonably sane */
651  if ( strnlen ( name, max_len ) == max_len ) {
652  DBG ( "[Excessively long or invalid CodeView name]" );
653  return NULL;
654  }
655 
656  /* Skip any directory components. We cannot modify this data
657  * or create a temporary buffer, so do not use basename().
658  */
659  while ( ( ( tmp = strchr ( name, '/' ) ) != NULL ) ||
660  ( ( tmp = strchr ( name, '\\' ) ) != NULL ) ) {
661  name = ( tmp + 1 );
662  }
663 
664  /* Copy base name to buffer */
665  snprintf ( buf, sizeof ( buf ), "%s", name );
666 
667  /* Strip file suffix, if present */
668  if ( ( tmp = strrchr ( buf, '.' ) ) != NULL )
669  *tmp = '\0';
670 
671  return buf;
672 }
673 
674 /**
675  * Get initial loaded image name
676  *
677  * @v loaded Loaded image
678  * @ret name Initial loaded image name, or NULL
679  */
680 static const char *
682 
683  /* Sanity check */
684  if ( ! loaded ) {
685  DBG ( "[NULL LoadedImage]" );
686  return NULL;
687  }
688 
689  return ( ( loaded->ParentHandle == NULL ) ? "DxeCore(?)" : NULL );
690 }
691 
692 /**
693  * Get loaded image name from file path
694  *
695  * @v loaded Loaded image
696  * @ret name Loaded image name, or NULL
697  */
698 static const char *
700 
701  /* Sanity check */
702  if ( ! loaded ) {
703  DBG ( "[NULL LoadedImage]" );
704  return NULL;
705  }
706 
707  return efi_devpath_text ( loaded->FilePath );
708 }
709 
710 /**
711  * Get console input handle name
712  *
713  * @v input Simple text input protocol
714  * @ret name Console input handle name, or NULL
715  */
716 static const char *
718 
719  /* Check for match against ConIn */
720  if ( input == efi_systab->ConIn )
721  return "ConIn";
722 
723  return NULL;
724 }
725 
726 /**
727  * Get console output handle name
728  *
729  * @v output Simple text output protocol
730  * @ret name Console output handle name, or NULL
731  */
732 static const char *
734 
735  /* Check for match against ConOut */
736  if ( output == efi_systab->ConOut )
737  return "ConOut";
738 
739  /* Check for match against StdErr (if different from ConOut) */
740  if ( output == efi_systab->StdErr )
741  return "StdErr";
742 
743  return NULL;
744 }
745 
746 /** An EFI handle name type */
748  /** Protocol */
750  /**
751  * Get name
752  *
753  * @v interface Protocol interface
754  * @ret name Name of handle, or NULL on failure
755  */
756  const char * ( * name ) ( void *interface );
757 };
758 
759 /**
760  * Define an EFI handle name type
761  *
762  * @v protocol Protocol interface
763  * @v name Method to get name
764  * @ret type EFI handle name type
765  */
766 #define EFI_HANDLE_NAME_TYPE( protocol, name ) { \
767  (protocol), \
768  ( const char * ( * ) ( void * ) ) (name), \
769  }
770 
771 /** EFI handle name types */
773  /* Device path */
776  /* Driver name (for driver image handles) */
779  /* Driver name (via obsolete original ComponentName protocol) */
781  efi_driver_name ),
782  /* PE/COFF debug filename (for image handles) */
785  /* Loaded image device path (for image handles) */
788  /* First loaded image name (for the DxeCore image) */
791  /* Handle's loaded image file path (for image handles) */
794  /* Our standard input file handle */
796  efi_conin_name ),
797  /* Our standard output and standard error file handles */
799  efi_conout_name ),
800 };
801 
802 /**
803  * Get name of an EFI handle
804  *
805  * @v handle EFI handle
806  * @ret text Name of handle, or NULL
807  */
808 const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) {
810  struct efi_handle_name_type *type;
811  static char buf[256];
812  size_t used = 0;
813  EFI_GUID **protocols;
814  UINTN count;
815  unsigned int i;
816  void *interface;
817  const char *name;
818  EFI_STATUS efirc;
819 
820  /* Fail immediately for NULL handles */
821  if ( ! handle )
822  return NULL;
823 
824  /* Try each name type in turn */
825  for ( i = 0 ; i < ( sizeof ( efi_handle_name_types ) /
826  sizeof ( efi_handle_name_types[0] ) ) ; i++ ) {
828  DBG2 ( "<%d", i );
829 
830  /* Try to open the applicable protocol */
831  efirc = bs->OpenProtocol ( handle, type->protocol, &interface,
834  if ( efirc != 0 ) {
835  DBG2 ( ">" );
836  continue;
837  }
838 
839  /* Try to get name from this protocol */
840  DBG2 ( "-" );
841  name = type->name ( interface );
842  DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );
843 
844  /* Close protocol */
845  bs->CloseProtocol ( handle, type->protocol,
847  DBG2 ( ">" );
848 
849  /* Use this name, if possible */
850  if ( name && name[0] )
851  return name;
852  }
853 
854  /* If no name is found, then use the raw handle value and a
855  * list of installed protocols.
856  */
857  used = ssnprintf ( buf, sizeof ( buf ), "UNKNOWN<%p", handle );
858  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
859  &count ) ) == 0 ) {
860  for ( i = 0 ; i < count ; i++ ) {
861  used += ssnprintf ( ( buf + used ),
862  ( sizeof ( buf ) - used ), ",%s",
863  efi_guid_ntoa ( protocols[i] ) );
864  }
865  bs->FreePool ( protocols );
866  }
867  used += ssnprintf ( ( buf + used ), ( sizeof ( buf ) - used ), ">" );
868  return buf;
869 }
EFI_GUID efi_nii31_protocol_guid
Network interface identifier protocol GUID (new version)
Definition: efi_guid.c:279
EFI_GUID efi_mtftp6_service_binding_protocol_guid
MTFTPv6 service binding protocol GUID.
Definition: efi_guid.c:271
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:2081
#define EFI_PAGE_SIZE
Definition: UefiBaseType.h:187
EFI_GUID efi_ip4_config_protocol_guid
IPv4 configuration protocol GUID.
Definition: efi_guid.c:211
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:171
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:151
EFI Oprn Protocol Information Entry.
Definition: UefiSpec.h:1421
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:195
#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:355
EFI_GUID efi_tcg_protocol_guid
TCG protocol GUID.
Definition: efi_guid.c:327
EFI_GUID efi_block_io2_protocol_guid
Block I/O version 2 protocol GUID.
Definition: efi_guid.c:123
EFI_HANDLE ControllerHandle
Definition: UefiSpec.h:1423
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:223
EFI_GUID efi_udp6_service_binding_protocol_guid
UDPv6 service binding protocol GUID.
Definition: efi_guid.c:363
EFI_HANDLE AgentHandle
Definition: UefiSpec.h:1422
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:699
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:717
EFI_GUID efi_dhcp6_service_binding_protocol_guid
DHCPv6 service binding protocol GUID.
Definition: efi_guid.c:159
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1511
EFI_GUID efi_pci_io_protocol_guid
PCI I/O protocol GUID.
Definition: efi_guid.c:283
The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
Definition: SimpleTextIn.h:118
EFI_GUID efi_arp_service_binding_protocol_guid
ARP service binding protocol GUID.
Definition: efi_guid.c:115
EFI_GUID efi_usb_hc_protocol_guid
USB host controller protocol GUID.
Definition: efi_guid.c:375
uint16_t max_len
Maximum length (in bytes)
Definition: ntlm.h:18
static const char * efi_driver_name(EFI_COMPONENT_NAME_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:501
EFI_GUID efi_usb2_hc_protocol_guid
USB2 host controller protocol GUID.
Definition: efi_guid.c:379
EFI_GUID efi_graphics_output_protocol_guid
Graphics output protocol GUID.
Definition: efi_guid.c:187
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:311
EFI_GUID efi_loaded_image_device_path_protocol_guid
Loaded image device path protocol GUID.
Definition: efi_guid.c:247
EFI_GUID efi_dhcp4_protocol_guid
DHCPv4 protocol GUID.
Definition: efi_guid.c:147
EFI_GUID efi_simple_network_protocol_guid
Simple network protocol GUID.
Definition: efi_guid.c:307
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:243
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:1515
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:395
EFI_GUID efi_tcp4_protocol_guid
TCPv4 protocol GUID.
Definition: efi_guid.c:331
Universally unique IDs.
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:108
Definition: PeImage.h:660
#define EFI_HANDLE_NAME_TYPE(protocol, name)
Define an EFI handle name type.
Definition: efi_debug.c:766
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:291
EFI_GUID efi_ip4_config2_protocol_guid
IPv4 configuration 2 protocol GUID.
Definition: efi_guid.c:215
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:255
EFI_GUID efi_ip6_service_binding_protocol_guid
IPv6 service binding protocol GUID.
Definition: efi_guid.c:231
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:1987
void dbg_efi_opener(EFI_HANDLE handle, EFI_GUID *protocol, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener)
Print opened protocol information.
Definition: efi_debug.c:334
static const char * efi_driver_name2(EFI_COMPONENT_NAME2_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:531
EFI_GUID efi_disk_io_protocol_guid
Disk I/O protocol GUID.
Definition: efi_guid.c:163
EFI_GUID efi_hii_config_access_protocol_guid
HII configuration access protocol GUID.
Definition: efi_guid.c:191
EFI_GUID efi_console_control_protocol_guid
Console control protocol GUID.
Definition: efi_guid.c:139
EFI_GUID efi_simple_text_output_protocol_guid
Simple text output protocol GUID.
Definition: efi_guid.c:323
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:263
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:53
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:367
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:339
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:2063
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:335
EFI_GUID efi_tree_protocol_guid
TrEE protocol GUID.
Definition: efi_guid.c:347
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:155
EFI_GUID efi_simple_file_system_protocol_guid
Simple file system protocol GUID.
Definition: efi_guid.c:303
EFI_GUID efi_ip4_service_binding_protocol_guid
IPv4 service binding protocol GUID.
Definition: efi_guid.c:219
EFI_GUID efi_acpi_table_protocol_guid
ACPI table protocol GUID.
Definition: efi_guid.c:103
UEFI Component Name 2 Protocol as defined in the UEFI 2.1 specification.
UINT32 OpenCount
Definition: UefiSpec.h:1425
static EFI_GUID efi_iscsi_dxe_guid
IScsiDxe module GUID.
Definition: efi_debug.c:57
UINT32 Attributes
Definition: UefiSpec.h:1424
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is associated with ConsoleInHandle.
Definition: UefiSpec.h:2054
const char * efi_locate_search_type_name(EFI_LOCATE_SEARCH_TYPE search_type)
Name locate search type.
Definition: efi_debug.c:287
EFI_HANDLE_PROTOCOL HandleProtocol
Definition: UefiSpec.h:1954
EFI_GUID efi_vlan_config_protocol_guid
VLAN configuration protocol GUID.
Definition: efi_guid.c:387
EFI_GUID efi_ip6_config_protocol_guid
IPv6 configuration protocol GUID.
Definition: efi_guid.c:227
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:461
uint64_t debug
Debug area base address.
Definition: ena.h:14
#define EFI_OPEN_PROTOCOL_GET_PROTOCOL
Definition: UefiSpec.h:1344
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:808
static struct efi_handle_name_type efi_handle_name_types[]
EFI handle name types.
Definition: efi_debug.c:772
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:254
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:383
EFI_GUID efi_load_file2_protocol_guid
Load file 2 protocol GUID.
Definition: efi_guid.c:239
EFI Boot Services Table.
Definition: UefiSpec.h:1917
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:295
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:562
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:359
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:143
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:135
#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:319
void dbg_efi_protocols(EFI_HANDLE handle)
Print list of protocol handlers attached to a handle.
Definition: efi_debug.c:422
const char * uuid_ntoa(const union uuid *uuid)
Convert UUID to printable string.
Definition: uuid.c:45
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1936
Debug Directory Format.
Definition: PeImage.h:642
EFI_GUID efi_simple_text_input_protocol_guid
Simple text input protocol GUID.
Definition: efi_guid.c:315
EFI_GUID efi_bus_specific_driver_override_protocol_guid
Bus specific driver override protocol GUID.
Definition: efi_guid.c:127
EFI_GUID efi_mtftp4_protocol_guid
MTFTPv4 protocol GUID.
Definition: efi_guid.c:259
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:1988
#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:733
EFI_GUID efi_tcp6_service_binding_protocol_guid
TCPv6 service binding protocol GUID.
Definition: efi_guid.c:343
EFI_GUID efi_nii_protocol_guid
Network interface identifier protocol GUID (old version)
Definition: efi_guid.c:275
EFI_GUID efi_dns4_protocol_guid
DNSv4 protocol GUID.
Definition: efi_guid.c:167
EFI_GUID efi_absolute_pointer_protocol_guid
Absolute pointer protocol GUID.
Definition: efi_guid.c:99
EFI_GUID efi_arp_protocol_guid
ARP protocol GUID.
Definition: efi_guid.c:111
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:107
static const char * efi_first_loaded_image_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get initial loaded image name.
Definition: efi_debug.c:681
UINT16 e_magic
Magic number.
Definition: PeImage.h:60
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:1993
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition: PeImage.h:187
uint32_t len
Length.
Definition: ena.h:14
uint32_t type
Operating system type.
Definition: ena.h:12
EFI_GUID efi_block_io_protocol_guid
Block I/O protocol GUID.
Definition: efi_guid.c:119
#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:749
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:59
EFI_GUID efi_pci_root_bridge_io_protocol_guid
PCI root bridge I/O protocol GUID.
Definition: efi_guid.c:287
union @17 u
An EFI handle name type.
Definition: efi_debug.c:747
const char * efi_open_attributes_name(unsigned int attributes)
Name protocol open attributes.
Definition: efi_debug.c:312
EFI_GUID efi_http_protocol_guid
HTTP protocol GUID.
Definition: efi_guid.c:199
#define FALSE
Definition: tlan.h:45
EFI_GUID efi_ip4_protocol_guid
IPv4 protocol GUID.
Definition: efi_guid.c:207
EFI_GUID efi_shim_lock_protocol_guid
Shim lock protocol GUID.
Definition: efi_guid.c:299
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:203
Retrieve the set of handles from the handle database that support a specified protocol.
Definition: UefiSpec.h:1520
EFI_GUID efi_dns6_service_binding_protocol_guid
DNSv6 service binding protocol GUID.
Definition: efi_guid.c:179
EFI_IMAGE_NT_HEADERS64 Pe32Plus
Definition: PeImage.h:807
EFI_SYSTEM_TABLE * efi_systab
EFI_OPEN_PROTOCOL OpenProtocol
Definition: UefiSpec.h:1986
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition: efi_guid.c:131
EFI_GUID efi_dns6_protocol_guid
DNSv6 protocol GUID.
Definition: efi_guid.c:175
uint16_t protocol
Protocol ID.
Definition: stp.h:18
EFI_LOCATE_SEARCH_TYPE
Enumeration of EFI Locate Search Types.
Definition: UefiSpec.h:1507
#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:371
EFI_GUID efi_mtftp6_protocol_guid
MTFTPv6 protocol GUID.
Definition: efi_guid.c:267
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
EFI_GUID efi_load_file_protocol_guid
Load file protocol GUID.
Definition: efi_guid.c:235
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: PeImage.h:196
EFI_GUID efi_udp4_protocol_guid
UDPv4 protocol GUID.
Definition: efi_guid.c:351
EFI_GUID efi_udp4_service_binding_protocol_guid
UDPv4 service binding protocol GUID.
Definition: efi_guid.c:355
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
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:183
#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:2073
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:251