summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-12-24 08:31:31 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2009-12-24 08:31:31 +0000
commit423401f9ea83daffc754864b922f56f06a84cbab (patch)
treecaeeacb12d81c1af79fa3beb3fa6676d6a27adcf /MdeModulePkg/Bus
parenta1158366091c74f831da8232d8bbb39dc2befda9 (diff)
downloadedk2-platforms-423401f9ea83daffc754864b922f56f06a84cbab.tar.xz
1. Fix bug in some boundary cases to calculate SectorCountExp.
2. Add assertion to ensure the boolean value must be 0 or 1 before the use of array index git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9597 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Bus')
-rw-r--r--MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
index d2a9182712..aea6af5227 100644
--- a/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
+++ b/MdeModulePkg/Bus/Ata/AtaBusDxe/AtaPassThruExecute.c
@@ -409,6 +409,11 @@ TransferAtaDevice (
EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
//
+ // Ensure AtaDevice->Lba48Bit and IsWrite are valid boolean values
+ //
+ ASSERT ((UINTN) AtaDevice->Lba48Bit < 2);
+ ASSERT ((UINTN) IsWrite < 2);
+ //
// Prepare for ATA command block.
//
Acb = ZeroMem (&AtaDevice->Acb, sizeof (*Acb));
@@ -417,15 +422,15 @@ TransferAtaDevice (
Acb->AtaCylinderLow = (UINT8) RShiftU64 (StartLba, 8);
Acb->AtaCylinderHigh = (UINT8) RShiftU64 (StartLba, 16);
Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort << 4));
+ Acb->AtaSectorCount = (UINT8) TransferLength;
if (AtaDevice->Lba48Bit) {
Acb->AtaSectorNumberExp = (UINT8) RShiftU64 (StartLba, 24);
+ Acb->AtaCylinderLowExp = (UINT8) RShiftU64 (StartLba, 32);
+ Acb->AtaCylinderHighExp = (UINT8) RShiftU64 (StartLba, 40);
+ Acb->AtaSectorCountExp = (UINT8) (TransferLength >> 8);
} else {
Acb->AtaDeviceHead = (UINT8) (Acb->AtaDeviceHead | RShiftU64 (StartLba, 24));
}
- Acb->AtaCylinderLowExp = (UINT8) RShiftU64 (StartLba, 32);
- Acb->AtaCylinderHighExp = (UINT8) RShiftU64 (StartLba, 40);
- Acb->AtaSectorCount = (UINT8) TransferLength;
- Acb->AtaSectorCountExp = (UINT8) (TransferLength >> 8);
//
// Prepare for ATA pass through packet.
@@ -475,6 +480,10 @@ AccessAtaDevice(
UINTN TransferBlockNumber;
UINTN BlockSize;
+ //
+ // Ensure AtaDevice->Lba48Bit is a valid boolean value
+ //
+ ASSERT ((UINTN) AtaDevice->Lba48Bit < 2);
MaxTransferBlockNumber = mMaxTransferBlockNumber[AtaDevice->Lba48Bit];
BlockSize = AtaDevice->BlockMedia.BlockSize;
do {