TianoCore EDK2 master
Loading...
Searching...
No Matches
PlatformBmMemoryTest.c
Go to the documentation of this file.
1
9#include "PlatformBm.h"
10
11//
12// BDS Platform Functions
13//
14
28 )
29{
30 EFI_STATUS Status;
31 EFI_STATUS KeyStatus;
32 EFI_STATUS InitStatus;
33 EFI_STATUS ReturnStatus;
34 BOOLEAN RequireSoftECCInit;
36 UINT64 TestedMemorySize;
37 UINT64 TotalMemorySize;
38 BOOLEAN ErrorOut;
39 BOOLEAN TestAbort;
40 EFI_INPUT_KEY Key;
41
42 ReturnStatus = EFI_SUCCESS;
43 ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
44
45 TestedMemorySize = 0;
46 TotalMemorySize = 0;
47 ErrorOut = FALSE;
48 TestAbort = FALSE;
49
50 RequireSoftECCInit = FALSE;
51
52 Status = gBS->LocateProtocol (
53 &gEfiGenericMemTestProtocolGuid,
54 NULL,
55 (VOID **)&GenMemoryTest
56 );
57 if (EFI_ERROR (Status)) {
58 return EFI_SUCCESS;
59 }
60
61 InitStatus = GenMemoryTest->MemoryTestInit (
62 GenMemoryTest,
63 Level,
64 &RequireSoftECCInit
65 );
66 if (InitStatus == EFI_NO_MEDIA) {
67 //
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.
73 //
74 return EFI_SUCCESS;
75 }
76
77 DEBUG ((DEBUG_INFO, "Enter memory test.\n"));
78 do {
79 Status = GenMemoryTest->PerformMemoryTest (
80 GenMemoryTest,
81 &TestedMemorySize,
82 &TotalMemorySize,
83 &ErrorOut,
84 TestAbort
85 );
86 if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
87 PrintXY (10, 10, NULL, NULL, L"Memory Testing failed!");
88 ASSERT (0);
89 }
90
91 DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n"));
92
93 if (!PcdGetBool (PcdConInConnectOnDemand)) {
94 KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
95 if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {
96 if (!RequireSoftECCInit) {
97 Status = GenMemoryTest->Finished (GenMemoryTest);
98 goto Done;
99 }
100
101 TestAbort = TRUE;
102 }
103 }
104 } while (Status != EFI_NOT_FOUND);
105
106 Status = GenMemoryTest->Finished (GenMemoryTest);
107
108Done:
109 DEBUG ((DEBUG_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize));
110
111 return ReturnStatus;
112}
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EXTENDMEM_COVERAGE_LEVEL
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define PcdGetBool(TokenName)
Definition: PcdLib.h:401
EFI_STATUS PlatformBootManagerMemoryTest(IN EXTENDMEM_COVERAGE_LEVEL Level)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS
UINTN EFIAPI PrintXY(IN UINTN PointX, IN UINTN PointY, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround OPTIONAL, IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround OPTIONAL, IN CONST CHAR16 *Format,...)
Definition: UefiLibPrint.c:617
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
Definition: UefiSpec.h:2053