mirror of https://github.com/acidanthera/audk.git
Read-Capacity16 command added for SCSI drivers
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8000 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
ccb491c862
commit
b96cd3133d
|
@ -921,9 +921,9 @@ ScsiDiskInquiryDevice (
|
|||
}
|
||||
|
||||
//
|
||||
// if goes here, meant SubmitInquiryCommand() failed.
|
||||
// if goes here, meant ScsiInquiryCommand() failed.
|
||||
// if ScsiDiskRequestSenseKeys() succeeds at last,
|
||||
// better retry SubmitInquiryCommand(). (by setting *NeedRetry = TRUE)
|
||||
// better retry ScsiInquiryCommand(). (by setting *NeedRetry = TRUE)
|
||||
//
|
||||
MaxRetry = 3;
|
||||
for (Index = 0; Index < MaxRetry; Index++) {
|
||||
|
@ -1159,41 +1159,67 @@ ScsiDiskReadCapacity (
|
|||
OUT UINTN *NumberOfSenseKeys
|
||||
)
|
||||
{
|
||||
EFI_SCSI_DISK_CAPACITY_DATA CapacityData;
|
||||
UINT32 DataLength;
|
||||
UINT8 HostAdapterStatus;
|
||||
UINT8 TargetStatus;
|
||||
EFI_STATUS CommandStatus;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Index;
|
||||
UINT8 MaxRetry;
|
||||
UINT8 SenseDataLength;
|
||||
UINT8 HostAdapterStatus;
|
||||
UINT8 TargetStatus;
|
||||
EFI_STATUS CommandStatus;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Index;
|
||||
UINT8 MaxRetry;
|
||||
UINT8 SenseDataLength;
|
||||
UINT8 ScsiVersion;
|
||||
UINT32 DataLength10;
|
||||
UINT32 DataLength16;
|
||||
EFI_SCSI_DISK_CAPACITY_DATA CapacityData10;
|
||||
EFI_SCSI_DISK_CAPACITY_DATA16 CapacityData16;
|
||||
|
||||
SenseDataLength = 0;
|
||||
ZeroMem (&CapacityData, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
|
||||
DataLength = sizeof (EFI_SCSI_DISK_CAPACITY_DATA);
|
||||
|
||||
SenseDataLength = 0;
|
||||
DataLength10 = sizeof (EFI_SCSI_DISK_CAPACITY_DATA);
|
||||
DataLength16 = sizeof (EFI_SCSI_DISK_CAPACITY_DATA16);
|
||||
ZeroMem (&CapacityData10, sizeof (EFI_SCSI_DISK_CAPACITY_DATA));
|
||||
ZeroMem (&CapacityData16, sizeof (EFI_SCSI_DISK_CAPACITY_DATA16));
|
||||
|
||||
*NumberOfSenseKeys = 0;
|
||||
*NeedRetry = FALSE;
|
||||
//
|
||||
// submit Read Capacity Command. in this call,not request sense data
|
||||
//
|
||||
CommandStatus = ScsiReadCapacityCommand (
|
||||
ScsiDiskDevice->ScsiIo,
|
||||
EFI_TIMER_PERIOD_SECONDS (1),
|
||||
NULL,
|
||||
&SenseDataLength,
|
||||
&HostAdapterStatus,
|
||||
&TargetStatus,
|
||||
(VOID *) &CapacityData,
|
||||
&DataLength,
|
||||
FALSE
|
||||
);
|
||||
//
|
||||
ScsiVersion = (UINT8)(ScsiDiskDevice->InquiryData.Version & 0x03);
|
||||
|
||||
if (ScsiVersion < SCSI_COMMAND_VERSION_3) {
|
||||
//
|
||||
// submit Read Capacity(10) Command. in this call,not request sense data
|
||||
//
|
||||
CommandStatus = ScsiReadCapacityCommand (
|
||||
ScsiDiskDevice->ScsiIo,
|
||||
EFI_TIMER_PERIOD_SECONDS(1),
|
||||
NULL,
|
||||
&SenseDataLength,
|
||||
&HostAdapterStatus,
|
||||
&TargetStatus,
|
||||
(VOID *) &CapacityData10,
|
||||
&DataLength10,
|
||||
FALSE
|
||||
);
|
||||
} else {
|
||||
//
|
||||
// submit Read Capacity(16) Command to get parameter LogicalBlocksPerPhysicalBlock
|
||||
// and LowestAlignedLba
|
||||
//
|
||||
CommandStatus = ScsiReadCapacity16Command (
|
||||
ScsiDiskDevice->ScsiIo,
|
||||
EFI_TIMER_PERIOD_SECONDS (1),
|
||||
NULL,
|
||||
&SenseDataLength,
|
||||
&HostAdapterStatus,
|
||||
&TargetStatus,
|
||||
(VOID *) &CapacityData16,
|
||||
&DataLength16,
|
||||
FALSE
|
||||
);
|
||||
}
|
||||
//
|
||||
// no need to check HostAdapterStatus and TargetStatus
|
||||
//
|
||||
if (CommandStatus == EFI_SUCCESS) {
|
||||
GetMediaInfo (ScsiDiskDevice, &CapacityData);
|
||||
GetMediaInfo (ScsiDiskDevice, &CapacityData10,&CapacityData16);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
} else if (CommandStatus == EFI_NOT_READY) {
|
||||
|
@ -1238,9 +1264,9 @@ ScsiDiskReadCapacity (
|
|||
}
|
||||
|
||||
//
|
||||
// if goes here, meant SubmitReadCapacityCommand() failed.
|
||||
// if goes here, meant ScsiReadCapacityCommand() failed.
|
||||
// if ScsiDiskRequestSenseKeys() succeeds at last,
|
||||
// better retry SubmitReadCapacityCommand(). (by setting *NeedRetry = TRUE)
|
||||
// better retry ScsiReadCapacityCommand(). (by setting *NeedRetry = TRUE)
|
||||
//
|
||||
MaxRetry = 3;
|
||||
for (Index = 0; Index < MaxRetry; Index++) {
|
||||
|
@ -1457,19 +1483,54 @@ ScsiDiskRequestSenseKeys (
|
|||
VOID
|
||||
GetMediaInfo (
|
||||
IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
|
||||
IN EFI_SCSI_DISK_CAPACITY_DATA *Capacity
|
||||
EFI_SCSI_DISK_CAPACITY_DATA *Capacity10,
|
||||
EFI_SCSI_DISK_CAPACITY_DATA16 *Capacity16
|
||||
)
|
||||
{
|
||||
ScsiDiskDevice->BlkIo.Media->LastBlock = (Capacity->LastLba3 << 24) |
|
||||
(Capacity->LastLba2 << 16) |
|
||||
(Capacity->LastLba1 << 8) |
|
||||
Capacity->LastLba0;
|
||||
UINT8 ScsiVersion;
|
||||
UINT8 *Ptr;
|
||||
|
||||
ScsiVersion = (UINT8)(ScsiDiskDevice->InquiryData.Version & 0x03);
|
||||
ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = 0;
|
||||
ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = 1;
|
||||
|
||||
|
||||
if (ScsiVersion < SCSI_COMMAND_VERSION_3) {
|
||||
ScsiDiskDevice->BlkIo.Media->LastBlock = (Capacity10->LastLba3 << 24) |
|
||||
(Capacity10->LastLba2 << 16) |
|
||||
(Capacity10->LastLba1 << 8) |
|
||||
Capacity10->LastLba0;
|
||||
|
||||
ScsiDiskDevice->BlkIo.Media->BlockSize = (Capacity10->BlockSize3 << 24) |
|
||||
(Capacity10->BlockSize2 << 16) |
|
||||
(Capacity10->BlockSize1 << 8) |
|
||||
Capacity10->BlockSize0;
|
||||
ScsiDiskDevice->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION;
|
||||
} else {
|
||||
|
||||
Ptr = (UINT8*)&ScsiDiskDevice->BlkIo.Media->LastBlock;
|
||||
*Ptr++ = Capacity16->LastLba0;
|
||||
*Ptr++ = Capacity16->LastLba1;
|
||||
*Ptr++ = Capacity16->LastLba2;
|
||||
*Ptr++ = Capacity16->LastLba3;
|
||||
*Ptr++ = Capacity16->LastLba4;
|
||||
*Ptr++ = Capacity16->LastLba5;
|
||||
*Ptr++ = Capacity16->LastLba6;
|
||||
*Ptr = Capacity16->LastLba7;
|
||||
|
||||
ScsiDiskDevice->BlkIo.Media->BlockSize = (Capacity16->BlockSize3 << 24) |
|
||||
(Capacity16->BlockSize2 << 16) |
|
||||
(Capacity16->BlockSize1 << 8) |
|
||||
Capacity16->BlockSize0;
|
||||
|
||||
ScsiDiskDevice->BlkIo.Media->LowestAlignedLba = (Capacity16->LowestAlignLogic2 << 8)|(Capacity16->LowestAlignLogic1);
|
||||
ScsiDiskDevice->BlkIo.Media->LogicalBlocksPerPhysicalBlock = Capacity16->LogicPerPhysical;
|
||||
ScsiDiskDevice->BlkIo.Revision = EFI_BLOCK_IO_PROTOCOL_REVISION2;
|
||||
}
|
||||
|
||||
|
||||
ScsiDiskDevice->BlkIo.Media->MediaPresent = TRUE;
|
||||
ScsiDiskDevice->BlkIo.Media->BlockSize = (Capacity->BlockSize3 << 24) |
|
||||
(Capacity->BlockSize2 << 16) |
|
||||
(Capacity->BlockSize1 << 8) |
|
||||
Capacity->BlockSize0;
|
||||
|
||||
if (ScsiDiskDevice->DeviceType == EFI_SCSI_TYPE_DISK) {
|
||||
ScsiDiskDevice->BlkIo.Media->BlockSize = 0x200;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,11 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2;
|
|||
#define ACTION_READ_CAPACITY 0x01
|
||||
#define ACTION_RETRY_COMMAND_LATER 0x02
|
||||
|
||||
#define SCSI_COMMAND_VERSION_1 0x01
|
||||
#define SCSI_COMMAND_VERSION_2 0x02
|
||||
#define SCSI_COMMAND_VERSION_3 0x03
|
||||
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle.
|
||||
|
||||
|
@ -649,13 +654,14 @@ ScsiDiskWrite10 (
|
|||
Get information from media read capacity command.
|
||||
|
||||
@param ScsiDiskDevice The pointer of SCSI_DISK_DEV
|
||||
@param Capacity The pointer of EFI_SCSI_DISK_CAPACITY_DATA
|
||||
|
||||
@param Capacity10 The pointer of EFI_SCSI_DISK_CAPACITY_DATA
|
||||
@param Capacity16 The pointer of EFI_SCSI_DISK_CAPACITY_DATA16
|
||||
**/
|
||||
VOID
|
||||
GetMediaInfo (
|
||||
IN OUT SCSI_DISK_DEV *ScsiDiskDevice,
|
||||
IN EFI_SCSI_DISK_CAPACITY_DATA *Capacity
|
||||
SCSI_DISK_DEV *ScsiDiskDevice,
|
||||
EFI_SCSI_DISK_CAPACITY_DATA *Capacity10,
|
||||
EFI_SCSI_DISK_CAPACITY_DATA16 *Capacity16
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue