From nobody Mon Feb 9 21:02:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+49493+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49493+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1572229915; cv=none; d=zoho.com; s=zohoarc; b=h3oZS6RTvvIq+ZCdIoMk287VkK9SO8QYa9NpoBkLoQ5bPZjVmpcvTW+n+qC5j5apepFEvWp1UOJ73V9fdnrT3lXevrB/lWmgyKH4Cp1NiUSnFaXL8cElrwI5HYFrWiyyIzlVW9Z8uyXBPn5WzNZEuv9CE5M19oaWsG3CA6Ggodc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572229915; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=KzzuTKqaH/svfCSWZDVdyGptV9lFkQL11Lkzy0zcxh4=; b=HjZalX+0ZeRlQwl6CzW8w5UXVsrMY9RFs9RrMfXaAqiZSMRBabRwHzKJqvSWLDTDe2eDST/o9CNSiXYtryuNc2nWANLeOR83mPZQLvor2vZuImaRGueluetJYEuViym6nmTrOoDF9GF313pi2/ZWHaiwCpNlmCnLpKgbSg1KgsM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+49493+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1572229915279760.5078070754339; Sun, 27 Oct 2019 19:31:55 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ON6cYY1788612xTZUkfHN8i5; Sun, 27 Oct 2019 19:31:54 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web11.572.1572229910496209442 for ; Sun, 27 Oct 2019 19:31:50 -0700 X-Received: from pps.filterd (m0134422.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9S2Vh3x024684; Mon, 28 Oct 2019 02:31:50 GMT X-Received: from g4t3425.houston.hpe.com (g4t3425.houston.hpe.com [15.241.140.78]) by mx0b-002e3701.pphosted.com with ESMTP id 2vw02avn9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 28 Oct 2019 02:31:50 +0000 X-Received: from g4t3433.houston.hpecorp.net (g4t3433.houston.hpecorp.net [16.208.49.245]) by g4t3425.houston.hpe.com (Postfix) with ESMTP id 5CFCEA8; Mon, 28 Oct 2019 02:31:49 +0000 (UTC) X-Received: from UB16Abner.asiapacific.hpqcorp.net (ub16abner.asiapacific.hpqcorp.net [15.119.209.229]) by g4t3433.houston.hpecorp.net (Postfix) with ESMTP id 0629846; Mon, 28 Oct 2019 02:31:47 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com, Leif Lindholm , Gilbert Chen Subject: [edk2-devel] [edk2-staging/RISC-V-V2 PATCH v3 19/39] RiscVPkg/Library: RISC-V platform level DxeIPL libraries. Date: Mon, 28 Oct 2019 09:58:57 +0800 Message-Id: <1572227957-13169-20-git-send-email-abner.chang@hpe.com> In-Reply-To: <1572227957-13169-1-git-send-email-abner.chang@hpe.com> References: <1572227957-13169-1-git-send-email-abner.chang@hpe.com> X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: 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: qgODIpzb6vpFXHuiShuGnaVVx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1572229914; bh=v8SOhwLW/OOOz1WABFfLuXOBCAxCvuIdrFMVPjSRzKc=; h=Cc:Date:From:Reply-To:Subject:To; b=YBCn1AKSYzjULl2DL8sqaGFdxq214ie/w0tNlS/yNiUpm8D2TXT4xatDBb+jOyxkgSB 7eHNu60HmPlX9LFydy16TMpfx/HPA2uqJoFfXFTrRG6M8E3OMWYoGW04A4axXEHLeTDLH 54lhL9Jh+wHodgER2BO7DDzpraLzAl9qdVw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" RiscVDxeIplHandoffLib.inf: Simply use stack switch to hand off to DXE phase. RiscVDxeIplHandoffOpenSbiLib.inf: Hand off to DXE phase using OpenSBI interface. Signed-off-by: Abner Chang Cc: Leif Lindholm Cc: Gilbert Chen --- .../RiscVDxeIplHandoffLib.inf | 32 +++++++ .../RiscVDxeIplHandoffOpenSbiLib.inf | 33 +++++++ .../RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.c | 41 +++++++++ .../RiscVDxeIplHandoffOpenSbiLib.c | 101 +++++++++++++++++= ++++ 4 files changed, 207 insertions(+) create mode 100644 RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHando= ffLib.inf create mode 100644 RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeI= plHandoffOpenSbiLib.inf create mode 100644 RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHando= ffLib.c create mode 100644 RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeI= plHandoffOpenSbiLib.c diff --git a/RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.i= nf b/RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.inf new file mode 100644 index 0000000..986db1d --- /dev/null +++ b/RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.inf @@ -0,0 +1,32 @@ +## @file +# Instance of RISC-V DXE IPL to DXE core handoff platform library +# +# Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001b + BASE_NAME =3D RiscVPlatformDxeIplLib + FILE_GUID =3D 2A77EE71-9F55-43F9-8773-7854A5B56086 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RiscVPlatformDxeIplLib|PEIM PEI_CORE + +# +# VALID_ARCHITECTURES =3D RISCV64 +# + +[Sources] + RiscVDxeIplHandoffLib.c + +[Packages] + MdePkg/MdePkg.dec + RiscVPkg/RiscVPkg.dec + +[LibraryClasses] + DebugLib + RiscVCpuLib + RiscVOpensbiLib + diff --git a/RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeIplHando= ffOpenSbiLib.inf b/RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeIp= lHandoffOpenSbiLib.inf new file mode 100644 index 0000000..262071d --- /dev/null +++ b/RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeIplHandoffOpenS= biLib.inf @@ -0,0 +1,33 @@ +## @file +# Instance of RISC-V DXE IPL to DXE core handoff platform library using O= penSBI +# +# Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All righ= ts reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 0x0001001b + BASE_NAME =3D RiscVPlatformDxeIplLib + FILE_GUID =3D 906A4BB9-8DE2-4CE0-A609-23818A8FF514 + MODULE_TYPE =3D PEIM + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D RiscVPlatformDxeIplLib|PEIM PEI_CORE + +# +# VALID_ARCHITECTURES =3D RISCV64 +# + +[Sources] + RiscVDxeIplHandoffOpenSbiLib.c + +[Packages] + MdePkg/MdePkg.dec + RiscVPkg/RiscVPkg.dec + +[LibraryClasses] + DebugLib + RiscVCpuLib + RiscVOpensbiLib + diff --git a/RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.c= b/RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.c new file mode 100644 index 0000000..211b4e8 --- /dev/null +++ b/RiscVPkg/Library/RiscVDxeIplHandoffLib/RiscVDxeIplHandoffLib.c @@ -0,0 +1,41 @@ +/** @file + RISC-V platform level DXE core hand off library + + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All right= s reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +/** + RISC-V platform DXE IPL to DXE core handoff process. + + This function performs a CPU architecture specific operations to execute + the entry point of DxeCore with the parameters of HobList. + It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase. + + @param BaseOfStack Base address of stack + @param TopOfStack Top address of stack + @param DxeCoreEntryPoint The entry point of DxeCore. + @param HobList The start of HobList passed to DxeCore. + +**/ + +VOID +RiscVPlatformHandOffToDxeCore ( + IN VOID *BaseOfStack, + IN VOID *TopOfStack, + IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, + IN EFI_PEI_HOB_POINTERS HobList + ) +{ + + // + // Transfer the control to the entry point of DxeCore. + // + SwitchStack ( + (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint, + HobList.Raw, + NULL, + TopOfStack + ); +} diff --git a/RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeIplHando= ffOpenSbiLib.c b/RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeIplH= andoffOpenSbiLib.c new file mode 100644 index 0000000..26975c0 --- /dev/null +++ b/RiscVPkg/Library/RiscVDxeIplHandoffOpenSbiLib/RiscVDxeIplHandoffOpenS= biLib.c @@ -0,0 +1,101 @@ +/** @file + RISC-V DXE IPL to DXE core handoff platform library using OpenSBI + + Copyright (c) 2019, Hewlett Packard Enterprise Development LP. All right= s reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + RISC-V platform DXE IPL to DXE OpenSBI mdoe switch handler. + This function is executed in RISC-V Supervisor mode. + + This function performs a CPU architecture specific operations to execute + the entry point of DxeCore with the parameters of HobList. + It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase. + + @param BaseOfStack Base address of stack + @param TopOfStack Top address of stack + @param DxeCoreEntryPoint The entry point of DxeCore. + @param HobList The start of HobList passed to DxeCore. + +**/ +VOID +RiscVDxeIplHandoffOpenSbiHandler ( + IN UINTN HardId, + IN OPENSBI_SWITCH_MODE_CONTEXT *ThisSwitchContext + ) +{ + DEBUG ((DEBUG_INFO, "OpenSBI mode switch DXE IPL Handoff handler entry\n= ")); + + SwitchStack ( + (SWITCH_STACK_ENTRY_POINT)(UINTN)ThisSwitchContext->DxeCoreEntryPoint, + ThisSwitchContext->HobList.Raw, + NULL, + ThisSwitchContext->TopOfStack + ); + + // + // Shold never came back. + // + UNREACHABLE(); +} + + +/** + RISC-V platform DXE IPL to DXE core handoff process. + + This function performs a CPU architecture specific operations to execute + the entry point of DxeCore with the parameters of HobList. + It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase. + + @param BaseOfStack Base address of stack + @param TopOfStack Top address of stack + @param DxeCoreEntryPoint The entry point of DxeCore. + @param HobList The start of HobList passed to DxeCore. + +**/ +VOID +RiscVPlatformHandOffToDxeCore ( + IN VOID *BaseOfStack, + IN VOID *TopOfStack, + IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint, + IN EFI_PEI_HOB_POINTERS HobList + ) +{ + struct sbi_scratch *ThisScratch; + OPENSBI_SWITCH_MODE_CONTEXT OpenSbiSwitchModeContext; + + DEBUG ((DEBUG_INFO, "DXE IPL to DXE Core using OpenSBI\n")); + // + // Setup next address in OpenSBI scratch + // + OpenSbiSwitchModeContext.BaseOfStack =3D BaseOfStack; + OpenSbiSwitchModeContext.TopOfStack =3D TopOfStack; + OpenSbiSwitchModeContext.HobList =3D HobList; + OpenSbiSwitchModeContext.DxeCoreEntryPoint =3D DxeCoreEntryPoint; + ThisScratch =3D sbi_scratch_thishart_ptr (); + ThisScratch->next_arg1 =3D (UINTN)&OpenSbiSwitchModeContext; + ThisScratch->next_addr =3D (UINTN)RiscVDxeIplHandoffOpenSbiHandler; + ThisScratch->next_mode =3D PRV_S; + + DEBUG ((DEBUG_INFO, " Base address of satck: 0x%x\n", BaseOfSta= ck)); + DEBUG ((DEBUG_INFO, " Top address of satck: 0x%x\n", TopOfStack= )); + DEBUG ((DEBUG_INFO, " HOB list address: 0x%x\n", &HobList)); + DEBUG ((DEBUG_INFO, " DXE core entry pointer: 0x%x\n", DxeCoreE= ntryPoint)); + DEBUG ((DEBUG_INFO, " OpenSBI Switch mode arg1: 0x%x\n", (UINTN= )&OpenSbiSwitchModeContext)); + DEBUG ((DEBUG_INFO, " OpenSBI Switch mode handler address: 0x%x= \n", (UINTN)RiscVDxeIplHandoffOpenSbiHandler)); + DEBUG ((DEBUG_INFO, " OpenSBI Switch mode to privilege 0x%x\n",= PRV_S)); + sbi_init (ThisScratch); +} --=20 2.7.4 -=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 (#49493): https://edk2.groups.io/g/devel/message/49493 Mute This Topic: https://groups.io/mt/38757515/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-