From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1885C7803DF for ; Wed, 12 Jun 2024 07:39:18 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=tEdZEDg+8oueDqskUzbtmUvSMzM1u5FwD5DdUrKC4SU=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20240206; t=1718177958; v=1; b=sjGvG53fMKX98W9Yvmjn/Vbu0Gdyl9LN4GTD3R+j4xRjZGmdRoWrQt8XDRHifeDO+Kby87Qi 4g47mTOIIYqEKbWX99D0IRWZUMKUjMETZlQ2qjC5EDLQlKvKybX1Vck7HiJgAbgXXnPkGSsiptC Xd3lgDpOWiOGOHQXBjFkNiSoeaV3t8gtJtnu2I5xEcpsBNBkLVV60d//cY26eWJCLx2RKumvPBg 7lKOVQImYB4FvcvzIKWtqrs17x27rXDS+sG2tXhn53OUZ+9OwBu3Pe3Eu1629vOx76cMJ8KLLSV 88IenoA8xsT2E5W4GVVgldBkiVa/iHzjq1KR3hahriYsg== X-Received: by 127.0.0.2 with SMTP id HDCWYY7687511x0qSSW2KTsn; Wed, 12 Jun 2024 00:39:17 -0700 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.5867.1718177951009551296 for ; Wed, 12 Jun 2024 00:39:11 -0700 X-Received: from loongson.cn (unknown [10.40.24.149]) by gateway (Coremail) with SMTP id _____8CxyOmaUGlmuugFAA--.11207S3; Wed, 12 Jun 2024 15:39:07 +0800 (CST) X-Received: from [10.40.24.149] (unknown [10.40.24.149]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxDMeaUGlm3eMcAA--.5344S3; Wed, 12 Jun 2024 15:39:06 +0800 (CST) Message-ID: <177fe1eb-9f64-4f76-804b-8dc10b379888@loongson.cn> Date: Wed, 12 Jun 2024 15:39:06 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [edk2-platforms][PATCH V2] Platform/Loongson: Remove minimium memory size limitation To: devel@edk2.groups.io, lixianglai@loongson.cn Cc: Bibo Mao References: <20240402075555.986594-1-lixianglai@loongson.cn> From: "Chao Li" In-Reply-To: <20240402075555.986594-1-lixianglai@loongson.cn> X-CM-TRANSID: AQAAf8AxDMeaUGlm3eMcAA--.5344S3 X-CM-SenderInfo: xolfxt3r6o00pqjv00gofq/1tbiAQAGCGZo-xQCpAABsN X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 12 Jun 2024 00:39:11 -0700 Resent-From: lichao@loongson.cn Reply-To: devel@edk2.groups.io,lichao@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: pi0s9zvWCgW1aEJaRBdAMpBjx7686176AA= Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=sjGvG53f; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io

Reviewed-by: Chao Li <lichao@loongson.cn>


=
Thanks,
Chao
On 2024/4/2 15:55, xianglai wrote:
From: Bibo Mao <maobibo@loongso=
n.cn>

Temparory stack memory on PEI is hardcoded now, also minimium memory
size 256M is hardcoded now. Here memory map table from fw cfg can be
parsed. If there is memory map entry contains pei stack, it can be
published as usable memory at PEI stage.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
Cc: Bibo Mao <maobibo@loongson.cn>
Cc: Chao Li <lichao@loongson.cn>
---
changelog:
V1->V2:
- After finding the appropriate memory in memmap,
jump out of the search loop statement in time.

 .../Loongson/LoongArchQemuPkg/Loongson.dec    |  2 -
 .../Loongson/LoongArchQemuPkg/Loongson.dsc    |  6 ---
 .../LoongArchQemuPkg/PlatformPei/MemDetect.c  | 38 ++++++++++++++++++-
 .../PlatformPei/PlatformPei.inf               |  2 -
 4 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dec b/Platform/Loo=
ngson/LoongArchQemuPkg/Loongson.dec
index e638b835e4..c2c6cc9596 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dec
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dec
@@ -48,8 +48,6 @@
=20
   gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamBase|0|UINT64|0x0000000b
   gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize|0|UINT32|0x0000000c
-  gLoongArchQemuPkgTokenSpaceGuid.PcdUefiRamTop|0x0|UINT64|0x0000000d
-  gLoongArchQemuPkgTokenSpaceGuid.PcdRamRegionsBottom|0x0|UINT64|0x0000000=
e
   gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvBase|0x0|UINT64|0x0000000f
   gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvSize|0x0|UINT32|0x00000010
=20
diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc b/Platform/Loo=
ngson/LoongArchQemuPkg/Loongson.dsc
index 58aa16d3a9..aab2ca9b28 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
@@ -356,12 +356,6 @@
   gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamBase                 | 0=
x10000
   gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize                 | 0=
x10000
   gLoongArchQemuPkgTokenSpaceGuid.PcdDeviceTreeBase                    | 0=
x100000
-  #
-  # minimal memory for uefi bios should be 512M
-  # 0x00000000 - 0x10000000
-  # 0x90000000 - 0xA0000000
-  #
-  gLoongArchQemuPkgTokenSpaceGuid.PcdUefiRamTop                        | 0=
x10000000
   gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions           | 0=
x06
=20
   gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile                | {=
 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0x=
f4, 0x66, 0x23, 0x31 }
diff --git a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c b/P=
latform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
index 7e6a4a3aa9..7aa6fdc175 100644
--- a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
+++ b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/MemDetect.c
@@ -40,12 +40,48 @@ PublishPeiMemory (
   UINT64 Base;
   UINT64      Size;
   UINT64      RamTop;
+  FIRMWARE_CONFIG_ITEM FwCfgItem;
+  UINTN                FwCfgSize;
+  UINTN                Processed;
+  LOONGARCH_MEMMAP_ENTRY  MemoryMapEntry;
=20
   //
   // Determine the range of memory to use during PEI
   //
   Base =3D PcdGet64 (PcdSecPeiTempRamBase) + PcdGet32 (PcdSecPeiTempRamSiz=
e);
-  RamTop =3D PcdGet64 (PcdUefiRamTop);
+  RamTop =3D 0;
+
+  Status =3D QemuFwCfgFindFile ("etc/memmap", &FwCfgItem, &FwCfgSi=
ze);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  if (FwCfgSize % sizeof MemoryMapEntry !=3D 0) {
+    return EFI_PROTOCOL_ERROR;
+  }
+
+  QemuFwCfgSelectItem (FwCfgItem);
+  for (Processed =3D 0; Processed < FwCfgSize; Processed +=3D sizeof Me=
moryMapEntry) {
+    QemuFwCfgReadBytes (sizeof MemoryMapEntry, &MemoryMapEntry);
+    if (MemoryMapEntry.Type !=3D EfiAcpiAddressRangeMemory) {
+      continue;
+    }
+
+    /*
+     * Find memory map entry where PEI temp stack is located
+     */
+    if ((MemoryMapEntry.BaseAddr <=3D Base) &&
+        (Base < (MemoryMapEntry.BaseAddr + MemoryMapEntry.Length))) {
+        RamTop =3D MemoryMapEntry.BaseAddr + MemoryMapEntry.Length;
+        break;
+    }
+  }
+
+  if (RamTop =3D=3D 0) {
+    DEBUG ((DEBUG_ERROR, "ERROR: No memory map entry contains temp stack \=
n"));
+    ASSERT (FALSE);
+  }
+
   Size =3D RamTop - Base;
=20
   //
diff --git a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf=
 b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
index 6cc3513b63..65591a4d7b 100644
--- a/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
+++ b/Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
@@ -64,8 +64,6 @@
 [FixedPcd]
   gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvBase
   gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvSize
-  gLoongArchQemuPkgTokenSpaceGuid.PcdRamRegionsBottom
-  gLoongArchQemuPkgTokenSpaceGuid.PcdUefiRamTop
   gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamBase
   gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize
   gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#119560) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_