1 /* 2 * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef AMU_H 8 #define AMU_H 9 10 #include <stdbool.h> 11 #include <stdint.h> 12 13 #include <context.h> 14 15 #include <platform_def.h> 16 17 #if ENABLE_FEAT_AMU 18 #if __aarch64__ 19 void amu_enable(cpu_context_t *ctx); 20 void amu_init_el3(void); 21 void amu_init_el2_unused(void); 22 void amu_enable_per_world(per_world_context_t *per_world_ctx); 23 #else 24 void amu_enable(bool el2_unused); 25 #endif /* __aarch64__ */ 26 27 #else 28 #if __aarch64__ amu_enable(cpu_context_t * ctx)29void amu_enable(cpu_context_t *ctx) 30 { 31 } amu_init_el3(void)32void amu_init_el3(void) 33 { 34 } amu_init_el2_unused(void)35void amu_init_el2_unused(void) 36 { 37 } amu_enable_per_world(per_world_context_t * per_world_ctx)38void amu_enable_per_world(per_world_context_t *per_world_ctx) 39 { 40 } 41 #else amu_enable(bool el2_unused)42static inline void amu_enable(bool el2_unused) 43 { 44 } 45 #endif /*__aarch64__ */ 46 #endif /* ENABLE_FEAT_AMU */ 47 48 #if ENABLE_AMU_AUXILIARY_COUNTERS 49 /* 50 * AMU data for a single core. 51 */ 52 struct amu_core { 53 uint16_t enable; /* Mask of auxiliary counters to enable */ 54 }; 55 56 /* 57 * Topological platform data specific to the AMU. 58 */ 59 struct amu_topology { 60 struct amu_core cores[PLATFORM_CORE_COUNT]; /* Per-core data */ 61 }; 62 63 #if !ENABLE_AMU_FCONF 64 /* 65 * Retrieve the platform's AMU topology. A `NULL` return value is treated as a 66 * non-fatal error, in which case no auxiliary counters will be enabled. 67 */ 68 const struct amu_topology *plat_amu_topology(void); 69 #endif /* ENABLE_AMU_FCONF */ 70 #endif /* ENABLE_AMU_AUXILIARY_COUNTERS */ 71 72 #endif /* AMU_H */ 73