MdeModulePkg ScsiDiskDxe: Add BlockIO2 Support

Together with EFI_BLOCK_IO_PROTOCOL, EFI_BLOCK_IO2_PROTOCOL is installed
as well in ScsiDiskDxe.

Block I/O 2 functions are implemented:
Reset
ReadBlocksEx
WriteBlocksEx
FlushBlocksEx

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19215 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Hao Wu 2015-12-11 01:58:15 +00:00 committed by hwu1225
parent 9c58193927
commit d670bf5336
4 changed files with 1767 additions and 14 deletions

View File

@ -1,7 +1,7 @@
/** @file
UEFI Component Name(2) protocol implementation for SCSI disk driver.
Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -211,7 +211,7 @@ ScsiDiskComponentNameGetControllerName (
return Status;
}
ScsiDiskDevice = SCSI_DISK_DEV_FROM_THIS (BlockIo);
ScsiDiskDevice = SCSI_DISK_DEV_FROM_BLKIO (BlockIo);
return LookupUnicodeString2 (
Language,

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/** @file
Header file for SCSI Disk Driver.
Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@ -22,6 +22,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/ScsiIo.h>
#include <Protocol/ComponentName.h>
#include <Protocol/BlockIo.h>
#include <Protocol/BlockIo2.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/ScsiPassThruExt.h>
#include <Protocol/ScsiPassThru.h>
@ -50,6 +51,7 @@ typedef struct {
EFI_HANDLE Handle;
EFI_BLOCK_IO_PROTOCOL BlkIo;
EFI_BLOCK_IO2_PROTOCOL BlkIo2;
EFI_BLOCK_IO_MEDIA BlkIoMedia;
EFI_SCSI_IO_PROTOCOL *ScsiIo;
UINT8 DeviceType;
@ -75,12 +77,59 @@ typedef struct {
// The flag indicates if 16-byte command can be used
//
BOOLEAN Cdb16Byte;
//
// The queue for BlockIo2 requests
//
LIST_ENTRY BlkIo2Queue;
} SCSI_DISK_DEV;
#define SCSI_DISK_DEV_FROM_THIS(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)
#define SCSI_DISK_DEV_FROM_BLKIO(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)
#define SCSI_DISK_DEV_FROM_BLKIO2(a) CR (a, SCSI_DISK_DEV, BlkIo2, SCSI_DISK_DEV_SIGNATURE)
#define SCSI_DISK_DEV_FROM_DISKINFO(a) CR (a, SCSI_DISK_DEV, DiskInfo, SCSI_DISK_DEV_SIGNATURE)
//
// Asynchronous I/O request
//
//
// Private data structure for a BlockIo2 request
//
typedef struct {
EFI_BLOCK_IO2_TOKEN *Token;
//
// The queue for Scsi Read/Write requests of a BlockIo2
//
LIST_ENTRY ScsiRWQueue;
LIST_ENTRY Link;
} SCSI_BLKIO2_REQUEST;
//
// Private data structure for a SCSI Read/Write request
//
typedef struct {
SCSI_DISK_DEV *ScsiDiskDevice;
UINT64 Timeout;
EFI_SCSI_SENSE_DATA *SenseData;
UINT8 SenseDataLength;
UINT8 HostAdapterStatus;
UINT8 TargetStatus;
UINT8 *InBuffer;
UINT8 *OutBuffer;
UINT32 DataLength;
UINT64 StartLba;
UINT32 SectorCount;
UINT8 TimesRetry;
//
// The BlockIo2 request this SCSI command belongs to
//
SCSI_BLKIO2_REQUEST *BlkIo2Req;
LIST_ENTRY Link;
} SCSI_ASYNC_RW_REQUEST;
//
// Global Variables
//
@ -410,6 +459,116 @@ ScsiDiskFlushBlocks (
);
/**
Reset SCSI Disk.
@param This The pointer of EFI_BLOCK_IO2_PROTOCOL.
@param ExtendedVerification The flag about if extend verificate.
@retval EFI_SUCCESS The device was reset.
@retval EFI_DEVICE_ERROR The device is not functioning properly and could
not be reset.
@return EFI_STATUS is returned from EFI_SCSI_IO_PROTOCOL.ResetDevice().
**/
EFI_STATUS
EFIAPI
ScsiDiskResetEx (
IN EFI_BLOCK_IO2_PROTOCOL *This,
IN BOOLEAN ExtendedVerification
);
/**
The function is to Read Block from SCSI Disk.
@param This The pointer of EFI_BLOCK_IO_PROTOCOL.
@param MediaId The Id of Media detected.
@param Lba The logic block address.
@param Token A pointer to the token associated with the transaction.
@param BufferSize The size of Buffer.
@param Buffer The buffer to fill the read out data.
@retval EFI_SUCCESS The read request was queued if Token-> Event is
not NULL. The data was read correctly from the
device if theToken-> Event is NULL.
@retval EFI_DEVICE_ERROR The device reported an error while attempting
to perform the read operation.
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
the intrinsic block size of the device.
@retval EFI_INVALID_PARAMETER The read request contains LBAs that are not
valid, or the buffer is not on proper
alignment.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
lack of resources.
**/
EFI_STATUS
EFIAPI
ScsiDiskReadBlocksEx (
IN EFI_BLOCK_IO2_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
OUT VOID *Buffer
);
/**
The function is to Write Block to SCSI Disk.
@param This The pointer of EFI_BLOCK_IO_PROTOCOL.
@param MediaId The Id of Media detected.
@param Lba The logic block address.
@param Token A pointer to the token associated with the transaction.
@param BufferSize The size of Buffer.
@param Buffer The buffer to fill the read out data.
@retval EFI_SUCCESS The data were written correctly to the device.
@retval EFI_WRITE_PROTECTED The device cannot be written to.
@retval EFI_NO_MEDIA There is no media in the device.
@retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
@retval EFI_DEVICE_ERROR The device reported an error while attempting
to perform the write operation.
@retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of
the intrinsic block size of the device.
@retval EFI_INVALID_PARAMETER The write request contains LBAs that are not
valid, or the buffer is not on proper
alignment.
**/
EFI_STATUS
EFIAPI
ScsiDiskWriteBlocksEx (
IN EFI_BLOCK_IO2_PROTOCOL *This,
IN UINT32 MediaId,
IN EFI_LBA Lba,
IN OUT EFI_BLOCK_IO2_TOKEN *Token,
IN UINTN BufferSize,
IN VOID *Buffer
);
/**
Flush the Block Device.
@param This Indicates a pointer to the calling context.
@param Token A pointer to the token associated with the transaction.
@retval EFI_SUCCESS All outstanding data was written to the device.
@retval EFI_DEVICE_ERROR The device reported an error while writing back the
data.
@retval EFI_NO_MEDIA There is no media in the device.
**/
EFI_STATUS
EFIAPI
ScsiDiskFlushBlocksEx (
IN EFI_BLOCK_IO2_PROTOCOL *This,
IN OUT EFI_BLOCK_IO2_TOKEN *Token
);
/**
Provides inquiry information for the controller type.
@ -717,6 +876,54 @@ ScsiDiskWriteSectors (
IN UINTN NumberOfBlocks
);
/**
Asynchronously read sector from SCSI Disk.
@param ScsiDiskDevice The pointer of SCSI_DISK_DEV.
@param Buffer The buffer to fill in the read out data.
@param Lba Logic block address.
@param NumberOfBlocks The number of blocks to read.
@param Token A pointer to the token associated with the
non-blocking read request.
@retval EFI_INVALID_PARAMETER Token is NULL or Token->Event is NULL.
@retval EFI_DEVICE_ERROR Indicates a device error.
@retval EFI_SUCCESS Operation is successful.
**/
EFI_STATUS
ScsiDiskAsyncReadSectors (
IN SCSI_DISK_DEV *ScsiDiskDevice,
OUT VOID *Buffer,
IN EFI_LBA Lba,
IN UINTN NumberOfBlocks,
IN EFI_BLOCK_IO2_TOKEN *Token
);
/**
Asynchronously write sector to SCSI Disk.
@param ScsiDiskDevice The pointer of SCSI_DISK_DEV.
@param Buffer The buffer of data to be written into SCSI Disk.
@param Lba Logic block address.
@param NumberOfBlocks The number of blocks to read.
@param Token A pointer to the token associated with the
non-blocking read request.
@retval EFI_INVALID_PARAMETER Token is NULL or Token->Event is NULL
@retval EFI_DEVICE_ERROR Indicates a device error.
@retval EFI_SUCCESS Operation is successful.
**/
EFI_STATUS
ScsiDiskAsyncWriteSectors (
IN SCSI_DISK_DEV *ScsiDiskDevice,
IN VOID *Buffer,
IN EFI_LBA Lba,
IN UINTN NumberOfBlocks,
IN EFI_BLOCK_IO2_TOKEN *Token
);
/**
Submit Read(10) command.
@ -815,6 +1022,130 @@ ScsiDiskWrite16 (
IN UINT32 SectorCount
);
/**
Submit Async Read(10) command.
@param ScsiDiskDevice The pointer of ScsiDiskDevice.
@param Timeout The time to complete the command.
@param DataBuffer The buffer to fill with the read out data.
@param DataLength The length of buffer.
@param StartLba The start logic block address.
@param SectorCount The number of blocks to read.
@param BlkIo2Req The upstream BlockIo2 request.
@param Token The pointer to the token associated with the
non-blocking read request.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
lack of resources.
@return others Status returned by calling
ScsiRead10CommandEx().
**/
EFI_STATUS
ScsiDiskAsyncRead10 (
IN SCSI_DISK_DEV *ScsiDiskDevice,
IN UINT64 Timeout,
OUT UINT8 *DataBuffer,
IN UINT32 DataLength,
IN UINT32 StartLba,
IN UINT32 SectorCount,
IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,
IN EFI_BLOCK_IO2_TOKEN *Token
);
/**
Submit Async Write(10) command.
@param ScsiDiskDevice The pointer of ScsiDiskDevice.
@param Timeout The time to complete the command.
@param DataBuffer The buffer contains the data to write.
@param DataLength The length of buffer.
@param StartLba The start logic block address.
@param SectorCount The number of blocks to write.
@param BlkIo2Req The upstream BlockIo2 request.
@param Token The pointer to the token associated with the
non-blocking read request.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
lack of resources.
@return others Status returned by calling
ScsiWrite10CommandEx().
**/
EFI_STATUS
ScsiDiskAsyncWrite10 (
IN SCSI_DISK_DEV *ScsiDiskDevice,
IN UINT64 Timeout,
IN UINT8 *DataBuffer,
IN UINT32 DataLength,
IN UINT32 StartLba,
IN UINT32 SectorCount,
IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,
IN EFI_BLOCK_IO2_TOKEN *Token
);
/**
Submit Async Read(16) command.
@param ScsiDiskDevice The pointer of ScsiDiskDevice.
@param Timeout The time to complete the command.
@param DataBuffer The buffer to fill with the read out data.
@param DataLength The length of buffer.
@param StartLba The start logic block address.
@param SectorCount The number of blocks to read.
@param BlkIo2Req The upstream BlockIo2 request.
@param Token The pointer to the token associated with the
non-blocking read request.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
lack of resources.
@return others Status returned by calling
ScsiRead16CommandEx().
**/
EFI_STATUS
ScsiDiskAsyncRead16 (
IN SCSI_DISK_DEV *ScsiDiskDevice,
IN UINT64 Timeout,
OUT UINT8 *DataBuffer,
IN UINT32 DataLength,
IN UINT64 StartLba,
IN UINT32 SectorCount,
IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,
IN EFI_BLOCK_IO2_TOKEN *Token
);
/**
Submit Async Write(16) command.
@param ScsiDiskDevice The pointer of ScsiDiskDevice.
@param Timeout The time to complete the command.
@param DataBuffer The buffer contains the data to write.
@param DataLength The length of buffer.
@param StartLba The start logic block address.
@param SectorCount The number of blocks to write.
@param BlkIo2Req The upstream BlockIo2 request.
@param Token The pointer to the token associated with the
non-blocking read request.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a
lack of resources.
@return others Status returned by calling
ScsiWrite16CommandEx().
**/
EFI_STATUS
ScsiDiskAsyncWrite16 (
IN SCSI_DISK_DEV *ScsiDiskDevice,
IN UINT64 Timeout,
IN UINT8 *DataBuffer,
IN UINT32 DataLength,
IN UINT64 StartLba,
IN UINT32 SectorCount,
IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,
IN EFI_BLOCK_IO2_TOKEN *Token
);
/**
Get information from media read capacity command.

View File

@ -1,8 +1,9 @@
## @file
# The Scsi Disk driver is used to retrieve the media info in the attached SCSI disk.
# It detects the SCSI disk media and installs Block I/O Protocol on the device handle.
# It detects the SCSI disk media and installs Block I/O and Block I/O2 Protocol on
# the device handle.
#
# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -55,6 +56,7 @@
[Protocols]
gEfiDiskInfoProtocolGuid ## BY_START
gEfiBlockIoProtocolGuid ## BY_START
gEfiBlockIo2ProtocolGuid ## BY_START
gEfiScsiIoProtocolGuid ## TO_START
gEfiScsiPassThruProtocolGuid ## TO_START
gEfiExtScsiPassThruProtocolGuid ## TO_START