mirror of https://github.com/acidanthera/audk.git
Fix a issue "BlockIOProtocolTest failed on Several Platforms during EFI and UEFI SCT". EFI_BLOCK_IO_PROTOCOL.ReadBlocks may assert when Reading block without media present in the device
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5763 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
be9b89f598
commit
9ebae8aefa
|
@ -805,7 +805,7 @@ PioReadWriteData (
|
|||
|
||||
@param[in] *IdeDev Pointer pointing to IDE_BLK_IO_DEV data structure, used
|
||||
to record all the information of the IDE device.
|
||||
@param[in] *SenseCount Sense count for this packet command
|
||||
@param[in] *SResult Sense result for this packet command.
|
||||
|
||||
@retval EFI_SUCCESS Device is accessible.
|
||||
@retval EFI_DEVICE_ERROR Device is not accessible.
|
||||
|
@ -814,13 +814,12 @@ PioReadWriteData (
|
|||
EFI_STATUS
|
||||
AtapiTestUnitReady (
|
||||
IN IDE_BLK_IO_DEV *IdeDev,
|
||||
OUT UINTN *SenseCount
|
||||
OUT SENSE_RESULT *SResult
|
||||
)
|
||||
{
|
||||
ATAPI_PACKET_COMMAND Packet;
|
||||
EFI_STATUS Status;
|
||||
|
||||
*SenseCount = 0;
|
||||
UINTN SenseCount;
|
||||
|
||||
//
|
||||
// fill command packet
|
||||
|
@ -836,12 +835,12 @@ AtapiTestUnitReady (
|
|||
return Status;
|
||||
}
|
||||
|
||||
Status = AtapiRequestSense (IdeDev, SenseCount);
|
||||
Status = AtapiRequestSense (IdeDev, &SenseCount);
|
||||
if (EFI_ERROR (Status)) {
|
||||
*SenseCount = 0;
|
||||
return Status;
|
||||
}
|
||||
|
||||
ParseSenseData (IdeDev, SenseCount, SResult);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -964,7 +963,7 @@ AtapiRequestSense (
|
|||
|
||||
@param[in] *IdeDev Pointer pointing to IDE_BLK_IO_DEV data structure, used
|
||||
to record all the information of the IDE device.
|
||||
@param[in] SenseCount Sense count for this packet command
|
||||
@param[in] SResult Sense result for this packet command
|
||||
|
||||
@retval EFI_SUCCESS Read Capacity Command finally completes successfully.
|
||||
@retval EFI_DEVICE_ERROR Read Capacity Command failed because of device error.
|
||||
|
@ -976,7 +975,7 @@ AtapiRequestSense (
|
|||
EFI_STATUS
|
||||
AtapiReadCapacity (
|
||||
IN IDE_BLK_IO_DEV *IdeDev,
|
||||
OUT UINTN *SenseCount
|
||||
OUT SENSE_RESULT *SResult
|
||||
)
|
||||
{
|
||||
//
|
||||
|
@ -985,6 +984,7 @@ AtapiReadCapacity (
|
|||
EFI_STATUS Status;
|
||||
EFI_STATUS SenseStatus;
|
||||
ATAPI_PACKET_COMMAND Packet;
|
||||
UINTN SenseCount;
|
||||
|
||||
//
|
||||
// used for capacity data returned from ATAPI device
|
||||
|
@ -992,8 +992,6 @@ AtapiReadCapacity (
|
|||
ATAPI_READ_CAPACITY_DATA Data;
|
||||
ATAPI_READ_FORMAT_CAPACITY_DATA FormatData;
|
||||
|
||||
*SenseCount = 0;
|
||||
|
||||
ZeroMem (&Data, sizeof (Data));
|
||||
ZeroMem (&FormatData, sizeof (FormatData));
|
||||
|
||||
|
@ -1026,16 +1024,15 @@ AtapiReadCapacity (
|
|||
}
|
||||
|
||||
if (Status == EFI_TIMEOUT) {
|
||||
*SenseCount = 0;
|
||||
return Status;
|
||||
}
|
||||
|
||||
SenseStatus = AtapiRequestSense (IdeDev, SenseCount);
|
||||
SenseStatus = AtapiRequestSense (IdeDev, &SenseCount);
|
||||
|
||||
if (!EFI_ERROR (SenseStatus)) {
|
||||
ParseSenseData (IdeDev, SenseCount, SResult);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
|
||||
if (!EFI_ERROR (Status) && *SResult == SenseNoSenseKey) {
|
||||
if (IdeDev->Type == IdeCdRom) {
|
||||
|
||||
IdeDev->BlkIo.Media->LastBlock = (Data.LastLba3 << 24) |
|
||||
|
@ -1043,18 +1040,7 @@ AtapiReadCapacity (
|
|||
(Data.LastLba1 << 8) |
|
||||
Data.LastLba0;
|
||||
|
||||
if (IdeDev->BlkIo.Media->LastBlock != 0) {
|
||||
|
||||
IdeDev->BlkIo.Media->BlockSize = (Data.BlockSize3 << 24) |
|
||||
(Data.BlockSize2 << 16) |
|
||||
(Data.BlockSize1 << 8) |
|
||||
Data.BlockSize0;
|
||||
|
||||
IdeDev->BlkIo.Media->MediaPresent = TRUE;
|
||||
} else {
|
||||
IdeDev->BlkIo.Media->MediaPresent = FALSE;
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
IdeDev->BlkIo.Media->ReadOnly = TRUE;
|
||||
|
||||
|
@ -1101,7 +1087,6 @@ AtapiReadCapacity (
|
|||
return EFI_SUCCESS;
|
||||
|
||||
} else {
|
||||
*SenseCount = 0;
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -1145,7 +1130,6 @@ AtapiDetectMedia (
|
|||
EFI_BLOCK_IO_MEDIA OldMediaInfo;
|
||||
UINTN RetryTimes;
|
||||
UINTN RetryNotReady;
|
||||
UINTN SenseCount;
|
||||
SENSE_RESULT SResult;
|
||||
BOOLEAN WriteProtected;
|
||||
|
||||
|
@ -1168,7 +1152,7 @@ AtapiDetectMedia (
|
|||
RetryTimes = 5;
|
||||
while (RetryTimes != 0) {
|
||||
|
||||
Status = AtapiTestUnitReady (IdeDev, &SenseCount);
|
||||
Status = AtapiTestUnitReady (IdeDev, &SResult);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
//
|
||||
|
@ -1189,9 +1173,6 @@ AtapiDetectMedia (
|
|||
//
|
||||
continue;
|
||||
} else {
|
||||
|
||||
ParseSenseData (IdeDev, SenseCount, &SResult);
|
||||
|
||||
switch (SResult) {
|
||||
case SenseNoSenseKey:
|
||||
if (IdeDev->BlkIo.Media->MediaPresent) {
|
||||
|
@ -1245,15 +1226,12 @@ AtapiDetectMedia (
|
|||
|
||||
while (RetryTimes != 0) {
|
||||
|
||||
Status = AtapiReadCapacity (IdeDev, &SenseCount);
|
||||
Status = AtapiReadCapacity (IdeDev, &SResult);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
RetryTimes--;
|
||||
continue;
|
||||
} else {
|
||||
|
||||
ParseSenseData (IdeDev, SenseCount, &SResult);
|
||||
|
||||
switch (SResult) {
|
||||
case SenseNoSenseKey:
|
||||
goto Done;
|
||||
|
|
|
@ -683,7 +683,7 @@ PioReadWriteData (
|
|||
EFI_STATUS
|
||||
AtapiTestUnitReady (
|
||||
IN IDE_BLK_IO_DEV *IdeDev,
|
||||
OUT UINTN *SenseCount
|
||||
OUT SENSE_RESULT *SResult
|
||||
)
|
||||
;
|
||||
|
||||
|
@ -715,7 +715,7 @@ AtapiRequestSense (
|
|||
EFI_STATUS
|
||||
AtapiReadCapacity (
|
||||
IN IDE_BLK_IO_DEV *IdeDev,
|
||||
OUT UINTN *SenseCount
|
||||
OUT SENSE_RESULT *SResult
|
||||
)
|
||||
;
|
||||
|
||||
|
|
Loading…
Reference in New Issue