summaryrefslogtreecommitdiff
path: root/MdePkg/Library
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2014-11-28 10:24:56 +0000
committerlersek <lersek@Edk2>2014-11-28 10:24:56 +0000
commitb04a63ac48a73329006d25e8b7518bc09bb9843c (patch)
tree9fbf16f2a1215cab0dfaca0deecf373c44cc045a /MdePkg/Library
parentc128d5281ffb25d8c335a3cce6a9a9497df57059 (diff)
downloadedk2-platforms-b04a63ac48a73329006d25e8b7518bc09bb9843c.tar.xz
MdePkg: UefiScsiLib: do not encode LUN in CDB for other SCSI commands
The TEST UNIT READY, INQUIRY, MODE SENSE, REQUEST SENSE and READ CAPACITY commands define bits [7:5] of Cdb[1] as Reserved (potentially as part of a larger Reserved bitfield): Command Reserved bitfield in Cdb[1] SCSI spec reference ------------------ --------------------------- ------------------- TEST UNIT READY all bits SPC-4 6.37 INQUIRY bits [7:2] SPC-4 6.4.1 MODE SENSE (6) bits [7:4] SPC-4 6.11.1 MODE SENSE (10) bits [7:5] SPC-4 6.12 REQUEST SENSE bits [7:1] SPC-4 6.29 READ CAPACITY (10) bits [7:1] SBC-3 5.16 READ CAPACITY (16) bits [7:5] SBC-3 5.17 Update the UefiScsiLib functions accordingly. (In ScsiReadCapacity16Command() the LUN has not been encoded, so there we just remove the useless ScsiIo->GetDeviceLocation() call, with its auxiliary local variables.) The EFI_SCSI_TARGET_MAX_BYTES and EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK macros become unused with this patch, remove them too. Suggested-by: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16455 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library')
-rw-r--r--MdePkg/Library/UefiScsiLib/UefiScsiLib.c53
1 files changed, 1 insertions, 52 deletions
diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
index 1dbe874118..8a073db5f3 100644
--- a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
+++ b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
@@ -23,17 +23,6 @@
//
- // Max bytes needed to represent ID of a SCSI device
- //
-#define EFI_SCSI_TARGET_MAX_BYTES (0x10)
-
- //
- // bit5..7 are for Logical unit number
- // 11100000b (0xe0)
- //
-#define EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK 0xe0
-
- //
// Scsi Command Length
//
#define EFI_SCSI_OP_LENGTH_SIX 0x6
@@ -117,9 +106,6 @@ 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];
@@ -141,11 +127,7 @@ 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) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
CommandPacket.CdbLength = (UINT8) EFI_SCSI_OP_LENGTH_SIX;
CommandPacket.SenseDataLength = *SenseDataLength;
@@ -255,9 +237,6 @@ ScsiInquiryCommandEx (
)
{
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];
@@ -277,11 +256,7 @@ ScsiInquiryCommandEx (
CommandPacket.SenseDataLength = *SenseDataLength;
CommandPacket.Cdb = Cdb;
- Target = &TargetArray[0];
- ScsiIo->GetDeviceLocation (ScsiIo, &Target, &Lun);
-
Cdb[0] = EFI_SCSI_OP_INQUIRY;
- Cdb[1] = (UINT8) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
if (EnableVitalProductData) {
Cdb[1] |= 0x01;
Cdb[2] = PageCode;
@@ -510,9 +485,6 @@ 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];
@@ -533,14 +505,11 @@ 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) ((LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK) + ((DBDField << 3) & 0x08));
+ Cdb[1] = (UINT8) ((DBDField << 3) & 0x08);
//
// PageControl is in Cdb[2] bit7..6, PageCode is in Cdb[2] bit5..0
//
@@ -602,9 +571,6 @@ 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];
@@ -624,11 +590,7 @@ 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) (LShiftU64 (Lun, 5) & EFI_SCSI_LOGICAL_UNIT_NUMBER_MASK);
Cdb[4] = (UINT8) (*SenseDataLength);
CommandPacket.CdbLength = (UINT8) EFI_SCSI_OP_LENGTH_SIX;
@@ -695,9 +657,6 @@ 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];
@@ -718,11 +677,7 @@ 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) (LShiftU64 (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.
@@ -797,9 +752,6 @@ 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];
@@ -820,9 +772,6 @@ 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) {