Fix bugs in the UEFI SCSI Library.
authorrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 19 May 2009 05:42:37 +0000 (05:42 +0000)
committerrsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 19 May 2009 05:42:37 +0000 (05:42 +0000)
1. LUN number should not be encoded in CDB.
2. Left shift the PageControl field by 6 bits in ScsiModeSense10Command().

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8331 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/UefiScsiLib/UefiScsiLib.c

index c52f500..434640c 100644 (file)
@@ -115,9 +115,6 @@ ScsiTestUnitReadyCommand (
   )\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[EFI_SCSI_OP_LENGTH_SIX];\r
 \r
@@ -139,11 +136,7 @@ ScsiTestUnitReadyCommand (
   //\r
   // Fill Cdb for Test Unit Ready Command\r
   //\r
-  Target = &TargetArray[0];\r
-  ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
-\r
   Cdb[0]                        = EFI_SCSI_OP_TEST_UNIT_READY;\r
-  Cdb[1]                        = (UINT8) (Lun & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
   CommandPacket.CdbLength       = (UINT8) EFI_SCSI_OP_LENGTH_SIX;\r
   CommandPacket.SenseDataLength = *SenseDataLength;\r
 \r
@@ -250,9 +243,6 @@ ScsiInquiryCommand (
   )\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[EFI_SCSI_OP_LENGTH_SIX];\r
 \r
@@ -272,11 +262,7 @@ ScsiInquiryCommand (
   CommandPacket.SenseDataLength = *SenseDataLength;\r
   CommandPacket.Cdb             = Cdb;\r
 \r
-  Target = &TargetArray[0];\r
-  ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
-\r
   Cdb[0]  = EFI_SCSI_OP_INQUIRY;\r
-  Cdb[1]  = (UINT8) (Lun & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
   if (EnableVitalProductData) {\r
     Cdb[1] |= 0x01;\r
   }\r
@@ -398,9 +384,6 @@ ScsiModeSense10Command (
   )\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[EFI_SCSI_OP_LENGTH_TEN];\r
 \r
@@ -421,18 +404,15 @@ ScsiModeSense10Command (
   //\r
   // Fill Cdb for Mode Sense (10) Command\r
   //\r
-  Target = &TargetArray[0];\r
-  ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
-\r
   Cdb[0]                        = EFI_SCSI_OP_MODE_SEN10;\r
   //\r
   // DBDField is in Cdb[1] bit3 of (bit7..0)\r
   //\r
-  Cdb[1]                        = (UINT8) ((Lun & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK) + ((DBDField << 3) & 0x08));\r
+  Cdb[1]                        = (UINT8) ((DBDField << 3) & 0x08);\r
   //\r
   // PageControl is in Cdb[2] bit7..6, PageCode is in Cdb[2] bit5..0\r
   //\r
-  Cdb[2]                        = (UINT8) ((PageControl & 0xc0) | (PageCode & 0x3f));\r
+  Cdb[2]                        = (UINT8) (((PageControl & 0x3) << 6) | (PageCode & 0x3f));\r
   Cdb[7]                        = (UINT8) (*DataLength >> 8);\r
   Cdb[8]                        = (UINT8) (*DataLength);\r
 \r
@@ -490,9 +470,6 @@ ScsiRequestSenseCommand (
   )\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[EFI_SCSI_OP_LENGTH_SIX];\r
 \r
@@ -512,11 +489,7 @@ ScsiRequestSenseCommand (
   //\r
   // Fill Cdb for Request Sense Command\r
   //\r
-  Target = &TargetArray[0];\r
-  ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
-\r
   Cdb[0]                        = EFI_SCSI_OP_REQUEST_SENSE;\r
-  Cdb[1]                        = (UINT8) (Lun & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
   Cdb[4]                        = (UINT8) (*SenseDataLength);\r
 \r
   CommandPacket.CdbLength       = (UINT8) EFI_SCSI_OP_LENGTH_SIX;\r
@@ -583,9 +556,6 @@ ScsiReadCapacityCommand (
   )\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[EFI_SCSI_OP_LENGTH_TEN];\r
 \r
@@ -606,11 +576,7 @@ ScsiReadCapacityCommand (
   //\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_CAPACITY;\r
-  Cdb[1]  = (UINT8) (Lun & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
   if (!Pmi) {\r
     //\r
     // Partial medium indicator,if Pmi is FALSE, the Cdb.2 ~ Cdb.5 MUST BE ZERO.\r
@@ -685,9 +651,6 @@ ScsiReadCapacity16Command (
   )\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
@@ -702,9 +665,6 @@ ScsiReadCapacity16Command (
   //\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
@@ -785,9 +745,6 @@ ScsiRead10Command (
   )\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[EFI_SCSI_OP_LENGTH_TEN];\r
 \r
@@ -808,11 +765,7 @@ ScsiRead10Command (
   //\r
   // Fill Cdb for Read (10) Command\r
   //\r
-  Target = &TargetArray[0];\r
-  ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
-\r
   Cdb[0]                        = EFI_SCSI_OP_READ10;\r
-  Cdb[1]                        = (UINT8) (Lun & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
   Cdb[2]                        = (UINT8) (StartLba >> 24);\r
   Cdb[3]                        = (UINT8) (StartLba >> 16);\r
   Cdb[4]                        = (UINT8) (StartLba >> 8);\r
@@ -887,9 +840,6 @@ ScsiWrite10Command (
   )\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[EFI_SCSI_OP_LENGTH_TEN];\r
 \r
@@ -910,11 +860,7 @@ ScsiWrite10Command (
   //\r
   // Fill Cdb for Write (10) Command\r
   //\r
-  Target = &TargetArray[0];\r
-  ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);\r
-\r
   Cdb[0]                        = EFI_SCSI_OP_WRITE10;\r
-  Cdb[1]                        = (UINT8) (Lun & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);\r
   Cdb[2]                        = (UINT8) (StartLba >> 24);\r
   Cdb[3]                        = (UINT8) (StartLba >> 16);\r
   Cdb[4]                        = (UINT8) (StartLba >> 8);\r