Browse Source

[efi] Print raw device path when we have no DevicePathToTextProtocol

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
c77859931d
1 changed files with 18 additions and 4 deletions
  1. 18
    4
      src/interface/efi/efi_debug.c

+ 18
- 4
src/interface/efi/efi_debug.c View File

30
 #include <string.h>
30
 #include <string.h>
31
 #include <errno.h>
31
 #include <errno.h>
32
 #include <ipxe/uuid.h>
32
 #include <ipxe/uuid.h>
33
+#include <ipxe/base16.h>
33
 #include <ipxe/efi/efi.h>
34
 #include <ipxe/efi/efi.h>
34
 #include <ipxe/efi/efi_driver.h>
35
 #include <ipxe/efi/efi_driver.h>
35
 #include <ipxe/efi/Protocol/BlockIo.h>
36
 #include <ipxe/efi/Protocol/BlockIo.h>
316
 const char * efi_devpath_text ( EFI_DEVICE_PATH_PROTOCOL *path ) {
317
 const char * efi_devpath_text ( EFI_DEVICE_PATH_PROTOCOL *path ) {
317
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
318
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
318
 	static char text[256];
319
 	static char text[256];
320
+	void *start;
321
+	void *end;
322
+	size_t max_len;
323
+	size_t len;
319
 	CHAR16 *wtext;
324
 	CHAR16 *wtext;
320
 
325
 
321
 	/* Sanity checks */
326
 	/* Sanity checks */
322
-	if ( ! efidpt ) {
323
-		DBG ( "[No DevicePathToText]" );
324
-		return NULL;
325
-	}
326
 	if ( ! path ) {
327
 	if ( ! path ) {
327
 		DBG ( "[NULL DevicePath]" );
328
 		DBG ( "[NULL DevicePath]" );
328
 		return NULL;
329
 		return NULL;
329
 	}
330
 	}
330
 
331
 
332
+	/* If we have no DevicePathToText protocol then use a raw hex string */
333
+	if ( ! efidpt ) {
334
+		DBG ( "[No DevicePathToText]" );
335
+		start = path;
336
+		end = efi_devpath_end ( path );
337
+		len = ( end - start );
338
+		max_len = ( ( sizeof ( text ) - 1 /* NUL */ ) / 2 /* "xx" */ );
339
+		if ( len > max_len )
340
+			len = max_len;
341
+		base16_encode ( start, len, text );
342
+		return text;
343
+	}
344
+
331
 	/* Convert path to a textual representation */
345
 	/* Convert path to a textual representation */
332
 	wtext = efidpt->ConvertDevicePathToText ( path, TRUE, FALSE );
346
 	wtext = efidpt->ConvertDevicePathToText ( path, TRUE, FALSE );
333
 	if ( ! wtext )
347
 	if ( ! wtext )

Loading…
Cancel
Save