summaryrefslogtreecommitdiffstats
path: root/src/interface
diff options
context:
space:
mode:
authorMichael Brown2025-03-20 15:18:02 +0100
committerMichael Brown2025-03-20 15:20:36 +0100
commit7cda3dbf94936f265ab017841d0236bb62f51efa (patch)
tree34b91fa2bba4d46704e9130faf406a71c097ea67 /src/interface
parent[efi] Allow wrapping the global boot services table in situ (diff)
downloadipxe-7cda3dbf94936f265ab017841d0236bb62f51efa.tar.gz
ipxe-7cda3dbf94936f265ab017841d0236bb62f51efa.tar.xz
ipxe-7cda3dbf94936f265ab017841d0236bb62f51efa.zip
[efi] Attempt to retrieve driver name from image handle for debug messages
Not all drivers will install the driver binding protocol on the image handle. Accommodate these drivers by attempting to retrieve the driver name via the component name protocol(s) located on the driver binding's ImageHandle, as well as on the driver handle itself. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface')
-rw-r--r--src/interface/efi/efi_debug.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c
index 030c6a93e..1b778805e 100644
--- a/src/interface/efi/efi_debug.c
+++ b/src/interface/efi/efi_debug.c
@@ -38,6 +38,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/efi/efi_path.h>
#include <ipxe/efi/Protocol/ComponentName.h>
#include <ipxe/efi/Protocol/ComponentName2.h>
+#include <ipxe/efi/Protocol/DriverBinding.h>
#include <ipxe/efi/Protocol/DevicePathToText.h>
#include <ipxe/efi/IndustryStandard/PeImage.h>
@@ -321,6 +322,90 @@ static const char * efi_driver_name2 ( EFI_COMPONENT_NAME2_PROTOCOL *wtf ) {
}
/**
+ * Get driver binding name
+ *
+ * @v binding Driver binding protocol
+ * @ret name Driver name, or NULL
+ */
+static const char * efi_binding_name ( EFI_DRIVER_BINDING_PROTOCOL *binding ) {
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ union {
+ EFI_COMPONENT_NAME_PROTOCOL *name;
+ void *interface;
+ } u;
+ EFI_HANDLE image;
+ const char *name;
+ EFI_STATUS efirc;
+
+ /* Sanity check */
+ if ( ! binding ) {
+ DBG ( "[NULL DriverBinding]" );
+ return NULL;
+ }
+
+ /* Try to open component name protocol on image handle */
+ image = binding->ImageHandle;
+ if ( ( efirc = bs->OpenProtocol ( image,
+ &efi_component_name_protocol_guid,
+ &u.interface, efi_image_handle, image,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){
+ DBG ( "[DriverBinding no ComponentName]" );
+ return NULL;
+ }
+
+ /* Try to get name from component name protocol */
+ name = efi_driver_name ( u.name );
+
+ /* Close component name protocol */
+ bs->CloseProtocol ( image, &efi_component_name_protocol_guid,
+ efi_image_handle, image );
+
+ return name;
+}
+
+/**
+ * Get driver binding name
+ *
+ * @v binding Driver binding protocol
+ * @ret name Driver name, or NULL
+ */
+static const char * efi_binding_name2 ( EFI_DRIVER_BINDING_PROTOCOL *binding ){
+ EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
+ EFI_HANDLE image;
+ union {
+ EFI_COMPONENT_NAME2_PROTOCOL *name2;
+ void *interface;
+ } u;
+ const char *name;
+ EFI_STATUS efirc;
+
+ /* Sanity check */
+ if ( ! binding ) {
+ DBG ( "[NULL DriverBinding]" );
+ return NULL;
+ }
+
+ /* Try to open component name protocol on image handle */
+ image = binding->ImageHandle;
+ if ( ( efirc = bs->OpenProtocol ( image,
+ &efi_component_name2_protocol_guid,
+ &u.interface, efi_image_handle, image,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL)) !=0){
+ DBG ( "[DriverBinding no ComponentName2]" );
+ return NULL;
+ }
+
+ /* Try to get name from component name protocol */
+ name = efi_driver_name2 ( u.name2 );
+
+ /* Close component name protocol */
+ bs->CloseProtocol ( image, &efi_component_name2_protocol_guid,
+ efi_image_handle, image );
+
+ return name;
+}
+
+/**
* Get PE/COFF debug filename
*
* @v loaded Loaded image
@@ -547,6 +632,12 @@ static struct efi_handle_name_type efi_handle_name_types[] = {
/* Driver name (via obsolete original ComponentName protocol) */
EFI_HANDLE_NAME_TYPE ( &efi_component_name_protocol_guid,
efi_driver_name ),
+ /* Driver name (for driver binding handles) */
+ EFI_HANDLE_NAME_TYPE ( &efi_driver_binding_protocol_guid,
+ efi_binding_name2 ),
+ /* Driver name (via obsolete original ComponentName protocol) */
+ EFI_HANDLE_NAME_TYPE ( &efi_driver_binding_protocol_guid,
+ efi_binding_name ),
/* PE/COFF debug filename (for image handles) */
EFI_HANDLE_NAME_TYPE ( &efi_loaded_image_protocol_guid,
efi_pecoff_debug_name ),