diff options
author | rsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-20 07:36:11 +0000 |
---|---|---|
committer | rsun3 <rsun3@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-09-20 07:36:11 +0000 |
commit | 1e60a0ecfc8a2fc5f8b48052141e89a93c40f67f (patch) | |
tree | ab4c9d44cdc4f58694f5dc24cb4b3fa23b1d6c66 /UefiCpuPkg | |
parent | 89a90ae648e1c230bde94f0d5c76d7ddcb21c445 (diff) | |
download | edk2-1e60a0ecfc8a2fc5f8b48052141e89a93c40f67f.zip edk2-1e60a0ecfc8a2fc5f8b48052141e89a93c40f67f.tar.gz edk2-1e60a0ecfc8a2fc5f8b48052141e89a93c40f67f.tar.bz2 |
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
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r-- | UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c index edb75c0..04c6a1c 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -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;
}
|