From nobody Mon Feb 9 10:47:56 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+82323+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+82323+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1634634511; cv=none; d=zohomail.com; s=zohoarc; b=KRjTKhb8DOE/Srrl934b6B322VEx/CajvwlDgk99Xmfa34VHpTb95iilG6UxjoHJwKYPuKClz+HTN1D3vY8e2VgfZ0YfU/IWZzWeBKQ6Dxh1DLiqTdl8MAW95tapvgMkvzQZrHQSOdu8q/kDmddn5C3CRX2IonEHFssHLqJq42c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634634511; 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=ou3x1bdtGNcs1wgdmL0J+1uhI+IaTTKqaym7UbUFS8k=; b=LcK3hPqvpLxVPRu1vG3G0okmaKbwWPYo5NivRNBbrMVeGeL0cH5SGplPlMlyDmX7pZ9f96NteoEO4zfGmfoQP9g0XRsPuK8O4keZ9HIjfVRJXXtLaXTBYAB33KLkWmby2SiTPsWb792gtabfKOKRNhlzX/X8Jk8h6jpvYDRvxe0= 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+82323+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 1634634511637667.6214922458857; Tue, 19 Oct 2021 02:08:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id OparYY1788612x76sabpBEob; Tue, 19 Oct 2021 02:08:31 -0700 X-Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web10.7398.1634634502842422685 for ; Tue, 19 Oct 2021 02:08:30 -0700 X-Received: from pps.filterd (m0148663.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19J84La2029873; Tue, 19 Oct 2021 09:08:22 GMT X-Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) by mx0a-002e3701.pphosted.com with ESMTP id 3bst6drgnq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Oct 2021 09:08:22 +0000 X-Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3426.houston.hpe.com (Postfix) with ESMTP id 010904E; Tue, 19 Oct 2021 09:08:21 +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 E737A48; Tue, 19 Oct 2021 09:08:20 +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 07/30] Platform/RISC-V: Use PlatformSecPpiLib Date: Tue, 19 Oct 2021 16:09:44 +0800 Message-Id: <20211019081007.31165-8-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-ORIG-GUID: V6EgZKBhjgkjDoKed80e_dNO12gSTTlv X-Proofpoint-GUID: V6EgZKBhjgkjDoKed80e_dNO12gSTTlv 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: IDn8RVcM4uQ8bm1W8ttDkBS2x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634634511; bh=rabTFwxG1t439yMB3Rv++bYrY4vxxuvXE76bs9DdycA=; h=Cc:Date:From:Reply-To:Subject:To; b=AzeeEtQIjC+SRPyzD+vc0/KI1FNQ2NouhZ6DAgb9rTL0/5OaVEs4GMVDVigCuHH6N2C agnmypHN9gkzdir/nXvQ43Kzt7wB+PBzOjDDbUmUgdGHkd79DPT3vSnR7AQbOySKXm3lS 9hWaamKLiAaiZCDuOihujX4M5CkiaJEqziQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634634513642100002 Content-Type: text/plain; charset="utf-8" Use PlatformSecPpiLib to get PPI descriptor and remove PPI descriptor related code from SEC. Cc: Sunil V L Cc: Daniel Schaefer Signed-off-by: Abner Chang --- .../PeiCoreEntryPoint/PeiCoreEntryPoint.inf | 1 + .../PlatformPkg/Universal/Sec/SecMain.inf | 4 - .../PlatformPkg/Universal/Sec/SecMain.h | 17 ---- .../PeiCoreEntryPoint/PeiCoreEntryPoint.c | 15 +++- .../PlatformPkg/Universal/Sec/SecMain.c | 84 ------------------- 5 files changed, 14 insertions(+), 107 deletions(-) diff --git a/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreE= ntryPoint.inf b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCo= reEntryPoint.inf index e16a974636..4f3af27bcf 100644 --- a/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoi= nt.inf +++ b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoi= nt.inf @@ -32,5 +32,6 @@ [LibraryClasses] BaseLib DebugLib + PlatformSecPpiLib RiscVFirmwareContextLib =20 diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf b/Platfo= rm/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf index 4207c83413..9736277fa1 100644 --- a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf +++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.inf @@ -52,10 +52,6 @@ RiscVOpensbiPlatformLib RiscVEdk2SbiLib =20 -[Ppis] - gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED - gEfiTemporaryRamDonePpiGuid # PPI ALWAYS_PRODUCED - [FixedPcd] gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVPeiFvBase gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVPeiFvSize diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.h b/Platform= /RISC-V/PlatformPkg/Universal/Sec/SecMain.h index c04ddbad7f..496799efc0 100644 --- a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.h +++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.h @@ -25,8 +25,6 @@ #include #include #include -#include -#include =20 int SecPostOpenSbiPlatformEarlylInit( @@ -49,19 +47,4 @@ SecStartupPhase2 ( IN VOID *Context ); =20 -EFI_STATUS -EFIAPI -TemporaryRamMigration ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, - IN UINTN CopySize - ); - -EFI_STATUS -EFIAPI -TemporaryRamDone ( - VOID - ); - #endif // _SECMAIN_H_ diff --git a/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreE= ntryPoint.c b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCore= EntryPoint.c index 2fd0f2315b..16488b7bc9 100644 --- a/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoi= nt.c +++ b/Platform/RISC-V/PlatformPkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoi= nt.c @@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include =20 /** @@ -49,15 +50,25 @@ _ModuleEntryPoint( IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList ) { + EFI_STATUS Status; EFI_SEC_PEI_HAND_OFF *ThisSecCoreData; EFI_PEI_PPI_DESCRIPTOR *ThisPpiList; EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext; =20 FirmwareContext =3D (EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *)PpiList; SetFirmwareContextPointer (FirmwareContext); + FirmwareContext->BootHartId =3D (UINT64)SecCoreData; + ThisSecCoreData =3D (EFI_SEC_PEI_HAND_OFF *)FirmwareContext->SecPeiHandO= ffData; - ThisPpiList =3D (EFI_PEI_PPI_DESCRIPTOR *)FirmwareContext->SecPeiHandoff= Ppi; - ProcessModuleEntryPointList (ThisSecCoreData, ThisPpiList, NULL); + Status =3D GetPlatformPrePeiCorePpiDescriptor (&ThisPpiList); + if (EFI_ERROR (Status)) { + ThisPpiList =3D NULL; + } + + // + // Invoke PEI Core entry point. + // + ProcessModuleEntryPointList(ThisSecCoreData, ThisPpiList, NULL); =20 // // Should never return diff --git a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c b/Platform= /RISC-V/PlatformPkg/Universal/Sec/SecMain.c index 44984b0078..fb0adbca54 100644 --- a/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c +++ b/Platform/RISC-V/PlatformPkg/Universal/Sec/SecMain.c @@ -312,90 +312,6 @@ FindAndReportEntryPoints ( =20 return; } -/* - Print out the content of firmware context. - -**/ -VOID -DebugPrintFirmwareContext ( - EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext - ) -{ - DEBUG ((DEBUG_INFO, "%a: OpenSBI Firmware Context at 0x%x\n", __FUNCTION= __, FirmwareContext)); - DEBUG ((DEBUG_INFO, "%a: PEI Service at 0x%x\n\n", __FUNCTI= ON__, FirmwareContext->PeiServiceTable)); -} -/** Temporary RAM migration function. - - This function migrates the data from temporary RAM to permanent - memory. - - @param[in] PeiServices PEI service - @param[in] TemporaryMemoryBase Temporary memory base address - @param[in] PermanentMemoryBase Permanent memory base address - @param[in] CopySize Size to copy - -**/ -EFI_STATUS -EFIAPI -TemporaryRamMigration ( - IN CONST EFI_PEI_SERVICES **PeiServices, - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, - IN UINTN CopySize - ) -{ - VOID *OldHeap; - VOID *NewHeap; - VOID *OldStack; - VOID *NewStack; - EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext; - - DEBUG ((DEBUG_INFO, - "%a: Temp Mem Base:0x%Lx, Permanent Mem Base:0x%Lx, CopySize:0x%Lx\n", - __FUNCTION__, - TemporaryMemoryBase, - PermanentMemoryBase, - (UINT64)CopySize - )); - - OldHeap =3D (VOID*)(UINTN)TemporaryMemoryBase; - NewHeap =3D (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1)); - - OldStack =3D (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1)); - NewStack =3D (VOID*)(UINTN)PermanentMemoryBase; - - CopyMem (NewHeap, OldHeap, CopySize >> 1); // Migrate Heap - CopyMem (NewStack, OldStack, CopySize >> 1); // Migrate Stack - - // - // Reset firmware context pointer - // - SbiGetFirmwareContext (&FirmwareContext); - FirmwareContext =3D (VOID *)FirmwareContext + (unsigned long)((UINTN)New= Stack - (UINTN)OldStack); - SbiSetFirmwareContext (FirmwareContext); - - // - // Relocate PEI Service ** - // - FirmwareContext->PeiServiceTable +=3D (unsigned long)((UINTN)NewStack - = (UINTN)OldStack); - DEBUG ((DEBUG_INFO, "%a: OpenSBI Firmware Context is relocated to 0x%x\n= ", __FUNCTION__, FirmwareContext)); - DebugPrintFirmwareContext ((EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *)Firmwar= eContext); - - register uintptr_t a0 asm ("a0") =3D (uintptr_t)((UINTN)NewStack - (UINT= N)OldStack); - asm volatile ("add sp, sp, a0"::"r"(a0):); - return EFI_SUCCESS; -} - -/** Temprary RAM done function. - -**/ -EFI_STATUS EFIAPI TemporaryRamDone ( - VOID - ) -{ - DEBUG ((DEBUG_INFO, "%a: 2nd time PEI core, temporary ram done.\n", __FU= NCTION__)); - return EFI_SUCCESS; -} =20 /** Handles SBI calls of EDK2's SBI FW extension. --=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 (#82323): https://edk2.groups.io/g/devel/message/82323 Mute This Topic: https://groups.io/mt/86435675/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-