2 Perform the platform memory test
4 Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "PlatformBm.h"
18 // BDS Platform Functions
22 Perform the memory test base on the memory test intensive level,
23 and update the memory resource.
25 @param Level The memory test intensive level.
27 @retval EFI_STATUS Success test all the system memory and update
32 PlatformBootManagerMemoryTest (
33 IN EXTENDMEM_COVERAGE_LEVEL Level
38 EFI_STATUS InitStatus
;
39 EFI_STATUS ReturnStatus
;
40 BOOLEAN RequireSoftECCInit
;
41 EFI_GENERIC_MEMORY_TEST_PROTOCOL
*GenMemoryTest
;
42 UINT64 TestedMemorySize
;
43 UINT64 TotalMemorySize
;
48 ReturnStatus
= EFI_SUCCESS
;
49 ZeroMem (&Key
, sizeof (EFI_INPUT_KEY
));
56 RequireSoftECCInit
= FALSE
;
58 Status
= gBS
->LocateProtocol (
59 &gEfiGenericMemTestProtocolGuid
,
61 (VOID
**) &GenMemoryTest
63 if (EFI_ERROR (Status
)) {
67 InitStatus
= GenMemoryTest
->MemoryTestInit (
72 if (InitStatus
== EFI_NO_MEDIA
) {
74 // The PEI codes also have the relevant memory test code to check the memory,
75 // it can select to test some range of the memory or all of them. If PEI code
76 // checks all the memory, this BDS memory test will has no not-test memory to
77 // do the test, and then the status of EFI_NO_MEDIA will be returned by
78 // "MemoryTestInit". So it does not need to test memory again, just return.
83 DEBUG ((DEBUG_INFO
, "Enter memory test.\n"));
85 Status
= GenMemoryTest
->PerformMemoryTest (
92 if (ErrorOut
&& (Status
== EFI_DEVICE_ERROR
)) {
93 PrintXY (10, 10, NULL
, NULL
, L
"Memory Testing failed!");
98 DEBUG ((DEBUG_INFO
, "Perform memory test (ESC to skip).\n"));
100 if (!PcdGetBool (PcdConInConnectOnDemand
)) {
101 KeyStatus
= gST
->ConIn
->ReadKeyStroke (gST
->ConIn
, &Key
);
102 if (!EFI_ERROR (KeyStatus
) && (Key
.ScanCode
== SCAN_ESC
)) {
103 if (!RequireSoftECCInit
) {
104 Status
= GenMemoryTest
->Finished (GenMemoryTest
);
111 } while (Status
!= EFI_NOT_FOUND
);
113 Status
= GenMemoryTest
->Finished (GenMemoryTest
);
116 DEBUG ((DEBUG_INFO
, "%d bytes of system memory tested OK\r\n", TotalMemorySize
));