Code scrub for NullMemoryTest driver.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6429 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
xli24
2008-11-07 09:34:50 +00:00
parent a7cc3d261c
commit b3764698fa
3 changed files with 160 additions and 119 deletions

View File

@ -1,5 +1,5 @@
/** @file /** @file
Intall memory test protocol and bypass the real memory test procedure. Implementation of Generic Memory Test Protocol which does not perform real memory test.
Copyright (c) 2006 - 2008, Intel Corporation. <BR> Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
@ -15,16 +15,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "NullMemoryTest.h" #include "NullMemoryTest.h"
//
// Module global members
//
UINT64 mTestedSystemMemory = 0; UINT64 mTestedSystemMemory = 0;
UINT64 mTotalSystemMemory = 0; UINT64 mTotalSystemMemory = 0;
EFI_HANDLE mGenericMemoryTestHandle; EFI_HANDLE mGenericMemoryTestHandle;
//
// Driver entry here
//
EFI_GENERIC_MEMORY_TEST_PROTOCOL mGenericMemoryTest = { EFI_GENERIC_MEMORY_TEST_PROTOCOL mGenericMemoryTest = {
InitializeMemoryTest, InitializeMemoryTest,
GenPerformMemoryTest, GenPerformMemoryTest,
@ -32,51 +26,55 @@ EFI_GENERIC_MEMORY_TEST_PROTOCOL mGenericMemoryTest = {
GenCompatibleRangeTest GenCompatibleRangeTest
}; };
/**
Entry point of the NULL memory test driver.
This function is the entry point of the NULL memory test driver.
It simply installs the Generic Memory Test Protocol.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS Generic Memory Test Protocol is successfully installed.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GenericMemoryTestEntryPoint ( GenericMemoryTestEntryPoint (
IN EFI_HANDLE ImageHandle, IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
/*++
Routine Description:
The generic memory test driver's entry point, it can initialize private data
to default value
Arguments:
ImageHandle of the loaded driver
Pointer to the System Table
Returns:
Status
EFI_SUCCESS - Protocol successfully installed
EFI_OUT_OF_RESOURCES - Can not allocate protocol data structure in base
memory
--*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
//
// Install the protocol
//
Status = gBS->InstallProtocolInterface ( Status = gBS->InstallProtocolInterface (
&mGenericMemoryTestHandle, &mGenericMemoryTestHandle,
&gEfiGenericMemTestProtocolGuid, &gEfiGenericMemTestProtocolGuid,
EFI_NATIVE_INTERFACE, EFI_NATIVE_INTERFACE,
&mGenericMemoryTest &mGenericMemoryTest
); );
ASSERT_EFI_ERROR (Status);
return Status; return EFI_SUCCESS;
} }
//
// EFI_GENERIC_MEMORY_TEST_PROTOCOL implementation /**
// Initialize the generic memory test.
This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.MemoryTestInit.
It simply promotes untested reserved memory to system memory without real test.
@param This Protocol instance pointer.
@param Level The coverage level of the memory test.
@param RequireSoftECCInit Indicate if the memory need software ECC init.
@retval EFI_SUCCESS The generic memory test initialized correctly.
@retval EFI_NO_MEDIA There is not any non-tested memory found, in this
function if not any non-tesed memory found means
that the memory test driver have not detect any
non-tested extended memory of current system.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitializeMemoryTest ( InitializeMemoryTest (
@ -84,15 +82,6 @@ InitializeMemoryTest (
IN EXTENDMEM_COVERAGE_LEVEL Level, IN EXTENDMEM_COVERAGE_LEVEL Level,
OUT BOOLEAN *RequireSoftECCInit OUT BOOLEAN *RequireSoftECCInit
) )
/*++
Routine Description:
Arguments:
Returns:
--*/
{ {
UINTN NumberOfDescriptors; UINTN NumberOfDescriptors;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
@ -104,6 +93,9 @@ Returns:
(MemorySpaceMap[Index].Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) == (MemorySpaceMap[Index].Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) ==
(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED) (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)
) { ) {
//
// For those reserved memory that have not been tested, simply promote to system memory.
//
gDS->RemoveMemorySpace ( gDS->RemoveMemorySpace (
MemorySpaceMap[Index].BaseAddress, MemorySpaceMap[Index].BaseAddress,
MemorySpaceMap[Index].Length MemorySpaceMap[Index].Length
@ -130,6 +122,29 @@ Returns:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/**
Perform the memory test.
This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.PerformMemoryTest.
It simply returns EFI_NOT_FOUND.
@param This Protocol instance pointer.
@param TestedMemorySize Return the tested extended memory size.
@param TotalMemorySize Return the whole system physical memory size, this
value may be changed if in some case some error
DIMMs be disabled.
@param ErrorOut Any time the memory error occurs, this will be
TRUE.
@param IfTestAbort Indicate if the user press "ESC" to skip the memory
test.
@retval EFI_SUCCESS One block of memory test ok, the block size is hide
internally.
@retval EFI_NOT_FOUND Indicate all the non-tested memory blocks have
already go through.
@retval EFI_DEVICE_ERROR Mis-compare error, and no agent can handle it
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GenPerformMemoryTest ( GenPerformMemoryTest (
@ -139,15 +154,6 @@ GenPerformMemoryTest (
OUT BOOLEAN *ErrorOut, OUT BOOLEAN *ErrorOut,
IN BOOLEAN TestAbort IN BOOLEAN TestAbort
) )
/*++
Routine Description:
Arguments:
Returns:
--*/
{ {
*ErrorOut = FALSE; *ErrorOut = FALSE;
*TestedMemorySize = mTestedSystemMemory; *TestedMemorySize = mTestedSystemMemory;
@ -157,24 +163,43 @@ Returns:
} }
/**
The memory test finished.
This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.Finished.
It simply returns EFI_SUCCESS.
@param This Protocol instance pointer.
@retval EFI_SUCCESS Successful free all the generic memory test driver
allocated resource and notify to platform memory
test driver that memory test finished.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GenMemoryTestFinished ( GenMemoryTestFinished (
IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This
) )
/*++
Routine Description:
Arguments:
Returns:
--*/
{ {
return EFI_SUCCESS; return EFI_SUCCESS;
} }
/**
Provide capability to test compatible range which used by some special
driver required using memory range before BDS perform memory test.
This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.CompatibleRangeTest.
It simply sets the memory range to system memory.
@param This Protocol instance pointer.
@param StartAddress The start address of the memory range.
@param Length The memory range's length.
@retval EFI_SUCCESS The compatible memory range pass the memory test.
@retval EFI_INVALID_PARAMETER The compatible memory range must be below 16M.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GenCompatibleRangeTest ( GenCompatibleRangeTest (
@ -182,19 +207,10 @@ GenCompatibleRangeTest (
IN EFI_PHYSICAL_ADDRESS StartAddress, IN EFI_PHYSICAL_ADDRESS StartAddress,
IN UINT64 Length IN UINT64 Length
) )
/*++
Routine Description:
Arguments:
Returns:
--*/
{ {
EFI_GCD_MEMORY_SPACE_DESCRIPTOR descriptor; EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
gDS->GetMemorySpaceDescriptor (StartAddress, &descriptor); gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor);
gDS->RemoveMemorySpace (StartAddress, Length); gDS->RemoveMemorySpace (StartAddress, Length);
@ -202,7 +218,7 @@ Returns:
EfiGcdMemoryTypeSystemMemory, EfiGcdMemoryTypeSystemMemory,
StartAddress, StartAddress,
Length, Length,
descriptor.Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME) Descriptor.Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
); );
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -1,5 +1,5 @@
/** @file /** @file
The generic memory test driver definition Include file of the NULL memory test driver.
Copyright (c) 2006 - 2008, Intel Corporation. <BR> Copyright (c) 2006 - 2008, Intel Corporation. <BR>
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
#ifndef _NULL_MEMORY_TEST_H #ifndef _NULL_MEMORY_TEST_H_
#define _NULL_MEMORY_TEST_H #define _NULL_MEMORY_TEST_H_
#include <PiDxe.h> #include <PiDxe.h>
@ -28,51 +28,29 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
// //
// attributes for reserved memory before it is promoted to system memory // Definition of memory status.
// //
#define EFI_MEMORY_PRESENT 0x0100000000000000ULL #define EFI_MEMORY_PRESENT 0x0100000000000000ULL
#define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL #define EFI_MEMORY_INITIALIZED 0x0200000000000000ULL
#define EFI_MEMORY_TESTED 0x0400000000000000ULL #define EFI_MEMORY_TESTED 0x0400000000000000ULL
/**
Initialize the generic memory test.
// This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.MemoryTestInit.
// Some global define It simply promotes untested reserved memory to system memory without real test.
//
#define GENERIC_CACHELINE_SIZE 0x40
// @param This Protocol instance pointer.
// The SPARSE_SPAN_SIZE size can not small then the MonoTestSize @param Level The coverage level of the memory test.
// @param RequireSoftECCInit Indicate if the memory need software ECC init.
#define TEST_BLOCK_SIZE 0x2000000
#define QUICK_SPAN_SIZE (TEST_BLOCK_SIZE >> 2)
#define SPARSE_SPAN_SIZE (TEST_BLOCK_SIZE >> 4)
// @retval EFI_SUCCESS The generic memory test initialized correctly.
// This structure records every nontested memory range parsed through GCD @retval EFI_NO_MEDIA There is not any non-tested memory found, in this
// service. function if not any non-tesed memory found means
// that the memory test driver have not detect any
#define EFI_NONTESTED_MEMORY_RANGE_SIGNATURE EFI_SIGNATURE_32 ('N', 'T', 'M', 'E') non-tested extended memory of current system.
typedef struct {
UINTN Signature;
LIST_ENTRY Link;
EFI_PHYSICAL_ADDRESS StartAddress;
UINT64 Length;
UINT64 Capabilities;
BOOLEAN Above4G;
BOOLEAN AlreadyMapped;
} NONTESTED_MEMORY_RANGE;
#define NONTESTED_MEMORY_RANGE_FROM_LINK(link) \ **/
CR(link, NONTESTED_MEMORY_RANGE, Link, EFI_NONTESTED_MEMORY_RANGE_SIGNATURE)
//
// This is the memory test driver's structure definition
//
#define EFI_GENERIC_MEMORY_TEST_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('G', 'E', 'M', 'T')
//
// Function Prototypes
//
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitializeMemoryTest ( InitializeMemoryTest (
@ -81,6 +59,29 @@ InitializeMemoryTest (
OUT BOOLEAN *RequireSoftECCInit OUT BOOLEAN *RequireSoftECCInit
); );
/**
Perform the memory test.
This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.PerformMemoryTest.
It simply returns EFI_NOT_FOUND.
@param This Protocol instance pointer.
@param TestedMemorySize Return the tested extended memory size.
@param TotalMemorySize Return the whole system physical memory size, this
value may be changed if in some case some error
DIMMs be disabled.
@param ErrorOut Any time the memory error occurs, this will be
TRUE.
@param IfTestAbort Indicate if the user press "ESC" to skip the memory
test.
@retval EFI_SUCCESS One block of memory test ok, the block size is hide
internally.
@retval EFI_NOT_FOUND Indicate all the non-tested memory blocks have
already go through.
@retval EFI_DEVICE_ERROR Mis-compare error, and no agent can handle it
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GenPerformMemoryTest ( GenPerformMemoryTest (
@ -91,12 +92,40 @@ GenPerformMemoryTest (
IN BOOLEAN TestAbort IN BOOLEAN TestAbort
); );
/**
The memory test finished.
This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.Finished.
It simply returns EFI_SUCCESS.
@param This Protocol instance pointer.
@retval EFI_SUCCESS Successful free all the generic memory test driver
allocated resource and notify to platform memory
test driver that memory test finished.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GenMemoryTestFinished ( GenMemoryTestFinished (
IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This
); );
/**
Provide capability to test compatible range which used by some special
driver required using memory range before BDS perform memory test.
This function implements EFI_GENERIC_MEMORY_TEST_PROTOCOL.CompatibleRangeTest.
It simply set the memory range to system memory.
@param This Protocol instance pointer.
@param StartAddress The start address of the memory range.
@param Length The memory range's length.
@retval EFI_SUCCESS The compatible memory range pass the memory test.
@retval EFI_INVALID_PARAMETER The compatible memory range must be below 16M.
**/
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
GenCompatibleRangeTest ( GenCompatibleRangeTest (

View File

@ -1,9 +1,5 @@
#/** @file #/** @file
# # This driver installs Generic Memory Test Protocol which does not perform real memory test.
# Component description file for NullMemoryTest module.
#
# This driver installs EFI_GENERIC_MEMORY_TEST_PROTOCOL to
# provide simple generic memory test functions.
# #
# Copyright (c) 2006 - 2008, Intel Corporation. <BR> # Copyright (c) 2006 - 2008, Intel Corporation. <BR>
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials