]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiScsiLib/UefiScsiLib.c
Use GUIDed event for virtual address change event
[mirror_edk2.git] / MdePkg / Library / UefiScsiLib / UefiScsiLib.c
index 5f125ab29f6352b256e5afd9ecab605ac171c342..2b770b58e3fb656825ea8153eddc64f53ac413c0 100644 (file)
@@ -192,7 +192,7 @@ ScsiTestUnitReadyCommand (
                                          SCSI I/O Protocol in the UEFI Specification\r
                                          for details on the possible return values.\r
   @param[out]     TargetStatus           The status returned by the SCSI target specified\r
-                                         by ScsiIo when the SCSI Request Packat was\r
+                                         by ScsiIo when the SCSI Request Packet was\r
                                          executed on the SCSI Host Controller.\r
                                          See the EFI SCSI I/O Protocol in the UEFI\r
                                          Specification for details on the possible\r
@@ -338,7 +338,7 @@ ScsiInquiryCommand (
                                      UEFI Specification for details on the possible\r
                                      return values.\r
   @param[out]     TargetStatus       The status returned by the SCSI target specified\r
-                                     by ScsiIo when the SCSI Request Packat was executed\r
+                                     by ScsiIo when the SCSI Request Packet was executed\r
                                      on the SCSI Host Controller.  See the EFI SCSI\r
                                      I/O Protocol in the UEFI Specification for details\r
                                      on the possible return values.\r
@@ -539,7 +539,7 @@ ScsiRequestSenseCommand (
   Executes the SCSI Read Capacity command on the SCSI target specified by ScsiIo.\r
   If Timeout is zero, then this function waits indefinitely for the command to complete.\r
   If Timeout is greater than zero, then the command is executed and will timeout after\r
-  Timeout 100 ns units.  The PMI parameter is used to construct the CDB for this SCSI command.\r
+  Timeout 100 ns units.  The Pmi parameter is used to construct the CDB for this SCSI command.\r
   If ScsiIo is NULL, then ASSERT().\r
   If SenseDataLength is NULL, then ASSERT().\r
   If HostAdapterStatus is NULL, then ASSERT().\r
@@ -554,7 +554,7 @@ ScsiRequestSenseCommand (
   @param[out]     TargetStatus         The status of the target.\r
   @param[in, 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
+  @param[in]      Pmi                  Partial medium indicator.\r
 \r
   @retval  EFI_SUCCESS           Command is executed successfully.\r
   @retval  EFI_BAD_BUFFER_SIZE   The SCSI Request Packet was executed, but the entire\r
@@ -579,7 +579,7 @@ ScsiReadCapacityCommand (
      OUT UINT8                 *TargetStatus,\r
   IN OUT VOID                  *DataBuffer,   OPTIONAL\r
   IN OUT UINT32                *DataLength,\r
-  IN     BOOLEAN               PMI\r
+  IN     BOOLEAN               Pmi\r
   )\r
 {\r
   EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
@@ -611,9 +611,9 @@ ScsiReadCapacityCommand (
 \r
   Cdb[0]  = EFI_SCSI_OP_READ_CAPACITY;\r
   Cdb[1]  = (UINT8) (Lun & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
-  if (!PMI) {\r
+  if (!Pmi) {\r
     //\r
-    // Partial medium indicator,if PMI is FALSE, the Cdb.2 ~ Cdb.5 MUST BE ZERO.\r
+    // Partial medium indicator,if Pmi is FALSE, the Cdb.2 ~ Cdb.5 MUST BE ZERO.\r
     //\r
     ZeroMem ((Cdb + 2), 4);\r
   } else {\r
@@ -635,6 +635,99 @@ ScsiReadCapacityCommand (
 }\r
 \r
 \r
+/**\r
+  Function to submit read capacity16 command.\r
+\r
+  @param  ScsiIo            A pointer to SCSI IO protocol.\r
+  @param  Timeout           The length of timeout period.\r
+  @param  SenseData         A pointer to output sense data.\r
+  @param  SenseDataLength   The length of output sense data.\r
+  @param  HostAdapterStatus The status of Host Adapter.\r
+  @param  TargetStatus      The status of the target.\r
+  @param  DataBuffer        A pointer to a data buffer.\r
+  @param  DataLength        The length of data buffer.\r
+  @param  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.  \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
+EFIAPI\r
+ScsiReadCapacity16Command (\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
+  OUT VOID                  *DataBuffer,\r
+  IN OUT UINT32             *DataLength,\r
+  IN  BOOLEAN               Pmi\r
+  )\r
+{\r
+  EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
+  UINT64                          Lun;\r
+  UINT8                           *Target;\r
+  UINT8                           TargetArray[EFI_SCSI_TARGET_MAX_BYTES];\r
+  EFI_STATUS                      Status;\r
+  UINT8                           Cdb[16];\r
+\r
+  ZeroMem (&CommandPacket, sizeof (EFI_SCSI_IO_SCSI_REQUEST_PACKET));\r
+  ZeroMem (Cdb, 16);\r
+\r
+  CommandPacket.Timeout         = Timeout;\r
+  CommandPacket.InDataBuffer    = DataBuffer;\r
+  CommandPacket.SenseData       = SenseData;\r
+  CommandPacket.InTransferLength= *DataLength;\r
+  CommandPacket.Cdb             = Cdb;\r
+  //\r
+  // Fill Cdb for Read Capacity Command\r
+  //\r
+  Target = &TargetArray[0];\r
+  ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
+\r
+  Cdb[0]  = EFI_SCSI_OP_READ_CAPACITY16;\r
+  Cdb[1]  = 0x10;\r
+  if (!Pmi) {\r
+    //\r
+    // Partial medium indicator,if Pmi is FALSE, the Cdb.2 ~ Cdb.9 MUST BE ZERO.\r
+    //\r
+    ZeroMem ((Cdb + 2), 8);\r
+  } else {\r
+    Cdb[14] |= 0x01;\r
+  }\r
+\r
+  Cdb[13] = 0x20;\r
+  CommandPacket.CdbLength       = 16;\r
+  CommandPacket.DataDirection   = EFI_SCSI_DATA_IN;\r
+  CommandPacket.SenseDataLength = *SenseDataLength;\r
+\r
+  Status                        = ScsiIo->ExecuteScsiCommand (ScsiIo, &CommandPacket, NULL);\r
+\r
+  *HostAdapterStatus            = CommandPacket.HostAdapterStatus;\r
+  *TargetStatus                 = CommandPacket.TargetStatus;\r
+  *SenseDataLength              = CommandPacket.SenseDataLength;\r
+  *DataLength                   = CommandPacket.InTransferLength;\r
+\r
+  return Status;\r
+}\r
+\r
+\r
 /**\r
   Execute Read(10) SCSI command on a specific SCSI target.\r
 \r