diff options
Diffstat (limited to 'MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe')
-rw-r--r-- | MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c | 90 | ||||
-rw-r--r-- | MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.h | 26 |
2 files changed, 60 insertions, 56 deletions
diff --git a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c index 9c01610..846f9b8 100644 --- a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c +++ b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.c @@ -6,12 +6,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/
-
#include "NullMemoryTest.h"
-UINT64 mTestedSystemMemory = 0;
-UINT64 mTotalSystemMemory = 0;
-EFI_HANDLE mGenericMemoryTestHandle;
+UINT64 mTestedSystemMemory = 0;
+UINT64 mTotalSystemMemory = 0;
+EFI_HANDLE mGenericMemoryTestHandle;
EFI_GENERIC_MEMORY_TEST_PROTOCOL mGenericMemoryTest = {
InitializeMemoryTest,
@@ -35,8 +34,8 @@ EFI_GENERIC_MEMORY_TEST_PROTOCOL mGenericMemoryTest = { EFI_STATUS
EFIAPI
GenericMemoryTestEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
@@ -64,12 +63,13 @@ GenericMemoryTestEntryPoint ( **/
EFI_STATUS
ConvertToTestedMemory (
- IN UINT64 BaseAddress,
- IN UINT64 Length,
- IN UINT64 Capabilities
+ IN UINT64 BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Capabilities
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+
Status = gDS->RemoveMemorySpace (
BaseAddress,
Length
@@ -84,6 +84,7 @@ ConvertToTestedMemory ( (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
);
}
+
return Status;
}
@@ -107,22 +108,23 @@ ConvertToTestedMemory ( EFI_STATUS
EFIAPI
InitializeMemoryTest (
- IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
- IN EXTENDMEM_COVERAGE_LEVEL Level,
- OUT BOOLEAN *RequireSoftECCInit
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ IN EXTENDMEM_COVERAGE_LEVEL Level,
+ OUT BOOLEAN *RequireSoftECCInit
)
{
- EFI_STATUS Status;
- UINTN NumberOfDescriptors;
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
- UINTN Index;
+ EFI_STATUS Status;
+ UINTN NumberOfDescriptors;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
+ UINTN Index;
gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
for (Index = 0; Index < NumberOfDescriptors; Index++) {
- if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeReserved &&
- (MemorySpaceMap[Index].Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) ==
- (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)
- ) {
+ if ((MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeReserved) &&
+ ((MemorySpaceMap[Index].Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) ==
+ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED))
+ )
+ {
//
// For those reserved memory that have not been tested, simply promote to system memory.
//
@@ -133,9 +135,10 @@ InitializeMemoryTest ( );
ASSERT_EFI_ERROR (Status);
mTestedSystemMemory += MemorySpaceMap[Index].Length;
- mTotalSystemMemory += MemorySpaceMap[Index].Length;
+ mTotalSystemMemory += MemorySpaceMap[Index].Length;
} else if ((MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) ||
- (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMoreReliable)) {
+ (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMoreReliable))
+ {
mTotalSystemMemory += MemorySpaceMap[Index].Length;
}
}
@@ -172,11 +175,11 @@ InitializeMemoryTest ( EFI_STATUS
EFIAPI
GenPerformMemoryTest (
- IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
- IN OUT UINT64 *TestedMemorySize,
- OUT UINT64 *TotalMemorySize,
- OUT BOOLEAN *ErrorOut,
- IN BOOLEAN TestAbort
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ IN OUT UINT64 *TestedMemorySize,
+ OUT UINT64 *TotalMemorySize,
+ OUT BOOLEAN *ErrorOut,
+ IN BOOLEAN TestAbort
)
{
*ErrorOut = FALSE;
@@ -184,7 +187,6 @@ GenPerformMemoryTest ( *TotalMemorySize = mTotalSystemMemory;
return EFI_NOT_FOUND;
-
}
/**
@@ -203,7 +205,7 @@ GenPerformMemoryTest ( EFI_STATUS
EFIAPI
GenMemoryTestFinished (
- IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This
)
{
return EFI_SUCCESS;
@@ -227,15 +229,15 @@ GenMemoryTestFinished ( EFI_STATUS
EFIAPI
GenCompatibleRangeTest (
- IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
- IN EFI_PHYSICAL_ADDRESS StartAddress,
- IN UINT64 Length
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS StartAddress,
+ IN UINT64 Length
)
{
- EFI_STATUS Status;
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
- EFI_PHYSICAL_ADDRESS CurrentBase;
- UINT64 CurrentLength;
+ EFI_STATUS Status;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
+ EFI_PHYSICAL_ADDRESS CurrentBase;
+ UINT64 CurrentLength;
//
// Check if the parameter is below 16MB
@@ -243,6 +245,7 @@ GenCompatibleRangeTest ( if (StartAddress + Length > SIZE_16MB) {
return EFI_INVALID_PARAMETER;
}
+
CurrentBase = StartAddress;
do {
//
@@ -257,14 +260,16 @@ GenCompatibleRangeTest ( return Status;
}
- if (Descriptor.GcdMemoryType == EfiGcdMemoryTypeReserved &&
- (Descriptor.Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) ==
- (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)
- ) {
+ if ((Descriptor.GcdMemoryType == EfiGcdMemoryTypeReserved) &&
+ ((Descriptor.Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) ==
+ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED))
+ )
+ {
CurrentLength = Descriptor.BaseAddress + Descriptor.Length - CurrentBase;
if (CurrentBase + CurrentLength > StartAddress + Length) {
CurrentLength = StartAddress + Length - CurrentBase;
}
+
Status = ConvertToTestedMemory (
CurrentBase,
CurrentLength,
@@ -274,11 +279,12 @@ GenCompatibleRangeTest ( return Status;
}
}
+
CurrentBase = Descriptor.BaseAddress + Descriptor.Length;
} while (CurrentBase < StartAddress + Length);
+
//
// Here means the required range already be tested, so just return success.
//
return EFI_SUCCESS;
}
-
diff --git a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.h b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.h index cee9b78..5200600 100644 --- a/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.h +++ b/MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTest.h @@ -9,10 +9,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #ifndef _NULL_MEMORY_TEST_H_
#define _NULL_MEMORY_TEST_H_
-
#include <PiDxe.h>
-
#include <Protocol/GenericMemoryTest.h>
#include <Library/DebugLib.h>
@@ -48,9 +46,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent EFI_STATUS
EFIAPI
InitializeMemoryTest (
- IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
- IN EXTENDMEM_COVERAGE_LEVEL Level,
- OUT BOOLEAN *RequireSoftECCInit
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ IN EXTENDMEM_COVERAGE_LEVEL Level,
+ OUT BOOLEAN *RequireSoftECCInit
);
/**
@@ -79,11 +77,11 @@ InitializeMemoryTest ( EFI_STATUS
EFIAPI
GenPerformMemoryTest (
- IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
- IN OUT UINT64 *TestedMemorySize,
- OUT UINT64 *TotalMemorySize,
- OUT BOOLEAN *ErrorOut,
- IN BOOLEAN TestAbort
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ IN OUT UINT64 *TestedMemorySize,
+ OUT UINT64 *TotalMemorySize,
+ OUT BOOLEAN *ErrorOut,
+ IN BOOLEAN TestAbort
);
/**
@@ -102,7 +100,7 @@ GenPerformMemoryTest ( EFI_STATUS
EFIAPI
GenMemoryTestFinished (
- IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This
);
/**
@@ -123,9 +121,9 @@ GenMemoryTestFinished ( EFI_STATUS
EFIAPI
GenCompatibleRangeTest (
- IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
- IN EFI_PHYSICAL_ADDRESS StartAddress,
- IN UINT64 Length
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS StartAddress,
+ IN UINT64 Length
);
#endif
|