diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2021-12-08 08:01:45 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-12-13 14:47:37 +0000 |
commit | 759e3c6d2128f6b2673f95437854f067a532e59a (patch) | |
tree | 64398aba4d4c78d819d2605016ad88d1396fbeac /OvmfPkg/PlatformPei/MemDetect.c | |
parent | 557dede8a6b88ee14f541b7f96ff60830b98329a (diff) | |
download | edk2-759e3c6d2128f6b2673f95437854f067a532e59a.zip edk2-759e3c6d2128f6b2673f95437854f067a532e59a.tar.gz edk2-759e3c6d2128f6b2673f95437854f067a532e59a.tar.bz2 |
OvmfPkg/PlatformPei: prefer etc/e820 for memory detection
Prefer the e820 map provided via qemu firmware config interface
for memory detection. Use rtc cmos only as fallback, which should
be rarely needed these days as qemu supports etc/e820 since 2013.
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>
Diffstat (limited to 'OvmfPkg/PlatformPei/MemDetect.c')
-rw-r--r-- | OvmfPkg/PlatformPei/MemDetect.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index b0b7e46..1bcb5a0 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -320,8 +320,15 @@ GetSystemMemorySizeBelow4gb ( VOID
)
{
- UINT8 Cmos0x34;
- UINT8 Cmos0x35;
+ EFI_STATUS Status;
+ UINT64 LowerMemorySize = 0;
+ UINT8 Cmos0x34;
+ UINT8 Cmos0x35;
+
+ Status = ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL);
+ if ((Status == EFI_SUCCESS) && (LowerMemorySize > 0)) {
+ return (UINT32)LowerMemorySize;
+ }
//
// CMOS 0x34/0x35 specifies the system memory above 16 MB.
@@ -776,7 +783,6 @@ QemuInitializeRam ( // Determine total memory size available
//
LowerMemorySize = GetSystemMemorySizeBelow4gb ();
- UpperMemorySize = GetSystemMemorySizeAbove4gb ();
if (mBootMode == BOOT_ON_S3_RESUME) {
//
@@ -826,8 +832,11 @@ QemuInitializeRam ( // memory size read from the CMOS.
//
Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL);
- if (EFI_ERROR (Status) && (UpperMemorySize != 0)) {
- AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
+ if (EFI_ERROR (Status)) {
+ UpperMemorySize = GetSystemMemorySizeAbove4gb ();
+ if (UpperMemorySize != 0) {
+ AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
+ }
}
}
|