/* Execute READ CAPACITY(10) SCSI command on a specific UFS device. */
EFI_STATUS UfsPeimReadCapacity(IN UFS_PEIM_HC_PRIVATE_DATA *Private, IN UINTN Lun, OUT VOID *DataBuffer, OUT UINT32 *DataLength, OUT VOID *SenseData OPTIONAL, OUT UINT8 *SenseDataLength)
/* Execute READ CAPACITY(10) SCSI command on a specific UFS device. */
EFI_STATUS UfsPeimReadCapacity(IN UFS_PEIM_HC_PRIVATE_DATA *Private, IN UINTN Lun, OUT VOID *DataBuffer, OUT UINT32 *DataLength, OUT VOID *SenseData OPTIONAL, OUT UINT8 *SenseDataLength)
{
  UFS_SCSI_REQUEST_PACKET  Packet;
  UINT8                    Cdb[UFS_SCSI_OP_LENGTH_TEN];
  EFI_STATUS               Status;
  ZeroMem (&Packet, sizeof (UFS_SCSI_REQUEST_PACKET));
  ZeroMem (Cdb, sizeof (Cdb));
  Cdb[0] = EFI_SCSI_OP_READ_CAPACITY;
  Packet.Timeout          = UFS_TIMEOUT;
  Packet.Cdb              = Cdb;
  Packet.CdbLength        = sizeof (Cdb);
  Packet.InDataBuffer     = DataBuffer;
  Packet.InTransferLength = *DataLength;
  Packet.DataDirection    = UfsDataIn;
  Packet.SenseData        = SenseData;
  Packet.SenseDataLength  = *SenseDataLength;
  Status = UfsExecScsiCmds (Private, (UINT8)Lun, &Packet);
  if (*SenseDataLength != 0) {
    *SenseDataLength = Packet.SenseDataLength;
  }
  if (!EFI_ERROR (Status)) {
    *DataLength = Packet.InTransferLength;
  }
  return Status;
}