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.8554.1658500367452020371 for ; Fri, 22 Jul 2022 07:32:47 -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 AA18A1477; Fri, 22 Jul 2022 07:32:47 -0700 (PDT) Received: from pierre123.arm.com (pierre123.nice.arm.com [10.34.100.102]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9B0FD3F70D; Fri, 22 Jul 2022 07:32:45 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang , Pierre Gondois Subject: [PATCH v4 11/21] ArmPkg/ArmLib: Add ArmHasRngExt() Date: Fri, 22 Jul 2022 16:31:43 +0200 Message-Id: <20220722143153.913585-12-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220722143153.913585-1-Pierre.Gondois@arm.com> References: <20220722143153.913585-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pierre Gondois Add a ArmHasRngExt() to check for the FEAT_RNG extension. Also add a mask for the RNDR bits. Signed-off-by: Pierre Gondois --- ArmPkg/Include/Library/ArmLib.h | 12 +++++++++++- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c | 15 ++++++++++++++- ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h | 2 ++ ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c | 16 +++++++++++++++- 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/Arm= Lib.h index 6566deebdde2..8058634dbc53 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 - 2016, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2022, Arm Limited. All rights reserved.
Copyright (c) 2020 - 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -769,6 +769,16 @@ ArmHasCcidx ( VOID ); =20 +/** Check if FEAT_RNG extension is available. + + @retval TRUE if FEAT_RNG extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasRngExt ( + 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 7ab28e3e05fe..124b28e16874 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.
+ Portions copyright (c) 2011 - 2022, Arm Limited. All rights reserved.<= BR> Copyright (c) 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -104,3 +104,16 @@ ArmHasCcidx ( Mmfr2 =3D ArmReadIdAA64Mmfr2 (); return (((Mmfr2 >> 20) & 0xF) =3D=3D 1) ? TRUE : FALSE; } + +/** Check if FEAT_RNG extension is available. + + @retval TRUE if FEAT_RNG extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasRngExt ( + VOID + ) +{ + return ArmReadIdIsar0 () & ID_AA64ISAR0_EL1_RNDR_MASK; +} diff --git a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h b/ArmPkg/Library/= ArmLib/AArch64/AArch64Lib.h index 105a52ee16fe..61a775ea27e8 100644 --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.h @@ -11,6 +11,8 @@ #ifndef AARCH64_LIB_H_ #define AARCH64_LIB_H_ =20 +#define ID_AA64ISAR0_EL1_RNDR_MASK ((UINT64)0xF << 60U) + typedef VOID (*AARCH64_CACHE_OPERATION)( UINTN ); diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c b/ArmPkg/Library/ArmLib= /Arm/ArmV7Lib.c index 521d5be0de33..a4ec23c8f8d8 100644 --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c @@ -1,7 +1,7 @@ /** @file =20 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2014, ARM Limited. All rights reserved. + Copyright (c) 2011 - 2022, Arm Limited. All rights reserved. Copyright (c) 2021, NUVIA Inc. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -119,3 +119,17 @@ ArmHasCcidx ( Mmfr4 =3D ArmReadIdMmfr4 (); return (((Mmfr4 >> 24) & 0xF) =3D=3D 1) ? TRUE : FALSE; } + +/** Check if FEAT_RNG extension is available. + + @retval TRUE if FEAT_RNG extension is available. + @retval FALSE otherwise. +**/ +BOOLEAN +ArmHasRngExt ( + VOID + ) +{ + // Not supported. + return FALSE; +} --=20 2.25.1