From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web08.2751.1641618783983306664 for ; Fri, 07 Jan 2022 21:13:04 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=mfK68Hv3; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=000704d8ca=abner.chang@hpe.com) Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 208325Gk031762 for ; Sat, 8 Jan 2022 05:13:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=xUk9/t/uBGcHYkW37msdWD5EFqxRDcbmnMGm5XdUpL8=; b=mfK68Hv32Chgi57s4M6oCbHkSjaGAgP3xnceQMFr7TxDyD9Y4RM2Upal7QTEeAVTbp4v z9nPGitQY0Wt5UTTCXNBfY7qMSUqxPO2+wT/f7CdIo/+Wf50eJGfCIFockKaa7q3HSdH MVqNV4T0xcgwFY5LAT1lEPSR4U46xm1U1nE6MxfQu6tffyuexLisT+WUQZIRF1TJcYKg z9n5QRgFFoIlcK3RSYC1qP/8l6WIzEFdRUwE22r9auw/djKXK68lIfNSs5p97o/EQSCd kIyGpm7XfyQzLXf3Y5sei8soEG7J6ad7a2b8g4PQwvJ3MfHqeDZVLc3UMtPzqR4IdqCf ZA== Received: from g2t2353.austin.hpe.com (g2t2353.austin.hpe.com [15.233.44.26]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3df004935a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 08 Jan 2022 05:13:03 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2353.austin.hpe.com (Postfix) with ESMTP id 6246A6D for ; Sat, 8 Jan 2022 05:13:02 +0000 (UTC) Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.229]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id AAC743D; Sat, 8 Jan 2022 05:13:01 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com Subject: [PATCH 40/79] RISC-V: Add RISC-V PeiCoreEntryPoint library Date: Sat, 8 Jan 2022 12:11:00 +0800 Message-Id: <20220108041121.16005-39-abner.chang@hpe.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220108041121.16005-1-abner.chang@hpe.com> References: <20220108041121.16005-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: hndtoMv3kMrllEJ-eOkb8fFikNPcMH7Y X-Proofpoint-ORIG-GUID: hndtoMv3kMrllEJ-eOkb8fFikNPcMH7Y X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-08_01,2022-01-07_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 malwarescore=0 adultscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201080036 Content-Transfer-Encoding: quoted-printable (This is migrated from edk2-platforms:Platform) - 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 Reviewed-by: Daniel Schaefer Reviewed-by: Sunil V L --- .../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=0D # RISC-V platform package.=0D #=0D -# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All right= s reserved.
=0D +# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All right= s reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -58,6 +58,10 @@ TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplat= e.inf=0D PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeC= offGetEntryPointLib.inf=0D =0D +[LibraryClasses.common.PEI_CORE]=0D + # RISC-V platform PEI core entry point.=0D + PeiCoreEntryPoint|Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/= PeiCoreEntryPoint.inf=0D +=0D [LibraryClasses.common.PEIM]=0D FirmwareContextProcessorSpecificLib|Platform/RISC-V/PlatformPkg/Library/= FirmwareContextProcessorSpecificLib/FirmwareContextProcessorSpecificLib.inf= =0D HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf=0D @@ -77,6 +81,7 @@ Platform/RISC-V/PlatformPkg/Library/PlatformUpdateProgressLibNull/Platfo= rmUpdateProgressLibNull.inf=0D Platform/RISC-V/PlatformPkg/Library/FirmwareContextProcessorSpecificLib/= FirmwareContextProcessorSpecificLib.inf=0D Platform/RISC-V/PlatformPkg/Library/RiscVPlatformTempMemoryInitLibNull/R= iscVPlatformTempMemoryInitLibNull.inf=0D + Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.= inf=0D =0D [Components.common.SEC]=0D Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf=0D 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=0D +# Module entry point library for PEI core on RISC-V with RISC-V OpenSBI.=0D +#=0D +# Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All right= s reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D PeiCoreEntryPoint=0D + MODULE_UNI_FILE =3D PeiCoreEntryPoint.uni=0D + FILE_GUID =3D 2EBF4D2C-99B2-4A09-8C5C-318FB0EF7250= =0D + MODULE_TYPE =3D PEI_CORE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D PeiCoreEntryPoint|PEI_CORE=0D +=0D +#=0D +# VALID_ARCHITECTURES =3D RISCV64=0D +#=0D +=0D +[Sources]=0D + PeiCoreEntryPoint.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + Platform/RISC-V/PlatformPkg/RiscVPlatformPkg.dec=0D + Silicon/RISC-V/ProcessorPkg/RiscVProcessorPkg.dec=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + DebugLib=0D + RiscVFirmwareContextLib=0D +=0D 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=0D + Entry point to a the PEI Core on RISC-V platform with RISC-V OpenSBI.=0D +=0D +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All rights = reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +=0D +#include =0D +#include =0D +//=0D +// The Library classes this module produced=0D +//=0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/**=0D + The entry point of PE/COFF Image for the PEI Core.=0D +=0D + This function is the entry point for the PEI Foundation, which allows th= e SEC phase=0D + to pass information about the stack, temporary RAM and the Boot Firmware= Volume.=0D + In addition, it also allows the SEC phase to pass services and data forw= ard for use=0D + during the PEI phase in the form of one or more PPIs.=0D + There is no limit to the number of additional PPIs that can be passed fr= om SEC into=0D + the PEI Foundation. As part of its initialization phase, the PEI Foundat= ion will add=0D + these SEC-hosted PPIs to its PPI database such that both the PEI Foundat= ion and any=0D + modules can leverage the associated service calls and/or code in these e= arly PPIs.=0D + This function is required to call ProcessModuleEntryPointList() with the= Context=0D + parameter set to NULL. ProcessModuleEntryPoint() is never expected to r= eturn.=0D + The PEI Core is responsible for calling ProcessLibraryConstructorList() = as soon as=0D + the PEI Services Table and the file handle for the PEI Core itself have = been established.=0D + If ProcessModuleEntryPointList() returns, then ASSERT() and halt the sys= tem.=0D +=0D + @param SecCoreData This is actually the RISC-V boot HART ID passed in a= 0 register.=0D +=0D + @param PpiList This is actually the EFI_RISCV_OPENSBI_FIRMWARE_CONT= EXT passed=0D + in a1 register.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +_ModuleEntryPoint(=0D + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,=0D + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList=0D +)=0D +{=0D + EFI_SEC_PEI_HAND_OFF *ThisSecCoreData;=0D + EFI_PEI_PPI_DESCRIPTOR *ThisPpiList;=0D + EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext;=0D +=0D + FirmwareContext =3D (EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *)PpiList;=0D + SetFirmwareContextPointer (FirmwareContext);=0D + ThisSecCoreData =3D (EFI_SEC_PEI_HAND_OFF *)FirmwareContext->SecPeiHandO= ffData;=0D + ThisPpiList =3D (EFI_PEI_PPI_DESCRIPTOR *)FirmwareContext->SecPeiHandoff= Ppi;=0D + ProcessModuleEntryPointList (ThisSecCoreData, ThisPpiList, NULL);=0D +=0D + //=0D + // Should never return=0D + //=0D + ASSERT(FALSE);=0D + CpuDeadLoop ();=0D +}=0D +=0D +=0D +/**=0D + Required by the EBC compiler and identical in functionality to _ModuleEn= tryPoint().=0D +=0D + This function is required to call _ModuleEntryPoint() passing in SecCore= Data and PpiList.=0D +=0D + @param SecCoreData Points to a data structure containing information ab= out the PEI core's=0D + operating environment, such as the size and location= of temporary RAM,=0D + the stack location and the BFV location.=0D +=0D + @param PpiList Points to a list of one or more PPI descriptors to b= e installed=0D + initially by the PEI core. An empty PPI list consis= ts of=0D + a single descriptor with the end-tag=0D + EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST.=0D + As part of its initialization phase, the PEI Foundat= ion will=0D + add these SEC-hosted PPIs to its PPI database, such = that both=0D + the PEI Foundationand any modules can leverage the a= ssociated=0D + service calls and/or code in these early PPIs.=0D +=0D +**/=0D +VOID=0D +EFIAPI=0D +EfiMain (=0D + IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,=0D + IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList=0D + )=0D +{=0D + _ModuleEntryPoint (SecCoreData, PpiList);=0D +}=0D 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=0D +// Module entry point library for PEI core on RISC-V with RISC-V OpenSBI.= =0D +//=0D +// Copyright (c) 2021, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
=0D +//=0D +// SPDX-License-Identifier: BSD-2-Clause-Patent=0D +//=0D +// **/=0D +=0D +=0D +#string STR_MODULE_ABSTRACT #language en-US "RISC-V module ent= ry point library for PEI core"=0D +=0D +#string STR_MODULE_DESCRIPTION #language en-US "RISC-V module ent= ry point library for PEI core."=0D +=0D --=20 2.31.1