mirror of https://github.com/acidanthera/audk.git
OvmfPkg/PlatformPei: ScanOrAdd64BitE820Ram improvements
Add a bool parameter to ScanOrAdd64BitE820Ram to explicitly specify whenever ScanOrAdd64BitE820Ram should add HOBs for high memory (above 4G) or scan only. Also add a lowmem parameter so ScanOrAdd64BitE820Ram can report the memory size below 4G. This allows a more flexible usage of ScanOrAdd64BitE820Ram, a followup patch will use it for all memory detection. No functional change. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3593 Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
This commit is contained in:
parent
ec37fd9c1f
commit
557dede8a6
|
@ -223,6 +223,8 @@ QemuUc32BaseInitialization (
|
||||||
STATIC
|
STATIC
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
ScanOrAdd64BitE820Ram (
|
ScanOrAdd64BitE820Ram (
|
||||||
|
IN BOOLEAN AddHighHob,
|
||||||
|
OUT UINT64 *LowMemory OPTIONAL,
|
||||||
OUT UINT64 *MaxAddress OPTIONAL
|
OUT UINT64 *MaxAddress OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
@ -241,6 +243,10 @@ ScanOrAdd64BitE820Ram (
|
||||||
return EFI_PROTOCOL_ERROR;
|
return EFI_PROTOCOL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (LowMemory != NULL) {
|
||||||
|
*LowMemory = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (MaxAddress != NULL) {
|
if (MaxAddress != NULL) {
|
||||||
*MaxAddress = BASE_4GB;
|
*MaxAddress = BASE_4GB;
|
||||||
}
|
}
|
||||||
|
@ -256,10 +262,8 @@ ScanOrAdd64BitE820Ram (
|
||||||
E820Entry.Length,
|
E820Entry.Length,
|
||||||
E820Entry.Type
|
E820Entry.Type
|
||||||
));
|
));
|
||||||
if ((E820Entry.Type == EfiAcpiAddressRangeMemory) &&
|
if (E820Entry.Type == EfiAcpiAddressRangeMemory) {
|
||||||
(E820Entry.BaseAddr >= BASE_4GB))
|
if (AddHighHob && (E820Entry.BaseAddr >= BASE_4GB)) {
|
||||||
{
|
|
||||||
if (MaxAddress == NULL) {
|
|
||||||
UINT64 Base;
|
UINT64 Base;
|
||||||
UINT64 End;
|
UINT64 End;
|
||||||
|
|
||||||
|
@ -279,11 +283,13 @@ ScanOrAdd64BitE820Ram (
|
||||||
End
|
End
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (MaxAddress || LowMemory) {
|
||||||
UINT64 Candidate;
|
UINT64 Candidate;
|
||||||
|
|
||||||
Candidate = E820Entry.BaseAddr + E820Entry.Length;
|
Candidate = E820Entry.BaseAddr + E820Entry.Length;
|
||||||
if (Candidate > *MaxAddress) {
|
if (MaxAddress && (Candidate > *MaxAddress)) {
|
||||||
*MaxAddress = Candidate;
|
*MaxAddress = Candidate;
|
||||||
DEBUG ((
|
DEBUG ((
|
||||||
DEBUG_VERBOSE,
|
DEBUG_VERBOSE,
|
||||||
|
@ -292,6 +298,16 @@ ScanOrAdd64BitE820Ram (
|
||||||
*MaxAddress
|
*MaxAddress
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (LowMemory && (Candidate > *LowMemory) && (Candidate < BASE_4GB)) {
|
||||||
|
*LowMemory = Candidate;
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_VERBOSE,
|
||||||
|
"%a: LowMemory=0x%Lx\n",
|
||||||
|
__FUNCTION__,
|
||||||
|
*LowMemory
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -376,7 +392,7 @@ GetFirstNonAddress (
|
||||||
// Otherwise, get the flat size of the memory above 4GB from the CMOS (which
|
// Otherwise, get the flat size of the memory above 4GB from the CMOS (which
|
||||||
// can only express a size smaller than 1TB), and add it to 4GB.
|
// can only express a size smaller than 1TB), and add it to 4GB.
|
||||||
//
|
//
|
||||||
Status = ScanOrAdd64BitE820Ram (&FirstNonAddress);
|
Status = ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
|
FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
|
||||||
}
|
}
|
||||||
|
@ -809,7 +825,7 @@ QemuInitializeRam (
|
||||||
// entries. Otherwise, create a single memory HOB with the flat >=4GB
|
// entries. Otherwise, create a single memory HOB with the flat >=4GB
|
||||||
// memory size read from the CMOS.
|
// memory size read from the CMOS.
|
||||||
//
|
//
|
||||||
Status = ScanOrAdd64BitE820Ram (NULL);
|
Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL);
|
||||||
if (EFI_ERROR (Status) && (UpperMemorySize != 0)) {
|
if (EFI_ERROR (Status) && (UpperMemorySize != 0)) {
|
||||||
AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
|
AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue