From nobody Mon Feb 9 08:55:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82317+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82317+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1634634505; cv=none; d=zohomail.com; s=zohoarc; b=dsxmcO3OIZ335vjZq2oAYhgtWswnFvGxf0X6X5yHM/FFlrrYsZJ78jH4XfFpXUvsI9I2HZ1TbU7GJ6yfeuOD5OVVLVJZ6aN453UxtyqAyMOGMHHvmWWVOV0R8Czip+JhRE6nika4mTOZyHP5V1ayq3B2KSwKRYIskW+7UU4Qwko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634634505; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=NvGdvh0VpLmBrg1Y9AcGOiTQevePqwh6rGX2vFKiEZA=; b=RFEk7qCAobjzUBA5k8hXKOOTlJF1/N+woG8xhQQXzAbXaOveOASJFlI6QnxZSojYjXUFONEBpCLG9ucRuOxG9UrPxqJqETMhDTsU0JTLBlwc0yIriTSxgJt1tEsjf4cLLxSuoSYvCwa0wIFWvV2kO994lrGwPbu7Wbvs0kIo7MM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82317+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634634505315299.5389772030776; Tue, 19 Oct 2021 02:08:25 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JpPlYY1788612xVB552eMNhi; Tue, 19 Oct 2021 02:08:25 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web09.7330.1634634498108700986 for ; Tue, 19 Oct 2021 02:08:24 -0700 X-Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19J8CF9P020959; Tue, 19 Oct 2021 09:08:17 GMT X-Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) by mx0a-002e3701.pphosted.com with ESMTP id 3bsta50efd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Oct 2021 09:08:16 +0000 X-Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3425.houston.hpe.com (Postfix) with ESMTP id 0A51DC3; Tue, 19 Oct 2021 09:08:15 +0000 (UTC) X-Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.229]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id EFAAB48; Tue, 19 Oct 2021 09:08:13 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com, Sunil V L , Daniel Schaefer Subject: [edk2-devel] [edk2-platforms][PATCH 02/30] RISC-V: Add RISC-V PeiCoreEntryPoint library Date: Tue, 19 Oct 2021 16:09:39 +0800 Message-Id: <20211019081007.31165-3-abner.chang@hpe.com> In-Reply-To: <20211019081007.31165-1-abner.chang@hpe.com> References: <20211019081007.31165-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: 5vmMlaQB4py_A_1EWbkQcR6rlu4DS61X X-Proofpoint-ORIG-GUID: 5vmMlaQB4py_A_1EWbkQcR6rlu4DS61X X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@hpe.com X-Gm-Message-State: Pt5aOjGOi5FIwGFe0zxcHReAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634634505; bh=M0LMZFvsqtKkHASdtk/hH7uhQpgUSLHFLA+vccefAU0=; h=Cc:Date:From:Reply-To:Subject:To; b=SWwnYKbfaOziDFDChut2XELVsBnXEus1MrAZHumIqUW3Y4iVVpZ2SRLFYeWkBWp67VB 3tEFAzDXXDtcAf4i6+hb4JyLVw3g8Q/kY/Cscp32OjvNZp0rngws9fy5CFzfTv8RC0R8o 5hQhjwSj6502Q94Ly5AXvoenKIdI2FdBKA4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634634507128100018 Content-Type: text/plain; charset="utf-8" - Add RISC-V PeiCoreEntryPoint library that incorporates with opensbi next phase switching mechanism. - Use RiscVFirmwareContext library to get the pointer of opensbi FirmwareContext. Cc: Sunil V L Cc: Daniel Schaefer Signed-off-by: Abner Chang --- .../RISC-V/PlatformPkg/RiscVPlatformPkg.dsc | 7 +- .../PeiCoreEntryPoint/PeiCoreEntryPoint.inf | 36 +++++++ .../PeiCoreEntryPoint/PeiCoreEntryPoint.c | 97 +++++++++++++++++++ .../PeiCoreEntryPoint/PeiCoreEntryPoint.uni | 14 +++ 4 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/P= eiCoreEntryPoint.inf create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/P= eiCoreEntryPoint.c create mode 100644 Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/P= eiCoreEntryPoint.uni diff --git a/Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dsc b/Platform/RI= SC-V/PlatformPkg/RiscVPlatformPkg.dsc index 5d9674a965..8eec09549f 100644 --- a/Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dsc +++ b/Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dsc @@ -1,7 +1,7 @@ #/** @file # RISC-V platform package. # -# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All right= s reserved.
+# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All right= s reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -58,6 +58,10 @@ TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplat= e.inf PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeC= offGetEntryPointLib.inf =20 +[LibraryClasses.common.PEI_CORE] + # RISC-V platform PEI core entry point. + PeiCoreEntryPoint|Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/= PeiCoreEntryPoint.inf + [LibraryClasses.common.PEIM] FirmwareContextProcessorSpecificLib|Platform/RISC-V/PlatformPkg/Library/= FirmwareContextProcessorSpecificLib/FirmwareContextProcessorSpecificLib.inf HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf @@ -77,6 +81,7 @@ Platform/RISC-V/PlatformPkg/Library/PlatformUpdateProgressLibNull/Platfo= rmUpdateProgressLibNull.inf Platform/RISC-V/PlatformPkg/Library/FirmwareContextProcessorSpecificLib/= FirmwareContextProcessorSpecificLib.inf Platform/RISC-V/PlatformPkg/Library/RiscVPlatformTempMemoryInitLibNull/R= iscVPlatformTempMemoryInitLibNull.inf + Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.= inf =20 [Components.common.SEC] Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf diff --git a/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreE= ntryPoint.inf b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCo= reEntryPoint.inf new file mode 100644 index 0000000000..e16a974636 --- /dev/null +++ b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoi= nt.inf @@ -0,0 +1,36 @@ +## @file +# Module entry point library for PEI core on RISC-V with RISC-V OpenSBI. +# +# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All right= s reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D PeiCoreEntryPoint + MODULE_UNI_FILE =3D PeiCoreEntryPoint.uni + FILE_GUID =3D 2EBF4D2C-99B2-4A09-8C5C-318FB0EF7250 + MODULE_TYPE =3D PEI_CORE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PeiCoreEntryPoint|PEI_CORE + +# +# VALID_ARCHITECTURES =3D RISCV64 +# + +[Sources] + PeiCoreEntryPoint.c + +[Packages] + MdePkg/MdePkg.dec + Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec + Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec + +[LibraryClasses] + BaseLib + DebugLib + RiscVFirmwareContextLib + diff --git a/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreE= ntryPoint.c b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCore= EntryPoint.c new file mode 100644 index 0000000000..2fd0f2315b --- /dev/null +++ b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoi= nt.c @@ -0,0 +1,97 @@ +/** @file + Entry point to a the PEI Core on RISC-V platform with RISC-V OpenSBI. + +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights = reserved.
+ +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + + +#include +#include +// +// The Library classes this module produced +// +#include +#include +#include +#include + +/** + The entry point of PE/COFF Image for the PEI Core. + + This function is the entry point for the PEI Foundation, which allows th= e SEC phase + to pass information about the stack, temporary RAM and the Boot Firmware= Volume. + In addition, it also allows the SEC phase to pass services and data forw= ard for use + during the PEI phase in the form of one or more PPIs. + There is no limit to the number of additional PPIs that can be passed fr= om SEC into + the PEI Foundation. As part of its initialization phase, the PEI Foundat= ion will add + these SEC-hosted PPIs to its PPI database such that both the PEI Foundat= ion and any + modules can leverage the associated service calls and/or code in these e= arly PPIs. + This function is required to call ProcessModuleEntryPointList() with the= Context + parameter set to NULL. ProcessModuleEntryPoint() is never expected to r= eturn. + The PEI Core is responsible for calling ProcessLibraryConstructorList() = as soon as + the PEI Services Table and the file handle for the PEI Core itself have = been established. + If ProcessModuleEntryPointList() returns, then ASSERT() and halt the sys= tem. + + @param SecCoreData This is actually the RISC-V boot HART ID passed in a= 0 register. + + @param PpiList This is actually the EFI_RISCV_OPENSBI_FIRMWARE_CONT= EXT passed + in a1 register. + +**/ +VOID +EFIAPI +_ModuleEntryPoint( + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList +) +{ + EFI_SEC_PEI_HAND_OFF *ThisSecCoreData; + EFI_PEI_PPI_DESCRIPTOR *ThisPpiList; + EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext; + + FirmwareContext =3D (EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *)PpiList; + SetFirmwareContextPointer (FirmwareContext); + ThisSecCoreData =3D (EFI_SEC_PEI_HAND_OFF *)FirmwareContext->SecPeiHandO= ffData; + ThisPpiList =3D (EFI_PEI_PPI_DESCRIPTOR *)FirmwareContext->SecPeiHandoff= Ppi; + ProcessModuleEntryPointList (ThisSecCoreData, ThisPpiList, NULL); + + // + // Should never return + // + ASSERT(FALSE); + CpuDeadLoop (); +} + + +/** + Required by the EBC compiler and identical in functionality to _ModuleEn= tryPoint(). + + This function is required to call _ModuleEntryPoint() passing in SecCore= Data and PpiList. + + @param SecCoreData Points to a data structure containing information ab= out the PEI core's + operating environment, such as the size and location= of temporary RAM, + the stack location and the BFV location. + + @param PpiList Points to a list of one or more PPI descriptors to b= e installed + initially by the PEI core. An empty PPI list consis= ts of + a single descriptor with the end-tag + EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST. + As part of its initialization phase, the PEI Foundat= ion will + add these SEC-hosted PPIs to its PPI database, such = that both + the PEI Foundationand any modules can leverage the a= ssociated + service calls and/or code in these early PPIs. + +**/ +VOID +EFIAPI +EfiMain ( + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList + ) +{ + _ModuleEntryPoint (SecCoreData, PpiList); +} diff --git a/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreE= ntryPoint.uni b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCo= reEntryPoint.uni new file mode 100644 index 0000000000..1955b7a05b --- /dev/null +++ b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoi= nt.uni @@ -0,0 +1,14 @@ +// /** @file +// Module entry point library for PEI core on RISC-V with RISC-V OpenSBI. +// +// Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
+// +// SPDX-License-Identifier: BSD-2-Clause-Patent +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "RISC-V module ent= ry point library for PEI core" + +#string STR_MODULE_DESCRIPTION #language en-US "RISC-V module ent= ry point library for PEI core." + --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#82317): https://edk2.groups.io/g/devel/message/82317 Mute This Topic: https://groups.io/mt/86435667/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-