7.2.2 Multiple Driver Binding Protocols
If a UEFI driver supports more than one parent I/O abstraction, the driver should produce a Driver Binding Protocol for each of the parent I/O abstractions. For example, a UEFI driver could be written to support more than one type of hardware device (for example, USB and PCI). If code can be shared for the common features of a hardware device, then such a driver might save space and reduce maintenance. Example drivers in the EDK II that produce more than one Driver Binding Protocol are the console platform driver and the console splitter driver. These drivers contain multiple Driver Binding Protocols because they depend on multiple console-related parent I/O abstractions.
The first Driver Binding Protocol is typically installed onto the ImageHandle of the UEFI driver and additional Driver Binding Protocols are installed onto new handles. The UEFI driver library functions used in the previous two examples support the creation of new handles by passing in a
NULL
for the fourth argument. The example below shows the driver entry point for a driver that produces two instances of the Driver Binding Protocol with no optional driver-related protocols. When multiple Driver Binding Protocols are produced by a single driver, the optional driver-related protocols are installed onto the same handles as those of the Driver Binding Protocols.#include <Uefi.h>
#include <Protocol/DriverBinding.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/DebugLib.h>
#define ABC_VERSION 0x10
EFI_DRIVER_BINDING_PROTOCOL gAbcFooDriverBinding = {
AbcFooSupported,
AbcFooStart,
AbcFooStop,
ABC_VERSION,
NULL,
NULL
};
EFI_DRIVER_BINDING_PROTOCOL gAbcBarDriverBinding = {
AbcBarSupported,
AbcBarStart,
AbcBarStop,
ABC_VERSION,
NULL,
NULL
};
EFI_STATUS
EFIAPI
AbcDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
//
// Install first Driver Binding Protocol onto ImageHandle
//
Status = EfiLibInstallDriverBinding (
ImageHandle, // ImageHandle
SystemTable, // SystemTable
&gAbcFooDriverBinding, // DriverBinding
ImageHandle // DriverBindingHandle
);
ASSERT_EFI_ERROR (Status);
//
// Install second Driver Binding Protocol onto a new handle
//
Status = EfiLibInstallDriverBinding (
ImageHandle, // ImageHandle
SystemTable, // SystemTable
&gAbcBarDriverBinding, // DriverBinding
NULL // DriverBindingHandle
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}