refactor(amu): detect architected counters at runtime
This change removes the `AMU_GROUP0_COUNTERS_MASK` and
`AMU_GROUP0_MAX_COUNTERS` preprocessor definitions, instead retrieving
the number of group 0 counters dynamically through `AMCGCR_EL0.CG0NC`.
Change-Id: I70e39c30fbd5df89b214276fac79cc8758a89f72
Signed-off-by: Chris Kay <chris.kay@arm.com>
diff --git a/include/lib/extensions/amu_private.h b/include/lib/extensions/amu_private.h
index db44e64..9b4c29c 100644
--- a/include/lib/extensions/amu_private.h
+++ b/include/lib/extensions/amu_private.h
@@ -15,9 +15,7 @@
#include <platform_def.h>
-/* All group 0 counters */
-#define AMU_GROUP0_COUNTERS_MASK U(0xf)
-#define AMU_GROUP0_NR_COUNTERS U(4)
+#define AMU_GROUP0_MAX_COUNTERS U(16)
#if ENABLE_AMU_AUXILIARY_COUNTERS
#define AMU_GROUP1_COUNTERS_MASK U(0)
@@ -63,10 +61,10 @@
#endif
struct amu_ctx {
- uint64_t group0_cnts[AMU_GROUP0_NR_COUNTERS];
+ uint64_t group0_cnts[AMU_GROUP0_MAX_COUNTERS];
#if __aarch64__
/* Architected event counter 1 does not have an offset register. */
- uint64_t group0_voffsets[AMU_GROUP0_NR_COUNTERS-1];
+ uint64_t group0_voffsets[AMU_GROUP0_MAX_COUNTERS-1];
#endif
#if ENABLE_AMU_AUXILIARY_COUNTERS