Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 1 | /* |
johpow01 | fa59c6f | 2020-10-02 13:41:11 -0500 | [diff] [blame] | 2 | * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved. |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 7 | #ifndef AMU_H |
| 8 | #define AMU_H |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 9 | |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 10 | #include <stdbool.h> |
Chris Kay | f11909f | 2021-08-19 11:21:52 +0100 | [diff] [blame] | 11 | #include <stdint.h> |
| 12 | |
Arunachalam Ganapathy | cac7d16 | 2021-07-08 09:35:57 +0100 | [diff] [blame] | 13 | #include <context.h> |
Alexei Fedorov | 7e6306b | 2020-07-14 08:17:56 +0100 | [diff] [blame] | 14 | |
Chris Kay | f11909f | 2021-08-19 11:21:52 +0100 | [diff] [blame] | 15 | #include <platform_def.h> |
| 16 | |
Andre Przywara | 906776e | 2023-03-03 10:30:06 +0000 | [diff] [blame] | 17 | #if ENABLE_FEAT_AMU |
Arunachalam Ganapathy | cac7d16 | 2021-07-08 09:35:57 +0100 | [diff] [blame] | 18 | #if __aarch64__ |
Boyan Karatotev | 1e966f3 | 2023-03-27 17:02:43 +0100 | [diff] [blame] | 19 | void amu_enable(cpu_context_t *ctx); |
| 20 | void amu_init_el3(void); |
| 21 | void amu_init_el2_unused(void); |
Arunachalam Ganapathy | cac7d16 | 2021-07-08 09:35:57 +0100 | [diff] [blame] | 22 | #else |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 23 | void amu_enable(bool el2_unused); |
Arunachalam Ganapathy | cac7d16 | 2021-07-08 09:35:57 +0100 | [diff] [blame] | 24 | #endif |
Andre Przywara | 906776e | 2023-03-03 10:30:06 +0000 | [diff] [blame] | 25 | #else |
| 26 | #if __aarch64__ |
Boyan Karatotev | 1e966f3 | 2023-03-27 17:02:43 +0100 | [diff] [blame] | 27 | void amu_enable(cpu_context_t *ctx) |
| 28 | { |
| 29 | } |
| 30 | void amu_init_el3(void) |
| 31 | { |
| 32 | } |
| 33 | void amu_init_el2_unused(void) |
Andre Przywara | 906776e | 2023-03-03 10:30:06 +0000 | [diff] [blame] | 34 | { |
| 35 | } |
| 36 | #else |
| 37 | static inline void amu_enable(bool el2_unused) |
| 38 | { |
| 39 | } |
| 40 | #endif |
| 41 | #endif |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 42 | |
Chris Kay | f11909f | 2021-08-19 11:21:52 +0100 | [diff] [blame] | 43 | #if ENABLE_AMU_AUXILIARY_COUNTERS |
| 44 | /* |
| 45 | * AMU data for a single core. |
| 46 | */ |
| 47 | struct amu_core { |
| 48 | uint16_t enable; /* Mask of auxiliary counters to enable */ |
| 49 | }; |
| 50 | |
| 51 | /* |
| 52 | * Topological platform data specific to the AMU. |
| 53 | */ |
| 54 | struct 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 | */ |
| 63 | const struct amu_topology *plat_amu_topology(void); |
| 64 | #endif /* ENABLE_AMU_FCONF */ |
| 65 | #endif /* ENABLE_AMU_AUXILIARY_COUNTERS */ |
| 66 | |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 67 | #endif /* AMU_H */ |