From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 8B384740038 for ; Thu, 14 Sep 2023 23:10:47 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=lVnXnh3DzReu3FPXcGsjk8/sdXj5dZEcjg5nzgvsI7w=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1694733046; v=1; b=BbHU7iTAbZW7UYpRhVjFp/G6eSsKg71IPGZXEZvyTcIV0F7xLzF+UAl+FcRzYcz6Qq4Xd9uI /KHSTuDUK5SjnjH01d6+Z+Sdr4nym8T+gXNwsnSzXkFW1oXJj0nWK3QHKCfBMrnVvsJBizmnupK Jbw2Fan5NbX+OhIAcC3BRTDo= X-Received: by 127.0.0.2 with SMTP id jKLQYY7687511xRlHk0JLjmg; Thu, 14 Sep 2023 16:10:46 -0700 X-Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by mx.groups.io with SMTP id smtpd.web10.9111.1694733045558542331 for ; Thu, 14 Sep 2023 16:10:45 -0700 X-Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-68fac346f6aso1368624b3a.3 for ; Thu, 14 Sep 2023 16:10:45 -0700 (PDT) X-Gm-Message-State: ZZoefTYE8ZHV080a5tFMfIM7x7686176AA= X-Google-Smtp-Source: AGHT+IHUlVRXqr+ArEZz72TgsU63BMy4+qPdS6ECjk504iGr/z2YA8B1JZKVUAn9MZkI3yS484B1kw== X-Received: by 2002:a05:6a20:748d:b0:137:74f8:62ee with SMTP id p13-20020a056a20748d00b0013774f862eemr236875pzd.18.1694733044467; Thu, 14 Sep 2023 16:10:44 -0700 (PDT) X-Received: from localhost.localdomain (c-98-210-194-104.hsd1.ca.comcast.net. [98.210.194.104]) by smtp.gmail.com with ESMTPSA id d24-20020aa78e58000000b0066a4e561beesm1865591pfr.173.2023.09.14.16.10.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 16:10:44 -0700 (PDT) From: "Tuan Phan" To: devel@edk2.groups.io Cc: ardb+tianocore@kernel.org, sami.mujawar@arm.com, ray.ni@intel.com, huangming@linux.alibaba.com, sunilvl@ventanamicro.com, yong.li@intel.com, Tuan Phan Subject: [edk2-devel] [PATCH v2 1/2] StandaloneMmPkg: Make StandaloneMmCpu driver platform independent Date: Thu, 14 Sep 2023 16:10:36 -0700 Message-Id: <20230914231037.23950-2-tphan@ventanamicro.com> In-Reply-To: <20230914231037.23950-1-tphan@ventanamicro.com> References: <20230914231037.23950-1-tphan@ventanamicro.com> MIME-Version: 1.0 Precedence: Bulk 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,tphan@ventanamicro.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=BbHU7iTA; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io StandaloneMmCpu now can supports more platforms like RISC-V besides ARM/AARCH64. Signed-off-by: Tuan Phan --- .../Drivers/StandaloneMmCpu/EventHandle.c | 25 +++-------- .../Drivers/StandaloneMmCpu/StandaloneMmCpu.c | 42 +++++++++---------- .../StandaloneMmCpu/StandaloneMmCpu.inf | 9 ++-- .../StandaloneMmCpu.h | 22 +++++++--- StandaloneMmPkg/StandaloneMmPkg.dec | 2 +- 5 files changed, 46 insertions(+), 54 deletions(-) rename StandaloneMmPkg/{Drivers/StandaloneMmCpu =3D> Include}/StandaloneMm= Cpu.h (82%) diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c b/Standa= loneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c index 818e147f874c..dc11d4375a02 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c @@ -3,6 +3,7 @@ Copyright (c) 2016 HP Development Company, L.P.=0D Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.=0D Copyright (c) 2021, Linaro Limited=0D + Copyright (c) 2023, Ventana Micro System Inc. All rights reserved.=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -11,8 +12,6 @@ #include =0D #include =0D =0D -#include =0D -#include =0D #include =0D #include =0D #include =0D @@ -22,10 +21,7 @@ #include =0D #include =0D =0D -#include =0D -#include =0D -=0D -#include "StandaloneMmCpu.h"=0D +#include =0D =0D EFI_STATUS=0D EFIAPI=0D @@ -108,7 +104,7 @@ CheckBufferAddr ( }=0D =0D /**=0D - The PI Standalone MM entry point for the TF-A CPU driver.=0D + The PI Standalone MM entry point for the CPU driver.=0D =0D @param [in] EventId The event Id.=0D @param [in] CpuNumber The CPU number.=0D @@ -121,7 +117,7 @@ CheckBufferAddr ( @retval EFI_UNSUPPORTED Operation not supported.=0D **/=0D EFI_STATUS=0D -PiMmStandaloneArmTfCpuDriverEntry (=0D +PiMmStandaloneMmCpuDriverEntry (=0D IN UINTN EventId,=0D IN UINTN CpuNumber,=0D IN UINTN NsCommBufferAddr=0D @@ -135,17 +131,6 @@ PiMmStandaloneArmTfCpuDriverEntry ( DEBUG ((DEBUG_INFO, "Received event - 0x%x on cpu %d\n", EventId, CpuNum= ber));=0D =0D Status =3D EFI_SUCCESS;=0D - //=0D - // ARM TF passes SMC FID of the MM_COMMUNICATE interface as the Event ID= upon=0D - // receipt of a synchronous MM request. Use the Event ID to distinguish= =0D - // between synchronous and asynchronous events.=0D - //=0D - if ((ARM_SMC_ID_MM_COMMUNICATE !=3D EventId) &&=0D - (ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ !=3D EventId))=0D - {=0D - DEBUG ((DEBUG_ERROR, "UnRecognized Event - 0x%x\n", EventId));=0D - return EFI_INVALID_PARAMETER;=0D - }=0D =0D // Perform parameter validation of NsCommBufferAddr=0D if (NsCommBufferAddr =3D=3D (UINTN)NULL) {=0D @@ -177,7 +162,7 @@ PiMmStandaloneArmTfCpuDriverEntry ( }=0D =0D // X1 contains the VA of the normal world memory accessible from=0D - // S-EL0=0D + // secure world.=0D CopyMem (GuidedEventContext, (CONST VOID *)NsCommBufferAddr, NsCommBuffe= rSize);=0D =0D // Stash the pointer to the allocated Event Context for this CPU=0D diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c b/St= andaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c index 3d1dc6181bd9..c5ec1a5a80c5 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c @@ -3,6 +3,7 @@ Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
=0D Copyright (c) 2016 HP Development Company, L.P.=0D Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.=0D + Copyright (c) 2023, Ventana Micro System Inc. All rights reserved.=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -10,10 +11,7 @@ =0D #include =0D #include =0D -#include =0D #include =0D -#include =0D -#include =0D #include =0D #include =0D =0D @@ -22,7 +20,7 @@ #include =0D #include =0D =0D -#include "StandaloneMmCpu.h"=0D +#include =0D =0D // GUID to identify HOB with whereabouts of communication buffer with Norm= al=0D // World=0D @@ -31,7 +29,7 @@ extern EFI_GUID gEfiStandaloneMmNonSecureBufferGuid; // GUID to identify HOB where the entry point of this CPU driver will be=0D // populated to allow the entry point driver to invoke it upon receipt of = an=0D // event=0D -extern EFI_GUID gEfiArmTfCpuDriverEpDescriptorGuid;=0D +extern EFI_GUID gEfiMmCpuDriverEpDescriptorGuid;=0D =0D //=0D // Private copy of the MM system table for future use=0D @@ -96,17 +94,17 @@ StandaloneMmCpuInitialize ( IN EFI_MM_SYSTEM_TABLE *SystemTable // not actual systemtable=0D )=0D {=0D - ARM_TF_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc;=0D - EFI_CONFIGURATION_TABLE *ConfigurationTable;=0D - MP_INFORMATION_HOB_DATA *MpInformationHobData;=0D - EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange;=0D - EFI_STATUS Status;=0D - EFI_HANDLE DispatchHandle;=0D - UINT32 MpInfoSize;=0D - UINTN Index;=0D - UINTN ArraySize;=0D - VOID *HobStart;=0D - EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob;=0D + MM_CPU_DRIVER_EP_DESCRIPTOR *CpuDriverEntryPointDesc;=0D + EFI_CONFIGURATION_TABLE *ConfigurationTable;=0D + MP_INFORMATION_HOB_DATA *MpInformationHobData;=0D + EFI_MMRAM_DESCRIPTOR *NsCommBufMmramRange;=0D + EFI_STATUS Status;=0D + EFI_HANDLE DispatchHandle;=0D + UINT32 MpInfoSize;=0D + UINTN Index;=0D + UINTN ArraySize;=0D + VOID *HobStart;=0D + EFI_MMRAM_HOB_DESCRIPTOR_BLOCK *MmramRangesHob;=0D =0D ASSERT (SystemTable !=3D NULL);=0D mMmst =3D SystemTable;=0D @@ -133,7 +131,7 @@ StandaloneMmCpuInitialize ( }=0D =0D // Retrieve the Hoblist from the MMST to extract the details of the NS=0D - // communication buffer that has been reserved by S-EL1/EL3=0D + // communication buffer that has been reserved for StandaloneMmPkg=0D ConfigurationTable =3D mMmst->MmConfigurationTable;=0D for (Index =3D 0; Index < mMmst->NumberOfTableEntries; Index++) {=0D if (CompareGuid (&gEfiHobListGuid, &(ConfigurationTable[Index].VendorG= uid))) {=0D @@ -154,11 +152,11 @@ StandaloneMmCpuInitialize ( //=0D Status =3D GetGuidedHobData (=0D HobStart,=0D - &gEfiArmTfCpuDriverEpDescriptorGuid,=0D + &gEfiMmCpuDriverEpDescriptorGuid,=0D (VOID **)&CpuDriverEntryPointDesc=0D );=0D if (EFI_ERROR (Status)) {=0D - DEBUG ((DEBUG_ERROR, "ArmTfCpuDriverEpDesc HOB data extraction failed = - 0x%x\n", Status));=0D + DEBUG ((DEBUG_ERROR, "MmCpuDriverEpDesc HOB data extraction failed - 0= x%x\n", Status));=0D return Status;=0D }=0D =0D @@ -166,10 +164,10 @@ StandaloneMmCpuInitialize ( DEBUG ((=0D DEBUG_INFO,=0D "Sharing Cpu Driver EP *0x%lx =3D 0x%lx\n",=0D - (UINTN)CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr,=0D - (UINTN)PiMmStandaloneArmTfCpuDriverEntry=0D + (UINTN)CpuDriverEntryPointDesc->MmCpuDriverEpPtr,=0D + (UINTN)PiMmStandaloneMmCpuDriverEntry=0D ));=0D - *(CpuDriverEntryPointDesc->ArmTfCpuDriverEpPtr) =3D PiMmStandaloneArmTfC= puDriverEntry;=0D + *(CpuDriverEntryPointDesc->MmCpuDriverEpPtr) =3D PiMmStandaloneMmCpuDriv= erEntry;=0D =0D // Find the descriptor that contains the whereabouts of the buffer for=0D // communication with the Normal world.=0D diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf b/= StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf index 1fcb17d89d36..486ccbac1b7c 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf +++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf @@ -1,9 +1,10 @@ ## @file=0D -# Standalone MM CPU driver for ARM Standard Platforms=0D +# Standalone MM CPU driver=0D #=0D # Copyright (c) 2009, Apple Inc. All rights reserved.
=0D # Copyright (c) 2016 HP Development Company, L.P.=0D # Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.=0D +# Copyright (c) 2023, Ventana Micro System Inc. All rights reserved.=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D ##=0D @@ -19,18 +20,14 @@ =0D [Sources]=0D StandaloneMmCpu.c=0D - StandaloneMmCpu.h=0D EventHandle.c=0D =0D [Packages]=0D - ArmPkg/ArmPkg.dec=0D MdePkg/MdePkg.dec=0D MdeModulePkg/MdeModulePkg.dec=0D StandaloneMmPkg/StandaloneMmPkg.dec=0D =0D [LibraryClasses]=0D - ArmLib=0D - ArmSvcLib=0D BaseMemoryLib=0D DebugLib=0D HobLib=0D @@ -46,7 +43,7 @@ gZeroGuid=0D gMpInformationHobGuid=0D gEfiStandaloneMmNonSecureBufferGuid=0D - gEfiArmTfCpuDriverEpDescriptorGuid=0D + gEfiMmCpuDriverEpDescriptorGuid=0D =0D [Depex]=0D TRUE=0D diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h b/St= andaloneMmPkg/Include/StandaloneMmCpu.h similarity index 82% rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h rename to StandaloneMmPkg/Include/StandaloneMmCpu.h index 3d4698ec1957..1dce7c132ec2 100644 --- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h +++ b/StandaloneMmPkg/Include/StandaloneMmCpu.h @@ -7,14 +7,26 @@ =0D **/=0D =0D -#ifndef _ARM_TF_CPU_DRIVER_H_=0D -#define _ARM_TF_CPU_DRIVER_H_=0D +#ifndef MM_CPU_DRIVER_H_=0D +#define MM_CPU_DRIVER_H_=0D =0D #include =0D #include =0D #include =0D #include =0D =0D +typedef=0D +EFI_STATUS=0D +(*PI_MM_CPU_DRIVER_ENTRYPOINT) (=0D + IN UINTN EventId,=0D + IN UINTN CpuNumber,=0D + IN UINTN NsCommBufferAddr=0D + );=0D +=0D +typedef struct {=0D + PI_MM_CPU_DRIVER_ENTRYPOINT *MmCpuDriverEpPtr;=0D +} MM_CPU_DRIVER_EP_DESCRIPTOR;=0D +=0D //=0D // CPU driver initialization specific declarations=0D //=0D @@ -35,7 +47,7 @@ extern MP_INFORMATION_HOB_DATA *mMpInformationHobD= ata; extern EFI_MM_CONFIGURATION_PROTOCOL mMmConfig;=0D =0D /**=0D - The PI Standalone MM entry point for the TF-A CPU driver.=0D + The PI Standalone MM entry point for the CPU driver.=0D =0D @param [in] EventId The event Id.=0D @param [in] CpuNumber The CPU number.=0D @@ -48,7 +60,7 @@ extern EFI_MM_CONFIGURATION_PROTOCOL mMmConfig; @retval EFI_UNSUPPORTED Operation not supported.=0D **/=0D EFI_STATUS=0D -PiMmStandaloneArmTfCpuDriverEntry (=0D +PiMmStandaloneMmCpuDriverEntry (=0D IN UINTN EventId,=0D IN UINTN CpuNumber,=0D IN UINTN NsCommBufferAddr=0D @@ -79,4 +91,4 @@ PiMmCpuTpFwRootMmiHandler ( IN OUT UINTN *CommBufferSize OPTIONAL=0D );=0D =0D -#endif=0D +#endif /* MM_CPU_DRIVER_H_ */=0D diff --git a/StandaloneMmPkg/StandaloneMmPkg.dec b/StandaloneMmPkg/Standalo= neMmPkg.dec index 46784d94e421..f7cb9e8e2687 100644 --- a/StandaloneMmPkg/StandaloneMmPkg.dec +++ b/StandaloneMmPkg/StandaloneMmPkg.dec @@ -46,5 +46,5 @@ gEfiMmPeiMmramMemoryReserveGuid =3D { 0x0703f912, 0xbf8d, 0x4e2= a, { 0xbe, 0x07, 0xab, 0x27, 0x25, 0x25, 0xc5, 0x92 }}=0D =0D gEfiStandaloneMmNonSecureBufferGuid =3D { 0xf00497e3, 0xbfa2, 0x41a= 1, { 0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 }}=0D - gEfiArmTfCpuDriverEpDescriptorGuid =3D { 0x6ecbd5a1, 0xc0f8, 0x470= 2, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }}=0D + gEfiMmCpuDriverEpDescriptorGuid =3D { 0x6ecbd5a1, 0xc0f8, 0x470= 2, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }}=0D =0D --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#108661): https://edk2.groups.io/g/devel/message/108661 Mute This Topic: https://groups.io/mt/101369646/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-