summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>2009-05-19 09:07:38 +0000
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>2009-05-19 09:07:38 +0000
commit6b3ecf5cc2b47dba5bcc814f532c4d134e309c88 (patch)
tree1ed7de1f5c1dc7c5051ed7578c26e6c0c897cf2d
parent5dc4fd785603177d77d186f0d8d56ce7613db2cf (diff)
downloadedk2-platforms-6b3ecf5cc2b47dba5bcc814f532c4d134e309c88.tar.xz
Add back logic to encode LUN in CDB for compatibility with SCSI-2 spec, although LUN encoding in CDB is changed to be reserved in SCSI-3 spec.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8334 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdePkg/Library/UefiScsiLib/UefiScsiLib.c58
1 files changed, 56 insertions, 2 deletions
diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
index 434640ccd0..12af1338d3 100644
--- a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
+++ b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
@@ -115,6 +115,9 @@ ScsiTestUnitReadyCommand (
)
{
EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];
EFI_STATUS Status;
UINT8 Cdb[EFI_SCSI_OP_LENGTH_SIX];
@@ -136,7 +139,11 @@ ScsiTestUnitReadyCommand (
//
// Fill Cdb for Test Unit Ready Command
//
+ Target = &TargetArray[0];
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
Cdb[0] = EFI_SCSI_OP_TEST_UNIT_READY;
+ Cdb[1] = (UINT8) ((Lun << 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
CommandPacket.CdbLength = (UINT8) EFI_SCSI_OP_LENGTH_SIX;
CommandPacket.SenseDataLength = *SenseDataLength;
@@ -243,6 +250,9 @@ ScsiInquiryCommand (
)
{
EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];
EFI_STATUS Status;
UINT8 Cdb[EFI_SCSI_OP_LENGTH_SIX];
@@ -262,7 +272,11 @@ ScsiInquiryCommand (
CommandPacket.SenseDataLength = *SenseDataLength;
CommandPacket.Cdb = Cdb;
+ Target = &TargetArray[0];
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
Cdb[0] = EFI_SCSI_OP_INQUIRY;
+ Cdb[1] = (UINT8) ((Lun << 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
if (EnableVitalProductData) {
Cdb[1] |= 0x01;
}
@@ -384,6 +398,9 @@ ScsiModeSense10Command (
)
{
EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];
EFI_STATUS Status;
UINT8 Cdb[EFI_SCSI_OP_LENGTH_TEN];
@@ -404,15 +421,18 @@ ScsiModeSense10Command (
//
// Fill Cdb for Mode Sense (10) Command
//
+ Target = &TargetArray[0];
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
Cdb[0] = EFI_SCSI_OP_MODE_SEN10;
//
// DBDField is in Cdb[1] bit3 of (bit7..0)
//
- Cdb[1] = (UINT8) ((DBDField << 3) & 0x08);
+ Cdb[1] = (UINT8) (((Lun << 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK) + ((DBDField << 3) & 0x08));
//
// PageControl is in Cdb[2] bit7..6, PageCode is in Cdb[2] bit5..0
//
- Cdb[2] = (UINT8) (((PageControl & 0x3) << 6) | (PageCode & 0x3f));
+ Cdb[2] = (UINT8) (((PageControl << 6) & 0xc0) | (PageCode & 0x3f));
Cdb[7] = (UINT8) (*DataLength >> 8);
Cdb[8] = (UINT8) (*DataLength);
@@ -470,6 +490,9 @@ ScsiRequestSenseCommand (
)
{
EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];
EFI_STATUS Status;
UINT8 Cdb[EFI_SCSI_OP_LENGTH_SIX];
@@ -489,7 +512,11 @@ ScsiRequestSenseCommand (
//
// Fill Cdb for Request Sense Command
//
+ Target = &TargetArray[0];
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
Cdb[0] = EFI_SCSI_OP_REQUEST_SENSE;
+ Cdb[1] = (UINT8) ((Lun << 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
Cdb[4] = (UINT8) (*SenseDataLength);
CommandPacket.CdbLength = (UINT8) EFI_SCSI_OP_LENGTH_SIX;
@@ -556,6 +583,9 @@ ScsiReadCapacityCommand (
)
{
EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];
EFI_STATUS Status;
UINT8 Cdb[EFI_SCSI_OP_LENGTH_TEN];
@@ -576,7 +606,11 @@ ScsiReadCapacityCommand (
//
// Fill Cdb for Read Capacity Command
//
+ Target = &TargetArray[0];
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
Cdb[0] = EFI_SCSI_OP_READ_CAPACITY;
+ Cdb[1] = (UINT8) ((Lun << 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
if (!Pmi) {
//
// Partial medium indicator,if Pmi is FALSE, the Cdb.2 ~ Cdb.5 MUST BE ZERO.
@@ -651,6 +685,9 @@ ScsiReadCapacity16Command (
)
{
EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];
EFI_STATUS Status;
UINT8 Cdb[16];
@@ -665,6 +702,9 @@ ScsiReadCapacity16Command (
//
// Fill Cdb for Read Capacity Command
//
+ Target = &TargetArray[0];
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
Cdb[0] = EFI_SCSI_OP_READ_CAPACITY16;
Cdb[1] = 0x10;
if (!Pmi) {
@@ -745,6 +785,9 @@ ScsiRead10Command (
)
{
EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];
EFI_STATUS Status;
UINT8 Cdb[EFI_SCSI_OP_LENGTH_TEN];
@@ -765,7 +808,11 @@ ScsiRead10Command (
//
// Fill Cdb for Read (10) Command
//
+ Target = &TargetArray[0];
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
Cdb[0] = EFI_SCSI_OP_READ10;
+ Cdb[1] = (UINT8) ((Lun << 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
Cdb[2] = (UINT8) (StartLba >> 24);
Cdb[3] = (UINT8) (StartLba >> 16);
Cdb[4] = (UINT8) (StartLba >> 8);
@@ -840,6 +887,9 @@ ScsiWrite10Command (
)
{
EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;
+ UINT64 Lun;
+ UINT8 *Target;
+ UINT8 TargetArray[EFI_SCSI_TARGET_MAX_BYTES];
EFI_STATUS Status;
UINT8 Cdb[EFI_SCSI_OP_LENGTH_TEN];
@@ -860,7 +910,11 @@ ScsiWrite10Command (
//
// Fill Cdb for Write (10) Command
//
+ Target = &TargetArray[0];
+ ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
+
Cdb[0] = EFI_SCSI_OP_WRITE10;
+ Cdb[1] = (UINT8) ((Lun << 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
Cdb[2] = (UINT8) (StartLba >> 24);
Cdb[3] = (UINT8) (StartLba >> 16);
Cdb[4] = (UINT8) (StartLba >> 8);