From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 35EAEAC0E6F for ; Tue, 2 Apr 2024 07:56:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=9FVJSPxzE5FjMuo8lNwXoOLYQWLLI7YykSQRn/iO0qc=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20240206; t=1712044575; v=1; b=IoXOkfoUGbvpXFr4zjsElbNzUU1bmZ4dwjoaNf/RCuIWLIEaIXyxj4iFtp+cOXt1Jvy9Xwg6 TXUqm7niScooCWoBb4VzDmKKNFjA4oUEZI95WFEcKkSy1Rv5QsDZ8nIpvzfO/x5jV+I10tmcOmA xvOUmD7tJoaRIJePEfCTmFnI1ESAaA+UbEWC/uBc54vsQmvPsUti4nPDSTNmHGfjeeGje3u21Y6 Tm6zvP3y0HWfJsvawILrJDSYtrEv1qoik/s9/qWo9O5ercAZkmLk9Vr175Ez4JZJHGS+tB6E1oC BjrnK2N2uCVzZ5zeLrWhG+M+gFKJv6AG174A1ocMCspgA== X-Received: by 127.0.0.2 with SMTP id OoGHYY7687511xyAkqE6ai4a; Tue, 02 Apr 2024 00:56:15 -0700 X-Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web11.7208.1712044573915663666 for ; Tue, 02 Apr 2024 00:56:14 -0700 X-Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8DxdfEZugtmKT8iAA--.13727S3; Tue, 02 Apr 2024 15:56:10 +0800 (CST) X-Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxzxMYugtmLaNxAA--.33959S2; Tue, 02 Apr 2024 15:56:08 +0800 (CST) From: "xianglai" To: devel@edk2.groups.io Cc: Bibo Mao , Chao Li Subject: [edk2-devel] [edk2-platforms][PATCH V2] Platform/Loongson: Remove minimium memory size limitation Date: Tue, 2 Apr 2024 15:55:55 +0800 Message-Id: <20240402075555.986594-1-lixianglai@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxzxMYugtmLaNxAA--.33959S2 X-CM-SenderInfo: 5ol0xt5qjotxo6or00hjvr0hdfq/ 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: Tue, 02 Apr 2024 00:56:14 -0700 Resent-From: lixianglai@loongson.cn Reply-To: devel@edk2.groups.io,lixianglai@loongson.cn List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: snTTaSV4WzuseL4qdbECivQvx7686176AA= 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=IoXOkfoU; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Bibo Mao 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 Signed-off-by: Xianglai Li Cc: Bibo Mao Cc: Chao Li --- 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 @@ =0D gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamBase|0|UINT64|0x0000000b= =0D gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize|0|UINT32|0x0000000c= =0D - gLoongArchQemuPkgTokenSpaceGuid.PcdUefiRamTop|0x0|UINT64|0x0000000d=0D - gLoongArchQemuPkgTokenSpaceGuid.PcdRamRegionsBottom|0x0|UINT64|0x0000000= e=0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvBase|0x0|UINT64|0x0000000f= =0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvSize|0x0|UINT32|0x00000010= =0D =0D 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=0D gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize | 0= x10000=0D gLoongArchQemuPkgTokenSpaceGuid.PcdDeviceTreeBase | 0= x100000=0D - #=0D - # minimal memory for uefi bios should be 512M=0D - # 0x00000000 - 0x10000000=0D - # 0x90000000 - 0xA0000000=0D - #=0D - gLoongArchQemuPkgTokenSpaceGuid.PcdUefiRamTop | 0= x10000000=0D gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions | 0= x06=0D =0D gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile | {= 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0x= f4, 0x66, 0x23, 0x31 }=0D 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;=0D UINT64 Size;=0D UINT64 RamTop;=0D + FIRMWARE_CONFIG_ITEM FwCfgItem;=0D + UINTN FwCfgSize;=0D + UINTN Processed;=0D + LOONGARCH_MEMMAP_ENTRY MemoryMapEntry;=0D =0D //=0D // Determine the range of memory to use during PEI=0D //=0D Base =3D PcdGet64 (PcdSecPeiTempRamBase) + PcdGet32 (PcdSecPeiTempRamSiz= e);=0D - RamTop =3D PcdGet64 (PcdUefiRamTop);=0D + RamTop =3D 0;=0D +=0D + Status =3D QemuFwCfgFindFile ("etc/memmap", &FwCfgItem, &FwCfgSize);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + if (FwCfgSize % sizeof MemoryMapEntry !=3D 0) {=0D + return EFI_PROTOCOL_ERROR;=0D + }=0D +=0D + QemuFwCfgSelectItem (FwCfgItem);=0D + for (Processed =3D 0; Processed < FwCfgSize; Processed +=3D sizeof Memor= yMapEntry) {=0D + QemuFwCfgReadBytes (sizeof MemoryMapEntry, &MemoryMapEntry);=0D + if (MemoryMapEntry.Type !=3D EfiAcpiAddressRangeMemory) {=0D + continue;=0D + }=0D +=0D + /*=0D + * Find memory map entry where PEI temp stack is located=0D + */=0D + if ((MemoryMapEntry.BaseAddr <=3D Base) &&=0D + (Base < (MemoryMapEntry.BaseAddr + MemoryMapEntry.Length))) {=0D + RamTop =3D MemoryMapEntry.BaseAddr + MemoryMapEntry.Length;=0D + break;=0D + }=0D + }=0D +=0D + if (RamTop =3D=3D 0) {=0D + DEBUG ((DEBUG_ERROR, "ERROR: No memory map entry contains temp stack \= n"));=0D + ASSERT (FALSE);=0D + }=0D +=0D Size =3D RamTop - Base;=0D =0D //=0D 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]=0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvBase=0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvSize=0D - gLoongArchQemuPkgTokenSpaceGuid.PcdRamRegionsBottom=0D - gLoongArchQemuPkgTokenSpaceGuid.PcdUefiRamTop=0D gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamBase=0D gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize=0D gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize=0D --=20 2.39.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117331): https://edk2.groups.io/g/devel/message/117331 Mute This Topic: https://groups.io/mt/105283810/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-