summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Bus
diff options
context:
space:
mode:
authoreric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2008-09-01 09:46:38 +0000
committereric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2008-09-01 09:46:38 +0000
commit9ebae8aefad105d64619b2d8e39400f05ceb2fad (patch)
tree80c536f99e56884144d7beadf7f168ed133372ac /IntelFrameworkModulePkg/Bus
parentbe9b89f59831b108101cc2a60415bb681a753a78 (diff)
downloadedk2-platforms-9ebae8aefad105d64619b2d8e39400f05ceb2fad.tar.xz
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
Diffstat (limited to 'IntelFrameworkModulePkg/Bus')
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c52
-rw-r--r--IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h4
2 files changed, 17 insertions, 39 deletions
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c
index 5603896dde..c157c39e1f 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c
@@ -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)) {
-
- if (!EFI_ERROR (Status)) {
-
+ ParseSenseData (IdeDev, SenseCount, SResult);
+
+ 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->MediaPresent = TRUE;
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;
diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
index ec1f9e07a0..856e4a1dbf 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
+++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
@@ -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
)
;