From be33224754e3e03b11a95a320db08c0cdf047013 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 29 Mar 2025 15:11:57 +0000 Subject: [PATCH] [efi] Show all drivers claiming support for a handle in debug messages 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 --- src/interface/efi/efi_driver.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/interface/efi/efi_driver.c b/src/interface/efi/efi_driver.c index 5e8d253f0..9f2f08846 100644 --- a/src/interface/efi/efi_driver.c +++ b/src/interface/efi/efi_driver.c @@ -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; } /**