summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2018-02-10 22:22:15 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2018-02-27 13:56:00 +0800
commit2e5fb984ed6876b173b1bd558fdaa41f08b7ed6f (patch)
tree08b4ff6d96ab2b5c1565e62a9a8c1222e18452ee
parentf068aa038d09053c5dddea93c5f9576c51993546 (diff)
downloadedk2-2e5fb984ed6876b173b1bd558fdaa41f08b7ed6f.zip
edk2-2e5fb984ed6876b173b1bd558fdaa41f08b7ed6f.tar.gz
edk2-2e5fb984ed6876b173b1bd558fdaa41f08b7ed6f.tar.bz2
MdeModulePkg/GenericMemoryTest: Handle more reliable memory
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=650 Today's implementation converts the untested more reliable memory from reserved GCD type to system memory GCD type. Though it doesn't impact the return result of gBS->GetMemoryMap(). But it impacts the return result of gDS->GetMemorySpaceDescriptor(). The patch fixes the bug to convert the untested more reliable memory from reserved GCD type to more reliable memory GCD type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
-rw-r--r--MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c75
1 files changed, 50 insertions, 25 deletions
diff --git a/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c b/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c
index 477c914..a7ade95 100644
--- a/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c
+++ b/MdeModulePkg/Universal/MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c
@@ -1,6 +1,6 @@
/** @file
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -106,7 +106,8 @@ ConstructBaseMemoryRange (
gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
for (Index = 0; Index < NumberOfDescriptors; Index++) {
- if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
+ if ((MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) ||
+ (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMoreReliable)) {
Private->BaseMemorySize += MemorySpaceMap[Index].Length;
}
}
@@ -139,6 +140,41 @@ DestroyLinkList (
}
/**
+ Convert the memory range to tested.
+
+ @param BaseAddress Base address of the memory range.
+ @param Length Length of the memory range.
+ @param Capabilities Capabilities of the memory range.
+
+ @retval EFI_SUCCESS The memory range is converted to tested.
+ @retval others Error happens.
+**/
+EFI_STATUS
+ConvertToTestedMemory (
+ IN UINT64 BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Capabilities
+ )
+{
+ EFI_STATUS Status;
+ Status = gDS->RemoveMemorySpace (
+ BaseAddress,
+ Length
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gDS->AddMemorySpace (
+ ((Capabilities & EFI_MEMORY_MORE_RELIABLE) == EFI_MEMORY_MORE_RELIABLE) ?
+ EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemMemory,
+ BaseAddress,
+ Length,
+ Capabilities &~
+ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
+ );
+ }
+ return Status;
+}
+
+/**
Add the extened memory to whole system memory map.
@param[in] Private Point to generic memory test driver's private data.
@@ -160,18 +196,12 @@ UpdateMemoryMap (
while (Link != &Private->NonTestedMemRanList) {
Range = NONTESTED_MEMORY_RANGE_FROM_LINK (Link);
- gDS->RemoveMemorySpace (
- Range->StartAddress,
- Range->Length
- );
-
- gDS->AddMemorySpace (
- EfiGcdMemoryTypeSystemMemory,
- Range->StartAddress,
- Range->Length,
- Range->Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
- );
-
+ ConvertToTestedMemory (
+ Range->StartAddress,
+ Range->Length,
+ Range->Capabilities &~
+ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
+ );
Link = Link->ForwardLink;
}
@@ -215,17 +245,12 @@ DirectRangeTest (
//
// Add the tested compatible memory to system memory using GCD service
//
- gDS->RemoveMemorySpace (
- StartAddress,
- Length
- );
-
- gDS->AddMemorySpace (
- EfiGcdMemoryTypeSystemMemory,
- StartAddress,
- Length,
- Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
- );
+ ConvertToTestedMemory (
+ StartAddress,
+ Length,
+ Capabilities &~
+ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
+ );
return EFI_SUCCESS;
}