mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
c128d5281f
commit
b04a63ac48
|
@ -22,17 +22,6 @@
|
|||
#include <IndustryStandard/Scsi.h>
|
||||
|
||||
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue