From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: Star Zeng <star.zeng@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [PATCH v2 1/2] MdeModulePkg/GenericMemoryTest: Handle more reliable memory
Date: Sat, 10 Feb 2018 22:41:14 +0800 [thread overview]
Message-ID: <20180210144115.432040-2-ruiyu.ni@intel.com> (raw)
In-Reply-To: <20180210144115.432040-1-ruiyu.ni@intel.com>
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>
Cc: Liming Gao <liming.gao@intel.com>
---
.../GenericMemoryTestDxe/LightMemoryTest.c | 75 ++++++++++++++--------
1 file 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;
}
}
@@ -138,6 +139,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.
@@ -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;
}
--
2.16.1.windows.1
next prev parent reply other threads:[~2018-02-10 14:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-10 14:41 [PATCH v2 0/2] Update memory test driver to handle more reliable memory Ruiyu Ni
2018-02-10 14:41 ` Ruiyu Ni [this message]
2018-02-10 14:41 ` [PATCH v2 2/2] MdeModulePkg/NullMemoryTest: Handle " Ruiyu Ni
2018-02-27 5:15 ` [PATCH v2 0/2] Update memory test driver to handle " Gao, Liming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180210144115.432040-2-ruiyu.ni@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox