audk/EmulatorPkg/Library/PlatformBmLib/PlatformBmMemoryTest.c
Michael D Kinney e3ba31da1c EmulatorPkg: Replace BSD License with BSD+Patent License
https://bugzilla.tianocore.org/show_bug.cgi?id=1373

Replace BSD 2-Clause License with BSD+Patent License.  This change is
based on the following emails:

  https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html
  https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html

RFCs with detailed process for the license change:

  V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html
  V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html
  V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
2019-04-09 10:57:59 -07:00

114 lines
3.4 KiB
C

/** @file
Perform the platform memory test
Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "PlatformBm.h"
//
// BDS Platform Functions
//
/**
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;
EFI_STATUS KeyStatus;
EFI_STATUS InitStatus;
EFI_STATUS ReturnStatus;
BOOLEAN RequireSoftECCInit;
EFI_GENERIC_MEMORY_TEST_PROTOCOL *GenMemoryTest;
UINT64 TestedMemorySize;
UINT64 TotalMemorySize;
BOOLEAN ErrorOut;
BOOLEAN TestAbort;
EFI_INPUT_KEY Key;
ReturnStatus = EFI_SUCCESS;
ZeroMem (&Key, sizeof (EFI_INPUT_KEY));
TestedMemorySize = 0;
TotalMemorySize = 0;
ErrorOut = FALSE;
TestAbort = FALSE;
RequireSoftECCInit = FALSE;
Status = gBS->LocateProtocol (
&gEfiGenericMemTestProtocolGuid,
NULL,
(VOID **) &GenMemoryTest
);
if (EFI_ERROR (Status)) {
return EFI_SUCCESS;
}
InitStatus = GenMemoryTest->MemoryTestInit (
GenMemoryTest,
Level,
&RequireSoftECCInit
);
if (InitStatus == 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;
}
DEBUG ((DEBUG_INFO, "Enter memory test.\n"));
do {
Status = GenMemoryTest->PerformMemoryTest (
GenMemoryTest,
&TestedMemorySize,
&TotalMemorySize,
&ErrorOut,
TestAbort
);
if (ErrorOut && (Status == EFI_DEVICE_ERROR)) {
PrintXY (10, 10, NULL, NULL, L"Memory Testing failed!");
ASSERT (0);
}
DEBUG ((DEBUG_INFO, "Perform memory test (ESC to skip).\n"));
if (!PcdGetBool (PcdConInConnectOnDemand)) {
KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {
if (!RequireSoftECCInit) {
Status = GenMemoryTest->Finished (GenMemoryTest);
goto Done;
}
TestAbort = TRUE;
}
}
} while (Status != EFI_NOT_FOUND);
Status = GenMemoryTest->Finished (GenMemoryTest);
Done:
DEBUG ((DEBUG_INFO, "%d bytes of system memory tested OK\r\n", TotalMemorySize));
return ReturnStatus;
}