diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2017-03-31 22:04:17 +0800 |
---|---|---|
committer | Ruiyu Ni <ruiyu.ni@intel.com> | 2017-03-31 22:05:21 +0800 |
commit | 4ef6c3850e66617df1ed35a4a390567d2bbf6b76 (patch) | |
tree | 2384c49f7aab3e68c24dcfad9b4d56d2979fba46 /UefiCpuPkg/Library | |
parent | 47454e238cf9d716af728ca9b85ad314a4adcfc9 (diff) | |
download | edk2-4ef6c3850e66617df1ed35a4a390567d2bbf6b76.tar.gz edk2-4ef6c3850e66617df1ed35a4a390567d2bbf6b76.tar.bz2 edk2-4ef6c3850e66617df1ed35a4a390567d2bbf6b76.zip |
UefiCpuPkg/MtrrLib: Fix GCC build failure
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Diffstat (limited to 'UefiCpuPkg/Library')
-rw-r--r-- | UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c index 524f21e842..8e8427291f 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -836,7 +836,7 @@ MtrrLibGetMtrrNumber ( IN UINT64 Alignment0,
OUT UINT32 *SubLeft, // subtractive from BaseAddress to get more aligned address, to save MTRR
OUT UINT32 *SubRight // subtractive from BaseAddress + Length, to save MTRR
-)
+ )
{
UINT64 Alignment;
UINT32 LeastLeftMtrrNumber;
@@ -859,6 +859,8 @@ MtrrLibGetMtrrNumber ( // Get the optimal left subtraction solution.
//
if (BaseAddress != 0) {
+ SubtractiveBaseAddress = 0;
+ SubtractiveLength = 0;
//
// Get the MTRR number needed without left subtraction.
//
@@ -1371,6 +1373,8 @@ MtrrLibSetMemoryType ( UINT32 EndIndex;
UINT32 DeltaCount;
+ LengthRight = 0;
+ LengthLeft = 0;
Limit = BaseAddress + Length;
StartIndex = *Count;
EndIndex = *Count;
@@ -1847,6 +1851,8 @@ MtrrSetMemoryAttributeWorker ( if (((BaseAddress & ~MtrrValidAddressMask) != 0) || (Length & ~MtrrValidAddressMask) != 0) {
return RETURN_UNSUPPORTED;
}
+ OriginalVariableMtrrCount = 0;
+ VariableSettings = NULL;
ZeroMem (&WorkingFixedSettings, sizeof (WorkingFixedSettings));
for (Index = 0; Index < MTRR_NUMBER_OF_FIXED_MTRR; Index++) {
@@ -2048,7 +2054,7 @@ MtrrSetMemoryAttributeWorker ( if (VariableSettingModified[Index]) {
if (OriginalVariableMtrr[Index].Valid) {
VariableSettings->Mtrr[Index].Base = (OriginalVariableMtrr[Index].BaseAddress & MtrrValidAddressMask) | (UINT8) OriginalVariableMtrr[Index].Type;
- VariableSettings->Mtrr[Index].Mask = (~(OriginalVariableMtrr[Index].Length - 1)) & MtrrValidAddressMask | BIT11;
+ VariableSettings->Mtrr[Index].Mask = ((~(OriginalVariableMtrr[Index].Length - 1)) & MtrrValidAddressMask) | BIT11;
} else {
VariableSettings->Mtrr[Index].Base = 0;
VariableSettings->Mtrr[Index].Mask = 0;
@@ -2081,6 +2087,8 @@ Done: //
// Write variable MTRRs
+ // When only fixed MTRRs were changed, below loop doesn't run
+ // because OriginalVariableMtrrCount equals to 0.
//
for (Index = 0; Index < OriginalVariableMtrrCount; Index++) {
if (VariableSettingModified[Index]) {
@@ -2102,7 +2110,7 @@ Done: MtrrLibPostMtrrChange (&MtrrContext);
}
- return Status;
+ return RETURN_SUCCESS;
}
/**
|