]> 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 871c0a32807b7dbfa7b818fcf40dcae9b88aa7a7..836e7caeeda1661b9271b56689b86af1ce30f53a 100644 (file)
@@ -1,33 +1,49 @@
-/*++\r
+/** @file\r
+  Header file for SCSI Disk Driver.\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
-All rights reserved. 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
-http://opensource.org/licenses/bsd-license.php                                            \r
-                                                                                          \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \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
+http://opensource.org/licenses/bsd-license.php\r
 \r
-Module Name:\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-  ScsiDisk.h\r
+**/\r
+\r
+#ifndef _SCSI_DISK_H_\r
+#define _SCSI_DISK_H_\r
 \r
-Abstract:\r
-  \r
-  Header file for SCSI Disk Driver.\r
 \r
---*/\r
+#include <Uefi.h>\r
 \r
-#ifndef _SCSI_DISK_H\r
-#define _SCSI_DISK_H\r
 \r
+#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
+#include <Protocol/DiskInfo.h>\r
 \r
-#include <IndustryStandard/scsi.h>\r
 \r
-#define IsDeviceFixed(a)        (a)->FixedDevice ? 1 : 0\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiDriverEntryPoint.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiScsiLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
 \r
-#define SCSI_DISK_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'd', 'k')\r
+#include <IndustryStandard/Scsi.h>\r
+#include <IndustryStandard/Atapi.h>\r
+\r
+#define IS_DEVICE_FIXED(a)        (a)->FixedDevice ? 1 : 0\r
+\r
+#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')\r
 \r
 typedef struct {\r
   UINT32                    Signature;\r
@@ -35,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
@@ -47,9 +64,71 @@ typedef struct {
 \r
   EFI_UNICODE_STRING_TABLE  *ControllerNameTable;\r
 \r
+  EFI_DISK_INFO_PROTOCOL    DiskInfo;\r
+\r
+  //\r
+  // The following fields are only valid for ATAPI/SATA device\r
+  //\r
+  UINT32                    Channel;\r
+  UINT32                    Device;\r
+  ATAPI_IDENTIFY_DATA       IdentifyData;\r
+  \r
+  //\r
+  // 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
@@ -60,33 +139,100 @@ extern EFI_COMPONENT_NAME2_PROTOCOL  gScsiDiskComponentName2;
 //\r
 // action code used in detect media process\r
 //\r
-#define ACTION_NO_ACTION            0x00\r
-#define ACTION_READ_CAPACITY        0x01\r
-#define ACTION_RETRY_COMMAND_LATER  0x02\r
+#define ACTION_NO_ACTION               0x00\r
+#define ACTION_READ_CAPACITY           0x01\r
+#define ACTION_RETRY_COMMAND_LATER     0x02\r
+#define ACTION_RETRY_WITH_BACKOFF_ALGO 0x03\r
+\r
+#define SCSI_COMMAND_VERSION_1      0x01\r
+#define SCSI_COMMAND_VERSION_2      0x02\r
+#define SCSI_COMMAND_VERSION_3      0x03\r
+\r
+//\r
+// SCSI Disk Timeout Experience Value\r
+//\r
+#define SCSI_DISK_TIMEOUT           EFI_TIMER_PERIOD_SECONDS (3)\r
+\r
+/**\r
+  Test to see if this driver supports ControllerHandle.\r
+\r
+  This service is called by the EFI boot service ConnectController(). In order\r
+  to make drivers as small as possible, there are a few calling restrictions for\r
+  this service. ConnectController() must follow these calling restrictions.\r
+  If any other agent wishes to call Supported() it must also follow these\r
+  calling restrictions.\r
+\r
+  @param  This                Protocol instance pointer.\r
+  @param  ControllerHandle    Handle of device to test\r
+  @param  RemainingDevicePath Optional parameter use to pick a specific child\r
+                              device to start.\r
+\r
+  @retval EFI_SUCCESS         This driver supports this device\r
+  @retval EFI_ALREADY_STARTED This driver is already running on this device\r
+  @retval other               This driver does not support this device\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 ScsiDiskDriverBindingSupported (\r
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath   OPTIONAL\r
   );\r
 \r
+/**\r
+  Start this driver on ControllerHandle.\r
+\r
+  This service is called by the EFI boot service ConnectController(). In order\r
+  to make drivers as small as possible, there are a few calling restrictions for\r
+  this service. ConnectController() must follow these calling restrictions. If\r
+  any other agent wishes to call Start() it must also follow these calling\r
+  restrictions.\r
+\r
+  @param  This                 Protocol instance pointer.\r
+  @param  ControllerHandle     Handle of device to bind driver to\r
+  @param  RemainingDevicePath  Optional parameter use to pick a specific child\r
+                               device to start.\r
+\r
+  @retval EFI_SUCCESS          This driver is added to ControllerHandle\r
+  @retval EFI_ALREADY_STARTED  This driver is already running on ControllerHandle\r
+  @retval other                This driver does not support this device\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 ScsiDiskDriverBindingStart (\r
   IN EFI_DRIVER_BINDING_PROTOCOL  *This,\r
   IN EFI_HANDLE                   Controller,\r
-  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath\r
+  IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath   OPTIONAL\r
   );\r
 \r
+/**\r
+  Stop this driver on ControllerHandle.\r
+\r
+  This service is called by the EFI boot service DisconnectController().\r
+  In order to make drivers as small as possible, there are a few calling\r
+  restrictions for this service. DisconnectController() must follow these\r
+  calling restrictions. If any other agent wishes to call Stop() it must\r
+  also follow these calling restrictions.\r
+  \r
+  @param  This              Protocol instance pointer.\r
+  @param  ControllerHandle  Handle of device to stop driver on\r
+  @param  NumberOfChildren  Number of Handles in ChildHandleBuffer. If number of\r
+                            children is zero stop the entire bus driver.\r
+  @param  ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+  @retval EFI_SUCCESS       This driver is removed ControllerHandle\r
+  @retval other             This driver was not removed from this device\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 ScsiDiskDriverBindingStop (\r
   IN  EFI_DRIVER_BINDING_PROTOCOL     *This,\r
   IN  EFI_HANDLE                      Controller,\r
   IN  UINTN                           NumberOfChildren,\r
-  IN  EFI_HANDLE                      *ChildHandleBuffer\r
+  IN  EFI_HANDLE                      *ChildHandleBuffer   OPTIONAL\r
   );\r
 \r
 //\r
@@ -102,19 +248,19 @@ ScsiDiskDriverBindingStop (
   by This does not support the language specified by Language,\r
   then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param  Language              A pointer to a Null-terminated ASCII string\r
                                 array indicating the language. This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
                                 languages specified in SupportedLanguages. The\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified\r
-                                in RFC 3066 or ISO 639-2 language code format.\r
+                                in RFC 4646 or ISO 639-2 language code format.\r
 \r
-  @param  DriverName[out]       A pointer to the Unicode string to return.\r
+  @param  DriverName            A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 driver specified by This in the language\r
                                 specified by Language.\r
@@ -153,15 +299,15 @@ ScsiDiskComponentNameGetDriverName (
   then EFI_UNSUPPORTED is returned.  If the driver specified by This does not\r
   support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
 \r
-  @param  This[in]              A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
+  @param  This                  A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
                                 EFI_COMPONENT_NAME_PROTOCOL instance.\r
 \r
-  @param  ControllerHandle[in]  The handle of a controller that the driver\r
+  @param  ControllerHandle      The handle of a controller that the driver\r
                                 specified by This is managing.  This handle\r
                                 specifies the controller whose name is to be\r
                                 returned.\r
 \r
-  @param  ChildHandle[in]       The handle of the child controller to retrieve\r
+  @param  ChildHandle           The handle of the child controller to retrieve\r
                                 the name of.  This is an optional parameter that\r
                                 may be NULL.  It will be NULL for device\r
                                 drivers.  It will also be NULL for a bus drivers\r
@@ -170,16 +316,16 @@ ScsiDiskComponentNameGetDriverName (
                                 driver that wishes to retrieve the name of a\r
                                 child controller.\r
 \r
-  @param  Language[in]          A pointer to a Null-terminated ASCII string\r
+  @param  Language              A pointer to a Null-terminated ASCII string\r
                                 array indicating the language.  This is the\r
                                 language of the driver name that the caller is\r
                                 requesting, and it must match one of the\r
                                 languages specified in SupportedLanguages. The\r
                                 number of languages supported by a driver is up\r
                                 to the driver writer. Language is specified in\r
-                                RFC 3066 or ISO 639-2 language code format.\r
+                                RFC 4646 or ISO 639-2 language code format.\r
 \r
-  @param  ControllerName[out]   A pointer to the Unicode string to return.\r
+  @param  ControllerName        A pointer to the Unicode string to return.\r
                                 This Unicode string is the name of the\r
                                 controller specified by ControllerHandle and\r
                                 ChildHandle in the language specified by\r
@@ -191,7 +337,7 @@ ScsiDiskComponentNameGetDriverName (
                                 driver specified by This was returned in\r
                                 DriverName.\r
 \r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
 \r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
@@ -218,699 +364,975 @@ ScsiDiskComponentNameGetControllerName (
   OUT CHAR16                                          **ControllerName\r
   );\r
 \r
+/**\r
+  Reset SCSI Disk.\r
+\r
+\r
+  @param  This                 The pointer of EFI_BLOCK_IO_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 retured from EFI_SCSI_IO_PROTOCOL.ResetDevice().\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 ScsiDiskReset (\r
   IN  EFI_BLOCK_IO_PROTOCOL   *This,\r
   IN  BOOLEAN                 ExtendedVerification\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Reset SCSI Disk  \r
-\r
-Arguments:\r
+  );\r
 \r
-  This                  - The pointer of EFI_BLOCK_IO_PROTOCOL\r
-  ExtendedVerification  - The flag about if extend verificate\r
 \r
-Returns:\r
+/**\r
+  The function is to Read Block from SCSI Disk.\r
 \r
-  EFI_STATUS\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  BufferSize The size of Buffer\r
+  @param  Buffer     The buffer to fill the read out data\r
 \r
---*/\r
-;\r
+  @retval EFI_SUCCESS           Successfully to read out block.\r
+  @retval EFI_DEVICE_ERROR      Fail to detect media.\r
+  @retval EFI_NO_MEDIA          Media is not present.\r
+  @retval EFI_MEDIA_CHANGED     Media has changed.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
+  @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 ScsiDiskReadBlocks (\r
   IN  EFI_BLOCK_IO_PROTOCOL   *This,\r
   IN  UINT32                  MediaId,\r
-  IN  EFI_LBA                 LBA,\r
+  IN  EFI_LBA                 Lba,\r
   IN  UINTN                   BufferSize,\r
   OUT VOID                    *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The function is to Read Block from SCSI Disk\r
-\r
-Arguments:\r
-\r
-  This        - The pointer of EFI_BLOCK_IO_PROTOCOL\r
-  MediaId     - The Id of Media detected\r
-  LBA         - The logic block address\r
-  BufferSize  - The size of Buffer\r
-  Buffer      - The buffer to fill the read out data\r
-\r
-Returns:\r
+  );\r
 \r
-  EFI_INVALID_PARAMETER - Invalid parameter passed in.\r
-  EFI_SUCCESS           - Successfully to read out block.\r
-  EFI_DEVICE_ERROR      - Fail to detect media.\r
-  EFI_NO_MEDIA          - Media is not present.\r
-  EFI_MEDIA_CHANGED     - Media has changed.\r
-  EFI_BAD_BUFFER_SIZE   - The buffer size is not multiple of BlockSize.\r
 \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  BufferSize The size of Buffer\r
+  @param  Buffer     The buffer to fill the read out data\r
+\r
+  @retval EFI_SUCCESS           Successfully to read out block.\r
+  @retval EFI_WRITE_PROTECTED   The device can not be written to.\r
+  @retval EFI_DEVICE_ERROR      Fail to detect media.\r
+  @retval EFI_NO_MEDIA          Media is not present.\r
+  @retval EFI_MEDIA_CHNAGED     Media has changed.\r
+  @retval EFI_BAD_BUFFER_SIZE   The Buffer was not a multiple of the block size of the device.\r
+  @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 ScsiDiskWriteBlocks (\r
   IN  EFI_BLOCK_IO_PROTOCOL   *This,\r
   IN  UINT32                  MediaId,\r
-  IN  EFI_LBA                 LBA,\r
+  IN  EFI_LBA                 Lba,\r
   IN  UINTN                   BufferSize,\r
   IN  VOID                    *Buffer\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  The function is to Write Block to SCSI Disk\r
+  );\r
 \r
-Arguments:\r
 \r
-  This        - The pointer of EFI_BLOCK_IO_PROTOCOL\r
-  MediaId     - The Id of Media detected\r
-  LBA         - The logic block address\r
-  BufferSize  - The size of Buffer\r
-  Buffer      - The buffer to fill the read out data\r
+/**\r
+  Flush Block to Disk.\r
 \r
-Returns:\r
+  EFI_SUCCESS is returned directly.\r
 \r
-  EFI_INVALID_PARAMETER - Invalid parameter passed in.\r
-  EFI_SUCCESS           - Successfully to read out block.\r
-  EFI_DEVICE_ERROR      - Fail to detect media.\r
-  EFI_NO_MEDIA          - Media is not present.\r
-  EFI_MEDIA_CHANGED     - Media has changed.\r
-  EFI_BAD_BUFFER_SIZE   - The buffer size is not multiple of BlockSize.\r
+  @param  This              The pointer of EFI_BLOCK_IO_PROTOCOL\r
 \r
---*/\r
-;\r
+  @retval EFI_SUCCESS       All outstanding data was written to the device\r
 \r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 ScsiDiskFlushBlocks (\r
   IN  EFI_BLOCK_IO_PROTOCOL   *This\r
-  )\r
-/*++\r
+  );\r
 \r
-Routine Description:\r
 \r
-  Flush Block to Disk\r
+/**\r
+  Reset SCSI Disk.\r
 \r
-Arguments:\r
+  @param  This                 The pointer of EFI_BLOCK_IO2_PROTOCOL.\r
+  @param  ExtendedVerification The flag about if extend verificate.\r
 \r
-  This  - The pointer of EFI_BLOCK_IO_PROTOCOL\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
-Returns:\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiDiskResetEx (\r
+  IN  EFI_BLOCK_IO2_PROTOCOL  *This,\r
+  IN  BOOLEAN                 ExtendedVerification\r
+  );\r
 \r
-  EFI_SUCCESS \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
-;\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
-ScsiDiskDetectMedia (\r
-  SCSI_DISK_DEV   *ScsiDiskDevice,\r
-  BOOLEAN         MustReadCap,\r
-  BOOLEAN         *MediaChange\r
-  )\r
-/*++\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
-Routine Description:\r
+/**\r
+  Flush the Block Device.\r
 \r
-  Dectect Device and read out capacity ,if error occurs, parse the sense key.\r
+  @param  This       Indicates a pointer to the calling context.\r
+  @param  Token      A pointer to the token associated with the transaction.\r
 \r
-Arguments:\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
-  ScsiDiskDevice     - The pointer of SCSI_DISK_DEV\r
-  MustReadCapacity   - The flag about reading device capacity\r
-  MediaChange        - The pointer of flag indicates if media has changed \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
-Returns:\r
 \r
-  EFI_DEVICE_ERROR   - Indicates that error occurs\r
-  EFI_SUCCESS        - Successfully to detect media\r
+/**\r
+  Provides inquiry information for the controller type.\r
+  \r
+  This function is used by the IDE bus driver to get inquiry data.  Data format\r
+  of Identify data is defined by the Interface GUID.\r
 \r
---*/\r
-;\r
+  @param[in]      This              Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[in, out] InquiryData       Pointer to a buffer for the inquiry data.\r
+  @param[in, out] InquiryDataSize   Pointer to the value for the inquiry data size.\r
 \r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class \r
+  @retval EFI_DEVICE_ERROR       Error reading InquiryData from device \r
+  @retval EFI_BUFFER_TOO_SMALL   InquiryDataSize not big enough \r
+\r
+**/\r
 EFI_STATUS\r
-ScsiDiskTestUnitReady (\r
-  SCSI_DISK_DEV       *ScsiDiskDevice,\r
-  BOOLEAN             *NeedRetry,\r
-  EFI_SCSI_SENSE_DATA **SenseDataArray,\r
-  UINTN               *NumberOfSenseKeys\r
-  )\r
-/*++\r
+EFIAPI\r
+ScsiDiskInfoInquiry (\r
+  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
+  IN OUT VOID                     *InquiryData,\r
+  IN OUT UINT32                   *InquiryDataSize\r
+  );\r
 \r
-Routine Description:\r
 \r
-  When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;\r
-  When Test Unit Ready command encounters any error caused by host adapter or\r
-  target, return error without retrieving Sense Keys.\r
-  \r
-Arguments:\r
+/**\r
+  Provides identify information for the controller type.\r
 \r
-  ScsiDiskDevice  - The pointer of SCSI_DISK_DEV\r
-  NeedRetry       - The pointer of flag indicates try again\r
-  SenseDataArray  - The pointer of an array of sense data\r
-  NumberOfSenseKeys - The pointer of the number of sense data array\r
-  \r
-Returns:\r
+  This function is used by the IDE bus driver to get identify data.  Data format\r
+  of Identify data is defined by the Interface GUID.\r
 \r
-  EFI_DEVICE_ERROR   - Indicates that error occurs\r
-  EFI_SUCCESS        - Successfully to test unit\r
+  @param[in]     This               Pointer to the EFI_DISK_INFO_PROTOCOL \r
+                                    instance.\r
+  @param[in, out] IdentifyData      Pointer to a buffer for the identify data.\r
+  @param[in, out] IdentifyDataSize  Pointer to the value for the identify data\r
+                                    size.\r
 \r
---*/\r
-;\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class \r
+  @retval EFI_DEVICE_ERROR       Error reading IdentifyData from device \r
+  @retval EFI_BUFFER_TOO_SMALL   IdentifyDataSize not big enough \r
 \r
+**/\r
 EFI_STATUS\r
-DetectMediaParsingSenseKeys (\r
-  SCSI_DISK_DEV           *ScsiDiskDevice,\r
-  EFI_SCSI_SENSE_DATA     *SenseData,\r
-  UINTN                   NumberOfSenseKeys,\r
-  UINTN                   *Action\r
-  )\r
-/*++\r
+EFIAPI\r
+ScsiDiskInfoIdentify (\r
+  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
+  IN OUT VOID                     *IdentifyData,\r
+  IN OUT UINT32                   *IdentifyDataSize\r
+  );\r
 \r
-Routine Description:\r
 \r
-  Parsing Sense Keys which got from request sense command.\r
+/**\r
+  Provides sense data information for the controller type.\r
   \r
-Arguments:\r
+  This function is used by the IDE bus driver to get sense data. \r
+  Data format of Sense data is defined by the Interface GUID.\r
+\r
+  @param[in]      This              Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
+  @param[in, out] SenseData         Pointer to the SenseData.\r
+  @param[in, out] SenseDataSize     Size of SenseData in bytes.\r
+  @param[out]     SenseDataNumber   Pointer to the value for the sense data size.\r
+\r
+  @retval EFI_SUCCESS            The command was accepted without any errors.\r
+  @retval EFI_NOT_FOUND          Device does not support this data class.\r
+  @retval EFI_DEVICE_ERROR       Error reading SenseData from device.\r
+  @retval EFI_BUFFER_TOO_SMALL   SenseDataSize not big enough.\r
 \r
-  ScsiDiskDevice    - The pointer of SCSI_DISK_DEV\r
-  SenseData         - The pointer of EFI_SCSI_SENSE_DATA\r
-  NumberOfSenseKeys - The number of sense key  \r
-  Action            - The pointer of action which indicates what is need to do next\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ScsiDiskInfoSenseData (\r
+  IN     EFI_DISK_INFO_PROTOCOL   *This,\r
+  IN OUT VOID                     *SenseData,\r
+  IN OUT UINT32                   *SenseDataSize,\r
+  OUT    UINT8                    *SenseDataNumber\r
+  );\r
 \r
-Returns:\r
+/**\r
+  This function is used by the IDE bus driver to get controller information.\r
 \r
-  EFI_DEVICE_ERROR   - Indicates that error occurs\r
-  EFI_SUCCESS        - Successfully to complete the parsing\r
+  @param[in]  This         Pointer to the EFI_DISK_INFO_PROTOCOL instance. \r
+  @param[out] IdeChannel   Pointer to the Ide Channel number.  Primary or secondary.\r
+  @param[out] IdeDevice    Pointer to the Ide Device number.  Master or slave.\r
 \r
---*/\r
-;\r
+  @retval EFI_SUCCESS       IdeChannel and IdeDevice are valid.\r
+  @retval EFI_UNSUPPORTED   This is not an IDE device.\r
 \r
+**/\r
 EFI_STATUS\r
-ScsiDiskReadCapacity (\r
-  SCSI_DISK_DEV       *ScsiDiskDevice,\r
-  BOOLEAN             *NeedRetry,\r
-  EFI_SCSI_SENSE_DATA **SenseDataArray,\r
-  UINTN               *NumberOfSenseKeys\r
-  )\r
-/*++\r
+EFIAPI\r
+ScsiDiskInfoWhichIde (\r
+  IN  EFI_DISK_INFO_PROTOCOL   *This,\r
+  OUT UINT32                   *IdeChannel,\r
+  OUT UINT32                   *IdeDevice\r
+  );\r
 \r
-Routine Description:\r
 \r
-  Send read capacity command to device and get the device parameter\r
+/**\r
+  Detect Device and read out capacity ,if error occurs, parse the sense key.\r
 \r
-Arguments:\r
+  @param  ScsiDiskDevice    The pointer of SCSI_DISK_DEV\r
+  @param  MustReadCapacity  The flag about reading device capacity\r
+  @param  MediaChange       The pointer of flag indicates if media has changed \r
 \r
-  ScsiDiskDevice     -  The pointer of SCSI_DISK_DEV\r
-  NeedRetry          -  The pointer of flag indicates if need a retry\r
-  SenseDataArray     -  The pointer of an array of sense data\r
-  NumberOfSenseKeys  -  The number of sense key\r
+  @retval EFI_DEVICE_ERROR  Indicates that error occurs\r
+  @retval EFI_SUCCESS       Successfully to detect media\r
 \r
-Returns:\r
+**/\r
+EFI_STATUS\r
+ScsiDiskDetectMedia (\r
+  IN   SCSI_DISK_DEV   *ScsiDiskDevice,\r
+  IN   BOOLEAN         MustReadCapacity,\r
+  OUT  BOOLEAN         *MediaChange\r
+  );\r
 \r
-  EFI_DEVICE_ERROR   - Indicates that error occurs\r
-  EFI_SUCCESS        - Successfully to read capacity\r
+/**\r
+  To test device.\r
 \r
---*/\r
-;\r
+  When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;\r
+  When Test Unit Ready command encounters any error caused by host adapter or\r
+  target, return error without retrieving Sense Keys.\r
 \r
-EFI_STATUS\r
-CheckHostAdapterStatus (\r
-  UINT8   HostAdapterStatus\r
-  )\r
-/*++\r
+  @param  ScsiDiskDevice     The pointer of SCSI_DISK_DEV\r
+  @param  NeedRetry          The pointer of flag indicates try again\r
+  @param  SenseDataArray     The pointer of an array of sense data\r
+  @param  NumberOfSenseKeys  The pointer of the number of sense data array\r
 \r
-Routine Description:\r
+  @retval EFI_DEVICE_ERROR   Indicates that error occurs\r
+  @retval EFI_SUCCESS        Successfully to test unit\r
 \r
-  Check the HostAdapter status\r
-  \r
-Arguments:\r
+**/\r
+EFI_STATUS\r
+ScsiDiskTestUnitReady (\r
+  IN  SCSI_DISK_DEV         *ScsiDiskDevice,\r
+  OUT BOOLEAN               *NeedRetry,\r
+  OUT EFI_SCSI_SENSE_DATA   **SenseDataArray,\r
+  OUT UINTN                 *NumberOfSenseKeys\r
+  );\r
 \r
-  HostAdapterStatus - Host Adapter status\r
 \r
-Returns:\r
+/**\r
+  Parsing Sense Keys which got from request sense command.\r
 \r
-  EFI_SUCCESS       \r
-  EFI_TIMEOUT       \r
-  EFI_NOT_READY     \r
-  EFI_DEVICE_ERROR  \r
+  @param  ScsiDiskDevice     The pointer of SCSI_DISK_DEV\r
+  @param  SenseData          The pointer of EFI_SCSI_SENSE_DATA\r
+  @param  NumberOfSenseKeys  The number of sense key  \r
+  @param  Action             The pointer of action which indicates what is need to do next\r
 \r
---*/\r
-;\r
+  @retval EFI_DEVICE_ERROR   Indicates that error occurs\r
+  @retval EFI_SUCCESS        Successfully to complete the parsing\r
 \r
+**/\r
 EFI_STATUS\r
-CheckTargetStatus (\r
-  UINT8   TargetStatus\r
-  )\r
-/*++\r
+DetectMediaParsingSenseKeys (\r
+  OUT  SCSI_DISK_DEV           *ScsiDiskDevice,\r
+  IN   EFI_SCSI_SENSE_DATA     *SenseData,\r
+  IN   UINTN                   NumberOfSenseKeys,\r
+  OUT  UINTN                   *Action\r
+  );\r
 \r
-Routine Description:\r
 \r
-  Check the target status\r
-  \r
-Arguments:\r
+/**\r
+  Send read capacity command to device and get the device parameter.\r
 \r
-  TargetStatus  - Target status\r
+  @param  ScsiDiskDevice     The pointer of SCSI_DISK_DEV\r
+  @param  NeedRetry          The pointer of flag indicates if need a retry\r
+  @param  SenseDataArray     The pointer of an array of sense data\r
+  @param  NumberOfSenseKeys  The number of sense key\r
 \r
-Returns:\r
+  @retval EFI_DEVICE_ERROR   Indicates that error occurs\r
+  @retval EFI_SUCCESS        Successfully to read capacity\r
 \r
-  EFI_NOT_READY  \r
-  EFI_DEVICE_ERROR \r
-  EFI_SUCCESS\r
+**/\r
+EFI_STATUS\r
+ScsiDiskReadCapacity (\r
+  IN  OUT  SCSI_DISK_DEV           *ScsiDiskDevice,\r
+      OUT  BOOLEAN                 *NeedRetry,\r
+      OUT  EFI_SCSI_SENSE_DATA     **SenseDataArray,\r
+      OUT  UINTN                   *NumberOfSenseKeys\r
+  );\r
 \r
---*/\r
-;\r
+/**\r
+  Check the HostAdapter status and re-interpret it in EFI_STATUS.\r
 \r
+  @param  HostAdapterStatus  Host Adapter status\r
+\r
+  @retval  EFI_SUCCESS       Host adapter is OK.\r
+  @retval  EFI_TIMEOUT       Timeout.\r
+  @retval  EFI_NOT_READY     Adapter NOT ready.\r
+  @retval  EFI_DEVICE_ERROR  Adapter device error.\r
+\r
+**/\r
 EFI_STATUS\r
-ScsiDiskRequestSenseKeys (\r
-  SCSI_DISK_DEV           *ScsiDiskDevice,\r
-  BOOLEAN                 *NeedRetry,\r
-  EFI_SCSI_SENSE_DATA     **SenseDataArray,\r
-  UINTN                   *NumberOfSenseKeys,\r
-  BOOLEAN                 AskResetIfError\r
-  )\r
-/*++\r
+CheckHostAdapterStatus (\r
+  IN UINT8   HostAdapterStatus\r
+  );\r
 \r
-Routine Description:\r
 \r
-  Retrieve all sense keys from the device.\r
-  When encountering error during the process,\r
-  if retrieve sense keys before error encounterred,\r
-  return the sense keys with return status set to EFI_SUCCESS,\r
-  and NeedRetry set to FALSE; otherwize, return the proper return\r
-  status.\r
-\r
-Arguments:\r
-\r
-  ScsiDiskDevice     -  The pointer of SCSI_DISK_DEV\r
-  NeedRetry          -  The pointer of flag indicates if need a retry\r
-  SenseDataArray     -  The pointer of an array of sense data\r
-  NumberOfSenseKeys  -  The number of sense key\r
-  AskResetIfError    -  The flag indicates if need reset when error occurs\r
-  \r
-Returns:\r
+/**\r
+  Check the target status and re-interpret it in EFI_STATUS.\r
 \r
-  EFI_DEVICE_ERROR   - Indicates that error occurs\r
-  EFI_SUCCESS        - Successfully to request sense key\r
+  @param  TargetStatus  Target status\r
 \r
---*/\r
-;\r
+  @retval EFI_NOT_READY       Device is NOT ready.\r
+  @retval EFI_DEVICE_ERROR \r
+  @retval EFI_SUCCESS\r
 \r
+**/\r
 EFI_STATUS\r
-ScsiDiskInquiryDevice (\r
-  SCSI_DISK_DEV   *ScsiDiskDevice,\r
-  BOOLEAN         *NeedRetry\r
-  )\r
-/*++\r
+CheckTargetStatus (\r
+  IN  UINT8   TargetStatus\r
+  );\r
 \r
-Routine Description:\r
+/**\r
+  Retrieve all sense keys from the device.\r
 \r
-  Send out Inquiry command to Device\r
+  When encountering error during the process, if retrieve sense keys before\r
+  error encountered, it returns the sense keys with return status set to EFI_SUCCESS,\r
+  and NeedRetry set to FALSE; otherwize, return the proper return status.\r
 \r
-Arguments:\r
+  @param  ScsiDiskDevice     The pointer of SCSI_DISK_DEV\r
+  @param  NeedRetry          The pointer of flag indicates if need a retry\r
+  @param  SenseDataArray     The pointer of an array of sense data\r
+  @param  NumberOfSenseKeys  The number of sense key\r
+  @param  AskResetIfError    The flag indicates if need reset when error occurs\r
 \r
-  ScsiDiskDevice  - The pointer of SCSI_DISK_DEV\r
-  NeedRetry       - Indicates if needs try again when error happens\r
+  @retval EFI_DEVICE_ERROR   Indicates that error occurs\r
+  @retval EFI_SUCCESS        Successfully to request sense key\r
 \r
-Returns:\r
+**/\r
+EFI_STATUS\r
+ScsiDiskRequestSenseKeys (\r
+  IN  OUT  SCSI_DISK_DEV           *ScsiDiskDevice,\r
+      OUT  BOOLEAN                 *NeedRetry,\r
+      OUT  EFI_SCSI_SENSE_DATA     **SenseDataArray,\r
+      OUT  UINTN                   *NumberOfSenseKeys,\r
+  IN       BOOLEAN                 AskResetIfError\r
+  );\r
 \r
-  EFI_DEVICE_ERROR   - Indicates that error occurs\r
-  EFI_SUCCESS        - Successfully to detect media\r
+/**\r
+  Send out Inquiry command to Device.\r
 \r
---*/\r
-;\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV\r
+  @param  NeedRetry       Indicates if needs try again when error happens\r
 \r
-VOID\r
-ParseInquiryData (\r
-  SCSI_DISK_DEV   *ScsiDiskDevice\r
-  )\r
-/*++\r
+  @retval  EFI_DEVICE_ERROR  Indicates that error occurs\r
+  @retval  EFI_SUCCESS       Successfully to detect media\r
 \r
-Routine Description:\r
+**/\r
+EFI_STATUS\r
+ScsiDiskInquiryDevice (\r
+  IN OUT  SCSI_DISK_DEV   *ScsiDiskDevice,\r
+     OUT  BOOLEAN         *NeedRetry\r
+  );\r
 \r
-  Parse Inquiry data\r
+/**\r
+  Parse Inquiry data.\r
 \r
-Arguments:\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV\r
 \r
-  ScsiDiskDevice  - The pointer of SCSI_DISK_DEV\r
+**/\r
+VOID\r
+ParseInquiryData (\r
+  IN OUT SCSI_DISK_DEV   *ScsiDiskDevice\r
+  );\r
 \r
-Returns:\r
+/**\r
+  Read sector from SCSI Disk.\r
 \r
-  NONE\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
 \r
---*/\r
-;\r
+  @retval EFI_DEVICE_ERROR  Indicates a device error.\r
+  @retval EFI_SUCCESS       Operation is successful.\r
 \r
+**/\r
 EFI_STATUS\r
 ScsiDiskReadSectors (\r
-  SCSI_DISK_DEV     *ScsiDiskDevice,\r
-  VOID              *Buffer,\r
-  EFI_LBA           Lba,\r
-  UINTN             NumberOfBlocks\r
-  )\r
-/*++\r
+  IN   SCSI_DISK_DEV     *ScsiDiskDevice,\r
+  OUT  VOID              *Buffer,\r
+  IN   EFI_LBA           Lba,\r
+  IN   UINTN             NumberOfBlocks\r
+  );\r
 \r
-Routine Description:\r
+/**\r
+  Write sector to SCSI Disk.\r
 \r
-  Read sector from SCSI Disk\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
 \r
-Arguments:\r
+  @retval EFI_DEVICE_ERROR  Indicates a device error.\r
+  @retval EFI_SUCCESS       Operation is successful.\r
 \r
-  ScsiDiskDevice  - The poiniter of SCSI_DISK_DEV\r
-  Buffer          - The buffer to fill in the read out data\r
-  Lba             - Logic block address\r
-  NumberOfBlocks  - The number of blocks to read\r
+**/\r
+EFI_STATUS\r
+ScsiDiskWriteSectors (\r
+  IN  SCSI_DISK_DEV     *ScsiDiskDevice,\r
+  IN  VOID              *Buffer,\r
+  IN  EFI_LBA           Lba,\r
+  IN  UINTN             NumberOfBlocks\r
+  );\r
 \r
-Returns:\r
+/**\r
+  Asynchronously read sector from SCSI Disk.\r
 \r
-  EFI_DEVICE_ERROR\r
-  EFI_SUCCESS\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
---*/\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
-ScsiDiskWriteSectors (\r
-  SCSI_DISK_DEV     *ScsiDiskDevice,\r
-  VOID              *Buffer,\r
-  EFI_LBA           Lba,\r
-  UINTN             NumberOfBlocks\r
-  )\r
-/*++\r
-\r
-Routine Description:\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
-  Write SCSI Disk sectors\r
+/**\r
+  Asynchronously write sector to SCSI Disk.\r
 \r
-Arguments:\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
-  ScsiDiskDevice  - The pointer of SCSI_DISK_DEV\r
-  Buffer          - The data buffer to write sector\r
-  Lba             - Logic block address\r
-  NumberOfBlocks  - The number of blocks to write\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
-Returns:\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
-  EFI_DEVICE_ERROR \r
-  EFI_SUCCESS\r
+/**\r
+  Submit Read(10) command.\r
 \r
---*/\r
-;\r
+  @param  ScsiDiskDevice     The pointer of ScsiDiskDevice\r
+  @param  NeedRetry          The pointer of flag indicates if needs retry if error happens\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
 \r
+  @return  EFI_STATUS is returned by calling ScsiRead10Command().\r
+**/\r
 EFI_STATUS\r
 ScsiDiskRead10 (\r
-  SCSI_DISK_DEV         *ScsiDiskDevice,\r
-  BOOLEAN               *NeedRetry,\r
-  EFI_SCSI_SENSE_DATA   **SenseDataArray,\r
-  UINTN                 *NumberOfSenseKeys,\r
-  UINT64                Timeout,\r
-  UINT8                 *DataBuffer,\r
-  UINT32                *DataLength,\r
-  UINT32                StartLba,\r
-  UINT32                SectorSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+  IN     SCSI_DISK_DEV         *ScsiDiskDevice,\r
+     OUT BOOLEAN               *NeedRetry,\r
+  IN     UINT64                Timeout,\r
+     OUT UINT8                 *DataBuffer,\r
+  IN OUT UINT32                *DataLength,\r
+  IN     UINT32                StartLba,\r
+  IN     UINT32                SectorCount\r
+  );\r
 \r
-  Sumbmit Read command \r
+/**\r
+  Submit Write(10) Command.\r
 \r
-Arguments:\r
+  @param  ScsiDiskDevice     The pointer of ScsiDiskDevice\r
+  @param  NeedRetry          The pointer of flag indicates if needs retry if error happens\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 write\r
 \r
-  ScsiDiskDevice    - The pointer of ScsiDiskDevice\r
-  NeedRetry         - The pointer of flag indicates if needs retry if error happens\r
-  SenseDataArray    - The pointer of an array of sense data\r
-  NumberOfSenseKeys - The number of sense key\r
-  Timeout           - The time to complete the command\r
-  DataBuffer        - The buffer to fill with the read out data\r
-  DataLength        - The length of buffer\r
-  StartLba          - The start logic block address\r
-  SectorSize        - The size of sector\r
+  @return  EFI_STATUS is returned by calling ScsiWrite10Command().\r
 \r
-Returns:\r
+**/\r
+EFI_STATUS\r
+ScsiDiskWrite10 (\r
+  IN     SCSI_DISK_DEV         *ScsiDiskDevice,\r
+     OUT BOOLEAN               *NeedRetry,\r
+  IN     UINT64                Timeout,\r
+  IN     UINT8                 *DataBuffer,\r
+  IN OUT UINT32                *DataLength,\r
+  IN     UINT32                StartLba,\r
+  IN     UINT32                SectorCount\r
+  );\r
 \r
-  EFI_STATUS\r
+/**\r
+  Submit Read(16) command.\r
 \r
---*/\r
-;\r
+  @param  ScsiDiskDevice     The pointer of ScsiDiskDevice\r
+  @param  NeedRetry          The pointer of flag indicates if needs retry if error happens\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
 \r
+  @return  EFI_STATUS is returned by calling ScsiRead16Command().\r
+**/\r
 EFI_STATUS\r
-ScsiDiskWrite10 (\r
-  SCSI_DISK_DEV         *ScsiDiskDevice,\r
-  BOOLEAN               *NeedRetry,\r
-  EFI_SCSI_SENSE_DATA   **SenseDataArray,\r
-  UINTN                 *NumberOfSenseKeys,\r
-  UINT64                Timeout,\r
-  UINT8                 *DataBuffer,\r
-  UINT32                *DataLength,\r
-  UINT32                StartLba,\r
-  UINT32                SectorSize\r
-  )\r
-/*++\r
+ScsiDiskRead16 (\r
+  IN     SCSI_DISK_DEV         *ScsiDiskDevice,\r
+     OUT BOOLEAN               *NeedRetry,\r
+  IN     UINT64                Timeout,\r
+     OUT UINT8                 *DataBuffer,\r
+  IN OUT UINT32                *DataLength,\r
+  IN     UINT64                StartLba,\r
+  IN     UINT32                SectorCount\r
+  );\r
+  \r
+/**\r
+  Submit Write(16) Command.\r
 \r
-Routine Description:\r
+  @param  ScsiDiskDevice     The pointer of ScsiDiskDevice\r
+  @param  NeedRetry          The pointer of flag indicates if needs retry if error happens\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 write\r
 \r
-  Submit Write Command\r
+  @return  EFI_STATUS is returned by calling ScsiWrite16Command().\r
 \r
-Arguments:\r
+**/\r
+EFI_STATUS\r
+ScsiDiskWrite16 (\r
+  IN     SCSI_DISK_DEV         *ScsiDiskDevice,\r
+     OUT BOOLEAN               *NeedRetry,\r
+  IN     UINT64                Timeout,\r
+  IN     UINT8                 *DataBuffer,\r
+  IN OUT UINT32                *DataLength,\r
+  IN     UINT64                StartLba,\r
+  IN     UINT32                SectorCount\r
+  );  \r
 \r
-  ScsiDiskDevice    - The pointer of ScsiDiskDevice\r
-  NeedRetry         - The pointer of flag indicates if needs retry if error happens\r
-  SenseDataArray    - The pointer of an array of sense data\r
-  NumberOfSenseKeys - The number of sense key\r
-  Timeout           - The time to complete the command\r
-  DataBuffer        - The buffer to fill with the read out data\r
-  DataLength        - The length of buffer\r
-  StartLba          - The start logic block address\r
-  SectorSize        - The size of sector\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
-Returns:\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
-  EFI_STATUS\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
-;\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
-VOID\r
-GetMediaInfo (\r
-  SCSI_DISK_DEV                 *ScsiDiskDevice,\r
-  EFI_SCSI_DISK_CAPACITY_DATA   *Capacity\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
-Routine Description:\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
-  Get information from media read capacity command\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
-Arguments:\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
-  ScsiDiskDevice  - The pointer of SCSI_DISK_DEV\r
-  Capacity        - The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
+/**\r
+  Get information from media read capacity command.\r
 \r
-Returns:\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV\r
+  @param  Capacity10      The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
+  @param  Capacity16      The pointer of EFI_SCSI_DISK_CAPACITY_DATA16\r
+**/\r
+VOID\r
+GetMediaInfo (\r
+  IN OUT SCSI_DISK_DEV                  *ScsiDiskDevice,\r
+  IN     EFI_SCSI_DISK_CAPACITY_DATA    *Capacity10,\r
+  IN     EFI_SCSI_DISK_CAPACITY_DATA16  *Capacity16\r
+  );\r
 \r
-  NONE\r
+/**\r
+  Check sense key to find if media presents.\r
 \r
---*/\r
-;\r
+  @param  SenseData   The pointer of EFI_SCSI_SENSE_DATA\r
+  @param  SenseCounts The number of sense key\r
 \r
+  @retval TRUE    NOT any media\r
+  @retval FALSE   Media presents\r
+**/\r
 BOOLEAN\r
 ScsiDiskIsNoMedia (\r
   IN  EFI_SCSI_SENSE_DATA   *SenseData,\r
   IN  UINTN                 SenseCounts\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check sense key to find if media presents\r
-\r
-Arguments:\r
-\r
-  SenseData   - The pointer of EFI_SCSI_SENSE_DATA\r
-  SenseCounts - The number of sense key\r
+  );\r
 \r
-Returns:\r
+/**\r
+  Parse sense key.\r
 \r
-  BOOLEAN\r
+  @param  SenseData    The pointer of EFI_SCSI_SENSE_DATA\r
+  @param  SenseCounts  The number of sense key\r
 \r
---*/\r
-;\r
+  @retval TRUE   Error\r
+  @retval FALSE  NOT error\r
 \r
+**/\r
 BOOLEAN\r
 ScsiDiskIsMediaError (\r
   IN  EFI_SCSI_SENSE_DATA   *SenseData,\r
   IN  UINTN                 SenseCounts\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Parse sense key\r
-\r
-Arguments:\r
-\r
-  SenseData   - The pointer of EFI_SCSI_SENSE_DATA\r
-  SenseCounts - The number of sense key\r
+  );\r
 \r
-Returns:\r
+/**\r
+  Check sense key to find if hardware error happens.\r
 \r
-  BOOLEAN\r
+  @param  SenseData     The pointer of EFI_SCSI_SENSE_DATA\r
+  @param  SenseCounts   The number of sense key\r
 \r
---*/\r
-;\r
+  @retval TRUE  Hardware error exits.\r
+  @retval FALSE NO error.\r
 \r
+**/\r
 BOOLEAN\r
 ScsiDiskIsHardwareError (\r
   IN  EFI_SCSI_SENSE_DATA   *SenseData,\r
   IN  UINTN                 SenseCounts\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check sense key to find if hardware error happens\r
-\r
-Arguments:\r
-\r
-  SenseData   - The pointer of EFI_SCSI_SENSE_DATA\r
-  SenseCounts - The number of sense key\r
-\r
-Returns:\r
+  );\r
 \r
-  BOOLEAN\r
+/**\r
+  Check sense key to find if media has changed.\r
 \r
---*/\r
-;\r
+  @param  SenseData    The pointer of EFI_SCSI_SENSE_DATA\r
+  @param  SenseCounts  The number of sense key\r
 \r
+  @retval TRUE   Media is changed.\r
+  @retval FALSE  Medit is NOT changed.\r
+**/\r
 BOOLEAN\r
 ScsiDiskIsMediaChange (\r
   IN  EFI_SCSI_SENSE_DATA   *SenseData,\r
   IN  UINTN                 SenseCounts\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-Routine Description:\r
-\r
- Check sense key to find if media has changed\r
-\r
-Arguments:\r
-\r
-  SenseData   - The pointer of EFI_SCSI_SENSE_DATA\r
-  SenseCounts - The number of sense key\r
+  );\r
 \r
-Returns:\r
+/**\r
+  Check sense key to find if reset happens.\r
 \r
-  BOOLEAN\r
+  @param  SenseData    The pointer of EFI_SCSI_SENSE_DATA\r
+  @param  SenseCounts  The number of sense key\r
 \r
---*/\r
-;\r
+  @retval TRUE  It is reset before.\r
+  @retval FALSE It is NOT reset before.\r
 \r
+**/\r
 BOOLEAN\r
 ScsiDiskIsResetBefore (\r
   IN  EFI_SCSI_SENSE_DATA   *SenseData,\r
   IN  UINTN                 SenseCounts\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check sense key to find if reset happens\r
-\r
-Arguments:\r
-\r
-  SenseData   - The pointer of EFI_SCSI_SENSE_DATA\r
-  SenseCounts - The number of sense key\r
+  );\r
 \r
-Returns:\r
+/**\r
+  Check sense key to find if the drive is ready.\r
 \r
-  BOOLEAN\r
+  @param  SenseData    The pointer of EFI_SCSI_SENSE_DATA\r
+  @param  SenseCounts  The number of sense key\r
+  @param  RetryLater   The flag means if need a retry \r
 \r
---*/\r
-;\r
+  @retval TRUE  Drive is ready.\r
+  @retval FALSE Drive is NOT ready.\r
 \r
+**/\r
 BOOLEAN\r
 ScsiDiskIsDriveReady (\r
   IN  EFI_SCSI_SENSE_DATA   *SenseData,\r
   IN  UINTN                 SenseCounts,\r
-  OUT BOOLEAN               *NeedRetry\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check sense key to find if the drive is ready\r
-\r
-Arguments:\r
-\r
-  SenseData   - The pointer of EFI_SCSI_SENSE_DATA\r
-  SenseCounts - The number of sense key\r
-  RetryLater  - The flag means if need a retry \r
+  OUT BOOLEAN               *RetryLater\r
+  );\r
 \r
-Returns:\r
+/**\r
+  Check sense key to find if it has sense key.\r
 \r
-  BOOLEAN\r
+  @param  SenseData   - The pointer of EFI_SCSI_SENSE_DATA\r
+  @param  SenseCounts - The number of sense key\r
 \r
---*/\r
-;\r
+  @retval TRUE  It has sense key.\r
+  @retval FALSE It has NOT any sense key.\r
 \r
+**/\r
 BOOLEAN\r
 ScsiDiskHaveSenseKey (\r
   IN  EFI_SCSI_SENSE_DATA   *SenseData,\r
   IN  UINTN                 SenseCounts\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Check sense key to find if it has sense key\r
-\r
-Arguments:\r
-\r
-  SenseData   - The pointer of EFI_SCSI_SENSE_DATA\r
-  SenseCounts - The number of sense key\r
-\r
-Returns:\r
+  );\r
 \r
-  BOOLEAN\r
+/**\r
+  Release resource about disk device.\r
 \r
---*/\r
-;\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV\r
 \r
+**/\r
 VOID\r
 ReleaseScsiDiskDeviceResources (\r
   IN  SCSI_DISK_DEV   *ScsiDiskDevice\r
-  )\r
-/*++\r
+  );\r
 \r
-Routine Description:\r
+/**\r
+  Determine if Block Io should be produced.\r
+  \r
 \r
-  Release resource about disk device\r
+  @param  ChildHandle  Child Handle to retrieve Parent information.\r
+  \r
+  @retval  TRUE    Should produce Block Io.\r
+  @retval  FALSE   Should not produce Block Io.\r
 \r
-Arguments:\r
+**/  \r
+BOOLEAN\r
+DetermineInstallBlockIo (\r
+  IN  EFI_HANDLE      ChildHandle\r
+  );\r
 \r
-  ScsiDiskDevice  - The pointer of SCSI_DISK_DEV\r
+/**\r
+  Initialize the installation of DiskInfo protocol.\r
 \r
-Returns:\r
+  This function prepares for the installation of DiskInfo protocol on the child handle.\r
+  By default, it installs DiskInfo protocol with SCSI interface GUID. If it further\r
+  detects that the physical device is an ATAPI/AHCI device, it then updates interface GUID\r
+  to be IDE/AHCI interface GUID.\r
 \r
-  NONE\r
+  @param  ScsiDiskDevice  The pointer of SCSI_DISK_DEV.\r
+  @param  ChildHandle     Child handle to install DiskInfo protocol.\r
+  \r
+**/  \r
+VOID\r
+InitializeInstallDiskInfo (\r
+  IN  SCSI_DISK_DEV   *ScsiDiskDevice,\r
+  IN  EFI_HANDLE      ChildHandle\r
+  ); \r
 \r
---*/\r
-;\r
+/**\r
+  Search protocol database and check to see if the protocol\r
+  specified by ProtocolGuid is present on a ControllerHandle and opened by\r
+  ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
+  If the ControllerHandle is found, then the protocol specified by ProtocolGuid\r
+  will be opened on it.  \r
+  \r
+\r
+  @param  ProtocolGuid   ProtocolGuid pointer.\r
+  @param  ChildHandle    Child Handle to retrieve Parent information.\r
+  \r
+**/ \r
+VOID *\r
+EFIAPI\r
+GetParentProtocol (\r
+  IN  EFI_GUID                          *ProtocolGuid,\r
+  IN  EFI_HANDLE                        ChildHandle\r
+  );\r
 \r
 #endif\r