From 1920aa43764981597da57616cdb75c040d730712 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 20 Mar 2013 15:25:16 +0000 Subject: [efi] Provide efi_guid_ntoa() for printing EFI GUIDs Signed-off-by: Michael Brown --- src/interface/efi/efi_debug.c | 25 ++++++++++++++++++++++--- src/interface/efi/efi_file.c | 5 ++--- src/interface/efi/efi_init.c | 13 +++++++------ 3 files changed, 31 insertions(+), 12 deletions(-) (limited to 'src/interface/efi') diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index 7f3c115d5..a7ba7e2ed 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -27,6 +27,8 @@ FILE_LICENCE ( GPL2_OR_LATER ); */ #include +#include +#include #include #include #include @@ -36,6 +38,24 @@ FILE_LICENCE ( GPL2_OR_LATER ); static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *efidpt; EFI_REQUIRE_PROTOCOL ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt ); +/** + * Convert GUID to a printable string + * + * @v guid GUID + * @ret string Printable string + */ +const char * efi_guid_ntoa ( EFI_GUID *guid ) { + union { + union uuid uuid; + EFI_GUID guid; + } u; + + /* Convert GUID to standard endianness */ + memcpy ( &u.guid, guid, sizeof ( u.guid ) ); + uuid_mangle ( &u.uuid ); + return uuid_ntoa ( &u.uuid ); +} + /** * Print list of protocol handlers attached to a handle * @@ -57,9 +77,8 @@ void dbg_efi_protocols ( EFI_HANDLE handle ) { } /* Dump list of protocols */ - for ( i = 0 ; i < count ; i++ ) { - printf ( "%s\n", uuid_ntoa ( ( union uuid * ) protocols[i] ) ); - } + for ( i = 0 ; i < count ; i++ ) + printf ( "%s\n", efi_guid_ntoa ( protocols[i] ) ); /* Free list */ bs->FreePool ( protocols ); diff --git a/src/interface/efi/efi_file.c b/src/interface/efi/efi_file.c index ffe25fd66..6f9d44f83 100644 --- a/src/interface/efi/efi_file.c +++ b/src/interface/efi/efi_file.c @@ -414,8 +414,7 @@ static EFI_STATUS EFIAPI efi_file_get_info ( EFI_FILE_PROTOCOL *this, } else { DBGC ( file, "EFIFILE %s cannot get information of type %s\n", - efi_file_name ( file ), - uuid_ntoa ( ( union uuid * ) type ) ); + efi_file_name ( file ), efi_guid_ntoa ( type ) ); return EFI_UNSUPPORTED; } } @@ -435,7 +434,7 @@ efi_file_set_info ( EFI_FILE_PROTOCOL *this, EFI_GUID *type, struct efi_file *file = container_of ( this, struct efi_file, file ); DBGC ( file, "EFIFILE %s cannot set information of type %s\n", - efi_file_name ( file ), uuid_ntoa ( ( union uuid * ) type ) ); + efi_file_name ( file ), efi_guid_ntoa ( type ) ); return EFI_WRITE_PROTECTED; } diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index aaf894718..48cac538f 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -121,13 +121,14 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, /* Look up used protocols */ for_each_table_entry ( prot, EFI_PROTOCOLS ) { - if ( ( efirc = bs->LocateProtocol ( &prot->u.guid, NULL, + if ( ( efirc = bs->LocateProtocol ( &prot->guid, NULL, prot->protocol ) ) == 0 ) { DBGC ( systab, "EFI protocol %s is at %p\n", - uuid_ntoa ( &prot->u.uuid ), *(prot->protocol)); + efi_guid_ntoa ( &prot->guid ), + *(prot->protocol) ); } else { DBGC ( systab, "EFI does not provide protocol %s\n", - uuid_ntoa ( &prot->u.uuid ) ); + efi_guid_ntoa ( &prot->guid ) ); /* All protocols are required */ return efirc; } @@ -135,12 +136,12 @@ EFI_STATUS efi_init ( EFI_HANDLE image_handle, /* Look up used configuration tables */ for_each_table_entry ( tab, EFI_CONFIG_TABLES ) { - if ( ( *(tab->table) = efi_find_table ( &tab->u.guid ) ) ) { + if ( ( *(tab->table) = efi_find_table ( &tab->guid ) ) ) { DBGC ( systab, "EFI configuration table %s is at %p\n", - uuid_ntoa ( &tab->u.uuid ), *(tab->table) ); + efi_guid_ntoa ( &tab->guid ), *(tab->table) ); } else { DBGC ( systab, "EFI does not provide configuration " - "table %s\n", uuid_ntoa ( &tab->u.uuid ) ); + "table %s\n", efi_guid_ntoa ( &tab->guid ) ); if ( tab->required ) return EFI_NOT_AVAILABLE_YET; } -- cgit v1.2.3-55-g7522