]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
refactor(amu): convert FEAT_AMUv1 to new scheme
authorAndre Przywara <andre.przywara@arm.com>
Thu, 10 Nov 2022 14:41:07 +0000 (14:41 +0000)
committerAndre Przywara <andre.przywara@arm.com>
Wed, 11 Jan 2023 16:02:58 +0000 (16:02 +0000)
For the FGT context save/restore operation, we need to look at the AMUv1
feature, so migrate this one over to the new scheme.
This uses the generic check function in feat_detect.c, and splits the
feature check into two functions, as was done before for FEAT_FGT.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Change-Id: I95ad797f15001b2c9d1800c9d4af33fba79e136f

common/feat_detect.c
include/arch/aarch64/arch_features.h

index cbbee977109126600816cb294b3bc47186f78ccd..9544b4f63b03e929bcc54d401e11d18ace820fa5 100644 (file)
@@ -121,16 +121,6 @@ static void read_feat_dit(void)
 #endif
 }
 
-/*********************************************************
- * Feature : FEAT_AMUv1 (Activity Monitors Extensions v1)
- ********************************************************/
-static void read_feat_amuv1(void)
-{
-#if (ENABLE_FEAT_AMUv1 == FEAT_STATE_ALWAYS)
-       feat_detect_panic(is_armv8_4_feat_amuv1_present(), "AMUv1");
-#endif
-}
-
 /****************************************************************************
  * Feature : FEAT_MPAM (Memory Partitioning and Monitoring (MPAM) Extension)
  ***************************************************************************/
@@ -332,7 +322,7 @@ void detect_arch_features(void)
 
        /* v8.4 features */
        read_feat_dit();
-       read_feat_amuv1();
+       check_feature(ENABLE_FEAT_AMUv1, read_feat_amu_id_field(), "AMUv1");
        read_feat_mpam();
        read_feat_nv2();
        read_feat_sel2();
index 73dfcef26fc2ffcb655be29411c4006f7cd2e26b..e959708255d11058a59155eddeb9aed5a57bdb7b 100644 (file)
@@ -129,10 +129,31 @@ static inline bool is_armv8_5_rng_present(void)
                ID_AA64ISAR0_RNDR_MASK);
 }
 
+/*******************************************************************************
+ * Functions to identify the presence of the Activity Monitors Extension
+ ******************************************************************************/
+static unsigned int read_feat_amu_id_field(void)
+{
+       return (read_id_aa64pfr0_el1() >> ID_AA64PFR0_AMU_SHIFT) &
+               ID_AA64PFR0_AMU_MASK;
+}
+
+static inline bool is_feat_amu_supported(void)
+{
+       if (ENABLE_FEAT_AMUv1 == FEAT_STATE_DISABLED) {
+               return false;
+       }
+
+       if (ENABLE_FEAT_AMUv1 == FEAT_STATE_ALWAYS) {
+               return true;
+       }
+
+       return read_feat_amu_id_field() >= ID_AA64PFR0_AMU_V1;
+}
+
 static inline bool is_armv8_6_feat_amuv1p1_present(void)
 {
-       return (((read_id_aa64pfr0_el1() >> ID_AA64PFR0_AMU_SHIFT) &
-               ID_AA64PFR0_AMU_MASK) >= ID_AA64PFR0_AMU_V1P1);
+       return read_feat_amu_id_field() >= ID_AA64PFR0_AMU_V1P1;
 }
 
 /*
@@ -240,16 +261,6 @@ static inline bool is_arm8_4_feat_trf_present(void)
                ID_AA64DFR0_TRACEFILT_MASK) == ID_AA64DFR0_TRACEFILT_SUPPORTED);
 }
 
-/*******************************************************************************
- * Function to identify the presence of FEAT_AMUv1 (Activity Monitors-
- * Extension v1)
- ******************************************************************************/
-static inline bool is_armv8_4_feat_amuv1_present(void)
-{
-       return (((read_id_aa64pfr0_el1() >> ID_AA64PFR0_AMU_SHIFT) &
-               ID_AA64PFR0_AMU_MASK) >= ID_AA64PFR0_AMU_V1);
-}
-
 /********************************************************************************
  * Function to identify the presence of FEAT_NV2 (Enhanced Nested Virtualization
  * Support)