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.web11.1243.1689086249724439219 for ; Tue, 11 Jul 2023 07:37:29 -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 A1F9C1FB; Tue, 11 Jul 2023 07:38:11 -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 848D63F740; Tue, 11 Jul 2023 07:37:28 -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 14/20] ArmPkg/MmCommunicationDxe: Introduce FF-A version check Date: Tue, 11 Jul 2023 15:36:52 +0100 Message-Id: <20230711143658.781597-15-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 adds support for querying whether FF-A v1.1 is supported by th= e FF-A impplementation. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf | 3 +++ ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h | 7 ++++++- ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 17 ++++++++++++-= ---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf b/ArmP= kg/Drivers/MmCommunicationDxe/MmCommunication.inf index 05b6de73ff34..c15b1a7a86ae 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf @@ -31,6 +31,9 @@ ArmPkg/ArmPkg.dec MdePkg/MdePkg.dec =20 +[FixedPcd] + gArmTokenSpaceGuid.PcdFfaEnable + [LibraryClasses] ArmLib ArmSmcLib diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h b/ArmPkg/D= rivers/MmCommunicationDxe/MmCommunicate.h index 5c5fcb576856..71edf7f49174 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunicate.h @@ -16,7 +16,12 @@ #define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIF= T) #define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK) =20 +#if (FixedPcdGet32 (PcdFfaEnable) =3D=3D 1) #define MM_CALLER_MAJOR_VER 0x1UL -#define MM_CALLER_MINOR_VER 0x0 +#define MM_CALLER_MINOR_VER 0x1UL +#else +#define MM_CALLER_MAJOR_VER 0x1UL +#define MM_CALLER_MINOR_VER 0x0UL +#endif =20 #endif /* MM_COMMUNICATE_H_ */ diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg= /Drivers/MmCommunicationDxe/MmCommunication.c index 85d9034555f0..a6fcd590a65b 100644 --- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c +++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c @@ -18,6 +18,7 @@ =20 #include =20 +#include #include =20 #include "MmCommunicate.h" @@ -250,14 +251,20 @@ GetMmCompatibility ( { EFI_STATUS Status; UINT32 MmVersion; - ARM_SMC_ARGS MmVersionArgs; + ARM_SMC_ARGS SmcArgs =3D {0}; =20 - // MM_VERSION uses SMC32 calling conventions - MmVersionArgs.Arg0 =3D ARM_SMC_ID_MM_VERSION_AARCH32; + if (FixedPcdGet32 (PcdFfaEnable) !=3D 0) { + SmcArgs.Arg0 =3D ARM_SVC_ID_FFA_VERSION_AARCH32; + SmcArgs.Arg1 =3D MM_CALLER_MAJOR_VER << MM_MAJOR_VER_SHIFT; + SmcArgs.Arg1 |=3D MM_CALLER_MINOR_VER; + } else { + // MM_VERSION uses SMC32 calling conventions + SmcArgs.Arg0 =3D ARM_SMC_ID_MM_VERSION_AARCH32; + } =20 - ArmCallSmc (&MmVersionArgs); + ArmCallSmc (&SmcArgs); =20 - MmVersion =3D MmVersionArgs.Arg0; + MmVersion =3D SmcArgs.Arg0; =20 if ((MM_MAJOR_VER (MmVersion) =3D=3D MM_CALLER_MAJOR_VER) && (MM_MINOR_VER (MmVersion) >=3D MM_CALLER_MINOR_VER)) --=20 2.34.1