mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg MTRR Library: enhance MTRR Library.
When it finds that a request range is covered by an existing MTRR with same cache type, the MTRR library set a flag and continues to check other MTRRs and invalidate any MTRR of the same request range with a higher-priority cache type. Signed-off-by: rsun3 Reviewed-by: gxing git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12388 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
89a90ae648
commit
1e60a0ecfc
|
@ -477,10 +477,12 @@ CombineMemoryAttribute (
|
|||
UINT64 MtrrEnd;
|
||||
UINT64 EndAddress;
|
||||
UINT32 FirmwareVariableMtrrCount;
|
||||
BOOLEAN CoveredByExistingMtrr;
|
||||
|
||||
FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount ();
|
||||
|
||||
*OverwriteExistingMtrr = FALSE;
|
||||
CoveredByExistingMtrr = FALSE;
|
||||
EndAddress = *Base +*Length - 1;
|
||||
|
||||
for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) {
|
||||
|
@ -501,11 +503,12 @@ CombineMemoryAttribute (
|
|||
//
|
||||
if (Attributes == VariableMtrr[Index].Type) {
|
||||
//
|
||||
// if the Mtrr range contain the request range, return RETURN_SUCCESS
|
||||
// if the Mtrr range contain the request range, set a flag, then continue to
|
||||
// invalidate any MTRR of the same request range with higher priority cache type.
|
||||
//
|
||||
if (VariableMtrr[Index].BaseAddress <= *Base && MtrrEnd >= EndAddress) {
|
||||
*Length = 0;
|
||||
return RETURN_SUCCESS;
|
||||
CoveredByExistingMtrr = TRUE;
|
||||
continue;
|
||||
}
|
||||
//
|
||||
// invalid this MTRR, and program the combine range
|
||||
|
@ -552,6 +555,10 @@ CombineMemoryAttribute (
|
|||
return RETURN_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
if (CoveredByExistingMtrr) {
|
||||
*Length = 0;
|
||||
}
|
||||
|
||||
return RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1007,8 +1014,9 @@ MtrrSetMemoryAttribute (
|
|||
|
||||
if (Length == 0) {
|
||||
//
|
||||
// Combined successfully
|
||||
// Combined successfully, invalidate the now-unused MTRRs
|
||||
//
|
||||
InvalidateMtrr(VariableMtrr);
|
||||
Status = RETURN_SUCCESS;
|
||||
goto Done;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue