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.web08.12685.1656515281185269485 for ; Wed, 29 Jun 2022 08:08:01 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@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 1DD5A1A32; Wed, 29 Jun 2022 08:08:01 -0700 (PDT) Received: from pierre123.arm.com (unknown [10.57.42.208]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 45C473F792; Wed, 29 Jun 2022 08:07:59 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Edward Pickup Subject: [PATCH v1 4/7] ArmPkg/ArmLib: Add ArmHasAesExt() Date: Wed, 29 Jun 2022 17:07:10 +0200 Message-Id: <20220629150713.2600465-5-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220629150713.2600465-1-Pierre.Gondois@arm.com> References: <20220629150713.2600465-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pierre Gondois Add a ArmHasAesExt() to check for the FEAT_AES extension. Signed-off-by: Pierre Gondois --- ArmPkg/Include/Library/ArmLib.h | 12 +++++++++++- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c | 13 +++++++++++++ ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h | 1 + ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c | 13 +++++++++++++ ArmPkg/Library/ArmLib/Arm/ArmV7Lib.h | 2 ++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/Arm= Lib.h index 8058634dbc53..5cd2bc1a26e5 100644 --- a/ArmPkg/Include/Library/ArmLib.h +++ b/ArmPkg/Include/Library/ArmLib.h @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2022, Arm Limited. All rights reserved.
+ Copyright (c) 2011 - 2022, Arm Ltd. All rights reserved.
Copyright (c) 2020 - 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -779,6 +779,16 @@ ArmHasRngExt ( VOID ); =20 +/** Check if FEAT_AES extension is available. + + @retval TRUE if FEAT_AES extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasAesExt ( + VOID + ); + #ifdef MDE_CPU_ARM /// /// AArch32-only ID Register Helper functions diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c b/ArmPkg/Library/= ArmLib/AArch64/AArch64Lib.c index 124b28e16874..dac406362114 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c @@ -117,3 +117,16 @@ ArmHasRngExt ( { return ArmReadIdIsar0 () & ID_AA64ISAR0_EL1_RNDR_MASK; } + +/** Check if FEAT_AES extension is available. + + @retval TRUE if FEAT_AES extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasAesExt ( + VOID + ) +{ + return ArmReadIdIsar0 () & ID_AA64ISAR0_EL1_AES_MASK; +} diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h b/ArmPkg/Library/= ArmLib/AArch64/AArch64Lib.h index 61a775ea27e8..9f5ad3e0214f 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h @@ -11,6 +11,7 @@ #ifndef AARCH64_LIB_H_ #define AARCH64_LIB_H_ =20 +#define ID_AA64ISAR0_EL1_AES_MASK ((UINT64)0xF << 4U) #define ID_AA64ISAR0_EL1_RNDR_MASK ((UINT64)0xF << 60U) =20 typedef VOID (*AARCH64_CACHE_OPERATION)( diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c b/ArmPkg/Library/ArmLib= /Arm/ArmV7Lib.c index a4ec23c8f8d8..ee3a847c1b50 100644 --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c @@ -133,3 +133,16 @@ ArmHasRngExt ( // Not supported. return FALSE; } + +/** Check if FEAT_AES extension is available. + + @retval TRUE if FEAT_AES extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasAesExt ( + VOID + ) +{ + return ArmReadIdIsaR5 () & ID_ISAR5_AES_MASK; +} diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.h b/ArmPkg/Library/ArmLib= /Arm/ArmV7Lib.h index 1cfd6e5f65ac..1b91db66fb43 100644 --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.h +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.h @@ -10,6 +10,8 @@ #ifndef ARM_V7_LIB_H_ #define ARM_V7_LIB_H_ =20 +#define ID_ISAR5_AES_MASK (0xF << 4U) + #define ID_MMFR0_SHARELVL_SHIFT 12 #define ID_MMFR0_SHARELVL_MASK 0xf #define ID_MMFR0_SHARELVL_ONE 0 --=20 2.25.1