summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg
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:58:11 +0800
commit9aea281020534363a7bb49ed4de62930c8c9def0 (patch)
tree48c8b014e21240f8ffaf694b06175a6381a4f10b /MdeModulePkg
parent04da8cbd1f83ecf2d59a30fbbcaeb0c28ec862d0 (diff)
downloadedk2-9aea281020534363a7bb49ed4de62930c8c9def0.tar.gz
edk2-9aea281020534363a7bb49ed4de62930c8c9def0.tar.bz2
edk2-9aea281020534363a7bb49ed4de62930c8c9def0.zip
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> (cherry picked from commit 2e5fb984ed6876b173b1bd558fdaa41f08b7ed6f)
Diffstat (limited to 'MdeModulePkg')
-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 477c914059..a7ade955c3 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;
}