diff options
author | Ruiyu Ni <ruiyu.ni@intel.com> | 2015-08-06 08:39:30 +0000 |
---|---|---|
committer | niruiyu <niruiyu@Edk2> | 2015-08-06 08:39:30 +0000 |
commit | 8f227c2fd97c8160c6e3f99c532d778942efaf62 (patch) | |
tree | 5a14fc962d1e1934373c9107b658fa0a4093afad /Nt32Pkg | |
parent | 72362a75a48b4acb555c2828ac9df134338f6daa (diff) | |
download | edk2-8f227c2fd97c8160c6e3f99c532d778942efaf62.tar.gz edk2-8f227c2fd97c8160c6e3f99c532d778942efaf62.tar.bz2 edk2-8f227c2fd97c8160c6e3f99c532d778942efaf62.zip |
Nt32Pkg: Platform BDS should test the untested memory
NT32 has two ranges of memory, each 64MB. The first range is tested
but the second range is not tested. Platform BDS should have code
to use MemoryTest protocol to test the memory so that the second
range of untested memory can be added to the system memory pool.
Without the code SCT MemoryAllocation test case may fail. Because it
firstly use GetMemoryMap to find the biggest free memory descriptor
and then requests to allocate one page more than that biggest free memory.
It expects the allocation fails but actually the DXE core automatically
converts the second range of untested memory to tested and allocate the memory
from the second range.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18172 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Nt32Pkg')
3 files changed, 92 insertions, 0 deletions
diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c index a527a4233d..7964b2b808 100644 --- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c +++ b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.c @@ -19,6 +19,93 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. EFI_GUID mUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, 0xAD, 0x65, 0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 };
/**
+ Perform the memory test base on the memory test intensive level,
+ and update the memory resource.
+
+ @param Level The memory test intensive level.
+
+ @retval EFI_STATUS Success test all the system memory and update
+ the memory resource
+
+**/
+EFI_STATUS
+PlatformBootManagerMemoryTest (
+ IN EXTENDMEM_COVERAGE_LEVEL Level
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN RequireSoftECCInit;
+ EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
+ UINT64 TestedMemorySize;
+ UINT64 TotalMemorySize;
+ UINTN TestPercent;
+ UINT64 PreviousValue;
+ BOOLEAN ErrorOut;
+ UINT32 TempData;
+
+ TestedMemorySize = 0;
+ TotalMemorySize = 0;
+ PreviousValue = 0;
+
+ RequireSoftECCInit = FALSE;
+
+ Status = gBS->LocateProtocol (
+ &gEfiGenericMemTestProtocolGuid,
+ NULL,
+ (VOID **) &GenMemoryTest
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+
+ Status = GenMemoryTest->MemoryTestInit (
+ GenMemoryTest,
+ Level,
+ &RequireSoftECCInit
+ );
+ if (Status == EFI_NO_MEDIA) {
+ //
+ // The PEI codes also have the relevant memory test code to check the memory,
+ // it can select to test some range of the memory or all of them. If PEI code
+ // checks all the memory, this BDS memory test will has no not-test memory to
+ // do the test, and then the status of EFI_NO_MEDIA will be returned by
+ // "MemoryTestInit". So it does not need to test memory again, just return.
+ //
+ return EFI_SUCCESS;
+ }
+
+ do {
+ Status = GenMemoryTest->PerformMemoryTest (
+ GenMemoryTest,
+ &TestedMemorySize,
+ &TotalMemorySize,
+ &ErrorOut,
+ FALSE
+ );
+ if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
+ Print (L"System encounters memory errors!");
+ CpuDeadLoop ();
+ }
+
+ TempData = (UINT32) DivU64x32 (TotalMemorySize, 16);
+ TestPercent = (UINTN) DivU64x32 (
+ DivU64x32 (MultU64x32 (TestedMemorySize, 100), 16),
+ TempData
+ );
+ if (TestPercent != PreviousValue) {
+ Print (L"Perform memory test: %d/100", TestPercent);
+ PreviousValue = TestPercent;
+ }
+ } while (Status != EFI_NOT_FOUND);
+
+ Status = GenMemoryTest->Finished (GenMemoryTest);
+
+ Print (L"\r%dM bytes of system memory tested OK\n", (UINT32) DivU64x32 (TotalMemorySize, 1024 * 1024));
+ return EFI_SUCCESS;
+}
+
+
+/**
Return the index of the load option in the load option array.
The function consider two load options are equal when the
@@ -197,6 +284,7 @@ PlatformBootManagerAfterConsole ( VOID
)
{
+ PlatformBootManagerMemoryTest (QUICK);
EfiBootManagerConnectAll ();
EfiBootManagerRefreshAllBootOption ();
Print (
diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.h b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.h index 6ab7d9f70c..eb1ffe1c71 100644 --- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.h +++ b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManager.h @@ -17,6 +17,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <PiDxe.h>
#include <Guid/WinNtSystemConfig.h>
+#include <Protocol/GenericMemoryTest.h>
#include <Protocol/WinNtThunk.h>
#include <Protocol/WinNtIo.h>
#include <Protocol/LoadedImage.h>
diff --git a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index 897c5cd2ce..7fac55b3fd 100644 --- a/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/Nt32Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -47,6 +47,9 @@ [Guids]
gEfiWinNtSystemConfigGuid
+[Protocols]
+ gEfiGenericMemTestProtocolGuid ## CONSUMES
+
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn
|