blob: a396b99181b6c5ec256ebca8ee256372c3f751c4 [file] [log] [blame]
Dimitris Papastamose08005a2017-10-12 13:02:29 +01001/*
Elizabeth Ho4fc00d22023-07-18 14:10:25 +01002 * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved.
Dimitris Papastamose08005a2017-10-12 13:02:29 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +01007#ifndef AMU_H
8#define AMU_H
Dimitris Papastamose08005a2017-10-12 13:02:29 +01009
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010010#include <stdbool.h>
Chris Kayf11909f2021-08-19 11:21:52 +010011#include <stdint.h>
12
Arunachalam Ganapathycac7d162021-07-08 09:35:57 +010013#include <context.h>
Alexei Fedorov7e6306b2020-07-14 08:17:56 +010014
Chris Kayf11909f2021-08-19 11:21:52 +010015#include <platform_def.h>
16
Andre Przywara906776e2023-03-03 10:30:06 +000017#if ENABLE_FEAT_AMU
Arunachalam Ganapathycac7d162021-07-08 09:35:57 +010018#if __aarch64__
Boyan Karatotev1e966f32023-03-27 17:02:43 +010019void amu_enable(cpu_context_t *ctx);
20void amu_init_el3(void);
21void amu_init_el2_unused(void);
Elizabeth Ho4fc00d22023-07-18 14:10:25 +010022void amu_enable_per_world(per_world_context_t *per_world_ctx);
Arunachalam Ganapathycac7d162021-07-08 09:35:57 +010023#else
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010024void amu_enable(bool el2_unused);
Elizabeth Ho4fc00d22023-07-18 14:10:25 +010025#endif /* __aarch64__ */
26
Andre Przywara906776e2023-03-03 10:30:06 +000027#else
28#if __aarch64__
Boyan Karatotev1e966f32023-03-27 17:02:43 +010029void amu_enable(cpu_context_t *ctx)
30{
31}
32void amu_init_el3(void)
33{
34}
35void amu_init_el2_unused(void)
Andre Przywara906776e2023-03-03 10:30:06 +000036{
37}
Elizabeth Ho4fc00d22023-07-18 14:10:25 +010038void amu_enable_per_world(per_world_context_t *per_world_ctx)
39{
40}
Andre Przywara906776e2023-03-03 10:30:06 +000041#else
42static inline void amu_enable(bool el2_unused)
43{
44}
Elizabeth Ho4fc00d22023-07-18 14:10:25 +010045#endif /*__aarch64__ */
46#endif /* ENABLE_FEAT_AMU */
Dimitris Papastamose08005a2017-10-12 13:02:29 +010047
Chris Kayf11909f2021-08-19 11:21:52 +010048#if ENABLE_AMU_AUXILIARY_COUNTERS
49/*
50 * AMU data for a single core.
51 */
52struct amu_core {
53 uint16_t enable; /* Mask of auxiliary counters to enable */
54};
55
56/*
57 * Topological platform data specific to the AMU.
58 */
59struct 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 */
68const struct amu_topology *plat_amu_topology(void);
69#endif /* ENABLE_AMU_FCONF */
70#endif /* ENABLE_AMU_AUXILIARY_COUNTERS */
71
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010072#endif /* AMU_H */