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.web10.7398.1634634502842422685 for ; Tue, 19 Oct 2021 02:08:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=fGZnPZn2; spf=temperror, err=temporary DNS error (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0926d272d9=abner.chang@hpe.com) 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 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=FvwT7vgRQjBsdd0gvX2v3DDFmYHu6yWwOYUuvwlVvQg=; b=fGZnPZn2J99iXX9NieU2DFUtdus0cgqPSyHgNr5tuBHOKMbNvQ0AkiN51kBtewg9KwG4 Km2WZVHxin9moI9xWhXl4q+sfUauwNR7MPdUjFf96vZpAYU1KSCJ7a66+1ABZ38iO78Q di56Eu0cCs/ioxt84wHJKqDnakHikNx5mqZBWicRWIqG1ICe7gYo0CY3Vxnyrhcu1HON nPnXsUOGXqW5Bh04V0zecrfhAZM0ptddBefI3ekYOwmFnK6k32ct89Klg4ipwCJKIaAV RZGRz6fO7gcggYFf5kWr4t5yVyzIkUrzFoxqJkK/84u0NwqT5xg5I3oPHWswggRvDyTe jw== 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 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) 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-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> X-Mailer: git-send-email 2.31.1 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 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-18_07,2021-10-18_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 phishscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110190056 Content-Transfer-Encoding: quoted-printable 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]=0D BaseLib=0D DebugLib=0D + PlatformSecPpiLib=0D RiscVFirmwareContextLib=0D =0D 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=0D RiscVEdk2SbiLib=0D =0D -[Ppis]=0D - gEfiTemporaryRamSupportPpiGuid # PPI ALWAYS_PRODUCED=0D - gEfiTemporaryRamDonePpiGuid # PPI ALWAYS_PRODUCED=0D -=0D [FixedPcd]=0D gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVPeiFvBase=0D gUefiRiscVPlatformPkgTokenSpaceGuid.PcdRiscVPeiFvSize=0D 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 =0D #include =0D #include =0D -#include =0D -#include =0D =0D int=0D SecPostOpenSbiPlatformEarlylInit(=0D @@ -49,19 +47,4 @@ SecStartupPhase2 ( IN VOID *Context=0D );=0D =0D -EFI_STATUS=0D -EFIAPI=0D -TemporaryRamMigration (=0D - IN CONST EFI_PEI_SERVICES **PeiServices,=0D - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,=0D - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,=0D - IN UINTN CopySize=0D - );=0D -=0D -EFI_STATUS=0D -EFIAPI=0D -TemporaryRamDone (=0D - VOID=0D - );=0D -=0D #endif // _SECMAIN_H_=0D 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 =0D #include =0D #include =0D +#include =0D #include =0D =0D /**=0D @@ -49,15 +50,25 @@ _ModuleEntryPoint( IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList=0D )=0D {=0D + EFI_STATUS Status;=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 + FirmwareContext->BootHartId =3D (UINT64)SecCoreData;=0D +=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 + Status =3D GetPlatformPrePeiCorePpiDescriptor (&ThisPpiList);=0D + if (EFI_ERROR (Status)) {=0D + ThisPpiList =3D NULL;=0D + }=0D +=0D + //=0D + // Invoke PEI Core entry point.=0D + //=0D + ProcessModuleEntryPointList(ThisSecCoreData, ThisPpiList, NULL);=0D =0D //=0D // Should never return=0D 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 ( =0D return;=0D }=0D -/*=0D - Print out the content of firmware context.=0D -=0D -**/=0D -VOID=0D -DebugPrintFirmwareContext (=0D - EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext=0D - )=0D -{=0D - DEBUG ((DEBUG_INFO, "%a: OpenSBI Firmware Context at 0x%x\n", __FUNCTION= __, FirmwareContext));=0D - DEBUG ((DEBUG_INFO, "%a: PEI Service at 0x%x\n\n", __FUNCTI= ON__, FirmwareContext->PeiServiceTable));=0D -}=0D -/** Temporary RAM migration function.=0D -=0D - This function migrates the data from temporary RAM to permanent=0D - memory.=0D -=0D - @param[in] PeiServices PEI service=0D - @param[in] TemporaryMemoryBase Temporary memory base address=0D - @param[in] PermanentMemoryBase Permanent memory base address=0D - @param[in] CopySize Size to copy=0D -=0D -**/=0D -EFI_STATUS=0D -EFIAPI=0D -TemporaryRamMigration (=0D - IN CONST EFI_PEI_SERVICES **PeiServices,=0D - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,=0D - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,=0D - IN UINTN CopySize=0D - )=0D -{=0D - VOID *OldHeap;=0D - VOID *NewHeap;=0D - VOID *OldStack;=0D - VOID *NewStack;=0D - EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *FirmwareContext;=0D -=0D - DEBUG ((DEBUG_INFO,=0D - "%a: Temp Mem Base:0x%Lx, Permanent Mem Base:0x%Lx, CopySize:0x%Lx\n",= =0D - __FUNCTION__,=0D - TemporaryMemoryBase,=0D - PermanentMemoryBase,=0D - (UINT64)CopySize=0D - ));=0D -=0D - OldHeap =3D (VOID*)(UINTN)TemporaryMemoryBase;=0D - NewHeap =3D (VOID*)((UINTN)PermanentMemoryBase + (CopySize >> 1));=0D -=0D - OldStack =3D (VOID*)((UINTN)TemporaryMemoryBase + (CopySize >> 1));=0D - NewStack =3D (VOID*)(UINTN)PermanentMemoryBase;=0D -=0D - CopyMem (NewHeap, OldHeap, CopySize >> 1); // Migrate Heap=0D - CopyMem (NewStack, OldStack, CopySize >> 1); // Migrate Stack=0D -=0D - //=0D - // Reset firmware context pointer=0D - //=0D - SbiGetFirmwareContext (&FirmwareContext);=0D - FirmwareContext =3D (VOID *)FirmwareContext + (unsigned long)((UINTN)New= Stack - (UINTN)OldStack);=0D - SbiSetFirmwareContext (FirmwareContext);=0D -=0D - //=0D - // Relocate PEI Service **=0D - //=0D - FirmwareContext->PeiServiceTable +=3D (unsigned long)((UINTN)NewStack - = (UINTN)OldStack);=0D - DEBUG ((DEBUG_INFO, "%a: OpenSBI Firmware Context is relocated to 0x%x\n= ", __FUNCTION__, FirmwareContext));=0D - DebugPrintFirmwareContext ((EFI_RISCV_OPENSBI_FIRMWARE_CONTEXT *)Firmwar= eContext);=0D -=0D - register uintptr_t a0 asm ("a0") =3D (uintptr_t)((UINTN)NewStack - (UINT= N)OldStack);=0D - asm volatile ("add sp, sp, a0"::"r"(a0):);=0D - return EFI_SUCCESS;=0D -}=0D -=0D -/** Temprary RAM done function.=0D -=0D -**/=0D -EFI_STATUS EFIAPI TemporaryRamDone (=0D - VOID=0D - )=0D -{=0D - DEBUG ((DEBUG_INFO, "%a: 2nd time PEI core, temporary ram done.\n", __FU= NCTION__));=0D - return EFI_SUCCESS;=0D -}=0D =0D /**=0D Handles SBI calls of EDK2's SBI FW extension.=0D --=20 2.31.1