blob: 09d8deec0767958b023971449408449ab18e7157 [file] [log] [blame]
Dimitris Papastamose08005a2017-10-12 13:02:29 +01001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * Copyright (c) 2017-2021, 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);
Arunachalam Ganapathycac7d162021-07-08 09:35:57 +010022#else
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010023void amu_enable(bool el2_unused);
Arunachalam Ganapathycac7d162021-07-08 09:35:57 +010024#endif
Andre Przywara906776e2023-03-03 10:30:06 +000025#else
26#if __aarch64__
Boyan Karatotev1e966f32023-03-27 17:02:43 +010027void amu_enable(cpu_context_t *ctx)
28{
29}
30void amu_init_el3(void)
31{
32}
33void amu_init_el2_unused(void)
Andre Przywara906776e2023-03-03 10:30:06 +000034{
35}
36#else
37static inline void amu_enable(bool el2_unused)
38{
39}
40#endif
41#endif
Dimitris Papastamose08005a2017-10-12 13:02:29 +010042
Chris Kayf11909f2021-08-19 11:21:52 +010043#if ENABLE_AMU_AUXILIARY_COUNTERS
44/*
45 * AMU data for a single core.
46 */
47struct amu_core {
48 uint16_t enable; /* Mask of auxiliary counters to enable */
49};
50
51/*
52 * Topological platform data specific to the AMU.
53 */
54struct amu_topology {
55 struct amu_core cores[PLATFORM_CORE_COUNT]; /* Per-core data */
56};
57
58#if !ENABLE_AMU_FCONF
59/*
60 * Retrieve the platform's AMU topology. A `NULL` return value is treated as a
61 * non-fatal error, in which case no auxiliary counters will be enabled.
62 */
63const struct amu_topology *plat_amu_topology(void);
64#endif /* ENABLE_AMU_FCONF */
65#endif /* ENABLE_AMU_AUXILIARY_COUNTERS */
66
Antonio Nino Diaz033b4bb2018-10-25 16:52:26 +010067#endif /* AMU_H */