Overview
Version 1.10 12/01/02 2-13
Figure 2-4 shows the construction of a protocol. The EFI driver contains functions specific to one
or more protocol implementations, and registers them with the Boot Service
InstallProtocolInterface()
. The firmware returns the Protocol Interface for the
protocol that is then used to invoke the protocol specific services. The EFI driver keeps private,
device-specific context with protocol interfaces.
O
M
13147
Protocol Interface
Function Pointer
Function Pointer
Device specific
context
...
GUID 1
GUID 2
Protocol
specific
functions
Protocol
specific
functions
EFI Driver
Invoking one of
the protocol
services
HandleProtocol (GUID, ...)
Handle
Device, or
next Driver
Figure 2-4. Construction of a Protocol
The following C code fragment illustrates the use of protocols:
// There is a global “EffectsDevice” structure. This
// structure contains information pertinent to the device.
// Connect to the ILLUSTRATION_PROTOCOL on the EffectsDevice,
// by calling HandleProtocol with the device’s EFI device handle
// and the ILLUSTRATION_PROTOCOL GUID.
EffectsDevice.Handle = DeviceHandle;
Status = HandleProtocol (
EffectsDevice.EFIHandle,
&IllustrationProtocolGuid,
&EffectsDevice.IllustrationProtocol
);
// Use the EffectsDevice illustration protocol’s “MakeEffects”
// service to make flashy and noisy effects.
Status = EffectsDevice.IllustrationProtocol->MakeEffects (
EffectsDevice.IllustrationProtocol,
TheFlashyAndNoisyEffect
);