Download UEFI Driver Writer`s Guide

Transcript
20.2
SCSI Bus Driver
EDK II contains a generic SCSI bus driver. This driver uses the services of
EFI_EXT_SCSI_PASS_THRU_PROTOCOL to enumerate SCSI devices and produce child handles
with EFI_DEVICE_PATH_PROTOCOL and EFI_SCSI_IO_PROTOCOL. The implementation of the
SCSI Bus Driver is found in the MdeModulePkg in the directory
MdeModulePkg/Bus/Scsi/ScsiBusDxe.
If UEFI-based system firmware is ported to a new platform, most of the SCSI-related
changes occur in the implementation of the SCSI host controller driver. If new types of
SCSI devices are introduced that are required to provide a console or provide a UEFI
boot capability, then the implementation of new SCSI Device Drivers are also required.
The SCSI bus driver is designed to be a generic, platform-agnostic driver. As a result,
customizing the SCSI bus driver is strongly discouraged. The detailed design and
implementation of the SCSI bus driver is not covered in this guide
20.3
SCSI Device Driver
SCSI device drivers use services provided by EFI_SCSI_IO_PROTOCOL to produce one or
more protocols that provide I/O abstractions of a SCSI device. SCSI device drivers
must follow the UEFI Driver Model. The EDK II provides a SCSI Device Driver for blockoriented SCSI devices such as hard drives, CD-ROM, and DVD-ROM. The
implementation of the SCSI Disk Driver is found in the MdeModulePkg in the directory
MdeModulePkg/Bus/Scsi/ScsiDiskDxe.
20.3.1
Driver Binding Protocol Supported()
SCSI device drivers and must implement the EFI_DRIVER_BINDING_PROTOCOL that contains
the Supported(), Start(), and Stop() services. The Supported() service checks the
controller handle that has been passed in to see whether this handle represents a SCSI
device that this driver knows how to manage.
The following is the most common method for doing the check:
•
Check if this handle has EFI_SCSI_IO_PROTOCOL installed. If not, this handle is
not a SCSI device on the current SCSI channel.
•
Retrieve the 8-bit SCSI device type to see if the type is one that this driver can
manage.
If the above two checks are passed, it means that the SCSI device driver can manage
the device that the controller handle represents. The Supported() service returns
EFI_SUCCESS. Otherwise, the Supported() service returns EFI_UNSUPPORTED. In addition,
this check process must not disturb the current state of the SCSI device, because a
another SCSI device driver may be managing this SCSI device.
The following example shows an implementation of the Driver Binding Protocol
Supported() service for a SCSI mass storage device. It opens the SCSI I/O Protocol
with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. It then used the GetDeviceType()
service of the SCSI I/O Protocol and evaluates the type information to see if it is a hard
drive or a CD-ROM.
410
3/8/2012
Version 1.01