From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Ard Biesheuvel" <ardb+tianocore@kernel.org>,
"Pawel Polawski" <ppolawsk@redhat.com>,
"Jordan Justen" <jordan.l.justen@intel.com>,
"Jiewen Yao" <jiewen.yao@intel.com>,
"Gerd Hoffmann" <kraxel@redhat.com>
Subject: [PATCH v4 3/3] RFC: OvmfPkg/PlatformPei: stop using cmos for memory detection
Date: Wed, 8 Dec 2021 08:01:46 +0100 [thread overview]
Message-ID: <20211208070146.1239368-4-kraxel@redhat.com> (raw)
In-Reply-To: <20211208070146.1239368-1-kraxel@redhat.com>
Not needed for qemu 1.7 (released in 2013) and newer.
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3593
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
OvmfPkg/PlatformPei/MemDetect.c | 59 +++------------------------------
1 file changed, 4 insertions(+), 55 deletions(-)
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index e0f2caa9cd3c..21b0b9af26a1 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -37,7 +37,6 @@ Module Name:
#include <Library/QemuFwCfgSimpleParserLib.h>
#include "Platform.h"
-#include "Cmos.h"
UINT8 mPhysMemAddressWidth;
@@ -315,51 +314,11 @@ GetSystemMemorySizeBelow4gb (
{
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.
- // * CMOS(0x35) is the high byte
- // * CMOS(0x34) is the low byte
- // * The size is specified in 64kb chunks
- // * Since this is memory above 16MB, the 16MB must be added
- // into the calculation to get the total memory size.
- //
-
- Cmos0x34 = (UINT8)CmosRead8 (0x34);
- Cmos0x35 = (UINT8)CmosRead8 (0x35);
-
- return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
-}
-
-STATIC
-UINT64
-GetSystemMemorySizeAbove4gb (
- )
-{
- UINT32 Size;
- UINTN CmosIndex;
-
- //
- // CMOS 0x5b-0x5d specifies the system memory above 4GB MB.
- // * CMOS(0x5d) is the most significant size byte
- // * CMOS(0x5c) is the middle size byte
- // * CMOS(0x5b) is the least significant size byte
- // * The size is specified in 64kb chunks
- //
-
- Size = 0;
- for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) {
- Size = (UINT32)(Size << 8) + (UINT32)CmosRead8 (CmosIndex);
- }
-
- return LShiftU64 (Size, 16);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (LowerMemorySize > 0);
+ return (UINT32)LowerMemorySize;
}
/**
@@ -389,12 +348,9 @@ GetFirstNonAddress (
// If QEMU presents an E820 map, then get the highest exclusive >=4GB RAM
// address from it. This can express an address >= 4GB+1TB.
//
- // 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.
- //
Status = ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress);
if (EFI_ERROR (Status)) {
- FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
+ FirstNonAddress = BASE_4GB;
}
//
@@ -766,7 +722,6 @@ QemuInitializeRam (
)
{
UINT64 LowerMemorySize;
- UINT64 UpperMemorySize;
MTRR_SETTINGS MtrrSettings;
EFI_STATUS Status;
@@ -825,12 +780,6 @@ QemuInitializeRam (
// memory size read from the CMOS.
//
Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL);
- if (EFI_ERROR (Status)) {
- UpperMemorySize = GetSystemMemorySizeAbove4gb ();
- if (UpperMemorySize != 0) {
- AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
- }
- }
}
//
--
2.33.1
next prev parent reply other threads:[~2021-12-08 7:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 7:01 [PATCH v4 0/3] OvmfPkg/PlatformPei: prefer etc/e820 for memory detection Gerd Hoffmann
2021-12-08 7:01 ` [PATCH v4 1/3] OvmfPkg/PlatformPei: ScanOrAdd64BitE820Ram improvements Gerd Hoffmann
2021-12-08 7:01 ` [PATCH v4 2/3] OvmfPkg/PlatformPei: prefer etc/e820 for memory detection Gerd Hoffmann
2021-12-08 7:01 ` Gerd Hoffmann [this message]
2021-12-13 11:55 ` [PATCH v4 3/3] RFC: OvmfPkg/PlatformPei: stop using cmos " Ard Biesheuvel
2021-12-13 15:01 ` [PATCH v4 0/3] OvmfPkg/PlatformPei: prefer etc/e820 " Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211208070146.1239368-4-kraxel@redhat.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox