]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiScsiLib/UefiScsiLib.c
Code Scrub the common includes in MdePkg.
[mirror_edk2.git] / MdePkg / Library / UefiScsiLib / UefiScsiLib.c
index 5eb94ba09c524880042fca68f70d686e7dac2378..ac032cd4d5bce9964a97ecb2716204291809d812 100644 (file)
@@ -1,75 +1,66 @@
-/*++\r
-\r
-Copyright (c) 2006, 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
-\r
---*/\r
-\r
-//\r
-// The package level header files this module uses\r
-//\r
-#include <PiDxe.h>\r
+/** @file\r
+  UEFI SCSI Library implementation\r
+\r
+  Copyright (c) 2006 - 2007, Intel Corporation.<BR>\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
+\r
+**/\r
+\r
 \r
-//\r
-// The protocols, PPI and GUID defintions for this module\r
-//\r
-//\r
-// The Library classes this module consumes\r
-//\r
+#include <PiDxe.h>\r
+#include <Library/DebugLib.h>\r
 #include <Library/ScsiLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 \r
-#include <IndustryStandard/scsi.h>\r
-\r
+#include <IndustryStandard/Scsi.h>\r
+\r
+\r
+/**\r
+  Function test the ready status of the SCSI unit.\r
+\r
+  @param[in]     ScsiIo             A pointer to SCSI IO protocol.\r
+  @param[in]     Timeout            The length of timeout period.\r
+  @param[in out] SenseData          A pointer to the sense data that \r
+                                    was generated by the execution of the SCSI Request Packet.\r
+  @param[in out] SenseDataLength    On input, the length in bytes of the SenseData buffer. On\r
+                                    output, the number of bytes written to the SenseData buffer.\r
+  @param[out]    HostAdapterStatus  The status of Host Adapter.\r
+  @param[out]    TargetStatus       The status of the target.\r
+\r
+  @retval EFI_SUCCESS           The status of the unit is tested successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE   The SCSI Request Packet was executed, \r
+                                but the entire DataBuffer could not be transferred.\r
+                                The actual number of bytes transferred is returned\r
+                                in InTransferLength.\r
+  @retval EFI_NOT_READY         The SCSI Request Packet could not be sent because \r
+                                there are too many SCSI Command Packets already \r
+                                queued.\r
+  @retval EFI_DEVICE_ERROR      A device error occurred while attempting to send \r
+                                the SCSI Request Packet.\r
+  @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL.  \r
+  @retval EFI_UNSUPPORTED       The command described by the SCSI Request Packet\r
+                                is not supported by the SCSI initiator(i.e., SCSI \r
+                                Host Controller).\r
+  @retval EFI_TIMEOUT           A timeout occurred while waiting for the SCSI \r
+                                Request Packet to execute.\r
+\r
+**/\r
 EFI_STATUS\r
-SubmitTestUnitReadyCommand (\r
+EFIAPI\r
+ScsiTestUnitReadyCommand (\r
   IN  EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
   IN  UINT64                Timeout,\r
-  OUT VOID                  *SenseData,\r
-  OUT UINT8                 *SenseDataLength,\r
+  IN OUT VOID               *SenseData,\r
+  IN OUT UINT8              *SenseDataLength,\r
   OUT UINT8                 *HostAdapterStatus,\r
   OUT UINT8                 *TargetStatus\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Function tests the ready status of SCSI unit.\r
-\r
-Arguments:\r
-  ScsiIo               - A pointer to SCSI IO protocol.\r
-  Timeout              - The length of timeout period.\r
-  SenseData            - A pointer to output sense data.\r
-  SenseDataLength      - The length of output sense data.\r
-  HostAdapterStatus    - The status of Host Adapter.\r
-  TargetStatus         - The status of the target.\r
-\r
-Returns:\r
-\r
-  Returns:\r
-    EFI_SUCCESS            - The status of the unit is tested successfully.\r
-  EFI_BAD_BUFFER_SIZE        - The SCSI Request Packet was executed, \r
-                            but the entire DataBuffer could not be transferred.\r
-                            The actual number of bytes transferred is returned\r
-                            in InTransferLength.\r
-    EFI_NOT_READY          - The SCSI Request Packet could not be sent because \r
-                            there are too many SCSI Command Packets already \r
-                            queued.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
-                            the SCSI Request Packet.\r
-    EFI_INVALID_PARAMETER  - The contents of CommandPacket are invalid.  \r
-    EFI_UNSUPPORTED        - The command described by the SCSI Request Packet\r
-                            is not supported by the SCSI initiator(i.e., SCSI \r
-                            Host Controller).\r
-    EFI_TIMEOUT            - A timeout occurred while waiting for the SCSI \r
-                            Request Packet to execute.\r
-\r
---*/\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
   UINT64                          Lun;\r
@@ -78,6 +69,13 @@ Returns:
   EFI_STATUS                      Status;\r
   UINT8                           Cdb[6];\r
 \r
+  ASSERT (SenseDataLength != NULL);\r
+  ASSERT (HostAdapterStatus != NULL);\r
+  ASSERT (TargetStatus != NULL);\r
+  \r
+  if (ScsiIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
 \r
   ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
   ZeroMem (Cdb, 6);\r
@@ -109,55 +107,52 @@ Returns:
   return Status;\r
 }\r
 \r
+\r
+/**\r
+  Function to submit SCSI inquiry command.\r
+\r
+  @param[in]     ScsiIo             SCSI IO Protocol to use\r
+  @param[in]     Timeout            The length of timeout period.\r
+  @param[out]    SenseData          A pointer to output sense data.\r
+  @param[in out] SenseDataLength    On input, the length in bytes of the SenseData buffer. On\r
+                                    output, the number of bytes written to the SenseData buffer.\r
+  @param[out]    HostAdapterStatus  The status of Host Adapter.\r
+  @param[out]    TargetStatus       The status of the target.\r
+  @param[in]     InquirydataBuffer  A pointer to inquiry data buffer.\r
+  @param[in,out] InquiryDataLength  The length of inquiry data buffer.\r
+  @param[in]     EnableVitalProductData  Boolean to enable Vital Product Data.\r
+\r
+  @retval EFI_SUCCESS         The status of the unit is tested successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed, \r
+                              but the entire DataBuffer could not be transferred.\r
+                              The actual number of bytes transferred is returned\r
+                              in TransferLength.\r
+  @retval EFI_NOT_READY   The SCSI Request Packet could not be sent because \r
+                          there are too many SCSI Command Packets already \r
+                          queued.\r
+  @retval EFI_DEVICE_ERROR  A device error occurred while attempting to send \r
+                            the SCSI Request Packet.\r
+  @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid, or ScsiIo is NULL.\r
+  @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
+                          is not supported by the SCSI initiator(i.e., SCSI \r
+                          Host Controller).\r
+  @retval EFI_TIMEOUT     A timeout occurred while waiting for the SCSI \r
+                          Request Packet to execute.\r
+\r
+**/\r
 EFI_STATUS\r
-SubmitInquiryCommand (\r
+EFIAPI\r
+ScsiInquiryCommand (\r
   IN  EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
   IN  UINT64                Timeout,\r
   IN  VOID                  *SenseData,\r
   IN OUT UINT8              *SenseDataLength,\r
   OUT UINT8                 *HostAdapterStatus,\r
   OUT UINT8                 *TargetStatus,\r
-  IN OUT VOID               *InquiryDataBuffer,\r
+  IN VOID                   *InquiryDataBuffer,\r
   IN OUT UINT32             *InquiryDataLength,\r
   IN  BOOLEAN               EnableVitalProductData\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Function to submit SCSI inquiry command.\r
-\r
-Arguments:\r
-  ScsiIo               - A pointer to SCSI IO protocol.\r
-  Timeout              - The length of timeout period.\r
-  SenseData            - A pointer to output sense data.\r
-  SenseDataLength      - The length of output sense data.\r
-  HostAdapterStatus    - The status of Host Adapter.\r
-  TargetStatus         - The status of the target.\r
-  InquiryDataBuffer    - A pointer to inquiry data buffer.\r
-  InquiryDataLength    - The length of inquiry data buffer.\r
-  EnableVitalProductData - Boolean to enable Vital Product Data.\r
-\r
-Returns:\r
-\r
-  Returns:\r
-    EFI_SUCCESS            - The status of the unit is tested successfully.\r
-  EFI_BAD_BUFFER_SIZE        - The SCSI Request Packet was executed, \r
-                            but the entire DataBuffer could not be transferred.\r
-                            The actual number of bytes transferred is returned\r
-                            in TransferLength.\r
-    EFI_NOT_READY          - The SCSI Request Packet could not be sent because \r
-                            there are too many SCSI Command Packets already \r
-                            queued.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
-                            the SCSI Request Packet.\r
-    EFI_INVALID_PARAMETER  - The contents of CommandPacket are invalid.  \r
-    EFI_UNSUPPORTED        - The command described by the SCSI Request Packet\r
-                            is not supported by the SCSI initiator(i.e., SCSI \r
-                            Host Controller).\r
-    EFI_TIMEOUT            - A timeout occurred while waiting for the SCSI \r
-                            Request Packet to execute.\r
-\r
---*/\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
   UINT64                          Lun;\r
@@ -166,6 +161,15 @@ Returns:
   EFI_STATUS                      Status;\r
   UINT8                           Cdb[6];\r
 \r
+  ASSERT (SenseDataLength != NULL);\r
+  ASSERT (HostAdapterStatus != NULL);\r
+  ASSERT (TargetStatus != NULL);\r
+  ASSERT (InquiryDataLength != NULL);\r
+  \r
+  if (ScsiIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
   ZeroMem (Cdb, 6);\r
 \r
@@ -203,8 +207,44 @@ Returns:
   return Status;\r
 }\r
 \r
+\r
+/**\r
+  Function to submit SCSI mode sense 10 command.\r
+\r
+  @param[in]     ScsiIo             A pointer to SCSI IO protocol.\r
+  @param[in]     Timeout            The length of timeout period.\r
+  @param[out]    SenseData          A pointer to output sense data.\r
+  @param[in out] SenseDataLength    On input, the length in bytes of the SenseData buffer. On\r
+                                    output, the number of bytes written to the SenseData buffer.\r
+  @param[out]    HostAdapterStatus  The status of Host Adapter.\r
+  @param[out]    TargetStatus       The status of the target.\r
+  @param[in]     DataBuffer         A pointer to input data buffer.\r
+  @param[in,out] DataLength         The length of input data buffer.\r
+  @param[in]     DBDField           The DBD Field (Optional).\r
+  @param[in]     PageControl        Page Control.\r
+  @param[in]     PageCode           Page code.\r
+\r
+  @retval EFI_SUCCESS               The status of the unit is tested successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE       The SCSI Request Packet was executed, \r
+                                    but the entire DataBuffer could not be transferred.\r
+                                    The actual number of bytes transferred is returned\r
+                                    in TransferLength.\r
+  @retval EFI_NOT_READY             The SCSI Request Packet could not be sent because \r
+                                    there are too many SCSI Command Packets already \r
+                                    queued.\r
+  @retval EFI_DEVICE_ERROR          A device error occurred while attempting to send \r
+                                    the SCSI Request Packet.\r
+  @retval EFI_INVALID_PARAMETER     The contents of CommandPacket are invalid, or ScsiIo is NULL.  \r
+  @retval EFI_UNSUPPORTED           The command described by the SCSI Request Packet\r
+                                    is not supported by the SCSI initiator(i.e., SCSI \r
+                                    Host Controller).\r
+  @retval EFI_TIMEOUT               A timeout occurred while waiting for the SCSI \r
+                                    Request Packet to execute.\r
+\r
+**/\r
 EFI_STATUS\r
-SubmitModeSense10Command (\r
+EFIAPI\r
+ScsiModeSense10Command (\r
   IN  EFI_SCSI_IO_PROTOCOL    *ScsiIo,\r
   IN  UINT64                  Timeout,\r
   IN  VOID                    *SenseData,\r
@@ -217,45 +257,6 @@ SubmitModeSense10Command (
   IN  UINT8                   PageControl,\r
   IN  UINT8                   PageCode\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Function to submit SCSI mode sense 10 command.\r
-\r
-Arguments:\r
-  ScsiIo               - A pointer to SCSI IO protocol.\r
-  Timeout              - The length of timeout period.\r
-  SenseData            - A pointer to output sense data.\r
-  SenseDataLength      - The length of output sense data.\r
-  HostAdapterStatus    - The status of Host Adapter.\r
-  TargetStatus         - The status of the target.\r
-  DataBuffer           - A pointer to input data buffer.\r
-  DataLength           - The length of input data buffer.\r
-  DBDField             - The DBD Field (Optional).\r
-  PageControl          - Page Control.\r
-  PageCode             - Page code.\r
-\r
-Returns:\r
-\r
-  Returns:\r
-    EFI_SUCCESS            - The status of the unit is tested successfully.\r
-    EFI_WARN_BUFFER_TOO_SMALL  - The SCSI Request Packet was executed, \r
-                            but the entire DataBuffer could not be transferred.\r
-                            The actual number of bytes transferred is returned\r
-                            in TransferLength.\r
-    EFI_NOT_READY          - The SCSI Request Packet could not be sent because \r
-                            there are too many SCSI Command Packets already \r
-                            queued.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
-                            the SCSI Request Packet.\r
-    EFI_INVALID_PARAMETER  - The contents of CommandPacket are invalid.  \r
-    EFI_UNSUPPORTED        - The command described by the SCSI Request Packet\r
-                            is not supported by the SCSI initiator(i.e., SCSI \r
-                            Host Controller).\r
-    EFI_TIMEOUT            - A timeout occurred while waiting for the SCSI \r
-                            Request Packet to execute.\r
-\r
---*/\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
   UINT64                          Lun;\r
@@ -264,6 +265,15 @@ Returns:
   EFI_STATUS                      Status;\r
   UINT8                           Cdb[10];\r
 \r
+  ASSERT (SenseDataLength != NULL);\r
+  ASSERT (HostAdapterStatus != NULL);\r
+  ASSERT (TargetStatus != NULL);\r
+  ASSERT (DataLength != NULL);\r
+  \r
+  if (ScsiIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
   ZeroMem (Cdb, 10);\r
 \r
@@ -279,7 +289,7 @@ Returns:
   ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
 \r
   Cdb[0]                        = EFI_SCSI_OP_MODE_SEN10;\r
-  Cdb[1]                        = (UINT8) (Lun & 0xe0 + (DBDField << 3) & 0x08);\r
+  Cdb[1]                        = (UINT8) ((Lun & 0xe0) + ((DBDField << 3) & 0x08));\r
   Cdb[2]                        = (UINT8) ((PageControl & 0xc0) | (PageCode & 0x3f));\r
   Cdb[7]                        = (UINT8) (*DataLength >> 8);\r
   Cdb[8]                        = (UINT8) (*DataLength);\r
@@ -298,8 +308,40 @@ Returns:
   return Status;\r
 }\r
 \r
+\r
+/**\r
+  Function to submit SCSI request sense command.\r
+\r
+  @param[in]     ScsiIo             A pointer to SCSI IO protocol.\r
+  @param[in]     Timeout            The length of timeout period.\r
+  @param[in]     SenseData          A pointer to output sense data.\r
+  @param[in out] SenseDataLength    On input, the length in bytes of the SenseData buffer. On\r
+                                    output, the number of bytes written to the SenseData buffer.\r
+  @param[out]    HostAdapterStatus  The status of Host Adapter.\r
+  @param[out]    TargetStatus       The status of the target.\r
+\r
+  @retval EFI_SUCCESS        Valid data returned\r
+  @retval EFI_SUCCESS        The status of the unit is tested successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE       The SCSI Request Packet was executed, \r
+                                    but the entire DataBuffer could not be transferred.\r
+                                    The actual number of bytes transferred is returned\r
+                                    in TransferLength.\r
+  @retval EFI_NOT_READY             The SCSI Request Packet could not be sent because \r
+                                    there are too many SCSI Command Packets already \r
+                                    queued.\r
+  @retval EFI_DEVICE_ERROR          A device error occurred while attempting to send \r
+                                    the SCSI Request Packet.\r
+  @retval EFI_INVALID_PARAMETER     The contents of CommandPacket are invalid, or ScsiIo is NULL.\r
+  @retval EFI_UNSUPPORTED           The command described by the SCSI Request Packet\r
+                                    is not supported by the SCSI initiator(i.e., SCSI \r
+                                    Host Controller).\r
+  @retval EFI_TIMEOUT               A timeout occurred while waiting for the SCSI \r
+                                    Request Packet to execute.\r
+\r
+**/\r
 EFI_STATUS\r
-SubmitRequestSenseCommand (\r
+EFIAPI\r
+ScsiRequestSenseCommand (\r
   IN  EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
   IN  UINT64                Timeout,\r
   IN  VOID                  *SenseData,\r
@@ -307,40 +349,6 @@ SubmitRequestSenseCommand (
   OUT UINT8                 *HostAdapterStatus,\r
   OUT UINT8                 *TargetStatus\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Function to submit SCSI request sense command.\r
-\r
-Arguments:\r
-  ScsiIo               - A pointer to SCSI IO protocol.\r
-  Timeout              - The length of timeout period.\r
-  SenseData            - A pointer to output sense data.\r
-  SenseDataLength      - The length of output sense data.\r
-  HostAdapterStatus    - The status of Host Adapter.\r
-  TargetStatus         - The status of the target.\r
-\r
-Returns:\r
-\r
-  Returns:\r
-    EFI_SUCCESS            - The status of the unit is tested successfully.\r
-    EFI_WARN_BUFFER_TOO_SMALL  - The SCSI Request Packet was executed, \r
-                            but the entire DataBuffer could not be transferred.\r
-                            The actual number of bytes transferred is returned\r
-                            in TransferLength.\r
-    EFI_NOT_READY          - The SCSI Request Packet could not be sent because \r
-                            there are too many SCSI Command Packets already \r
-                            queued.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
-                            the SCSI Request Packet.\r
-    EFI_INVALID_PARAMETER  - The contents of CommandPacket are invalid.  \r
-    EFI_UNSUPPORTED        - The command described by the SCSI Request Packet\r
-                            is not supported by the SCSI initiator(i.e., SCSI \r
-                            Host Controller).\r
-    EFI_TIMEOUT            - A timeout occurred while waiting for the SCSI \r
-                            Request Packet to execute.\r
-\r
---*/\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
   UINT64                          Lun;\r
@@ -349,6 +357,14 @@ Returns:
   EFI_STATUS                      Status;\r
   UINT8                           Cdb[6];\r
 \r
+  ASSERT (SenseDataLength != NULL);\r
+  ASSERT (HostAdapterStatus != NULL);\r
+  ASSERT (TargetStatus != NULL);\r
+  \r
+  if (ScsiIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
   ZeroMem (Cdb, 6);\r
 \r
@@ -380,8 +396,42 @@ Returns:
   return Status;\r
 }\r
 \r
+\r
+/**\r
+  Function to submit read capacity command.\r
+\r
+  @param[in]     ScsiIo             A pointer to SCSI IO protocol.\r
+  @param[in]     Timeout            The length of timeout period.\r
+  @param[out]    SenseData          A pointer to output sense data.\r
+  @param[in out] SenseDataLength    On input, the length in bytes of the SenseData buffer. On\r
+                                    output, the number of bytes written to the SenseData buffer.\r
+  @param[out]    HostAdapterStatus  The status of Host Adapter.\r
+  @param[out]    TargetStatus       The status of the target.\r
+  @param[out]    DataBuffer         A pointer to a data buffer.\r
+  @param[in,out] DataLength         The length of data buffer.\r
+  @param[in]     PMI                Partial medium indicator.\r
+\r
+  @retval  EFI_SUCCESS                The status of the unit is tested successfully.\r
+  @retval  EFI_BAD_BUFFER_SIZE        The SCSI Request Packet was executed, \r
+                                      but the entire DataBuffer could not be transferred.\r
+                                      The actual number of bytes transferred is returned\r
+                                      in TransferLength.\r
+  @retval  EFI_NOT_READY              The SCSI Request Packet could not be sent because \r
+                                      there are too many SCSI Command Packets already \r
+                                      queued.\r
+  @retval  EFI_DEVICE_ERROR           A device error occurred while attempting to send \r
+                                      the SCSI Request Packet.\r
+  @retval  EFI_INVALID_PARAMETER      The contents of CommandPacket are invalid, or ScsiIo is NULL.\r
+  @retval  EFI_UNSUPPORTED            The command described by the SCSI Request Packet\r
+                                      is not supported by the SCSI initiator(i.e., SCSI \r
+                                      Host Controller).\r
+  @retval  EFI_TIMEOUT                A timeout occurred while waiting for the SCSI \r
+                                      Request Packet to execute.\r
+\r
+**/\r
 EFI_STATUS\r
-SubmitReadCapacityCommand (\r
+EFIAPI\r
+ScsiReadCapacityCommand (\r
   IN  EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
   IN  UINT64                Timeout,\r
   IN  VOID                  *SenseData,\r
@@ -392,43 +442,6 @@ SubmitReadCapacityCommand (
   IN OUT UINT32             *DataLength,\r
   IN  BOOLEAN               PMI\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Function to submit read capacity command.\r
-\r
-Arguments:\r
-  ScsiIo               - A pointer to SCSI IO protocol.\r
-  Timeout              - The length of timeout period.\r
-  SenseData            - A pointer to output sense data.\r
-  SenseDataLength      - The length of output sense data.\r
-  HostAdapterStatus    - The status of Host Adapter.\r
-  TargetStatus         - The status of the target.\r
-  DataBuffer           - A pointer to a data buffer.\r
-  DataLength           - The length of data buffer.\r
-  PMI                  - Partial medium indicator.\r
-\r
-Returns:\r
-\r
-  Returns:\r
-    EFI_SUCCESS            - The status of the unit is tested successfully.\r
-    EFI_WARN_BUFFER_TOO_SMALL  - The SCSI Request Packet was executed, \r
-                            but the entire DataBuffer could not be transferred.\r
-                            The actual number of bytes transferred is returned\r
-                            in TransferLength.\r
-    EFI_NOT_READY          - The SCSI Request Packet could not be sent because \r
-                            there are too many SCSI Command Packets already \r
-                            queued.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
-                            the SCSI Request Packet.\r
-    EFI_INVALID_PARAMETER  - The contents of CommandPacket are invalid.  \r
-    EFI_UNSUPPORTED        - The command described by the SCSI Request Packet\r
-                            is not supported by the SCSI initiator(i.e., SCSI \r
-                            Host Controller).\r
-    EFI_TIMEOUT            - A timeout occurred while waiting for the SCSI \r
-                            Request Packet to execute.\r
-\r
---*/\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
   UINT64                          Lun;\r
@@ -437,6 +450,15 @@ Returns:
   EFI_STATUS                      Status;\r
   UINT8                           Cdb[10];\r
 \r
+  ASSERT (SenseDataLength != NULL);\r
+  ASSERT (HostAdapterStatus != NULL);\r
+  ASSERT (TargetStatus != NULL);\r
+  ASSERT (DataLength != NULL);\r
+  \r
+  if (ScsiIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
   ZeroMem (Cdb, 10);\r
 \r
@@ -476,8 +498,43 @@ Returns:
   return Status;\r
 }\r
 \r
+\r
+/**\r
+  Function to submit read 10 command.\r
+\r
+  @param[in]     ScsiIo             A pointer to SCSI IO protocol.\r
+  @param[in]     Timeout            The length of timeout period.\r
+  @param[out]    SenseData          A pointer to output sense data.\r
+  @param[in out] SenseDataLength    On input, the length in bytes of the SenseData buffer. On\r
+                                    output, the number of bytes written to the SenseData buffer.\r
+  @param[out]    HostAdapterStatus  The status of Host Adapter.\r
+  @param[out]    TargetStatus       The status of the target.\r
+  @param[out]    DataBuffer         Read 10 command data.\r
+  @param[in,out] DataLength         The length of data buffer.\r
+  @param[in]     StartLba           The start address of LBA.\r
+  @param[in]     SectorSize         The sector size.\r
+\r
+  @retval EFI_SUCCESS               The status of the unit is tested successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE       The SCSI Request Packet was executed, \r
+                                    but the entire DataBuffer could not be transferred.\r
+                                    The actual number of bytes transferred is returned\r
+                                    in TransferLength.\r
+  @retval EFI_NOT_READY             The SCSI Request Packet could not be sent because \r
+                                    there are too many SCSI Command Packets already \r
+                                    queued.\r
+  @retval EFI_DEVICE_ERROR          A device error occurred while attempting to send \r
+                                    the SCSI Request Packet.\r
+  @retval EFI_INVALID_PARAMETER     The contents of CommandPacket are invalid, or ScsiIo is NULL.\r
+  @retval EFI_UNSUPPORTED           The command described by the SCSI Request Packet\r
+                                    is not supported by the SCSI initiator(i.e., SCSI \r
+                                    Host Controller).\r
+  @retval EFI_TIMEOUT               A timeout occurred while waiting for the SCSI \r
+                                    Request Packet to execute.\r
+\r
+**/\r
 EFI_STATUS\r
-SubmitRead10Command (\r
+EFIAPI\r
+ScsiRead10Command (\r
   IN  EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
   IN  UINT64                Timeout,\r
   IN  VOID                  *SenseData,\r
@@ -489,44 +546,6 @@ SubmitRead10Command (
   IN  UINT32                StartLba,\r
   IN  UINT32                SectorSize\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Function to submit read 10 command.\r
-\r
-Arguments:\r
-  ScsiIo               - A pointer to SCSI IO protocol.\r
-  Timeout              - The length of timeout period.\r
-  SenseData            - A pointer to output sense data.\r
-  SenseDataLength      - The length of output sense data.\r
-  HostAdapterStatus    - The status of Host Adapter.\r
-  TargetStatus         - The status of the target.\r
-  DataBuffer           - A pointer to a data buffer.\r
-  DataLength           - The length of data buffer.\r
-  StartLba             - The start address of LBA.\r
-  SectorSize           - The sector size.\r
-\r
-Returns:\r
-\r
-  Returns:\r
-    EFI_SUCCESS            - The status of the unit is tested successfully.\r
-    EFI_WARN_BUFFER_TOO_SMALL  - The SCSI Request Packet was executed, \r
-                            but the entire DataBuffer could not be transferred.\r
-                            The actual number of bytes transferred is returned\r
-                            in TransferLength.\r
-    EFI_NOT_READY          - The SCSI Request Packet could not be sent because \r
-                            there are too many SCSI Command Packets already \r
-                            queued.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
-                            the SCSI Request Packet.\r
-    EFI_INVALID_PARAMETER  - The contents of CommandPacket are invalid.  \r
-    EFI_UNSUPPORTED        - The command described by the SCSI Request Packet\r
-                            is not supported by the SCSI initiator(i.e., SCSI \r
-                            Host Controller).\r
-    EFI_TIMEOUT            - A timeout occurred while waiting for the SCSI \r
-                            Request Packet to execute.\r
-\r
---*/\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
   UINT64                          Lun;\r
@@ -535,6 +554,15 @@ Returns:
   EFI_STATUS                      Status;\r
   UINT8                           Cdb[10];\r
 \r
+  ASSERT (SenseDataLength != NULL);\r
+  ASSERT (HostAdapterStatus != NULL);\r
+  ASSERT (TargetStatus != NULL);\r
+  ASSERT (DataLength != NULL);\r
+  \r
+  if (ScsiIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
   ZeroMem (Cdb, 10);\r
 \r
@@ -572,8 +600,43 @@ Returns:
   return Status;\r
 }\r
 \r
+\r
+/**\r
+  Function to submit SCSI write 10 command.\r
+\r
+  @param[in]     ScsiIo             SCSI IO Protocol to use\r
+  @param[in]     Timeout            The length of timeout period.\r
+  @param[out]    SenseData          A pointer to output sense data.\r
+  @param[in out] SenseDataLength    On input, the length in bytes of the SenseData buffer. On\r
+                                    output, the number of bytes written to the SenseData buffer.\r
+  @param[out]    HostAdapterStatus  The status of Host Adapter.\r
+  @param[out]    TargetStatus       The status of the target.\r
+  @param[out]    DataBuffer         A pointer to a data buffer.\r
+  @param[in,out] DataLength         The length of data buffer.\r
+  @param[in]     StartLba           The start address of LBA.\r
+  @param[in]     SectorSize         The sector size.\r
+\r
+  @retval EFI_SUCCESS               The status of the unit is tested successfully.\r
+  @retval EFI_BAD_BUFFER_SIZE       The SCSI Request Packet was executed, \r
+                                    but the entire DataBuffer could not be transferred.\r
+                                    The actual number of bytes transferred is returned\r
+                                    in InTransferLength.\r
+  @retval EFI_NOT_READY             The SCSI Request Packet could not be sent because \r
+                                    there are too many SCSI Command Packets already \r
+                                    queued.\r
+  @retval EFI_DEVICE_ERROR          A device error occurred while attempting to send \r
+                                    the SCSI Request Packet.\r
+  @retval EFI_INVALID_PARAMETER     The contents of CommandPacket are invalid, or ScsiIo is NULL.\r
+  @retval EFI_UNSUPPORTED           The command described by the SCSI Request Packet\r
+                                    is not supported by the SCSI initiator(i.e., SCSI \r
+                                    Host Controller).\r
+  @retval EFI_TIMEOUT               A timeout occurred while waiting for the SCSI \r
+                                    Request Packet to execute.\r
+\r
+**/\r
 EFI_STATUS\r
-SubmitWrite10Command (\r
+EFIAPI\r
+ScsiWrite10Command (\r
   IN  EFI_SCSI_IO_PROTOCOL  *ScsiIo,\r
   IN  UINT64                Timeout,\r
   IN  VOID                  *SenseData,\r
@@ -585,44 +648,6 @@ SubmitWrite10Command (
   IN  UINT32                StartLba,\r
   IN  UINT32                SectorSize\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-  Function to submit SCSI write 10 command.\r
-\r
-Arguments:\r
-  ScsiIo               - A pointer to SCSI IO protocol.\r
-  Timeout              - The length of timeout period.\r
-  SenseData            - A pointer to output sense data.\r
-  SenseDataLength      - The length of output sense data.\r
-  HostAdapterStatus    - The status of Host Adapter.\r
-  TargetStatus         - The status of the target.\r
-  DataBuffer           - A pointer to a data buffer.\r
-  DataLength           - The length of data buffer.\r
-  StartLba             - The start address of LBA.\r
-  SectorSize           - The sector size.\r
-\r
-Returns:\r
-\r
-  Returns:\r
-    EFI_SUCCESS            - The status of the unit is tested successfully.\r
-    EFI_WARN_BUFFER_TOO_SMALL  - The SCSI Request Packet was executed, \r
-                            but the entire DataBuffer could not be transferred.\r
-                            The actual number of bytes transferred is returned\r
-                            in InTransferLength.\r
-    EFI_NOT_READY          - The SCSI Request Packet could not be sent because \r
-                            there are too many SCSI Command Packets already \r
-                            queued.\r
-    EFI_DEVICE_ERROR      - A device error occurred while attempting to send \r
-                            the SCSI Request Packet.\r
-    EFI_INVALID_PARAMETER  - The contents of CommandPacket are invalid.  \r
-    EFI_UNSUPPORTED        - The command described by the SCSI Request Packet\r
-                            is not supported by the SCSI initiator(i.e., SCSI \r
-                            Host Controller).\r
-    EFI_TIMEOUT            - A timeout occurred while waiting for the SCSI \r
-                            Request Packet to execute.\r
-\r
---*/\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
   UINT64                          Lun;\r
@@ -631,6 +656,15 @@ Returns:
   EFI_STATUS                      Status;\r
   UINT8                           Cdb[10];\r
 \r
+  ASSERT (SenseDataLength != NULL);\r
+  ASSERT (HostAdapterStatus != NULL);\r
+  ASSERT (TargetStatus != NULL);\r
+  ASSERT (DataLength != NULL);\r
+  \r
+  if (ScsiIo == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
   ZeroMem (Cdb, 10);\r
 \r
@@ -663,7 +697,8 @@ Returns:
   *HostAdapterStatus            = CommandPacket.HostAdapterStatus;\r
   *TargetStatus                 = CommandPacket.TargetStatus;\r
   *SenseDataLength              = CommandPacket.SenseDataLength;\r
-  *DataLength                   = CommandPacket.InTransferLength;\r
+  *DataLength                   = CommandPacket.OutTransferLength;\r
 \r
   return Status;\r
 }\r
+\r