summaryrefslogtreecommitdiffstats
path: root/include/lib/extensions/amu.h
blob: a396b99181b6c5ec256ebca8ee256372c3f751c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * Copyright (c) 2017-2023, Arm Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef AMU_H
#define AMU_H

#include <stdbool.h>
#include <stdint.h>

#include <context.h>

#include <platform_def.h>

#if ENABLE_FEAT_AMU
#if __aarch64__
void amu_enable(cpu_context_t *ctx);
void amu_init_el3(void);
void amu_init_el2_unused(void);
void amu_enable_per_world(per_world_context_t *per_world_ctx);
#else
void amu_enable(bool el2_unused);
#endif /* __aarch64__ */

#else
#if __aarch64__
void amu_enable(cpu_context_t *ctx)
{
}
void amu_init_el3(void)
{
}
void amu_init_el2_unused(void)
{
}
void amu_enable_per_world(per_world_context_t *per_world_ctx)
{
}
#else
static inline void amu_enable(bool el2_unused)
{
}
#endif /*__aarch64__ */
#endif /* ENABLE_FEAT_AMU */

#if ENABLE_AMU_AUXILIARY_COUNTERS
/*
 * AMU data for a single core.
 */
struct amu_core {
	uint16_t enable; /* Mask of auxiliary counters to enable */
};

/*
 * Topological platform data specific to the AMU.
 */
struct amu_topology {
	struct amu_core cores[PLATFORM_CORE_COUNT]; /* Per-core data */
};

#if !ENABLE_AMU_FCONF
/*
 * Retrieve the platform's AMU topology. A `NULL` return value is treated as a
 * non-fatal error, in which case no auxiliary counters will be enabled.
 */
const struct amu_topology *plat_amu_topology(void);
#endif /* ENABLE_AMU_FCONF */
#endif /* ENABLE_AMU_AUXILIARY_COUNTERS */

#endif /* AMU_H */