mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-24 22:24:37 +02:00
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
This commit is contained in:
parent
a115836609
commit
423401f9ea
@ -408,6 +408,11 @@ TransferAtaDevice (
|
|||||||
EFI_ATA_COMMAND_BLOCK *Acb;
|
EFI_ATA_COMMAND_BLOCK *Acb;
|
||||||
EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet;
|
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.
|
// Prepare for ATA command block.
|
||||||
//
|
//
|
||||||
@ -417,15 +422,15 @@ TransferAtaDevice (
|
|||||||
Acb->AtaCylinderLow = (UINT8) RShiftU64 (StartLba, 8);
|
Acb->AtaCylinderLow = (UINT8) RShiftU64 (StartLba, 8);
|
||||||
Acb->AtaCylinderHigh = (UINT8) RShiftU64 (StartLba, 16);
|
Acb->AtaCylinderHigh = (UINT8) RShiftU64 (StartLba, 16);
|
||||||
Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort << 4));
|
Acb->AtaDeviceHead = (UINT8) (BIT7 | BIT6 | BIT5 | (AtaDevice->PortMultiplierPort << 4));
|
||||||
|
Acb->AtaSectorCount = (UINT8) TransferLength;
|
||||||
if (AtaDevice->Lba48Bit) {
|
if (AtaDevice->Lba48Bit) {
|
||||||
Acb->AtaSectorNumberExp = (UINT8) RShiftU64 (StartLba, 24);
|
Acb->AtaSectorNumberExp = (UINT8) RShiftU64 (StartLba, 24);
|
||||||
|
Acb->AtaCylinderLowExp = (UINT8) RShiftU64 (StartLba, 32);
|
||||||
|
Acb->AtaCylinderHighExp = (UINT8) RShiftU64 (StartLba, 40);
|
||||||
|
Acb->AtaSectorCountExp = (UINT8) (TransferLength >> 8);
|
||||||
} else {
|
} else {
|
||||||
Acb->AtaDeviceHead = (UINT8) (Acb->AtaDeviceHead | RShiftU64 (StartLba, 24));
|
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.
|
// Prepare for ATA pass through packet.
|
||||||
@ -475,6 +480,10 @@ AccessAtaDevice(
|
|||||||
UINTN TransferBlockNumber;
|
UINTN TransferBlockNumber;
|
||||||
UINTN BlockSize;
|
UINTN BlockSize;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Ensure AtaDevice->Lba48Bit is a valid boolean value
|
||||||
|
//
|
||||||
|
ASSERT ((UINTN) AtaDevice->Lba48Bit < 2);
|
||||||
MaxTransferBlockNumber = mMaxTransferBlockNumber[AtaDevice->Lba48Bit];
|
MaxTransferBlockNumber = mMaxTransferBlockNumber[AtaDevice->Lba48Bit];
|
||||||
BlockSize = AtaDevice->BlockMedia.BlockSize;
|
BlockSize = AtaDevice->BlockMedia.BlockSize;
|
||||||
do {
|
do {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user