[edk2-devel] [PATCH v5 09/23] ArmPkg: Add helper to read CCIDX status

Rebecca Cran posted 23 patches 5 months, 2 weeks ago

[edk2-devel] [PATCH v5 09/23] ArmPkg: Add helper to read CCIDX status

Posted by Rebecca Cran 5 months, 2 weeks ago
Add a helper function to determine CCIDX support.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
---
 ArmPkg/Include/Library/ArmLib.h            | 11 +++++++++++
 ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c | 17 +++++++++++++++++
 ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c       | 17 +++++++++++++++++
 3 files changed, 45 insertions(+)

diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
index fd4f06d24274..70b9d816b74c 100644
--- a/ArmPkg/Include/Library/ArmLib.h
+++ b/ArmPkg/Include/Library/ArmLib.h
@@ -725,6 +725,17 @@ ArmHasGicSystemRegisters (
   VOID
   );
 
+/** Checks if CCIDX is implemented.
+
+   @retval TRUE  CCIDX is implemented.
+   @retval FALSE CCIDX is not implemented.
+**/
+BOOLEAN
+EFIAPI
+ArmHasCcidx (
+  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 53e593bc994b..f0bf897da2a6 100644
--- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c
+++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c
@@ -87,3 +87,20 @@ ArmHasGicSystemRegisters (
 {
   return ((ArmReadIdAA64Pfr0 () & AARCH64_PFR0_GIC) != 0);
 }
+
+/** Checks if CCIDX is implemented.
+
+   @retval TRUE  CCIDX is implemented.
+   @retval FALSE CCIDX is not implemented.
+**/
+BOOLEAN
+EFIAPI
+ArmHasCcidx (
+  VOID
+  )
+{
+  UINTN Mmfr2;
+
+  Mmfr2 = ArmReadIdAA64Mmfr2 ();
+  return (((Mmfr2 >> 20) & 0xF) == 1) ? TRUE : FALSE;
+}
diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c
index 9f81a7223732..f5f1939c8fa4 100644
--- a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c
+++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c
@@ -102,3 +102,20 @@ ArmHasSecurityExtensions (
 {
   return ((ArmReadIdPfr1 () & ARM_PFR1_SEC) != 0);
 }
+
+/** Checks if CCIDX is implemented.
+
+   @retval TRUE  CCIDX is implemented.
+   @retval FALSE CCIDX is not implemented.
+**/
+BOOLEAN
+EFIAPI
+ArmHasCcidx (
+  VOID
+  )
+{
+  UINTN Mmfr4;
+
+  Mmfr4 = ArmReadIdMmfr4 ();
+  return (((Mmfr4 >> 24) & 0xF) == 1) ? TRUE : FALSE;
+}
-- 
2.26.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#69647): https://edk2.groups.io/g/devel/message/69647
Mute This Topic: https://groups.io/mt/79438411/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-


Re: [edk2-devel] [PATCH v5 09/23] ArmPkg: Add helper to read CCIDX status

Posted by Leif Lindholm 5 months, 1 week ago
On Mon, Jan 04, 2021 at 15:58:16 -0700, Rebecca Cran wrote:
> Add a helper function to determine CCIDX support.
> 
> Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Reviewed-by: Leif Lindholm <leif@nuviainc.com>

> ---
>  ArmPkg/Include/Library/ArmLib.h            | 11 +++++++++++
>  ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c | 17 +++++++++++++++++
>  ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c       | 17 +++++++++++++++++
>  3 files changed, 45 insertions(+)
> 
> diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
> index fd4f06d24274..70b9d816b74c 100644
> --- a/ArmPkg/Include/Library/ArmLib.h
> +++ b/ArmPkg/Include/Library/ArmLib.h
> @@ -725,6 +725,17 @@ ArmHasGicSystemRegisters (
>    VOID
>    );
>  
> +/** Checks if CCIDX is implemented.
> +
> +   @retval TRUE  CCIDX is implemented.
> +   @retval FALSE CCIDX is not implemented.
> +**/
> +BOOLEAN
> +EFIAPI
> +ArmHasCcidx (
> +  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 53e593bc994b..f0bf897da2a6 100644
> --- a/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c
> +++ b/ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c
> @@ -87,3 +87,20 @@ ArmHasGicSystemRegisters (
>  {
>    return ((ArmReadIdAA64Pfr0 () & AARCH64_PFR0_GIC) != 0);
>  }
> +
> +/** Checks if CCIDX is implemented.
> +
> +   @retval TRUE  CCIDX is implemented.
> +   @retval FALSE CCIDX is not implemented.
> +**/
> +BOOLEAN
> +EFIAPI
> +ArmHasCcidx (
> +  VOID
> +  )
> +{
> +  UINTN Mmfr2;
> +
> +  Mmfr2 = ArmReadIdAA64Mmfr2 ();
> +  return (((Mmfr2 >> 20) & 0xF) == 1) ? TRUE : FALSE;
> +}
> diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c
> index 9f81a7223732..f5f1939c8fa4 100644
> --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c
> +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c
> @@ -102,3 +102,20 @@ ArmHasSecurityExtensions (
>  {
>    return ((ArmReadIdPfr1 () & ARM_PFR1_SEC) != 0);
>  }
> +
> +/** Checks if CCIDX is implemented.
> +
> +   @retval TRUE  CCIDX is implemented.
> +   @retval FALSE CCIDX is not implemented.
> +**/
> +BOOLEAN
> +EFIAPI
> +ArmHasCcidx (
> +  VOID
> +  )
> +{
> +  UINTN Mmfr4;
> +
> +  Mmfr4 = ArmReadIdMmfr4 ();
> +  return (((Mmfr4 >> 24) & 0xF) == 1) ? TRUE : FALSE;
> +}
> -- 
> 2.26.2
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70081): https://edk2.groups.io/g/devel/message/70081
Mute This Topic: https://groups.io/mt/79438411/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-