MdeModulePkg/NullMemoryTest: Handle more reliable memory
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=650 Today's implementation converts the untested more reliable memory from reserved GCD type to system memory GCD type. Though it doesn't impact the return result of gBS->GetMemoryMap(). But it impacts the return result of gDS->GetMemorySpaceDescriptor(). The patch fixes the bug to convert the untested more reliable memory from reserved GCD type to more reliable memory GCD type. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Implementation of Generic Memory Test Protocol which does not perform real memory test.
|
Implementation of Generic Memory Test Protocol which does not perform real memory test.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -58,6 +58,38 @@ GenericMemoryTestEntryPoint (
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert the memory descriptor to tested.
|
||||||
|
|
||||||
|
@param Descriptor Pointer to EFI_GCD_MEMORY_SPACE_DESCRIPTOR
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The memory descriptor is converted to tested.
|
||||||
|
@retval others Error happens.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
ConvertToTestedMemory (
|
||||||
|
IN CONST EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
Status = gDS->RemoveMemorySpace (
|
||||||
|
Descriptor->BaseAddress,
|
||||||
|
Descriptor->Length
|
||||||
|
);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
|
Status = gDS->AddMemorySpace (
|
||||||
|
((Descriptor->Capabilities & EFI_MEMORY_MORE_RELIABLE) == EFI_MEMORY_MORE_RELIABLE) ?
|
||||||
|
EfiGcdMemoryTypeMoreReliable : EfiGcdMemoryTypeSystemMemory,
|
||||||
|
Descriptor->BaseAddress,
|
||||||
|
Descriptor->Length,
|
||||||
|
Descriptor->Capabilities &~
|
||||||
|
(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the generic memory test.
|
Initialize the generic memory test.
|
||||||
|
|
||||||
@ -83,6 +115,7 @@ InitializeMemoryTest (
|
|||||||
OUT BOOLEAN *RequireSoftECCInit
|
OUT BOOLEAN *RequireSoftECCInit
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
UINTN NumberOfDescriptors;
|
UINTN NumberOfDescriptors;
|
||||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
@ -96,22 +129,12 @@ InitializeMemoryTest (
|
|||||||
//
|
//
|
||||||
// For those reserved memory that have not been tested, simply promote to system memory.
|
// For those reserved memory that have not been tested, simply promote to system memory.
|
||||||
//
|
//
|
||||||
gDS->RemoveMemorySpace (
|
Status = ConvertToTestedMemory (&MemorySpaceMap[Index]);
|
||||||
MemorySpaceMap[Index].BaseAddress,
|
ASSERT_EFI_ERROR (Status);
|
||||||
MemorySpaceMap[Index].Length
|
|
||||||
);
|
|
||||||
|
|
||||||
gDS->AddMemorySpace (
|
|
||||||
EfiGcdMemoryTypeSystemMemory,
|
|
||||||
MemorySpaceMap[Index].BaseAddress,
|
|
||||||
MemorySpaceMap[Index].Length,
|
|
||||||
MemorySpaceMap[Index].Capabilities &~
|
|
||||||
(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
|
|
||||||
);
|
|
||||||
|
|
||||||
mTestedSystemMemory += MemorySpaceMap[Index].Length;
|
mTestedSystemMemory += MemorySpaceMap[Index].Length;
|
||||||
mTotalSystemMemory += MemorySpaceMap[Index].Length;
|
mTotalSystemMemory += MemorySpaceMap[Index].Length;
|
||||||
} else if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
|
} else if ((MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) ||
|
||||||
|
(MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeMoreReliable)) {
|
||||||
mTotalSystemMemory += MemorySpaceMap[Index].Length;
|
mTotalSystemMemory += MemorySpaceMap[Index].Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,22 +227,16 @@ EFI_STATUS
|
|||||||
EFIAPI
|
EFIAPI
|
||||||
GenCompatibleRangeTest (
|
GenCompatibleRangeTest (
|
||||||
IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
|
IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
|
||||||
IN EFI_PHYSICAL_ADDRESS StartAddress,
|
IN EFI_PHYSICAL_ADDRESS StartAddress,
|
||||||
IN UINT64 Length
|
IN UINT64 Length
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
|
EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
|
||||||
|
|
||||||
gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor);
|
Status = gDS->GetMemorySpaceDescriptor (StartAddress, &Descriptor);
|
||||||
|
if (!EFI_ERROR (Status)) {
|
||||||
gDS->RemoveMemorySpace (StartAddress, Length);
|
Status = ConvertToTestedMemory (&Descriptor);
|
||||||
|
}
|
||||||
gDS->AddMemorySpace (
|
return Status;
|
||||||
EfiGcdMemoryTypeSystemMemory,
|
|
||||||
StartAddress,
|
|
||||||
Length,
|
|
||||||
Descriptor.Capabilities &~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
|
|
||||||
);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user