Code Scrub:
MdeModulePkg\Bus\ScsiBusDxe\ MdeModulePkg\Bus\ScsiDisk\ git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6465 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -12,10 +12,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _SCSI_BUS_H
|
||||
#define _SCSI_BUS_H
|
||||
#ifndef _SCSI_BUS_H_
|
||||
#define _SCSI_BUS_H_
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/ScsiPassThru.h>
|
||||
#include <Protocol/ScsiPassThruExt.h>
|
||||
#include <Protocol/ScsiIo.h>
|
||||
#include <Protocol/ComponentName.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
#include <Protocol/DevicePath.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/UefiDriverEntryPoint.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/ScsiLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
|
||||
#include <IndustryStandard/Scsi.h>
|
||||
//
|
||||
// 1000 * 1000 * 10
|
||||
@@ -89,6 +107,25 @@ extern EFI_DRIVER_BINDING_PROTOCOL gScsiBusDriverBinding;
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gScsiBusComponentName2;
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle.
|
||||
|
||||
This service is called by the EFI boot service ConnectController(). In order
|
||||
to make drivers as small as possible, there are a few calling restrictions for
|
||||
this service. ConnectController() must follow these calling restrictions. If
|
||||
any other agent wishes to call Supported() it must also follow these calling
|
||||
restrictions.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to test
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver supports this device
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on this device
|
||||
@retval other This driver does not support this device
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SCSIBusDriverBindingSupported (
|
||||
@@ -97,6 +134,25 @@ SCSIBusDriverBindingSupported (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle.
|
||||
|
||||
This service is called by the EFI boot service ConnectController(). In order
|
||||
to make drivers as small as possible, there are a few calling restrictions for
|
||||
this service. ConnectController() must follow these calling restrictions. If
|
||||
any other agent wishes to call Start() it must also follow these calling
|
||||
restrictions.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to bind driver to
|
||||
@param RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver is added to ControllerHandle
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
|
||||
@retval other This driver does not support this device
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SCSIBusDriverBindingStart (
|
||||
@@ -105,6 +161,25 @@ SCSIBusDriverBindingStart (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
|
||||
);
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle.
|
||||
|
||||
This service is called by the EFI boot service DisconnectController().
|
||||
In order to make drivers as small as possible, there are a few calling
|
||||
restrictions for this service. DisconnectController() must follow these
|
||||
calling restrictions. If any other agent wishes to call Stop() it must also
|
||||
follow these calling restrictions.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param ControllerHandle Handle of device to stop driver on
|
||||
@param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||
children is zero stop the entire bus driver.
|
||||
@param ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
||||
@retval other This driver was not removed from this device
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
SCSIBusDriverBindingStop (
|
||||
@@ -127,10 +202,10 @@ SCSIBusDriverBindingStop (
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
||||
@param Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
@@ -139,7 +214,7 @@ SCSIBusDriverBindingStop (
|
||||
to the driver writer. Language is specified
|
||||
in RFC 3066 or ISO 639-2 language code format.
|
||||
|
||||
@param DriverName[out] A pointer to the Unicode string to return.
|
||||
@param DriverName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
driver specified by This in the language
|
||||
specified by Language.
|
||||
@@ -164,7 +239,6 @@ ScsiBusComponentNameGetDriverName (
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user readable name of the controller
|
||||
that is being managed by a driver.
|
||||
@@ -178,15 +252,15 @@ ScsiBusComponentNameGetDriverName (
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
@param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param ControllerHandle[in] The handle of a controller that the driver
|
||||
@param ControllerHandle The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
|
||||
@param ChildHandle[in] The handle of the child controller to retrieve
|
||||
@param ChildHandle The handle of the child controller to retrieve
|
||||
the name of. This is an optional parameter that
|
||||
may be NULL. It will be NULL for device
|
||||
drivers. It will also be NULL for a bus drivers
|
||||
@@ -195,7 +269,7 @@ ScsiBusComponentNameGetDriverName (
|
||||
driver that wishes to retrieve the name of a
|
||||
child controller.
|
||||
|
||||
@param Language[in] A pointer to a Null-terminated ASCII string
|
||||
@param Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
@@ -204,7 +278,7 @@ ScsiBusComponentNameGetDriverName (
|
||||
to the driver writer. Language is specified in
|
||||
RFC 3066 or ISO 639-2 language code format.
|
||||
|
||||
@param ControllerName[out] A pointer to the Unicode string to return.
|
||||
@param ControllerName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
controller specified by ControllerHandle and
|
||||
ChildHandle in the language specified by
|
||||
@@ -243,107 +317,87 @@ ScsiBusComponentNameGetControllerName (
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
/**
|
||||
Retrieves the device type information of the SCSI Controller.
|
||||
|
||||
@param This Protocol instance pointer.
|
||||
@param DeviceType A pointer to the device type information retrieved from
|
||||
the SCSI Controller.
|
||||
|
||||
@retval EFI_SUCCESS Retrieves the device type information successfully.
|
||||
@retval EFI_INVALID_PARAMETER The DeviceType is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ScsiGetDeviceType (
|
||||
IN EFI_SCSI_IO_PROTOCOL *This,
|
||||
OUT UINT8 *DeviceType
|
||||
)
|
||||
/*++
|
||||
);
|
||||
|
||||
Routine Description:
|
||||
/**
|
||||
Retrieves the device location in the SCSI channel.
|
||||
|
||||
Retrieves the device type information of the SCSI Controller.
|
||||
|
||||
Arguments:
|
||||
@param This Protocol instance pointer.
|
||||
@param Target A pointer to the Target ID of a SCSI device
|
||||
on the SCSI channel.
|
||||
@param Lun A pointer to the LUN of the SCSI device on
|
||||
the SCSI channel.
|
||||
|
||||
This - Protocol instance pointer.
|
||||
DeviceType - A pointer to the device type information
|
||||
retrieved from the SCSI Controller.
|
||||
@retval EFI_SUCCESS Retrieves the device location successfully.
|
||||
@retval EFI_INVALID_PARAMETER The Target or Lun is NULL.
|
||||
|
||||
Returns:
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ScsiGetDeviceLocation (
|
||||
IN EFI_SCSI_IO_PROTOCOL *This,
|
||||
IN OUT UINT8 **Target,
|
||||
OUT UINT64 *Lun
|
||||
);
|
||||
|
||||
EFI_SUCCESS - Retrieves the device type information successfully.
|
||||
EFI_INVALID_PARAMETER - The DeviceType is NULL.
|
||||
/**
|
||||
Resets the SCSI Bus that the SCSI Controller is attached to.
|
||||
|
||||
--*/
|
||||
;
|
||||
@param This Protocol instance pointer.
|
||||
|
||||
@retval EFI_SUCCESS The SCSI bus is reset successfully.
|
||||
@retval EFI_DEVICE_ERROR Errors encountered when resetting the SCSI bus.
|
||||
@retval EFI_UNSUPPORTED The bus reset operation is not supported by the
|
||||
SCSI Host Controller.
|
||||
@retval EFI_TIMEOUT A timeout occurred while attempting to reset
|
||||
the SCSI bus.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ScsiResetBus (
|
||||
IN EFI_SCSI_IO_PROTOCOL *This
|
||||
)
|
||||
/*++
|
||||
);
|
||||
|
||||
Routine Description:
|
||||
/**
|
||||
Resets the SCSI Controller that the device handle specifies.
|
||||
|
||||
Resets the SCSI Bus that the SCSI Controller is attached to.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - Protocol instance pointer.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - The SCSI bus is reset successfully.
|
||||
EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.
|
||||
EFI_UNSUPPORTED - The bus reset operation is not supported by the
|
||||
SCSI Host Controller.
|
||||
EFI_TIMEOUT - A timeout occurred while attempting to reset
|
||||
the SCSI bus.
|
||||
|
||||
--*/
|
||||
;
|
||||
@param This Protocol instance pointer.
|
||||
|
||||
@retval EFI_SUCCESS Reset the SCSI controller successfully.
|
||||
@retval EFI_DEVICE_ERROR Errors are encountered when resetting the SCSI Controller.
|
||||
@retval EFI_UNSUPPORTED The SCSI bus does not support a device reset operation.
|
||||
@retval EFI_TIMEOUT A timeout occurred while attempting to reset the
|
||||
SCSI Controller.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ScsiResetDevice (
|
||||
IN EFI_SCSI_IO_PROTOCOL *This
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
|
||||
Resets the SCSI Controller that the device handle specifies.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - Protocol instance pointer.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Reset the SCSI controller successfully.
|
||||
EFI_DEVICE_ERROR - Errors are encountered when resetting the
|
||||
SCSI Controller.
|
||||
EFI_UNSUPPORTED - The SCSI bus does not support a device
|
||||
reset operation.
|
||||
EFI_TIMEOUT - A timeout occurred while attempting to
|
||||
reset the SCSI Controller.
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ScsiExecuteSCSICommand (
|
||||
IN EFI_SCSI_IO_PROTOCOL *This,
|
||||
IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket,
|
||||
IN EFI_EVENT Event
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
);
|
||||
|
||||
/**
|
||||
Sends a SCSI Request Packet to the SCSI Controller for execution.
|
||||
|
||||
Arguments:
|
||||
|
||||
This - Protocol instance pointer.
|
||||
Packet - The SCSI request packet to send to the SCSI
|
||||
@param This Protocol instance pointer.
|
||||
@param CommandPacket The SCSI request packet to send to the SCSI
|
||||
Controller specified by the device handle.
|
||||
Event - If the SCSI bus where the SCSI device is attached
|
||||
@param Event If the SCSI bus where the SCSI device is attached
|
||||
does not support non-blocking I/O, then Event is
|
||||
ignored, and blocking I/O is performed.
|
||||
If Event is NULL, then blocking I/O is performed.
|
||||
@@ -351,92 +405,83 @@ Arguments:
|
||||
supported, then non-blocking I/O is performed,
|
||||
and Event will be signaled when the SCSI Request
|
||||
Packet completes.
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - The SCSI Request Packet was sent by the host
|
||||
successfully, and TransferLength bytes were
|
||||
transferred to/from DataBuffer.See
|
||||
HostAdapterStatus, TargetStatus,
|
||||
SenseDataLength, and SenseData in that order
|
||||
for additional status information.
|
||||
EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed,
|
||||
but the entire DataBuffer could not be transferred.
|
||||
The actual number of bytes transferred is returned
|
||||
in TransferLength. See HostAdapterStatus,
|
||||
TargetStatus, SenseDataLength, and SenseData in
|
||||
that order for additional status information.
|
||||
EFI_NOT_READY - The SCSI Request Packet could not be sent because
|
||||
there are too many SCSI Command Packets already
|
||||
queued.The caller may retry again later.
|
||||
EFI_DEVICE_ERROR - A device error occurred while attempting to send
|
||||
the SCSI Request Packet. See HostAdapterStatus,
|
||||
TargetStatus, SenseDataLength, and SenseData in
|
||||
that order for additional status information.
|
||||
EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
|
||||
The SCSI Request Packet was not sent, so no
|
||||
additional status information is available.
|
||||
EFI_UNSUPPORTED - The command described by the SCSI Request Packet
|
||||
is not supported by the SCSI initiator(i.e., SCSI
|
||||
Host Controller). The SCSI Request Packet was not
|
||||
sent, so no additional status information is
|
||||
available.
|
||||
EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
|
||||
Request Packet to execute. See HostAdapterStatus,
|
||||
TargetStatus, SenseDataLength, and SenseData in
|
||||
that order for additional status information.
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
@retval EFI_SUCCESS The SCSI Request Packet was sent by the host
|
||||
successfully, and TransferLength bytes were
|
||||
transferred to/from DataBuffer.See
|
||||
HostAdapterStatus, TargetStatus,
|
||||
SenseDataLength, and SenseData in that order
|
||||
for additional status information.
|
||||
@retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,
|
||||
but the entire DataBuffer could not be transferred.
|
||||
The actual number of bytes transferred is returned
|
||||
in TransferLength. See HostAdapterStatus,
|
||||
TargetStatus, SenseDataLength, and SenseData in
|
||||
that order for additional status information.
|
||||
@retval EFI_NOT_READY The SCSI Request Packet could not be sent because
|
||||
there are too many SCSI Command Packets already
|
||||
queued.The caller may retry again later.
|
||||
@retval EFI_DEVICE_ERROR A device error occurred while attempting to send
|
||||
the SCSI Request Packet. See HostAdapterStatus,
|
||||
TargetStatus, SenseDataLength, and SenseData in
|
||||
that order for additional status information.
|
||||
@retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.
|
||||
The SCSI Request Packet was not sent, so no
|
||||
additional status information is available.
|
||||
@retval EFI_UNSUPPORTED The command described by the SCSI Request Packet
|
||||
is not supported by the SCSI initiator(i.e., SCSI
|
||||
Host Controller). The SCSI Request Packet was not
|
||||
sent, so no additional status information is
|
||||
available.
|
||||
@retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI
|
||||
Request Packet to execute. See HostAdapterStatus,
|
||||
TargetStatus, SenseDataLength, and SenseData in
|
||||
that order for additional status information.
|
||||
**/
|
||||
EFI_STATUS
|
||||
ScsiScanCreateDevice (
|
||||
EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
EFI_HANDLE Controller,
|
||||
SCSI_TARGET_ID *TargetId,
|
||||
UINT64 Lun,
|
||||
SCSI_BUS_DEVICE *ScsiBusDev
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
EFIAPI
|
||||
ScsiExecuteSCSICommand (
|
||||
IN EFI_SCSI_IO_PROTOCOL *This,
|
||||
IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket,
|
||||
IN EFI_EVENT Event OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.
|
||||
|
||||
Arguments:
|
||||
@param This Protocol instance pointer
|
||||
@param Controller Controller handle
|
||||
@param TargetId Tartget to be scanned
|
||||
@param Lun The Lun of the SCSI device on the SCSI channel.
|
||||
@param ScsiBusDev The pointer of SCSI_BUS_DEVICE
|
||||
|
||||
This - Protocol instance pointer
|
||||
Controller - Controller handle
|
||||
Pun - The Pun of the SCSI device on the SCSI channel.
|
||||
Lun - The Lun of the SCSI device on the SCSI channel.
|
||||
ScsiBusDev - The pointer of SCSI_BUS_DEVICE
|
||||
@retval EFI_SUCCESS Successfully to discover the device and attach
|
||||
ScsiIoProtocol to it.
|
||||
@retval EFI_OUT_OF_RESOURCES Fail to discover the device.
|
||||
|
||||
Returns:
|
||||
|
||||
EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.
|
||||
EFI_OUT_OF_RESOURCES - Fail to discover the device.
|
||||
|
||||
--*/
|
||||
;
|
||||
|
||||
BOOLEAN
|
||||
DiscoverScsiDevice (
|
||||
SCSI_IO_DEV *ScsiIoDevice
|
||||
)
|
||||
/*++
|
||||
|
||||
Routine Description:
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
ScsiScanCreateDevice (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE Controller,
|
||||
IN SCSI_TARGET_ID *TargetId,
|
||||
IN UINT64 Lun,
|
||||
IN OUT SCSI_BUS_DEVICE *ScsiBusDev
|
||||
);
|
||||
|
||||
/**
|
||||
Discovery SCSI Device
|
||||
|
||||
Arguments:
|
||||
@param ScsiIoDevice The pointer of SCSI_IO_DEV
|
||||
|
||||
ScsiIoDevice - The pointer of SCSI_IO_DEV
|
||||
@retval TRUE Find SCSI Device and verify it.
|
||||
@retval FALSE Unable to find SCSI Device.
|
||||
|
||||
Returns:
|
||||
**/
|
||||
BOOLEAN
|
||||
DiscoverScsiDevice (
|
||||
IN OUT SCSI_IO_DEV *ScsiIoDevice
|
||||
);
|
||||
|
||||
TRUE - Find SCSI Device and verify it.
|
||||
FALSE - Unable to find SCSI Device.
|
||||
|
||||
--*/
|
||||
;
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user