You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

efi_debug.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  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. FILE_LICENCE ( GPL2_OR_LATER );
  20. /**
  21. * @file
  22. *
  23. * EFI debugging utilities
  24. *
  25. */
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include <errno.h>
  29. #include <ipxe/uuid.h>
  30. #include <ipxe/base16.h>
  31. #include <ipxe/efi/efi.h>
  32. #include <ipxe/efi/efi_utils.h>
  33. #include <ipxe/efi/Protocol/ComponentName.h>
  34. #include <ipxe/efi/Protocol/ComponentName2.h>
  35. #include <ipxe/efi/Protocol/DevicePathToText.h>
  36. #include <ipxe/efi/IndustryStandard/PeImage.h>
  37. /** Device path to text protocol */
  38. static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *efidpt;
  39. EFI_REQUEST_PROTOCOL ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt );
  40. /** A well-known GUID */
  41. struct efi_well_known_guid {
  42. /** GUID */
  43. EFI_GUID *guid;
  44. /** Name */
  45. const char *name;
  46. };
  47. /** Well-known GUIDs */
  48. static struct efi_well_known_guid efi_well_known_guids[] = {
  49. { &efi_block_io_protocol_guid,
  50. "BlockIo" },
  51. { &efi_bus_specific_driver_override_protocol_guid,
  52. "BusSpecificDriverOverride" },
  53. { &efi_component_name2_protocol_guid,
  54. "ComponentName2" },
  55. { &efi_component_name_protocol_guid,
  56. "ComponentName" },
  57. { &efi_device_path_protocol_guid,
  58. "DevicePath" },
  59. { &efi_driver_binding_protocol_guid,
  60. "DriverBinding" },
  61. { &efi_disk_io_protocol_guid,
  62. "DiskIo" },
  63. { &efi_graphics_output_protocol_guid,
  64. "GraphicsOutput" },
  65. { &efi_hii_config_access_protocol_guid,
  66. "HiiConfigAccess" },
  67. { &efi_load_file_protocol_guid,
  68. "LoadFile" },
  69. { &efi_load_file2_protocol_guid,
  70. "LoadFile2" },
  71. { &efi_loaded_image_protocol_guid,
  72. "LoadedImage" },
  73. { &efi_loaded_image_device_path_protocol_guid,
  74. "LoadedImageDevicePath"},
  75. { &efi_nii_protocol_guid,
  76. "Nii" },
  77. { &efi_nii31_protocol_guid,
  78. "Nii31" },
  79. { &efi_pci_io_protocol_guid,
  80. "PciIo" },
  81. { &efi_pci_root_bridge_io_protocol_guid,
  82. "PciRootBridgeIo" },
  83. { &efi_pxe_base_code_protocol_guid,
  84. "PxeBaseCode" },
  85. { &efi_simple_file_system_protocol_guid,
  86. "SimpleFileSystem" },
  87. { &efi_simple_network_protocol_guid,
  88. "SimpleNetwork" },
  89. { &efi_tcg_protocol_guid,
  90. "Tcg" },
  91. };
  92. /**
  93. * Convert GUID to a printable string
  94. *
  95. * @v guid GUID
  96. * @ret string Printable string
  97. */
  98. const char * efi_guid_ntoa ( EFI_GUID *guid ) {
  99. union {
  100. union uuid uuid;
  101. EFI_GUID guid;
  102. } u;
  103. unsigned int i;
  104. /* Sanity check */
  105. if ( ! guid )
  106. return NULL;
  107. /* Check for a match against well-known GUIDs */
  108. for ( i = 0 ; i < ( sizeof ( efi_well_known_guids ) /
  109. sizeof ( efi_well_known_guids[0] ) ) ; i++ ) {
  110. if ( memcmp ( guid, efi_well_known_guids[i].guid,
  111. sizeof ( *guid ) ) == 0 ) {
  112. return efi_well_known_guids[i].name;
  113. }
  114. }
  115. /* Convert GUID to standard endianness */
  116. memcpy ( &u.guid, guid, sizeof ( u.guid ) );
  117. uuid_mangle ( &u.uuid );
  118. return uuid_ntoa ( &u.uuid );
  119. }
  120. /**
  121. * Name protocol open attributes
  122. *
  123. * @v attributes Protocol open attributes
  124. * @ret name Protocol open attributes name
  125. *
  126. * Returns a (static) string with characters for each set bit
  127. * corresponding to BY_(H)ANDLE_PROTOCOL, (G)ET_PROTOCOL,
  128. * (T)EST_PROTOCOL, BY_(C)HILD_CONTROLLER, BY_(D)RIVER, and
  129. * E(X)CLUSIVE.
  130. */
  131. static const char * efi_open_attributes_name ( unsigned int attributes ) {
  132. static char attribute_chars[] = "HGTCDX";
  133. static char name[ sizeof ( attribute_chars ) ];
  134. char *tmp = name;
  135. unsigned int i;
  136. for ( i = 0 ; i < ( sizeof ( attribute_chars ) - 1 ) ; i++ ) {
  137. if ( attributes & ( 1 << i ) )
  138. *(tmp++) = attribute_chars[i];
  139. }
  140. *tmp = '\0';
  141. return name;
  142. }
  143. /**
  144. * Print list of openers of a given protocol on a given handle
  145. *
  146. * @v handle EFI handle
  147. * @v protocol Protocol GUID
  148. */
  149. void dbg_efi_openers ( EFI_HANDLE handle, EFI_GUID *protocol ) {
  150. EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
  151. EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *openers;
  152. EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener;
  153. UINTN count;
  154. unsigned int i;
  155. EFI_STATUS efirc;
  156. int rc;
  157. /* Sanity check */
  158. if ( ( ! handle ) || ( ! protocol ) ) {
  159. printf ( "EFI could not retrieve openers for %s on %p\n",
  160. efi_guid_ntoa ( protocol ), handle );
  161. return;
  162. }
  163. /* Retrieve list of openers */
  164. if ( ( efirc = bs->OpenProtocolInformation ( handle, protocol, &openers,
  165. &count ) ) != 0 ) {
  166. rc = -EEFI ( efirc );
  167. printf ( "EFI could not retrieve openers for %s on %p: %s\n",
  168. efi_guid_ntoa ( protocol ), handle, strerror ( rc ) );
  169. return;
  170. }
  171. /* Dump list of openers */
  172. for ( i = 0 ; i < count ; i++ ) {
  173. opener = &openers[i];
  174. printf ( "HANDLE %p %s %s opened %dx (%s)",
  175. handle, efi_handle_name ( handle ),
  176. efi_guid_ntoa ( protocol ), opener->OpenCount,
  177. efi_open_attributes_name ( opener->Attributes ) );
  178. printf ( " by %p %s", opener->AgentHandle,
  179. efi_handle_name ( opener->AgentHandle ) );
  180. if ( opener->ControllerHandle == handle ) {
  181. printf ( "\n" );
  182. } else {
  183. printf ( " for %p %s\n", opener->ControllerHandle,
  184. efi_handle_name ( opener->ControllerHandle ) );
  185. }
  186. }
  187. /* Free list */
  188. bs->FreePool ( openers );
  189. }
  190. /**
  191. * Print list of protocol handlers attached to a handle
  192. *
  193. * @v handle EFI handle
  194. */
  195. void dbg_efi_protocols ( EFI_HANDLE handle ) {
  196. EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
  197. EFI_GUID **protocols;
  198. EFI_GUID *protocol;
  199. UINTN count;
  200. unsigned int i;
  201. EFI_STATUS efirc;
  202. int rc;
  203. /* Sanity check */
  204. if ( ! handle ) {
  205. printf ( "EFI could not retrieve protocols for %p\n", handle );
  206. return;
  207. }
  208. /* Retrieve list of protocols */
  209. if ( ( efirc = bs->ProtocolsPerHandle ( handle, &protocols,
  210. &count ) ) != 0 ) {
  211. rc = -EEFI ( efirc );
  212. printf ( "EFI could not retrieve protocols for %p: %s\n",
  213. handle, strerror ( rc ) );
  214. return;
  215. }
  216. /* Dump list of protocols */
  217. for ( i = 0 ; i < count ; i++ ) {
  218. protocol = protocols[i];
  219. printf ( "HANDLE %p %s %s supported\n",
  220. handle, efi_handle_name ( handle ),
  221. efi_guid_ntoa ( protocol ) );
  222. dbg_efi_openers ( handle, protocol );
  223. }
  224. /* Free list */
  225. bs->FreePool ( protocols );
  226. }
  227. /**
  228. * Get textual representation of device path
  229. *
  230. * @v path Device path
  231. * @ret text Textual representation of device path, or NULL
  232. */
  233. const char * efi_devpath_text ( EFI_DEVICE_PATH_PROTOCOL *path ) {
  234. EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
  235. static char text[256];
  236. void *start;
  237. void *end;
  238. size_t max_len;
  239. size_t len;
  240. CHAR16 *wtext;
  241. /* Sanity checks */
  242. if ( ! path ) {
  243. DBG ( "[NULL DevicePath]" );
  244. return NULL;
  245. }
  246. /* If we have no DevicePathToText protocol then use a raw hex string */
  247. if ( ! efidpt ) {
  248. DBG ( "[No DevicePathToText]" );
  249. start = path;
  250. end = efi_devpath_end ( path );
  251. len = ( end - start );
  252. max_len = ( ( sizeof ( text ) - 1 /* NUL */ ) / 2 /* "xx" */ );
  253. if ( len > max_len )
  254. len = max_len;
  255. base16_encode ( start, len, text );
  256. return text;
  257. }
  258. /* Convert path to a textual representation */
  259. wtext = efidpt->ConvertDevicePathToText ( path, TRUE, FALSE );
  260. if ( ! wtext )
  261. return NULL;
  262. /* Store path in buffer */
  263. snprintf ( text, sizeof ( text ), "%ls", wtext );
  264. /* Free path */
  265. bs->FreePool ( wtext );
  266. return text;
  267. }
  268. /**
  269. * Get driver name
  270. *
  271. * @v wtf Component name protocol
  272. * @ret name Driver name, or NULL
  273. */
  274. static const char * efi_driver_name ( EFI_COMPONENT_NAME_PROTOCOL *wtf ) {
  275. static char name[64];
  276. CHAR16 *driver_name;
  277. EFI_STATUS efirc;
  278. /* Sanity check */
  279. if ( ! wtf ) {
  280. DBG ( "[NULL ComponentName]" );
  281. return NULL;
  282. }
  283. /* Try "eng" first; if that fails then try the first language */
  284. if ( ( ( efirc = wtf->GetDriverName ( wtf, "eng",
  285. &driver_name ) ) != 0 ) &&
  286. ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
  287. &driver_name ) ) != 0 ) ) {
  288. return NULL;
  289. }
  290. /* Convert name from CHAR16 to char */
  291. snprintf ( name, sizeof ( name ), "%ls", driver_name );
  292. return name;
  293. }
  294. /**
  295. * Get driver name
  296. *
  297. * @v wtf Component name protocol
  298. * @ret name Driver name, or NULL
  299. */
  300. static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) {
  301. static char name[64];
  302. CHAR16 *driver_name;
  303. EFI_STATUS efirc;
  304. /* Sanity check */
  305. if ( ! wtf ) {
  306. DBG ( "[NULL ComponentName2]" );
  307. return NULL;
  308. }
  309. /* Try "en" first; if that fails then try the first language */
  310. if ( ( ( efirc = wtf->GetDriverName ( wtf, "en",
  311. &driver_name ) ) != 0 ) &&
  312. ( ( efirc = wtf->GetDriverName ( wtf, wtf->SupportedLanguages,
  313. &driver_name ) ) != 0 ) ) {
  314. return NULL;
  315. }
  316. /* Convert name from CHAR16 to char */
  317. snprintf ( name, sizeof ( name ), "%ls", driver_name );
  318. return name;
  319. }
  320. /**
  321. * Get PE/COFF debug filename
  322. *
  323. * @v loaded Loaded image
  324. * @ret name PE/COFF debug filename, or NULL
  325. */
  326. static const char *
  327. efi_pecoff_debug_name ( EFI_LOADED_IMAGE_PROTOCOL *loaded ) {
  328. static char buf[32];
  329. EFI_IMAGE_DOS_HEADER *dos;
  330. EFI_IMAGE_OPTIONAL_HEADER_UNION *pe;
  331. EFI_IMAGE_OPTIONAL_HEADER32 *opt32;
  332. EFI_IMAGE_OPTIONAL_HEADER64 *opt64;
  333. EFI_IMAGE_DATA_DIRECTORY *datadir;
  334. EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *debug;
  335. EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY *codeview_nb10;
  336. EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY *codeview_rsds;
  337. EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY *codeview_mtoc;
  338. uint16_t dos_magic;
  339. uint32_t pe_magic;
  340. uint16_t opt_magic;
  341. uint32_t codeview_magic;
  342. size_t max_len;
  343. char *name;
  344. char *tmp;
  345. /* Sanity check */
  346. if ( ! loaded ) {
  347. DBG ( "[NULL LoadedImage]" );
  348. return NULL;
  349. }
  350. /* Parse DOS header */
  351. dos = loaded->ImageBase;
  352. if ( ! dos ) {
  353. DBG ( "[Missing DOS header]" );
  354. return NULL;
  355. }
  356. dos_magic = dos->e_magic;
  357. if ( dos_magic != EFI_IMAGE_DOS_SIGNATURE ) {
  358. DBG ( "[Bad DOS signature %#04x]", dos_magic );
  359. return NULL;
  360. }
  361. pe = ( loaded->ImageBase + dos->e_lfanew );
  362. /* Parse PE header */
  363. pe_magic = pe->Pe32.Signature;
  364. if ( pe_magic != EFI_IMAGE_NT_SIGNATURE ) {
  365. DBG ( "[Bad PE signature %#08x]", pe_magic );
  366. return NULL;
  367. }
  368. opt32 = &pe->Pe32.OptionalHeader;
  369. opt64 = &pe->Pe32Plus.OptionalHeader;
  370. opt_magic = opt32->Magic;
  371. if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ) {
  372. datadir = opt32->DataDirectory;
  373. } else if ( opt_magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC ) {
  374. datadir = opt64->DataDirectory;
  375. } else {
  376. DBG ( "[Bad optional header signature %#04x]", opt_magic );
  377. return NULL;
  378. }
  379. /* Parse data directory entry */
  380. if ( ! datadir[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress ) {
  381. DBG ( "[Empty debug directory entry]" );
  382. return NULL;
  383. }
  384. debug = ( loaded->ImageBase +
  385. datadir[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress );
  386. /* Parse debug directory entry */
  387. if ( debug->Type != EFI_IMAGE_DEBUG_TYPE_CODEVIEW ) {
  388. DBG ( "[Not a CodeView debug directory entry (type %d)]",
  389. debug->Type );
  390. return NULL;
  391. }
  392. codeview_nb10 = ( loaded->ImageBase + debug->RVA );
  393. codeview_rsds = ( loaded->ImageBase + debug->RVA );
  394. codeview_mtoc = ( loaded->ImageBase + debug->RVA );
  395. codeview_magic = codeview_nb10->Signature;
  396. /* Parse CodeView entry */
  397. if ( codeview_magic == CODEVIEW_SIGNATURE_NB10 ) {
  398. name = ( ( void * ) ( codeview_nb10 + 1 ) );
  399. } else if ( codeview_magic == CODEVIEW_SIGNATURE_RSDS ) {
  400. name = ( ( void * ) ( codeview_rsds + 1 ) );
  401. } else if ( codeview_magic == CODEVIEW_SIGNATURE_MTOC ) {
  402. name = ( ( void * ) ( codeview_mtoc + 1 ) );
  403. } else {
  404. DBG ( "[Bad CodeView signature %#08x]", codeview_magic );
  405. return NULL;
  406. }
  407. /* Sanity check - avoid scanning endlessly through memory */
  408. max_len = EFI_PAGE_SIZE; /* Reasonably sane */
  409. if ( strnlen ( name, max_len ) == max_len ) {
  410. DBG ( "[Excessively long or invalid CodeView name]" );
  411. return NULL;
  412. }
  413. /* Skip any directory components. We cannot modify this data
  414. * or create a temporary buffer, so do not use basename().
  415. */
  416. while ( ( ( tmp = strchr ( name, '/' ) ) != NULL ) ||
  417. ( ( tmp = strchr ( name, '\\' ) ) != NULL ) ) {
  418. name = ( tmp + 1 );
  419. }
  420. /* Copy base name to buffer */
  421. snprintf ( buf, sizeof ( buf ), "%s", name );
  422. /* Strip file suffix, if present */
  423. if ( ( tmp = strrchr ( name, '.' ) ) != NULL )
  424. *tmp = '\0';
  425. return name;
  426. }
  427. /**
  428. * Get initial loaded image name
  429. *
  430. * @v loaded Loaded image
  431. * @ret name Initial loaded image name, or NULL
  432. */
  433. static const char *
  434. efi_first_loaded_image_name ( EFI_LOADED_IMAGE_PROTOCOL *loaded ) {
  435. /* Sanity check */
  436. if ( ! loaded ) {
  437. DBG ( "[NULL LoadedImage]" );
  438. return NULL;
  439. }
  440. return ( ( loaded->ParentHandle == NULL ) ? "DxeCore(?)" : NULL );
  441. }
  442. /**
  443. * Get loaded image name from file path
  444. *
  445. * @v loaded Loaded image
  446. * @ret name Loaded image name, or NULL
  447. */
  448. static const char *
  449. efi_loaded_image_filepath_name ( EFI_LOADED_IMAGE_PROTOCOL *loaded ) {
  450. /* Sanity check */
  451. if ( ! loaded ) {
  452. DBG ( "[NULL LoadedImage]" );
  453. return NULL;
  454. }
  455. return efi_devpath_text ( loaded->FilePath );
  456. }
  457. /** An EFI handle name type */
  458. struct efi_handle_name_type {
  459. /** Protocol */
  460. EFI_GUID *protocol;
  461. /**
  462. * Get name
  463. *
  464. * @v interface Protocol interface
  465. * @ret name Name of handle, or NULL on failure
  466. */
  467. const char * ( * name ) ( void *interface );
  468. };
  469. /**
  470. * Define an EFI handle name type
  471. *
  472. * @v protocol Protocol interface
  473. * @v name Method to get name
  474. * @ret type EFI handle name type
  475. */
  476. #define EFI_HANDLE_NAME_TYPE( protocol, name ) { \
  477. (protocol), \
  478. ( const char * ( * ) ( void * ) ) (name), \
  479. }
  480. /** EFI handle name types */
  481. static struct efi_handle_name_type efi_handle_name_types[] = {
  482. /* Device path */
  483. EFI_HANDLE_NAME_TYPE ( &efi_device_path_protocol_guid,
  484. efi_devpath_text ),
  485. /* Driver name (for driver image handles) */
  486. EFI_HANDLE_NAME_TYPE ( &efi_component_name2_protocol_guid,
  487. efi_driver_name2 ),
  488. /* Driver name (via obsolete original ComponentName protocol) */
  489. EFI_HANDLE_NAME_TYPE ( &efi_component_name_protocol_guid,
  490. efi_driver_name ),
  491. /* PE/COFF debug filename (for image handles) */
  492. EFI_HANDLE_NAME_TYPE ( &efi_loaded_image_protocol_guid,
  493. efi_pecoff_debug_name ),
  494. /* Loaded image device path (for image handles) */
  495. EFI_HANDLE_NAME_TYPE ( &efi_loaded_image_device_path_protocol_guid,
  496. efi_devpath_text ),
  497. /* First loaded image name (for the DxeCore image) */
  498. EFI_HANDLE_NAME_TYPE ( &efi_loaded_image_protocol_guid,
  499. efi_first_loaded_image_name ),
  500. /* Handle's loaded image file path (for image handles) */
  501. EFI_HANDLE_NAME_TYPE ( &efi_loaded_image_protocol_guid,
  502. efi_loaded_image_filepath_name ),
  503. };
  504. /**
  505. * Get name of an EFI handle
  506. *
  507. * @v handle EFI handle
  508. * @ret text Name of handle, or NULL
  509. */
  510. const char * efi_handle_name ( EFI_HANDLE handle ) {
  511. EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
  512. struct efi_handle_name_type *type;
  513. unsigned int i;
  514. void *interface;
  515. const char *name;
  516. EFI_STATUS efirc;
  517. /* Fail immediately for NULL handles */
  518. if ( ! handle )
  519. return NULL;
  520. /* Try each name type in turn */
  521. for ( i = 0 ; i < ( sizeof ( efi_handle_name_types ) /
  522. sizeof ( efi_handle_name_types[0] ) ) ; i++ ) {
  523. type = &efi_handle_name_types[i];
  524. DBG2 ( "<%d", i );
  525. /* Try to open the applicable protocol */
  526. efirc = bs->OpenProtocol ( handle, type->protocol, &interface,
  527. efi_image_handle, handle,
  528. EFI_OPEN_PROTOCOL_GET_PROTOCOL );
  529. if ( efirc != 0 ) {
  530. DBG2 ( ">" );
  531. continue;
  532. }
  533. /* Try to get name from this protocol */
  534. DBG2 ( "-" );
  535. name = type->name ( interface );
  536. DBG2 ( "%c", ( name ? ( name[0] ? 'Y' : 'E' ) : 'N' ) );
  537. /* Close protocol */
  538. bs->CloseProtocol ( handle, type->protocol,
  539. efi_image_handle, handle );
  540. DBG2 ( ">" );
  541. /* Use this name, if possible */
  542. if ( name && name[0] )
  543. return name;
  544. }
  545. return "UNKNOWN";
  546. }