From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1278.1689086251887077554 for ; Tue, 11 Jul 2023 07:37:31 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: nishant.sharma@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CD0601FB; Tue, 11 Jul 2023 07:38:13 -0700 (PDT) Received: from usa.arm.com (iss-desktop02.cambridge.arm.com [10.1.196.79]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AF7883F740; Tue, 11 Jul 2023 07:37:30 -0700 (PDT) From: "Nishant Sharma" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Thomas Abraham , Sayanta Pattanayak , Achin Gupta Subject: [edk2-platforms][PATCH V1 16/20] ArmPkg/MmCommunicationDxe: Register FF-A RX/TX buffers Date: Tue, 11 Jul 2023 15:36:54 +0100 Message-Id: <20230711143658.781597-17-nishant.sharma@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711143658.781597-1-nishant.sharma@arm.com> References: <20230711143658.781597-1-nishant.sharma@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Achin Gupta This patch statically allocates an FF-A RX/TX buffer pair and registers them with the framework. This enables discovery of the StMM SP in a subsequent patch. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Include/IndustryStandard/ArmFfaSvc.h | 2 ++ ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 20 +++++++++++++++= +++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h b/ArmPkg/Include= /IndustryStandard/ArmFfaSvc.h index 20eeb822ea56..ebdf29e8d69a 100644 --- a/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h +++ b/ArmPkg/Include/IndustryStandard/ArmFfaSvc.h @@ -17,6 +17,8 @@ #define ARM_FFA_SVC_H_ =20 #define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063 +#define ARM_SVC_ID_FFA_RXTX_MAP_AARCH32 0x84000066 +#define ARM_SVC_ID_FFA_RXTX_MAP_AARCH64 0xC4000066 #define ARM_SVC_ID_FFA_ID_GET_AARCH32 0x84000069 #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F #define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070 diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg= /Drivers/MmCommunicationDxe/MmCommunication.c index f907ccf7349f..8a4d46e4f80a 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -28,6 +28,12 @@ // STATIC UINT16 mFfaPartId; =20 +// +// RX/TX pair if FF-A support is enabled +// +STATIC UINT8 FfaRxBuf[EFI_PAGE_SIZE] __attribute__ ((aligned (EFI_PAGE_S= IZE))); +STATIC UINT8 FfaTxBuf[EFI_PAGE_SIZE] __attribute__ ((aligned (EFI_PAGE_S= IZE))); + // // Address, Length of the pre-allocated buffer for communication with th= e secure // world. @@ -293,9 +299,8 @@ GetMmCompatibility ( Status =3D EFI_UNSUPPORTED; } =20 - // If FF-A is supported then discover our ID. + // If FF-A is supported then discover our ID and register our RX/TX bu= ffers. if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { - // Get our ID ZeroMem(&SmcArgs, sizeof(SmcArgs)); SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_ID_GET_AARCH32; @@ -307,6 +312,17 @@ GetMmCompatibility ( DEBUG ((DEBUG_INFO, "FF-A partition ID =3D 0x%lx.\n", SmcArgs.Arg2))= ; mFfaPartId =3D SmcArgs.Arg2; =20 + // Register our RX/TX pair + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_RXTX_MAP_AARCH64; + SmcArgs.Arg1 =3D (UINTN) FfaTxBuf; + SmcArgs.Arg2 =3D (UINTN) FfaRxBuf; + SmcArgs.Arg3 =3D EFI_PAGE_SIZE / SIZE_4KB; + ArmCallSmc (&SmcArgs); + if (SmcArgs.Arg0 =3D=3D ARM_SVC_ID_FFA_ERROR_AARCH32) { + DEBUG ((DEBUG_ERROR, "Unable to register FF-A RX/TX buffers (%d).\= n", SmcArgs.Arg2)); + return EFI_UNSUPPORTED; + } + return EFI_SUCCESS; } =20 --=20 2.34.1