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 <errno.h>
35 #include <ipxe/base16.h>
36 #include <ipxe/vsprintf.h>
37 #include <ipxe/efi/efi.h>
38 #include <ipxe/efi/efi_path.h>
44 
45 /** Device path to text protocol */
48 
49 /**
50  * Name EFI TPL
51  *
52  * @v tpl Task priority level
53  * @ret text Task priority level as text
54  */
55 const __attribute__ (( pure )) char * efi_tpl_name ( EFI_TPL tpl ) {
56  static char buf[ 19 /* "0xXXXXXXXXXXXXXXXX" + NUL */ ];
57 
58  switch ( tpl ) {
59  case TPL_APPLICATION: return "Application";
60  case TPL_CALLBACK: return "Callback";
61  case TPL_NOTIFY: return "Notify";
62  case TPL_HIGH_LEVEL: return "HighLevel";
63  default:
64  snprintf ( buf, sizeof ( buf ), "%#lx",
65  ( unsigned long ) tpl );
66  return buf;
67  }
68 }
69 
70 /**
71  * Name locate search type
72  *
73  * @v search_type Locate search type
74  * @ret name Locate search type name
75  */
76 const __attribute__ (( pure )) char *
78  static char buf[16];
79 
80  switch ( search_type ) {
81  case AllHandles : return "AllHandles";
82  case ByRegisterNotify: return "ByRegisterNotify";
83  case ByProtocol: return "ByProtocol";
84  default:
85  snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", search_type );
86  return buf;
87  }
88 }
89 
90 /**
91  * Name protocol open attributes
92  *
93  * @v attributes Protocol open attributes
94  * @ret name Protocol open attributes name
95  *
96  * Returns a (static) string with characters for each set bit
97  * corresponding to BY_(H)ANDLE_PROTOCOL, (G)ET_PROTOCOL,
98  * (T)EST_PROTOCOL, BY_(C)HILD_CONTROLLER, BY_(D)RIVER, and
99  * E(X)CLUSIVE.
100  */
101 const __attribute__ (( pure )) char *
102 efi_open_attributes_name ( unsigned int attributes ) {
103  static char attribute_chars[] = "HGTCDX";
104  static char name[ sizeof ( attribute_chars ) ];
105  char *tmp = name;
106  unsigned int i;
107 
108  for ( i = 0 ; i < ( sizeof ( attribute_chars ) - 1 ) ; i++ ) {
109  if ( attributes & ( 1 << i ) )
110  *(tmp++) = attribute_chars[i];
111  }
112  *tmp = '\0';
113 
114  return name;
115 }
116 
117 /**
118  * Print opened protocol information
119  *
120  * @v handle EFI handle
121  * @V protocol Protocol GUID
122  * @v opener Opened protocol information
123  */
126 
127  printf ( "HANDLE %s %s opened %dx (%s)", efi_handle_name ( handle ),
128  efi_guid_ntoa ( protocol ), opener->OpenCount,
129  efi_open_attributes_name ( opener->Attributes ) );
130  printf ( " by %s", efi_handle_name ( opener->AgentHandle ) );
131  if ( opener->ControllerHandle == handle ) {
132  printf ( "\n" );
133  } else {
134  printf ( " for %s\n",
135  efi_handle_name ( opener->ControllerHandle ) );
136  }
137 }
138 
139 /**
140  * Print list of openers of a given protocol on a given handle
141  *
142  * @v handle EFI handle
143  * @v protocol Protocol GUID
144  */
148  UINTN count;
149  unsigned int i;
150  EFI_STATUS efirc;
151  int rc;
152 
153  /* Sanity check */
154  if ( ( ! handle ) || ( ! protocol ) ) {
155  printf ( "HANDLE %s could not retrieve openers for %s\n",
157  efi_guid_ntoa ( protocol ) );
158  return;
159  }
160 
161  /* Retrieve list of openers */
162  if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
163  &count ) ) != 0 ) {
164  rc = -EEFI ( efirc );
165  printf ( "HANDLE %s could not retrieve openers for %s: %s\n",
167  efi_guid_ntoa ( protocol ), strerror ( rc ) );
168  return;
169  }
170 
171  /* Dump list of openers */
172  for ( i = 0 ; i < count ; i++ )
173  dbg_efi_opener ( handle, protocol, &openers[i] );
174 
175  /* Free list */
176  bs->FreePool ( openers );
177 }
178 
179 /**
180  * Print protocol information on a given handle
181  *
182  * @v handle EFI handle
183  * @v protocol Protocol GUID
184  */
186  VOID *interface;
187  int rc;
188 
189  /* Get protocol instance */
190  if ( ( rc = efi_open ( handle, protocol, &interface ) ) != 0 ) {
191  printf ( "HANDLE %s could not identify %s: %s\n",
193  efi_guid_ntoa ( protocol ), strerror ( rc ) );
194  return;
195  }
196  printf ( "HANDLE %s %s at %p\n", efi_handle_name ( handle ),
198 
199  /* Dump list of openers */
201 }
202 
203 /**
204  * Print list of protocol handlers attached to a handle
205  *
206  * @v handle EFI handle
207  */
210  EFI_GUID **protocols;
211  UINTN count;
212  unsigned int i;
213  EFI_STATUS efirc;
214  int rc;
215 
216  /* Sanity check */
217  if ( ! handle ) {
218  printf ( "HANDLE %p could not retrieve protocols\n", handle );
219  return;
220  }
221 
222  /* Retrieve list of protocols */
223  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
224  &count ) ) != 0 ) {
225  rc = -EEFI ( efirc );
226  printf ( "HANDLE %s could not retrieve protocols: %s\n",
227  efi_handle_name ( handle ), strerror ( rc ) );
228  return;
229  }
230 
231  /* Dump list of protocols */
232  for ( i = 0 ; i < count ; i++ ) {
233  dbg_efi_protocol ( handle, protocols[i] );
234  }
235 
236  /* Free list */
237  bs->FreePool ( protocols );
238 }
239 
240 /**
241  * Get textual representation of device path
242  *
243  * @v path Device path
244  * @ret text Textual representation of device path, or NULL
245  */
246 const __attribute__ (( pure )) char *
249  static char text[512];
250  size_t len;
251  CHAR16 *wtext;
252 
253  /* Sanity checks */
254  if ( ! path ) {
255  DBG ( "[NULL DevicePath]" );
256  return NULL;
257  }
258 
259  /* If we have no DevicePathToText protocol then use a raw hex string */
260  if ( ! efidpt ) {
261  DBG ( "[No DevicePathToText]" );
262  len = efi_path_len ( path );
263  base16_encode ( path, len, text, sizeof ( text ) );
264  return text;
265  }
266 
267  /* Convert path to a textual representation */
268  wtext = efidpt->ConvertDevicePathToText ( path, FALSE, FALSE );
269  if ( ! wtext )
270  return NULL;
271 
272  /* Store path in buffer */
273  snprintf ( text, sizeof ( text ), "%ls", wtext );
274 
275  /* Free path */
276  bs->FreePool ( wtext );
277 
278  return text;
279 }
280 
281 /**
282  * Get driver name
283  *
284  * @v wtf Component name protocol
285  * @ret name Driver name, or NULL
286  */
288  static char name[64];
289  CHAR16 *driver_name;
290  EFI_STATUS efirc;
291 
292  /* Sanity check */
293  if ( ! wtf ) {
294  DBG ( "[NULL ComponentName]" );
295  return NULL;
296  }
297 
298  /* Try "eng" first; if that fails then try the first language */
299  if ( ( ( efirc = wtf->GetDriverName ( wtf, "eng",
300  &driver_name ) ) != 0 ) &&
301  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
302  &driver_name ) ) != 0 ) ) {
303  return NULL;
304  }
305 
306  /* Convert name from CHAR16 to char */
307  snprintf ( name, sizeof ( name ), "%ls", driver_name );
308  return name;
309 }
310 
311 /**
312  * Get driver name
313  *
314  * @v wtf Component name protocol
315  * @ret name Driver name, or NULL
316  */
318  static char name[64];
319  CHAR16 *driver_name;
320  EFI_STATUS efirc;
321 
322  /* Sanity check */
323  if ( ! wtf ) {
324  DBG ( "[NULL ComponentName2]" );
325  return NULL;
326  }
327 
328  /* Try "en" first; if that fails then try the first language */
329  if ( ( ( efirc = wtf->GetDriverName ( wtf, "en",
330  &driver_name ) ) != 0 ) &&
331  ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
332  &driver_name ) ) != 0 ) ) {
333  return NULL;
334  }
335 
336  /* Convert name from CHAR16 to char */
337  snprintf ( name, sizeof ( name ), "%ls", driver_name );
338  return name;
339 }
340 
341 /**
342  * Get driver binding name
343  *
344  * @v binding Driver binding protocol
345  * @ret name Driver name, or NULL
346  */
347 static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) {
350  int rc;
351 
352  /* Sanity check */
353  if ( ! binding ) {
354  DBG ( "[NULL DriverBinding]" );
355  return NULL;
356  }
357 
358  /* Try to open component name protocol on image handle */
359  image = binding->ImageHandle;
361  &name ) ) != 0 ) {
362  DBG ( "[DriverBinding no ComponentName]" );
363  return NULL;
364  }
365 
366  /* Try to get name from component name protocol */
367  return efi_driver_name ( name );
368 }
369 
370 /**
371  * Get driver binding name
372  *
373  * @v binding Driver binding protocol
374  * @ret name Driver name, or NULL
375  */
376 static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){
379  int rc;
380 
381  /* Sanity check */
382  if ( ! binding ) {
383  DBG ( "[NULL DriverBinding]" );
384  return NULL;
385  }
386 
387  /* Try to open component name protocol on image handle */
388  image = binding->ImageHandle;
390  &name2 ) ) != 0 ) {
391  DBG ( "[DriverBinding no ComponentName2]" );
392  return NULL;
393  }
394 
395  /* Try to get name from component name protocol */
396  return efi_driver_name2 ( name2 );
397 }
398 
399 /**
400  * Get PE/COFF debug filename
401  *
402  * @v loaded Loaded image
403  * @ret name PE/COFF debug filename, or NULL
404  */
405 static const char *
407  static char buf[32];
412  EFI_IMAGE_DATA_DIRECTORY *datadir;
417  uint16_t dos_magic;
418  uint32_t pe_magic;
419  uint16_t opt_magic;
420  uint32_t codeview_magic;
421  size_t max_len;
422  char *name;
423  char *tmp;
424 
425  /* Sanity check */
426  if ( ! loaded ) {
427  DBG ( "[NULL LoadedImage]" );
428  return NULL;
429  }
430 
431  /* Parse DOS header */
432  dos = loaded->ImageBase;
433  if ( ! dos ) {
434  DBG ( "[Missing DOS header]" );
435  return NULL;
436  }
437  dos_magic = dos->e_magic;
438  if ( dos_magic != EFI_IMAGE_DOS_SIGNATURE ) {
439  DBG ( "[Bad DOS signature %#04x]", dos_magic );
440  return NULL;
441  }
442  pe = ( loaded->ImageBase + dos->e_lfanew );
443 
444  /* Parse PE header */
445  pe_magic = pe->Pe32.Signature;
446  if ( pe_magic != EFI_IMAGE_NT_SIGNATURE ) {
447  DBG ( "[Bad PE signature %#08x]", pe_magic );
448  return NULL;
449  }
450  opt32 = &pe->Pe32.OptionalHeader;
451  opt64 = &pe->Pe32Plus.OptionalHeader;
452  opt_magic = opt32->Magic;
453  if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ) {
454  datadir = opt32->DataDirectory;
455  } else if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC ) {
456  datadir = opt64->DataDirectory;
457  } else {
458  DBG ( "[Bad optional header signature %#04x]", opt_magic );
459  return NULL;
460  }
461 
462  /* Parse data directory entry */
463  if ( ! datadir[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress ) {
464  DBG ( "[Empty debug directory entry]" );
465  return NULL;
466  }
467  debug = ( loaded->ImageBase +
469 
470  /* Parse debug directory entry */
471  if ( debug->Type != EFI_IMAGE_DEBUG_TYPE_CODEVIEW ) {
472  DBG ( "[Not a CodeView debug directory entry (type %d)]",
473  debug->Type );
474  return NULL;
475  }
476  codeview_nb10 = ( loaded->ImageBase + debug->RVA );
477  codeview_rsds = ( loaded->ImageBase + debug->RVA );
478  codeview_mtoc = ( loaded->ImageBase + debug->RVA );
479  codeview_magic = codeview_nb10->Signature;
480 
481  /* Parse CodeView entry */
482  if ( codeview_magic == CODEVIEW_SIGNATURE_NB10 ) {
483  name = ( ( void * ) ( codeview_nb10 + 1 ) );
484  } else if ( codeview_magic == CODEVIEW_SIGNATURE_RSDS ) {
485  name = ( ( void * ) ( codeview_rsds + 1 ) );
486  } else if ( codeview_magic == CODEVIEW_SIGNATURE_MTOC ) {
487  name = ( ( void * ) ( codeview_mtoc + 1 ) );
488  } else {
489  DBG ( "[Bad CodeView signature %#08x]", codeview_magic );
490  return NULL;
491  }
492 
493  /* Sanity check - avoid scanning endlessly through memory */
494  max_len = EFI_PAGE_SIZE; /* Reasonably sane */
495  if ( strnlen ( name, max_len ) == max_len ) {
496  DBG ( "[Excessively long or invalid CodeView name]" );
497  return NULL;
498  }
499 
500  /* Skip any directory components. We cannot modify this data
501  * or create a temporary buffer, so do not use basename().
502  */
503  while ( ( ( tmp = strchr ( name, '/' ) ) != NULL ) ||
504  ( ( tmp = strchr ( name, '\\' ) ) != NULL ) ) {
505  name = ( tmp + 1 );
506  }
507 
508  /* Copy base name to buffer */
509  snprintf ( buf, sizeof ( buf ), "%s", name );
510 
511  /* Strip file suffix, if present */
512  if ( ( tmp = strrchr ( buf, '.' ) ) != NULL )
513  *tmp = '\0';
514 
515  return buf;
516 }
517 
518 /**
519  * Get initial loaded image name
520  *
521  * @v loaded Loaded image
522  * @ret name Initial loaded image name, or NULL
523  */
524 static const char *
526 
527  /* Sanity check */
528  if ( ! loaded ) {
529  DBG ( "[NULL LoadedImage]" );
530  return NULL;
531  }
532 
533  return ( ( loaded->ParentHandle == NULL ) ? "DxeCore(?)" : NULL );
534 }
535 
536 /**
537  * Get loaded image name from file path
538  *
539  * @v loaded Loaded image
540  * @ret name Loaded image name, or NULL
541  */
542 static const char *
544 
545  /* Sanity check */
546  if ( ! loaded ) {
547  DBG ( "[NULL LoadedImage]" );
548  return NULL;
549  }
550 
551  return efi_devpath_text ( loaded->FilePath );
552 }
553 
554 /**
555  * Get console input handle name
556  *
557  * @v input Simple text input protocol
558  * @ret name Console input handle name, or NULL
559  */
560 static const char *
562 
563  /* Check for match against ConIn */
564  if ( input == efi_systab->ConIn )
565  return "ConIn";
566 
567  return NULL;
568 }
569 
570 /**
571  * Get console output handle name
572  *
573  * @v output Simple text output protocol
574  * @ret name Console output handle name, or NULL
575  */
576 static const char *
578 
579  /* Check for match against ConOut */
580  if ( output == efi_systab->ConOut )
581  return "ConOut";
582 
583  /* Check for match against StdErr (if different from ConOut) */
584  if ( output == efi_systab->StdErr )
585  return "StdErr";
586 
587  return NULL;
588 }
589 
590 /** An EFI handle name type */
592  /** Protocol */
594  /**
595  * Get name
596  *
597  * @v interface Protocol interface
598  * @ret name Name of handle, or NULL on failure
599  */
600  const char * ( * name ) ( void *interface );
601 };
602 
603 /**
604  * Define an EFI handle name type
605  *
606  * @v protocol Protocol interface
607  * @v name Method to get name
608  * @ret type EFI handle name type
609  */
610 #define EFI_HANDLE_NAME_TYPE( protocol, name ) { \
611  (protocol), \
612  ( const char * ( * ) ( void * ) ) (name), \
613  }
614 
615 /** EFI handle name types */
617  /* Driver name (for driver binding handles) */
620  /* Driver name (via obsolete original ComponentName protocol) */
623  /* PE/COFF debug filename (for image handles) */
626  /* Loaded image device path (for image handles) */
629  /* First loaded image name (for the DxeCore image) */
632  /* Handle's loaded image file path (for image handles) */
635  /* Device path */
638  /* Our standard input file handle */
640  efi_conin_name ),
641  /* Our standard output and standard error file handles */
643  efi_conout_name ),
644 };
645 
646 /**
647  * Get name of an EFI handle
648  *
649  * @v handle EFI handle
650  * @ret text Name of handle, or NULL
651  */
652 const __attribute__ (( pure )) char * efi_handle_name ( EFI_HANDLE handle ) {
654  struct efi_handle_name_type *type;
655  static char buf[256];
656  size_t used = 0;
657  EFI_GUID **protocols;
658  UINTN count;
659  unsigned int i;
660  void *interface;
661  const char *name;
662  EFI_STATUS efirc;
663  int rc;
664 
665  /* Fail immediately for NULL handles */
666  if ( ! handle )
667  return NULL;
668 
669  /* Try each name type in turn */
670  for ( i = 0 ; i < ( sizeof ( efi_handle_name_types ) /
671  sizeof ( efi_handle_name_types[0] ) ) ; i++ ) {
673  DBG2 ( "<%d", i );
674 
675  /* Try to open the applicable protocol */
676  if ( ( rc = efi_open ( handle, type->protocol,
677  &interface ) ) != 0 ) {
678  DBG2 ( ">" );
679  continue;
680  }
681 
682  /* Try to get name from this protocol */
683  DBG2 ( "-" );
684  name = type->name ( interface );
685  DBG2 ( "%c>", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );
686 
687  /* Use this name, if possible */
688  if ( name && name[0] )
689  return name;
690  }
691 
692  /* If no name is found, then use the raw handle value and a
693  * list of installed protocols.
694  */
695  used = ssnprintf ( buf, sizeof ( buf ), "UNKNOWN<%p", handle );
696  if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
697  &count ) ) == 0 ) {
698  for ( i = 0 ; i < count ; i++ ) {
699  used += ssnprintf ( ( buf + used ),
700  ( sizeof ( buf ) - used ), ",%s",
701  efi_guid_ntoa ( protocols[i] ) );
702  }
703  bs->FreePool ( protocols );
704  }
705  used += ssnprintf ( ( buf + used ), ( sizeof ( buf ) - used ), ">" );
706  return buf;
707 }
UEFI DriverBinding Protocol is defined in UEFI specification.
#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
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 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...
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition: efi.h:174
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:145
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_HANDLE AgentHandle
Definition: UefiSpec.h:1432
static const char * efi_loaded_image_filepath_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get loaded image name from file path.
Definition: efi_debug.c:543
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.
static const char * efi_conin_name(EFI_SIMPLE_TEXT_INPUT_PROTOCOL *input)
Get console input handle name.
Definition: efi_debug.c:561
Retrieve all the handles in the handle database.
Definition: UefiSpec.h:1521
The EFI_SIMPLE_TEXT_INPUT_PROTOCOL is used on the ConsoleIn device.
Definition: SimpleTextIn.h:119
#define TPL_APPLICATION
Definition: UefiSpec.h:647
static const char * efi_driver_name(EFI_COMPONENT_NAME_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:287
uint32_t type
Operating system type.
Definition: ena.h:12
printf() and friends
EFI_GUID efi_loaded_image_device_path_protocol_guid
Loaded image device path protocol GUID.
Definition: efi_guid.c:276
EFI_GUID efi_loaded_image_protocol_guid
Loaded image protocol GUID.
Definition: efi_guid.c:272
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:804
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:185
size_t efi_path_len(EFI_DEVICE_PATH_PROTOCOL *path)
Find length of device path (excluding terminator)
Definition: efi_path.c:173
Definition: PeImage.h:659
#define EFI_HANDLE_NAME_TYPE(protocol, name)
Define an EFI handle name type.
Definition: efi_debug.c:610
unsigned short CHAR16
#define EFI_IMAGE_DOS_SIGNATURE
Definition: PeImage.h:49
Optional Header Standard Fields for PE32+.
Definition: PeImage.h:200
Optional Header Standard Fields for PE32.
Definition: PeImage.h:149
An executable image.
Definition: image.h:23
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 Component Name Protocol as defined in the EFI 1.1 specification.
static const char * efi_binding_name(EFI_DRIVER_BINDING_PROTOCOL *binding)
Get driver binding name.
Definition: efi_debug.c:347
EFI_IMAGE_NT_HEADERS32 Pe32
Definition: PeImage.h:805
void dbg_efi_opener(EFI_HANDLE handle, EFI_GUID *protocol, EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener)
Print opened protocol information.
Definition: efi_debug.c:124
static const char * efi_driver_name2(EFI_COMPONENT_NAME2_PROTOCOL *wtf)
Get driver name.
Definition: efi_debug.c:317
#define TPL_NOTIFY
Definition: UefiSpec.h:649
EFI_GUID efi_simple_text_output_protocol_guid
Simple text output protocol GUID.
Definition: efi_guid.c:356
The SIMPLE_TEXT_OUTPUT protocol is used to control text-based output devices.
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:64
static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL * efidpt
Device path to text protocol.
Definition: efi_debug.c:46
#define EFI_IMAGE_NT_SIGNATURE
Definition: PeImage.h:52
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
Definition: PeImage.h:689
Can be used on any image handle to obtain information about the loaded image.
Definition: LoadedImage.h:45
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:130
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:672
ring len
Length.
Definition: dwmac.h:231
UEFI Component Name 2 Protocol as defined in the UEFI 2.1 specification.
UINT32 OpenCount
Definition: UefiSpec.h:1435
UINT32 Attributes
Definition: UefiSpec.h:1434
static unsigned int count
Number of entries.
Definition: dwmac.h:225
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:77
const char * efi_devpath_text(EFI_DEVICE_PATH_PROTOCOL *path)
Get textual representation of device path.
Definition: efi_debug.c:247
uint64_t debug
Debug area base address.
Definition: ena.h:14
const char * efi_handle_name(EFI_HANDLE handle)
Get name of an EFI handle.
Definition: efi_debug.c:652
static struct efi_handle_name_type efi_handle_name_types[]
EFI handle name types.
Definition: efi_debug.c:616
UINT16 Magic
Standard fields.
Definition: PeImage.h:153
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
EFI Boot Services Table.
Definition: UefiSpec.h:1930
char * strchr(const char *src, int character)
Find character within a string.
Definition: string.c:271
UINT32 Signature
"NB10"
Definition: PeImage.h:660
#define CODEVIEW_SIGNATURE_MTOC
Debug Data Structure defined by Apple Mach-O to Coff utility.
Definition: PeImage.h:688
Header Data Directories.
Definition: PeImage.h:116
#define TPL_CALLBACK
Definition: UefiSpec.h:648
#define efi_open(handle, protocol, interface)
Open protocol for ephemeral use.
Definition: efi.h:443
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition: PeImage.h:236
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:406
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:258
This protocol provides the services required to determine if a driver supports a given controller.
EFI_GUID efi_device_path_protocol_guid
Device path protocol GUID.
Definition: efi_guid.c:168
const char * efi_guid_ntoa(CONST EFI_GUID *guid)
Convert GUID to a printable string.
Definition: efi_guid.c:725
EFI_GUID efi_component_name2_protocol_guid
Component name 2 protocol GUID.
Definition: efi_guid.c:160
#define VOID
Undeclared type.
Definition: Base.h:271
Definition: PeImage.h:673
unsigned int uint32_t
Definition: stdint.h:12
void dbg_efi_protocols(EFI_HANDLE handle)
Print list of protocol handlers attached to a handle.
Definition: efi_debug.c:208
EFI_HANDLE ImageHandle
The image handle of the UEFI driver that produced this instance of the EFI_DRIVER_BINDING_PROTOCOL.
EFI_FREE_POOL FreePool
Definition: UefiSpec.h:1949
Debug Directory Format.
Definition: PeImage.h:641
EFI_GUID efi_simple_text_input_protocol_guid
Simple text input protocol GUID.
Definition: efi_guid.c:348
#define TPL_HIGH_LEVEL
Definition: UefiSpec.h:650
EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation
Definition: UefiSpec.h:2001
#define CODEVIEW_SIGNATURE_NB10
Debug Data Structure defined in Microsoft C++.
Definition: PeImage.h:658
EFI API.
static const char * efi_conout_name(EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *output)
Get console output handle name.
Definition: efi_debug.c:577
UINT32 e_lfanew
File address of new exe header.
Definition: PeImage.h:77
static const char * efi_first_loaded_image_name(EFI_LOADED_IMAGE_PROTOCOL *loaded)
Get initial loaded image name.
Definition: efi_debug.c:525
UINTN EFI_TPL
Task priority level.
Definition: UefiBaseType.h:43
UINT16 e_magic
Magic number.
Definition: PeImage.h:59
EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle
Definition: UefiSpec.h:2006
EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES]
Definition: PeImage.h:186
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
Definition: UefiBaseType.h:31
EFI_GUID * protocol
Protocol.
Definition: efi_debug.c:593
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
An EFI handle name type.
Definition: efi_debug.c:591
const char * efi_open_attributes_name(unsigned int attributes)
Name protocol open attributes.
Definition: efi_debug.c:102
#define FALSE
Definition: tlan.h:45
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:1530
EFI_IMAGE_NT_HEADERS64 Pe32Plus
Definition: PeImage.h:806
EFI_SYSTEM_TABLE * efi_systab
EFI_GUID efi_component_name_protocol_guid
Component name protocol GUID.
Definition: efi_guid.c:156
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:144
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
Definition: PeImage.h:195
static const char * efi_binding_name2(EFI_DRIVER_BINDING_PROTOCOL *binding)
Get driver binding name.
Definition: efi_debug.c:376
EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText
uint16_t handle
Handle.
Definition: smbios.h:16
EFI_GUID efi_driver_binding_protocol_guid
Driver binding protocol GUID.
Definition: efi_guid.c:208
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
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:652
Definition: efi.h:61
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:246
const char * efi_tpl_name(EFI_TPL tpl)
Name EFI TPL.
Definition: efi_debug.c:55
#define DBG2(...)
Definition: compiler.h:515
Base16 encoding.