]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Include protocol interface address in debug output
authorMichael Brown <mcb30@ipxe.org>
Thu, 8 Jun 2023 10:15:27 +0000 (11:15 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 8 Jun 2023 10:15:27 +0000 (11:15 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/efi/efi.h
src/interface/efi/efi_debug.c

index 0bf16e3040abd52225e3cdf00670369ca26338e2..2137b824d1b0f933e90a2388dc09eb3fcda184a8 100644 (file)
@@ -269,6 +269,7 @@ efi_handle_name ( EFI_HANDLE handle );
 extern void dbg_efi_opener ( EFI_HANDLE handle, EFI_GUID *protocol,
                             EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *opener );
 extern void dbg_efi_openers ( EFI_HANDLE handle, EFI_GUID *protocol );
+extern void dbg_efi_protocol ( EFI_HANDLE handle, EFI_GUID *protocol );
 extern void dbg_efi_protocols ( EFI_HANDLE handle );
 
 #define DBG_EFI_OPENER_IF( level, handle, protocol,            \
@@ -303,6 +304,12 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle );
                DBG_DC_IF ( level );                            \
        } while ( 0 )
 
+#define DBGC_EFI_PROTOCOL_IF( level, id, ... ) do {            \
+               DBG_AC_IF ( level, id );                        \
+               DBG_EFI_PROTOCOL_IF ( level, __VA_ARGS__ );     \
+               DBG_DC_IF ( level );                            \
+       } while ( 0 )
+
 #define DBGC_EFI_PROTOCOLS_IF( level, id, ... ) do {           \
                DBG_AC_IF ( level, id );                        \
                DBG_EFI_PROTOCOLS_IF ( level, __VA_ARGS__ );    \
@@ -313,6 +320,8 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle );
        DBGC_EFI_OPENER_IF ( LOG, ##__VA_ARGS__ )
 #define DBGC_EFI_OPENERS( ... )                                        \
        DBGC_EFI_OPENERS_IF ( LOG, ##__VA_ARGS__ )
+#define DBGC_EFI_PROTOCOL( ... )                               \
+       DBGC_EFI_PROTOCOL_IF ( LOG, ##__VA_ARGS__ )
 #define DBGC_EFI_PROTOCOLS( ... )                              \
        DBGC_EFI_PROTOCOLS_IF ( LOG, ##__VA_ARGS__ )
 
@@ -320,6 +329,8 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle );
        DBGC_EFI_OPENER_IF ( EXTRA, ##__VA_ARGS__ )
 #define DBGC2_EFI_OPENERS( ... )                               \
        DBGC_EFI_OPENERS_IF ( EXTRA, ##__VA_ARGS__ )
+#define DBGC2_EFI_PROTOCOL( ... )                              \
+       DBGC_EFI_PROTOCOL_IF ( EXTRA, ##__VA_ARGS__ )
 #define DBGC2_EFI_PROTOCOLS( ... )                             \
        DBGC_EFI_PROTOCOLS_IF ( EXTRA, ##__VA_ARGS__ )
 
@@ -327,6 +338,8 @@ extern void dbg_efi_protocols ( EFI_HANDLE handle );
        DBGC_EFI_OPENER_IF ( PROFILE, ##__VA_ARGS__ )
 #define DBGCP_EFI_OPENERS( ... )                               \
        DBGC_EFI_OPENERS_IF ( PROFILE, ##__VA_ARGS__ )
+#define DBGCP_EFI_PROTOCOL( ... )                              \
+       DBGC_EFI_PROTOCOL_IF ( PROFILE, ##__VA_ARGS__ )
 #define DBGCP_EFI_PROTOCOLS( ... )                             \
        DBGC_EFI_PROTOCOLS_IF ( PROFILE, ##__VA_ARGS__ )
 
index 1bec758fe2562a26857db9726273b8f82f470878..1372776fe312001b8aa89058817f383492d5abfa 100644 (file)
@@ -386,6 +386,34 @@ void dbg_efi_openers ( EFI_HANDLE handle, EFI_GUID *protocol ) {
        bs->FreePool ( openers );
 }
 
+/**
+ * Print protocol information on a given handle
+ *
+ * @v handle           EFI handle
+ * @v protocol         Protocol GUID
+ */
+void dbg_efi_protocol ( EFI_HANDLE handle, EFI_GUID *protocol ) {
+       EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+       VOID *interface;
+       EFI_STATUS efirc;
+       int rc;
+
+       /* Get protocol instance */
+       if ( ( efirc = bs->HandleProtocol ( handle, protocol,
+                                           &interface ) ) != 0 ) {
+               rc = -EEFI ( efirc );
+               printf ( "HANDLE %s could not identify %s: %s\n",
+                        efi_handle_name ( handle ),
+                        efi_guid_ntoa ( protocol ), strerror ( rc ) );
+               return;
+       }
+       printf ( "HANDLE %s %s at %p\n", efi_handle_name ( handle ),
+                efi_guid_ntoa ( protocol ), interface );
+
+       /* Dump list of openers */
+       dbg_efi_openers ( handle, protocol );
+}
+
 /**
  * Print list of protocol handlers attached to a handle
  *
@@ -394,7 +422,6 @@ void dbg_efi_openers ( EFI_HANDLE handle, EFI_GUID *protocol ) {
 void dbg_efi_protocols ( EFI_HANDLE handle ) {
        EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
        EFI_GUID **protocols;
-       EFI_GUID *protocol;
        UINTN count;
        unsigned int i;
        EFI_STATUS efirc;
@@ -417,10 +444,7 @@ void dbg_efi_protocols ( EFI_HANDLE handle ) {
 
        /* Dump list of protocols */
        for ( i = 0 ; i < count ; i++ ) {
-               protocol = protocols[i];
-               printf ( "HANDLE %s %s supported\n", efi_handle_name ( handle ),
-                        efi_guid_ntoa ( protocol ) );
-               dbg_efi_openers ( handle, protocol );
+               dbg_efi_protocol ( handle, protocols[i] );
        }
 
        /* Free list */