TianoCore EDK2 master
Loading...
Searching...
No Matches
LightMemoryTest.c File Reference
#include "LightMemoryTest.h"

Go to the source code of this file.

Functions

INTN EFIAPI CompareMemWithoutCheckArgument (IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
 
EFI_STATUS ConstructBaseMemoryRange (IN GENERIC_MEMORY_TEST_PRIVATE *Private)
 
VOID DestroyLinkList (IN GENERIC_MEMORY_TEST_PRIVATE *Private)
 
EFI_STATUS ConvertToTestedMemory (IN UINT64 BaseAddress, IN UINT64 Length, IN UINT64 Capabilities)
 
EFI_STATUS UpdateMemoryMap (IN GENERIC_MEMORY_TEST_PRIVATE *Private)
 
EFI_STATUS DirectRangeTest (IN GENERIC_MEMORY_TEST_PRIVATE *Private, IN EFI_PHYSICAL_ADDRESS StartAddress, IN UINT64 Length, IN UINT64 Capabilities)
 
EFI_STATUS ConstructNonTestedMemoryRange (IN GENERIC_MEMORY_TEST_PRIVATE *Private)
 
EFI_STATUS WriteMemory (IN GENERIC_MEMORY_TEST_PRIVATE *Private, IN EFI_PHYSICAL_ADDRESS Start, IN UINT64 Size)
 
EFI_STATUS VerifyMemory (IN GENERIC_MEMORY_TEST_PRIVATE *Private, IN EFI_PHYSICAL_ADDRESS Start, IN UINT64 Size)
 
EFI_STATUS EFIAPI InitializeMemoryTest (IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, IN EXTENDMEM_COVERAGE_LEVEL Level, OUT BOOLEAN *RequireSoftECCInit)
 
EFI_STATUS EFIAPI GenPerformMemoryTest (IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, OUT UINT64 *TestedMemorySize, OUT UINT64 *TotalMemorySize, OUT BOOLEAN *ErrorOut, IN BOOLEAN TestAbort)
 
EFI_STATUS EFIAPI GenMemoryTestFinished (IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This)
 
EFI_STATUS EFIAPI GenCompatibleRangeTest (IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS StartAddress, IN UINT64 Length)
 
EFI_STATUS PerformAddressDataLineTest (IN GENERIC_MEMORY_TEST_PRIVATE *Private)
 
EFI_STATUS EFIAPI GenericMemoryTestEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_PHYSICAL_ADDRESS mCurrentAddress
 
LIST_ENTRYmCurrentLink
 
NONTESTED_MEMORY_RANGEmCurrentRange
 
UINT64 mTestedSystemMemory
 
UINT64 mNonTestedSystemMemory
 
UINT32 GenericMemoryTestMonoPattern [GENERIC_CACHELINE_SIZE/4]
 
GENERIC_MEMORY_TEST_PRIVATE mGenericMemoryTestPrivate
 

Detailed Description

Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file LightMemoryTest.c.

Function Documentation

◆ CompareMemWithoutCheckArgument()

INTN EFIAPI CompareMemWithoutCheckArgument ( IN CONST VOID *  DestinationBuffer,
IN CONST VOID *  SourceBuffer,
IN UINTN  Length 
)

Compares the contents of two buffers.

This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer. If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the value returned is the first mismatched byte in SourceBuffer subtracted from the first mismatched byte in DestinationBuffer.

If Length = 0, then ASSERT().

Parameters
[in]DestinationBufferThe pointer to the destination buffer to compare.
[in]SourceBufferThe pointer to the source buffer to compare.
[in]LengthThe number of bytes to compare.
Returns
0 All Length bytes of the two buffers are identical.
Return values
Non-zeroThe first mismatched byte in SourceBuffer subtracted from the first mismatched byte in DestinationBuffer.

Definition at line 62 of file LightMemoryTest.c.

◆ ConstructBaseMemoryRange()

EFI_STATUS ConstructBaseMemoryRange ( IN GENERIC_MEMORY_TEST_PRIVATE Private)

Construct the system base memory range through GCD service.

Parameters
[in]PrivatePoint to generic memory test driver's private data.
Return values
EFI_SUCCESSSuccessful construct the base memory range through GCD service.
EFI_OUT_OF_RESOURCECould not allocate needed resource from base memory.
OthersFailed to construct base memory range through GCD service.

Definition at line 90 of file LightMemoryTest.c.

◆ ConstructNonTestedMemoryRange()

EFI_STATUS ConstructNonTestedMemoryRange ( IN GENERIC_MEMORY_TEST_PRIVATE Private)

Construct the system non-tested memory range through GCD service.

Parameters
[in]PrivatePoint to generic memory test driver's private data.
Return values
EFI_SUCCESSSuccessful construct the non-tested memory range through GCD service.
EFI_OUT_OF_RESOURCECould not allocate needed resource from base memory.
OthersFailed to construct non-tested memory range through GCD service.

Definition at line 268 of file LightMemoryTest.c.

◆ ConvertToTestedMemory()

EFI_STATUS ConvertToTestedMemory ( IN UINT64  BaseAddress,
IN UINT64  Length,
IN UINT64  Capabilities 
)

Convert the memory range to tested.

Parameters
BaseAddressBase address of the memory range.
LengthLength of the memory range.
CapabilitiesCapabilities of the memory range.
Return values
EFI_SUCCESSThe memory range is converted to tested.
othersError happens.

Definition at line 149 of file LightMemoryTest.c.

◆ DestroyLinkList()

VOID DestroyLinkList ( IN GENERIC_MEMORY_TEST_PRIVATE Private)

Destroy the link list base on the correspond link list type.

Parameters
[in]PrivatePoint to generic memory test driver's private data.

Definition at line 121 of file LightMemoryTest.c.

◆ DirectRangeTest()

EFI_STATUS DirectRangeTest ( IN GENERIC_MEMORY_TEST_PRIVATE Private,
IN EFI_PHYSICAL_ADDRESS  StartAddress,
IN UINT64  Length,
IN UINT64  Capabilities 
)

Test a range of the memory directly .

Parameters
[in]PrivatePoint to generic memory test driver's private data.
[in]StartAddressStarting address of the memory range to be tested.
[in]LengthLength in bytes of the memory range to be tested.
[in]CapabilitiesThe bit mask of attributes that the memory range supports.
Return values
EFI_SUCCESSSuccessful test the range of memory.
OthersFailed to test the range of memory.

Definition at line 222 of file LightMemoryTest.c.

◆ GenCompatibleRangeTest()

EFI_STATUS EFIAPI GenCompatibleRangeTest ( IN EFI_GENERIC_MEMORY_TEST_PROTOCOL This,
IN EFI_PHYSICAL_ADDRESS  StartAddress,
IN UINT64  Length 
)

Provides the capability to test the compatible range used by some special drivers.

Parameters
[in]ThisThe protocol instance pointer.
[in]StartAddressThe start address of the compatible memory range that must be below 16M.
[in]LengthThe compatible memory range's length.
Return values
EFI_SUCCESSThe compatible memory range pass the memory test.
EFI_INVALID_PARAMETERThe compatible memory range are not below Low 16M.

Definition at line 727 of file LightMemoryTest.c.

◆ GenericMemoryTestEntryPoint()

EFI_STATUS EFIAPI GenericMemoryTestEntryPoint ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The generic memory test driver's entry point.

It initializes private data to default value.

Parameters
[in]ImageHandleThe firmware allocated handle for the EFI image.
[in]SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
EFI_NOT_FOUNDCan't find HandOff Hob in HobList.
otherSome error occurs when executing this entry point.

Definition at line 889 of file LightMemoryTest.c.

◆ GenMemoryTestFinished()

EFI_STATUS EFIAPI GenMemoryTestFinished ( IN EFI_GENERIC_MEMORY_TEST_PROTOCOL This)

Finish the memory test.

Parameters
[in]ThisThe protocol instance pointer.
Return values
EFI_SUCCESSSuccess. All resources used in the memory test are freed.

Definition at line 683 of file LightMemoryTest.c.

◆ GenPerformMemoryTest()

EFI_STATUS EFIAPI GenPerformMemoryTest ( IN EFI_GENERIC_MEMORY_TEST_PROTOCOL This,
OUT UINT64 *  TestedMemorySize,
OUT UINT64 *  TotalMemorySize,
OUT BOOLEAN *  ErrorOut,
IN BOOLEAN  TestAbort 
)

Perform the memory test.

Parameters
[in]ThisThe protocol instance pointer.
[out]TestedMemorySizeReturn the tested extended memory size.
[out]TotalMemorySizeReturn the whole system physical memory size. The total memory size does not include memory in a slot with a disabled DIMM.
[out]ErrorOutTRUE if the memory error occurred.
[in]IfTestAbortIndicates that the user pressed "ESC" to skip the memory test.
Return values
EFI_SUCCESSOne block of memory passed the test.
EFI_NOT_FOUNDAll memory blocks have already been tested.
EFI_DEVICE_ERRORMemory device error occurred, and no agent can handle it.

Definition at line 563 of file LightMemoryTest.c.

◆ InitializeMemoryTest()

EFI_STATUS EFIAPI InitializeMemoryTest ( IN EFI_GENERIC_MEMORY_TEST_PROTOCOL This,
IN EXTENDMEM_COVERAGE_LEVEL  Level,
OUT BOOLEAN *  RequireSoftECCInit 
)

Initialize the generic memory test.

Parameters
[in]ThisThe protocol instance pointer.
[in]LevelThe coverage level of the memory test.
[out]RequireSoftECCInitIndicate if the memory need software ECC init.
Return values
EFI_SUCCESSThe generic memory test is initialized correctly.
EFI_NO_MEDIAThe system had no memory to be tested.

Definition at line 460 of file LightMemoryTest.c.

◆ PerformAddressDataLineTest()

EFI_STATUS PerformAddressDataLineTest ( IN GENERIC_MEMORY_TEST_PRIVATE Private)

Perform the address line walking ones test.

Parameters
[in]PrivatePoint to generic memory test driver's private data.
Return values
EFI_SUCCESSSuccessful finished walking ones test.
EFI_OUT_OF_RESOURCECould not get resource in base memory.
EFI_ACCESS_DENIEDCode may can not run here because if walking one test failed, system may be already halt.

Definition at line 804 of file LightMemoryTest.c.

◆ UpdateMemoryMap()

EFI_STATUS UpdateMemoryMap ( IN GENERIC_MEMORY_TEST_PRIVATE Private)

Add the extened memory to whole system memory map.

Parameters
[in]PrivatePoint to generic memory test driver's private data.
Return values
EFI_SUCCESSSuccessful add all the extended memory to system memory map.
OthersFailed to add the tested extended memory.

Definition at line 185 of file LightMemoryTest.c.

◆ VerifyMemory()

EFI_STATUS VerifyMemory ( IN GENERIC_MEMORY_TEST_PRIVATE Private,
IN EFI_PHYSICAL_ADDRESS  Start,
IN UINT64  Size 
)

Verify the range of physical memory which covered by memory test pattern.

This function will also do not return any informatin just cause system reset, because the handle error encount fatal error and disable the bad DIMMs.

Parameters
[in]PrivatePoint to generic memory test driver's private data.
[in]StartThe memory range's start address.
[in]SizeThe memory range's size.
Return values
EFI_SUCCESSSuccessful verify the range of memory, no errors' location found.
OthersThe range of memory have errors contained.

Definition at line 379 of file LightMemoryTest.c.

◆ WriteMemory()

EFI_STATUS WriteMemory ( IN GENERIC_MEMORY_TEST_PRIVATE Private,
IN EFI_PHYSICAL_ADDRESS  Start,
IN UINT64  Size 
)

Write the memory test pattern into a range of physical memory.

Parameters
[in]PrivatePoint to generic memory test driver's private data.
[in]StartThe memory range's start address.
[in]SizeThe memory range's size.
Return values
EFI_SUCCESSSuccessful write the test pattern into the non-tested memory.
OthersThe test pattern may not really write into the physical memory.

Definition at line 330 of file LightMemoryTest.c.

Variable Documentation

◆ GenericMemoryTestMonoPattern

UINT32 GenericMemoryTestMonoPattern[GENERIC_CACHELINE_SIZE/4]
Initial value:
= {
0x5a5a5a5a,
0xa5a5a5a5,
0x5a5a5a5a,
0xa5a5a5a5,
0x5a5a5a5a,
0xa5a5a5a5,
0x5a5a5a5a,
0xa5a5a5a5,
0x5a5a5a5a,
0xa5a5a5a5,
0x5a5a5a5a,
0xa5a5a5a5,
0x5a5a5a5a,
0xa5a5a5a5,
0x5a5a5a5a,
0xa5a5a5a5
}

Definition at line 22 of file LightMemoryTest.c.

◆ mCurrentAddress

EFI_PHYSICAL_ADDRESS mCurrentAddress

Definition at line 16 of file LightMemoryTest.c.

◆ mCurrentLink

LIST_ENTRY* mCurrentLink

Definition at line 17 of file LightMemoryTest.c.

◆ mCurrentRange

NONTESTED_MEMORY_RANGE* mCurrentRange

Definition at line 18 of file LightMemoryTest.c.

◆ mGenericMemoryTestPrivate

GENERIC_MEMORY_TEST_PRIVATE mGenericMemoryTestPrivate
Initial value:
= {
EFI_GENERIC_MEMORY_TEST_PRIVATE_SIGNATURE,
{
},
0,
0,
0,
0,
{
}
}
EXTENDMEM_COVERAGE_LEVEL
EFI_STATUS EFIAPI GenPerformMemoryTest(IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, OUT UINT64 *TestedMemorySize, OUT UINT64 *TotalMemorySize, OUT BOOLEAN *ErrorOut, IN BOOLEAN TestAbort)
EFI_STATUS EFIAPI InitializeMemoryTest(IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, IN EXTENDMEM_COVERAGE_LEVEL Level, OUT BOOLEAN *RequireSoftECCInit)
EFI_STATUS EFIAPI GenMemoryTestFinished(IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This)
EFI_STATUS EFIAPI GenCompatibleRangeTest(IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS StartAddress, IN UINT64 Length)
#define NULL
Definition: Base.h:319

Definition at line 852 of file LightMemoryTest.c.

◆ mNonTestedSystemMemory

UINT64 mNonTestedSystemMemory

Definition at line 20 of file LightMemoryTest.c.

◆ mTestedSystemMemory

UINT64 mTestedSystemMemory

Definition at line 19 of file LightMemoryTest.c.