]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmLib: add ArmHasGicSystemRegisters () helper function
authorLeif Lindholm <leif@nuviainc.com>
Fri, 18 Dec 2020 11:55:52 +0000 (11:55 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 18 Dec 2020 15:27:26 +0000 (15:27 +0000)
Create a helper function to eliminate direct feature register reading,
which gets messy in code shared between ARM/AArch64.

Returns BOOLEAN True if the CPU implements the GIC System Register
Interface (any version), otherwise returns BOOL False.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
ArmPkg/Include/Library/ArmLib.h
ArmPkg/Library/ArmLib/AArch64/AArch64Lib.c
ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c

index 5a27b7c2fc274abaeb2ae2a0f74d627fdc342fa6..8a364f2ca96fef41eaef1faa7ad55b49d2dc757f 100644 (file)
@@ -2,6 +2,7 @@
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
   Copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2020, NUVIA Inc. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -715,4 +716,21 @@ ArmGetPhysicalAddressBits (
   VOID\r
   );\r
 \r
+\r
+///\r
+///  ID Register Helper functions\r
+///\r
+\r
+/**\r
+  Check whether the CPU supports the GIC system register interface (any version)\r
+\r
+  @return   Whether GIC System Register Interface is supported\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ArmHasGicSystemRegisters (\r
+  VOID\r
+  );\r
+\r
 #endif // __ARM_LIB__\r
index 3fbd591192e270131af594cca53f1babd7cb0489..5b10eb33c97d00c45b928d8e260d851fb793ddb0 100644 (file)
@@ -2,6 +2,7 @@
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
   Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2020, NUVIA Inc. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -71,3 +72,18 @@ ArmCleanDataCache (
   ArmDataSynchronizationBarrier ();\r
   AArch64DataCacheOperation (ArmCleanDataCacheEntryBySetWay);\r
 }\r
+\r
+/**\r
+  Check whether the CPU supports the GIC system register interface (any version)\r
+\r
+  @return   Whether GIC System Register Interface is supported\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ArmHasGicSystemRegisters (\r
+  VOID\r
+  )\r
+{\r
+  return ((ArmReadIdPfr0 () & AARCH64_PFR0_GIC) != 0);\r
+}\r
index 2c4a23e1a1b2a5e183b052716e51598b2d47a19a..3faada3a653945bc8a706ef288a152f499ae7859 100644 (file)
@@ -2,6 +2,7 @@
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
   Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.\r
+  Copyright (c) 2020, NUVIA Inc. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -71,3 +72,18 @@ ArmCleanDataCache (
   ArmDataSynchronizationBarrier ();\r
   ArmV7DataCacheOperation (ArmCleanDataCacheEntryBySetWay);\r
 }\r
+\r
+/**\r
+  Check whether the CPU supports the GIC system register interface (any version)\r
+\r
+  @return   Whether GIC System Register Interface is supported\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ArmHasGicSystemRegisters (\r
+  VOID\r
+  )\r
+{\r
+  return ((ArmReadIdPfr1 () & ARM_PFR1_GIC) != 0);\r
+}\r