Intel Extensible Firmware Interface User Manual

Page 251

Advertising
background image

Protocols

— EFI Driver Model

Version 1.10

12/01/02

9-9

Listed below is sample code of the

Supported()

function of device driver for a device on the

XYZ bus. The XYZ bus is abstracted with the

EFI_XYZ_IO_PROTOCOL

. Just the presence of

the

EFI_XYZ_IO_PROTOCOL

on

ControllerHandle

is enough to determine if this driver

supports

ControllerHandle

. The

gBS

variable is initialized in this driver’s entry point. See

Chapter 4.


extern EFI_GUID gEfiXyzIoProtocol;
EFI_BOOT_SERVICES_TABLE *gBS;

EFI_STATUS
AbcSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)

{
EFI_STATUS Status;
EFI_XYZ_IO_PROTOCOL *XyzIo;

Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiXyzIoProtocol,
&XyzIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}

gBS->CloseProtocol (
ControllerHandle,
&gEfiXyzIoProtocol,
This->DriverBindingHandle,
ControllerHandle
);

return EFI_SUCCESS;
}

Advertising