]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[efi] Show all drivers claiming support for a handle in debug messages
authorMichael Brown <mcb30@ipxe.org>
Sat, 29 Mar 2025 15:11:57 +0000 (15:11 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sat, 29 Mar 2025 18:44:34 +0000 (18:44 +0000)
UEFI assumes in several places that an image installs only a single
driver binding protocol instance, and that this is installed on the
image handle itself.  We therefore provide a single driver binding
protocol instance, which delegates to the various internal drivers
(for EFI_PCI_IO_PROTOCOL, EFI_USB_IO_PROTOCOL, etc) as appropriate.

The debug messages produced by our Supported() method can end up
slightly misleading, since they will report only the first internal
driver that claims support for a device.  In the common case of the
all-drivers build, there may be multiple drivers that claim support
for the same handle: for example, the PCI, NII, SNP, and MNP drivers
are all likely to initially find the protocols that they need on the
same device handle.

Report all internal drivers that claim support for a device, to avoid
confusing debug messages.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/interface/efi/efi_driver.c

index 5e8d253f0c50b7cd5c48666b57f50b3986a4820a..9f2f08846b378415b5b188bcc02297bce8320f49 100644 (file)
@@ -167,6 +167,7 @@ static EFI_STATUS EFIAPI
 efi_driver_supported ( EFI_DRIVER_BINDING_PROTOCOL *driver __unused,
                       EFI_HANDLE device, EFI_DEVICE_PATH_PROTOCOL *child ) {
        struct efi_driver *efidrv;
+       unsigned int count;
        int rc;
 
        DBGCP ( device, "EFIDRV %s DRIVER_SUPPORTED",
@@ -182,18 +183,24 @@ efi_driver_supported ( EFI_DRIVER_BINDING_PROTOCOL *driver __unused,
                return EFI_ALREADY_STARTED;
        }
 
-       /* Look for a driver claiming to support this device */
+       /* Count drivers claiming to support this device */
+       count = 0;
        for_each_table_entry ( efidrv, EFI_DRIVERS ) {
                if ( ( rc = efidrv->supported ( device ) ) == 0 ) {
                        DBGC ( device, "EFIDRV %s has driver \"%s\"\n",
                               efi_handle_name ( device ), efidrv->name );
-                       return 0;
+                       count++;
                }
        }
-       DBGCP ( device, "EFIDRV %s has no driver\n",
-               efi_handle_name ( device ) );
 
-       return EFI_UNSUPPORTED;
+       /* Check that we have at least one driver */
+       if ( ! count ) {
+               DBGCP ( device, "EFIDRV %s has no driver\n",
+                       efi_handle_name ( device ) );
+               return EFI_UNSUPPORTED;
+       }
+
+       return 0;
 }
 
 /**