2 Perform the platform memory test
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "PlatformBm.h"
12 // BDS Platform Functions
16 Perform the memory test base on the memory test intensive level,
17 and update the memory resource.
19 @param Level The memory test intensive level.
21 @retval EFI_STATUS Success test all the system memory and update
26 PlatformBootManagerMemoryTest (
27 IN EXTENDMEM_COVERAGE_LEVEL Level
32 EFI_STATUS InitStatus
;
33 EFI_STATUS ReturnStatus
;
34 BOOLEAN RequireSoftECCInit
;
35 EFI_GENERIC_MEMORY_TEST_PROTOCOL
*GenMemoryTest
;
36 UINT64 TestedMemorySize
;
37 UINT64 TotalMemorySize
;
42 ReturnStatus
= EFI_SUCCESS
;
43 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
50 RequireSoftECCInit
= FALSE
;
52 Status
= gBS
->LocateProtocol (
53 &gEfiGenericMemTestProtocolGuid
,
55 (VOID
**) &GenMemoryTest
57 if (EFI_ERROR (Status
)) {
61 InitStatus
= GenMemoryTest
->MemoryTestInit (
66 if (InitStatus
== EFI_NO_MEDIA
) {
68 // The PEI codes also have the relevant memory test code to check the memory,
69 // it can select to test some range of the memory or all of them. If PEI code
70 // checks all the memory, this BDS memory test will has no not-test memory to
71 // do the test, and then the status of EFI_NO_MEDIA will be returned by
72 // "MemoryTestInit". So it does not need to test memory again, just return.
77 DEBUG ((DEBUG_INFO
, "Enter memory test.\n"));
79 Status
= GenMemoryTest
->PerformMemoryTest (
86 if (ErrorOut
&& (Status
== EFI_DEVICE_ERROR
)) {
87 PrintXY (10, 10, NULL
, NULL
, L
"Memory Testing failed!");
92 DEBUG ((DEBUG_INFO
, "Perform memory test (ESC to skip).\n"));
94 if (!PcdGetBool (PcdConInConnectOnDemand
)) {
95 KeyStatus
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
96 if (!EFI_ERROR (KeyStatus
) && (Key
.ScanCode
== SCAN_ESC
)) {
97 if (!RequireSoftECCInit
) {
98 Status
= GenMemoryTest
->Finished (GenMemoryTest
);
105 } while (Status
!= EFI_NOT_FOUND
);
107 Status
= GenMemoryTest
->Finished (GenMemoryTest
);
110 DEBUG ((DEBUG_INFO
, "%d bytes of system memory tested OK\r\n", TotalMemorySize
));