diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-28 06:01:55 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-10-28 06:01:55 +0000 |
commit | 91ec78241c81a1af766fc5d8cb6c3abf3b0d6b32 (patch) | |
tree | 0f9c5cc208bc67e2c93e64a04fb8ac2c8dcc0e46 /UefiCpuPkg/CpuDxe | |
parent | beda2356f5128efa4461046f882b6516ece6afc7 (diff) | |
download | edk2-platforms-91ec78241c81a1af766fc5d8cb6c3abf3b0d6b32.tar.xz |
1. Introduce the API MtrrGetDefaultMemoryType () in Mtrr Library.
2. Invoke MtrrGetDefaultMemoryType() to get the default memory type instead of the hard code value in module.
3. Add go though for UC attributes.
Signed-off-by: vanjeff
Reviewed-by: rsun3
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12587 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UefiCpuPkg/CpuDxe')
-rw-r--r-- | UefiCpuPkg/CpuDxe/CpuDxe.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index ad4599dab9..c1eee028aa 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -23,7 +23,6 @@ EFI_CPU_INTERRUPT_HANDLER ExternalVectorTable[0x100]; BOOLEAN InterruptState = FALSE;
EFI_HANDLE mCpuHandle = NULL;
BOOLEAN mIsFlushingGCD;
-UINT8 mDefaultMemoryType = MTRR_CACHE_WRITE_BACK;
UINT64 mValidMtrrAddressMask = MTRR_LIB_CACHE_VALID_ADDRESS;
UINT64 mValidMtrrBitsMask = MTRR_LIB_MSR_VALID_MASK;
@@ -715,7 +714,7 @@ InitializeMtrrMask ( **/
UINT64
GetMemorySpaceAttributeFromMtrrType (
- IN UINT8 MtrrAttributes
+ IN MTRR_MEMORY_CACHE_TYPE MtrrAttributes
)
{
switch (MtrrAttributes) {
@@ -880,13 +879,14 @@ RefreshGcdMemoryAttributes ( UINT64 Length;
UINT64 Attributes;
UINT64 CurrentAttributes;
- UINT8 MtrrType;
+ MTRR_MEMORY_CACHE_TYPE MtrrType;
UINTN NumberOfDescriptors;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
UINT64 DefaultAttributes;
VARIABLE_MTRR VariableMtrr[MTRR_NUMBER_OF_VARIABLE_MTRR];
MTRR_FIXED_SETTINGS MtrrFixedSettings;
UINT32 FirmwareVariableMtrrCount;
+ MTRR_MEMORY_CACHE_TYPE DefaultMemoryType;
if (!IsMtrrSupported ()) {
return;
@@ -895,8 +895,7 @@ RefreshGcdMemoryAttributes ( FirmwareVariableMtrrCount = GetFirmwareVariableMtrrCount ();
ASSERT (FirmwareVariableMtrrCount <= MTRR_NUMBER_OF_VARIABLE_MTRR);
-// mIsFlushingGCD = TRUE;
- mIsFlushingGCD = FALSE;
+ mIsFlushingGCD = TRUE;
MemorySpaceMap = NULL;
//
@@ -922,7 +921,8 @@ RefreshGcdMemoryAttributes ( );
ASSERT_EFI_ERROR (Status);
- DefaultAttributes = GetMemorySpaceAttributeFromMtrrType (mDefaultMemoryType);
+ DefaultMemoryType = MtrrGetDefaultMemoryType ();
+ DefaultAttributes = GetMemorySpaceAttributeFromMtrrType (DefaultMemoryType);
//
// Set default attributes to all spaces.
@@ -954,13 +954,15 @@ RefreshGcdMemoryAttributes ( );
}
}
+
//
- // Go for variable MTRRs with Non-WB attribute
+ // Go for variable MTRRs with the attribute except for WB and UC attributes
//
for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) {
- if (VariableMtrr[Index].Valid &&
- VariableMtrr[Index].Type != MTRR_CACHE_WRITE_BACK) {
- Attributes = GetMemorySpaceAttributeFromMtrrType ((UINT8) VariableMtrr[Index].Type);
+ if (VariableMtrr[Index].Valid &&
+ VariableMtrr[Index].Type != MTRR_CACHE_WRITE_BACK &&
+ VariableMtrr[Index].Type != MTRR_CACHE_UNCACHEABLE) {
+ Attributes = GetMemorySpaceAttributeFromMtrrType ((MTRR_MEMORY_CACHE_TYPE) VariableMtrr[Index].Type);
SetGcdMemorySpaceAttributes (
MemorySpaceMap,
NumberOfDescriptors,
@@ -972,6 +974,22 @@ RefreshGcdMemoryAttributes ( }
//
+ // Go for variable MTRRs with UC attribute
+ //
+ for (Index = 0; Index < FirmwareVariableMtrrCount; Index++) {
+ if (VariableMtrr[Index].Valid &&
+ VariableMtrr[Index].Type == MTRR_CACHE_UNCACHEABLE) {
+ SetGcdMemorySpaceAttributes (
+ MemorySpaceMap,
+ NumberOfDescriptors,
+ VariableMtrr[Index].BaseAddress,
+ VariableMtrr[Index].Length,
+ EFI_MEMORY_UC
+ );
+ }
+ }
+
+ //
// Go for fixed MTRRs
//
Attributes = 0;
@@ -984,7 +1002,7 @@ RefreshGcdMemoryAttributes ( // Check for continuous fixed MTRR sections
//
for (SubIndex = 0; SubIndex < 8; SubIndex++) {
- MtrrType = (UINT8) RShiftU64 (RegValue, SubIndex * 8);
+ MtrrType = (MTRR_MEMORY_CACHE_TYPE) RShiftU64 (RegValue, SubIndex * 8);
CurrentAttributes = GetMemorySpaceAttributeFromMtrrType (MtrrType);
if (Length == 0) {
//
|