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