amu.h 1.4 KB

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