Intel Extensible Firmware Interface Network Router User Manual


  Open as PDF
of 1084
 
Protocols EFI Driver Model
Version 1.10 12/01/02 9-7
//
// EXAMPLE #2
//
// The RemainingDevicePath parameter can be used to initialize only
// the minimum devices required to boot. For example, maybe we only
// want to initialize 1 hard disk on a SCSI channel. If DriverImageHandle
// is a SCSI Bus Driver, and ControllerHandle is a SCSI Controller, and
// we only want to create a child handle for PUN=3 and LUN=0, then the
// RemainingDevicePath would be SCSI(3,0)/END. The following example
// would return EFI_SUCCESS if the SCSI driver supports creating the
// child handle for PUN=3, LUN=0. Otherwise it would return an error.
//
Status = DriverBinding->Supported (
DriverBinding,
ControllerHandle,
RemainingDevicePath
);
return Status;
Pseudo Code
Listed below are the algorithms for the Supported() function for three different types of
drivers. How the Start()
function of a driver is implemented can affect how the
Supported() function is implemented. All of the services in the
EFI_DRIVER_BINDING_PROTOCOL
need to work together to make sure that all resources
opened or allocated in Supported() and Start() are released in Stop()
.
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 bus driver that always creates
all of its child handles on the first call to Start(). 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().
Device Driver:
1. Ignore the parameter RemainingDevicePath.
2. Open all required protocols with OpenProtocol()
. 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.
3. If any of the calls to OpenProtocol() in (2) returned an error, then close all of the protocols
opened in (2) with CloseProtocol()
, and return the status code from the call to
OpenProtocol() that returned an error.
4. Use the protocol instances opened in (2) to test to see if this driver supports the controller.
Sometimes, just the presence of the protocols is enough of a test. Other times, the services of
the protocols opened in (2) are used to further check the identity of the controller. If any of
these tests fails, then close all the protocols opened in (2) with CloseProtocol() and
return EFI_UNSUPPORTED.
5. Close all protocols opened in (2) with CloseProtocol().
6. Return EFI_SUCCESS.