From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web10.3727.1641630349594215461 for ; Sat, 08 Jan 2022 00:25:49 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=LBM/uHAf; 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.143.35, mailfrom: prvs=000704d8ca=abner.chang@hpe.com) Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 2085W2Hg027481 for ; Sat, 8 Jan 2022 08:25:48 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=TBU+1QHCwoQXFLJbT6y8yQ/5i0HQF02vbe/KYR8eLuk=; b=LBM/uHAf0A86hdolpHHG+0bYayrtZ3ibQINHFxUmrZYEPU7ugBfr165nS7FyMHqL9E3h eTJVI5zRO7B56i5d1hBAC6mtgZmzt0ybB7c5h7Mnhknm3x5qSzhZ2/dC4ZBB7xmsgxUG RUp2nBECdMdVKJl2AsNq5KUv2X2FBsJVeMBZjCk+oI3I0qerh6Q00Fs9VnCM+FHzetHo g4BvMbV25/nTLvKW5iGwl2fBT5n53HzQuCJSgebCFfd313JpRXyGNF+WqTnwL/0OhmTJ fa6cqbfsp+w5HjYDKScW8idk+DjAWdsbEPGyO5w8nqfLqTWSC2USzN0WLCXZUbVFNYQU lA== Received: from g2t2354.austin.hpe.com (g2t2354.austin.hpe.com [15.233.44.27]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3df1kq18y6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 08 Jan 2022 08:25:48 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2354.austin.hpe.com (Postfix) with ESMTP id B90C091 for ; Sat, 8 Jan 2022 08:25:47 +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 0D1DE3F; Sat, 8 Jan 2022 08:25:46 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: abner.chang@hpe.com Subject: [PATCH 44/79] Platform/RISC-V: Use PlatformSecPpiLib Date: Sat, 8 Jan 2022 15:24:27 +0800 Message-Id: <20220108072444.17879-3-abner.chang@hpe.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220108072444.17879-1-abner.chang@hpe.com> References: <20220108072444.17879-1-abner.chang@hpe.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: DdRIKdc3cPMFOgPrRp3uaUETB8Hg8ow9 X-Proofpoint-GUID: DdRIKdc3cPMFOgPrRp3uaUETB8Hg8ow9 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_03,2022-01-07_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxlogscore=999 clxscore=1015 bulkscore=0 malwarescore=0 suspectscore=0 phishscore=0 mlxscore=0 impostorscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201080063 Content-Transfer-Encoding: quoted-printable (This is migrated from edk2-platforms:Platform) 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 Reviewed-by: Daniel Schaefer Reviewed-by: Sunil V L --- .../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