Intel Extensible Firmware Interface User Manual

Page 263

Advertising
background image

Protocols

— EFI Driver Model

Version 1.10

12/01/02

9-21

Listed below is sample code of the

Stop()

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

in

Start()

. The

gBS

variable is initialized in this driver’s entry point.

See Chapter 4.

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

EFI_STATUS
AbcStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)

{
EFI_STATUS Status;
EFI_ABC_IO AbcIo;
EFI_ABC_DEVICE AbcDevice;

//
// Get our context back
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiAbcIoProtocolGuid,
&AbcIo,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}

//
// Use Containment Record Macro to get AbcDevice structure from
// a pointer to the AbcIo structure within the AbcDevice structure.
//
AbcDevice = ABC_IO_PRIVATE_DATA_FROM_THIS (AbcIo);

Advertising