Skip to content

Commit

Permalink
[efi] Print well-known GUIDs by name in debug messages
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 16, 2014
1 parent c3b6ccf commit d4a7cbf
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/interface/efi/efi_debug.c
Expand Up @@ -34,6 +34,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/Protocol/DevicePath.h>
#include <ipxe/efi/Protocol/DevicePathToText.h>
#include <ipxe/efi/Protocol/BlockIo.h>
#include <ipxe/efi/Protocol/DiskIo.h>
#include <ipxe/efi/Protocol/SimpleFileSystem.h>
#include <ipxe/efi/Protocol/SimpleNetwork.h>

/** Device path protocol GUID */
static EFI_GUID efi_device_path_protocol_guid
Expand All @@ -43,6 +47,24 @@ static EFI_GUID efi_device_path_protocol_guid
static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *efidpt;
EFI_REQUEST_PROTOCOL ( EFI_DEVICE_PATH_TO_TEXT_PROTOCOL, &efidpt );

/** A well-known GUID */
struct efi_well_known_guid {
/** GUID */
EFI_GUID guid;
/** Name */
const char *name;
};

/** Well-known GUIDs */
static struct efi_well_known_guid efi_well_known_guids[] = {
{ EFI_BLOCK_IO_PROTOCOL_GUID, "BlockIo" },
{ EFI_DISK_IO_PROTOCOL_GUID, "DiskIo" },
{ EFI_DEVICE_PATH_PROTOCOL_GUID, "DevicePath" },
{ EFI_LOADED_IMAGE_PROTOCOL_GUID, "LoadedImage" },
{ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, "SimpleFileSystem" },
{ EFI_SIMPLE_NETWORK_PROTOCOL_GUID, "SimpleNetwork" },
};

/**
* Convert GUID to a printable string
*
Expand All @@ -54,6 +76,16 @@ const char * efi_guid_ntoa ( EFI_GUID *guid ) {
union uuid uuid;
EFI_GUID guid;
} u;
unsigned int i;

/* Check for a match against well-known GUIDs */
for ( i = 0 ; i < ( sizeof ( efi_well_known_guids ) /
sizeof ( efi_well_known_guids[0] ) ) ; i++ ) {
if ( memcmp ( guid, &efi_well_known_guids[i].guid,
sizeof ( *guid ) ) == 0 ) {
return efi_well_known_guids[i].name;
}
}

/* Convert GUID to standard endianness */
memcpy ( &u.guid, guid, sizeof ( u.guid ) );
Expand Down

0 comments on commit d4a7cbf

Please sign in to comment.