Intel Extensible Firmware Interface User Manual

Page 258

Advertising
background image

Extensible Firmware Interface Specification

9-16

12/01/02

Version 1.10

e. Call

OpenProtocol()

on behalf of the child C with an

Attribute

of

EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER

.

8. END

FOR

9. END

IF

10. Return

EFI_SUCCESS

.

Listed below is sample code of the

Start()

function of a device driver for a device on the XYZ

bus. The XYZ bus is abstracted with the

EFI_XYZ_IO_PROTOCOL

. This driver does allow the

EFI_XYZ_IO_PROTOCOL

to be shared with other drivers, and just the presence of the

EFI_XYZ_IO_PROTOCOL

on

ControllerHandle

is enough to determine if this driver

supports

ControllerHandle

. This driver installs the

EFI_ABC_IO_PROTOCOL

on

ControllerHandle

. The

gBS

variable is initialized in this driver’s entry point as shown in the

EFI Driver Model examples in Chapter 4.


extern EFI_GUID gEfiXyzIoProtocol;
extern EFI_GUID gEfiAbcIoProtocol;
EFI_BOOT_SERVICES_TABLE *gBS;

EFI_STATUS
AbcStart (
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;
EFI_ABC_DEVICE AbcDevice;

//
// Open the Xyz I/O Protocol that this driver consumes
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiXyzIoProtocol,
&XyzIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}

//
// Allocate and zero a private data structure for the Abc device.
//
Status = gBS->AllocatePool (
EfiBootServicesData,
sizeof (EFI_ABC_DEVICE),
&AbcDevice
);

Advertising