Intel Extensible Firmware Interface User Manual
Page 255

Protocols
— EFI Driver Model
Version 1.10
12/01/02
9-13
Pseudo Code
Listed below are the algorithms for the
function for three different types of drivers.
How the
Start()
function of a driver is implemented can affect how the
function is implemented. All of the services in the
work together to make sure that all resources opened or allocated in
Supported()
and
Start()
The first algorithm is a simple device driver that does not create any additional handles. It only
attaches one or more protocols to an existing handle. The second is a simple bus driver that always
creates all of its child handles on the first call to
Start()
. It does not attach any additional
protocols to the handle for the bus controller. The third is a more advanced bus driver that can
either create one child handles at a time on successive calls to
Start()
, or it can create all of its
child handles or all of the remaining child handles in a single call to
Start()
. Once again, it does
not attach any additional protocols to the handle for the bus controller.
Device Driver:
1. Ignore the parameter
RemainingDevicePath
.
2. Open all required protocols with
. A standard driver should use an
Attribute
of
EFI_OPEN_PROTOCOL_BY_DRIVER
. If this driver needs exclusive access
to a protocol interface, and it requires any drivers that may be using the protocol interface to
disconnect, then the driver should use an
Attribute
of
EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE
. It must
use the same
Attribute
value that was used in
Supported()
.
3. If any of the calls to
OpenProtocol()
in (2) returned an error, then close all of the protocols
opened in (2) with
, and return the status code from the call to
OpenProtocol()
that returned an error.
4. Initialize the device specified by
ControllerHandle
. If an error occurs, close all of the
protocols opened in (2) with
CloseProtocol()
, and return
EFI_DEVICE_ERROR
.
5. Allocate and initialize all of the data structures that this driver requires to manage the device
specified by
ControllerHandle
. This would include space for public protocols and space
for any additional private data structures that are related to
ControllerHandle
. If an error
occurs allocating the resources, then close all of the protocols opened in (2) with
CloseProtocol()
, and return
EFI_OUT_OF_RESOURCES
.
6. Install all the new protocol interfaces onto
ControllerHandle
using
InstallMultipleProtocolInterfaces()
. If an error occurs, close all of the
protocols opened in (1) with
CloseProtocol()
, and return the error from
InstallMultipleProtocolInterfaces
()
.
7. Return
EFI_SUCCESS
.