public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gerd Hoffmann" <kraxel@redhat.com>
To: devel@edk2.groups.io
Cc: Bob Feng <bob.c.feng@intel.com>,
	Yuwei Chen <yuwei.chen@intel.com>,
	Erdem Aktas <erdemaktas@google.com>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Peter Grehan <grehan@freebsd.org>,
	Rebecca Cran <rebecca@bsdio.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Jiewen Yao <jiewen.yao@intel.com>, Min Xu <min.m.xu@intel.com>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Oliver Steffen <osteffen@redhat.com>,
	Pawel Polawski <ppolawsk@redhat.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	James Bottomley <jejb@linux.ibm.com>
Subject: [PATCH 06/14] OvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob
Date: Fri,  2 Dec 2022 14:10:01 +0100	[thread overview]
Message-ID: <20221202131009.3190040-7-kraxel@redhat.com> (raw)
In-Reply-To: <20221202131009.3190040-1-kraxel@redhat.com>

Stop using the mPlatformInfoHob global variable in PublishPeiMemory()
and GetPeiMemoryCap() functions.  Pass a pointer to the PlatformInfoHob
instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 OvmfPkg/PlatformPei/Platform.h  |  2 +-
 OvmfPkg/PlatformPei/MemDetect.c | 36 ++++++++++++++++-----------------
 OvmfPkg/PlatformPei/Platform.c  |  2 +-
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 7baa5e1d289f..d0c673c5a346 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -32,7 +32,7 @@ Q35SmramAtDefaultSmbaseInitialization (
 
 EFI_STATUS
 PublishPeiMemory (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   );
 
 VOID
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index b9207107b4d9..3d8375320dcb 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -188,7 +188,7 @@ AddressWidthInitialization (
 STATIC
 UINT32
 GetPeiMemoryCap (
-  VOID
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   BOOLEAN  Page1GSupport;
@@ -225,15 +225,15 @@ GetPeiMemoryCap (
     }
   }
 
-  if (mPlatformInfoHob.PhysMemAddressWidth <= 39) {
+  if (PlatformInfoHob->PhysMemAddressWidth <= 39) {
     Pml4Entries = 1;
-    PdpEntries  = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 30);
+    PdpEntries  = 1 << (PlatformInfoHob->PhysMemAddressWidth - 30);
     ASSERT (PdpEntries <= 0x200);
   } else {
-    if (mPlatformInfoHob.PhysMemAddressWidth > 48) {
+    if (PlatformInfoHob->PhysMemAddressWidth > 48) {
       Pml4Entries = 0x200;
     } else {
-      Pml4Entries = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 39);
+      Pml4Entries = 1 << (PlatformInfoHob->PhysMemAddressWidth - 39);
     }
 
     ASSERT (Pml4Entries <= 0x200);
@@ -260,7 +260,7 @@ GetPeiMemoryCap (
 **/
 EFI_STATUS
 PublishPeiMemory (
-  VOID
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob
   )
 {
   EFI_STATUS            Status;
@@ -271,12 +271,12 @@ PublishPeiMemory (
   UINT32                S3AcpiReservedMemoryBase;
   UINT32                S3AcpiReservedMemorySize;
 
-  LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (&mPlatformInfoHob);
-  if (mPlatformInfoHob.SmmSmramRequire) {
+  LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);
+  if (PlatformInfoHob->SmmSmramRequire) {
     //
     // TSEG is chipped from the end of low RAM
     //
-    LowerMemorySize -= mPlatformInfoHob.Q35TsegMbytes * SIZE_1MB;
+    LowerMemorySize -= PlatformInfoHob->Q35TsegMbytes * SIZE_1MB;
   }
 
   S3AcpiReservedMemoryBase = 0;
@@ -287,27 +287,27 @@ PublishPeiMemory (
   // downwards. Its size is primarily dictated by CpuMpPei. The formula below
   // is an approximation.
   //
-  if (mPlatformInfoHob.S3Supported) {
+  if (PlatformInfoHob->S3Supported) {
     S3AcpiReservedMemorySize = SIZE_512KB +
-                               mPlatformInfoHob.PcdCpuMaxLogicalProcessorNumber *
+                               PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber *
                                PcdGet32 (PcdCpuApStackSize);
     S3AcpiReservedMemoryBase = LowerMemorySize - S3AcpiReservedMemorySize;
     LowerMemorySize          = S3AcpiReservedMemoryBase;
   }
 
-  mPlatformInfoHob.S3AcpiReservedMemoryBase = S3AcpiReservedMemoryBase;
-  mPlatformInfoHob.S3AcpiReservedMemorySize = S3AcpiReservedMemorySize;
+  PlatformInfoHob->S3AcpiReservedMemoryBase = S3AcpiReservedMemoryBase;
+  PlatformInfoHob->S3AcpiReservedMemorySize = S3AcpiReservedMemorySize;
 
-  if (mPlatformInfoHob.BootMode == BOOT_ON_S3_RESUME) {
+  if (PlatformInfoHob->BootMode == BOOT_ON_S3_RESUME) {
     MemoryBase = S3AcpiReservedMemoryBase;
     MemorySize = S3AcpiReservedMemorySize;
   } else {
-    PeiMemoryCap = GetPeiMemoryCap ();
+    PeiMemoryCap = GetPeiMemoryCap (PlatformInfoHob);
     DEBUG ((
       DEBUG_INFO,
       "%a: PhysMemAddressWidth=%d PeiMemoryCap=%u KB\n",
       __FUNCTION__,
-      mPlatformInfoHob.PhysMemAddressWidth,
+      PlatformInfoHob->PhysMemAddressWidth,
       PeiMemoryCap >> 10
       ));
 
@@ -321,7 +321,7 @@ PublishPeiMemory (
     // allocation HOB, and other allocations served from the permanent PEI RAM
     // shouldn't overlap with that HOB.
     //
-    MemoryBase = mPlatformInfoHob.S3Supported && mPlatformInfoHob.SmmSmramRequire ?
+    MemoryBase = PlatformInfoHob->S3Supported && PlatformInfoHob->SmmSmramRequire ?
                  PcdGet32 (PcdOvmfDecompressionScratchEnd) :
                  PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);
     MemorySize = LowerMemorySize - MemoryBase;
@@ -336,7 +336,7 @@ PublishPeiMemory (
   // normal boot permanent PEI RAM. Regarding the S3 boot path, the S3
   // permanent PEI RAM is located even higher.
   //
-  if (mPlatformInfoHob.SmmSmramRequire && mPlatformInfoHob.Q35SmramAtDefaultSmbase) {
+  if (PlatformInfoHob->SmmSmramRequire && PlatformInfoHob->Q35SmramAtDefaultSmbase) {
     ASSERT (SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE <= MemoryBase);
   }
 
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 8b055fb451d7..4cd77fd5f84f 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -361,7 +361,7 @@ InitializePlatform (
     Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob);
   }
 
-  PublishPeiMemory ();
+  PublishPeiMemory (&mPlatformInfoHob);
 
   PlatformQemuUc32BaseInitialization (&mPlatformInfoHob);
 
-- 
2.38.1


  parent reply	other threads:[~2022-12-02 13:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02 13:09 [PATCH 00/14] OvmfPkg: avoid global variables in PEI Gerd Hoffmann
2022-12-02 13:09 ` [PATCH 01/14] tools_def: remove GCC_IA32_CC_FLAGS/GCC_X64_CC_FLAGS Gerd Hoffmann
2022-12-02 13:09 ` [PATCH 02/14] tools_def: add -fno-omit-frame-pointer to GCC48_{IA32,X64}_CC_FLAGS Gerd Hoffmann
2022-12-02 13:09 ` [PATCH 03/14] OvmfPkg/PlatformPei: AmdSev: stop using mPlatformInfoHob Gerd Hoffmann
2022-12-02 13:09 ` [PATCH 04/14] OvmfPkg/PlatformPei: PeiFv: " Gerd Hoffmann
2022-12-02 13:10 ` [PATCH 05/14] OvmfPkg/PlatformPei Q35 SMM helpers: " Gerd Hoffmann
2022-12-02 13:10 ` Gerd Hoffmann [this message]
2022-12-02 13:10 ` [PATCH 07/14] OvmfPkg/PlatformPei: MemTypeInfo: " Gerd Hoffmann
2022-12-02 13:10 ` [PATCH 08/14] OvmfPkg/PlatformPei: NoExec: " Gerd Hoffmann
2022-12-02 13:10 ` [PATCH 09/14] OvmfPkg/PlatformPei: Verification: " Gerd Hoffmann
2022-12-02 13:10 ` [PATCH 10/14] OvmfPkg/PlatformPei: remove mPlatformInfoHob Gerd Hoffmann
2022-12-02 13:10 ` [PATCH 11/14] OvmfPkg/PlatformPei: remove mFeatureControlValue Gerd Hoffmann
2022-12-02 13:10 ` [PATCH 12/14] OvmfPkg/DebugLibIoPort: use Rom version for PEI Gerd Hoffmann
2022-12-02 13:10 ` [PATCH 13/14] OvmfPkg/QemuFwCfgLib: rewrite fw_cfg probe Gerd Hoffmann
2022-12-02 13:10 ` [PATCH 14/14] OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported Gerd Hoffmann
2022-12-12 16:58 ` [PATCH 00/14] OvmfPkg: avoid global variables in PEI Lendacky, Thomas
2022-12-14 17:26   ` 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=20221202131009.3190040-7-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