Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 1 | /* |
Elizabeth Ho | 4fc00d2 | 2023-07-18 14:10:25 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2023, 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); |
Elizabeth Ho | 4fc00d2 | 2023-07-18 14:10:25 +0100 | [diff] [blame] | 22 | void amu_enable_per_world(per_world_context_t *per_world_ctx); |
Arunachalam Ganapathy | cac7d16 | 2021-07-08 09:35:57 +0100 | [diff] [blame] | 23 | #else |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 24 | void amu_enable(bool el2_unused); |
Elizabeth Ho | 4fc00d2 | 2023-07-18 14:10:25 +0100 | [diff] [blame] | 25 | #endif /* __aarch64__ */ |
| 26 | |
Andre Przywara | 906776e | 2023-03-03 10:30:06 +0000 | [diff] [blame] | 27 | #else |
| 28 | #if __aarch64__ |
Boyan Karatotev | 1e966f3 | 2023-03-27 17:02:43 +0100 | [diff] [blame] | 29 | void amu_enable(cpu_context_t *ctx) |
| 30 | { |
| 31 | } |
| 32 | void amu_init_el3(void) |
| 33 | { |
| 34 | } |
| 35 | void amu_init_el2_unused(void) |
Andre Przywara | 906776e | 2023-03-03 10:30:06 +0000 | [diff] [blame] | 36 | { |
| 37 | } |
Elizabeth Ho | 4fc00d2 | 2023-07-18 14:10:25 +0100 | [diff] [blame] | 38 | void amu_enable_per_world(per_world_context_t *per_world_ctx) |
| 39 | { |
| 40 | } |
Andre Przywara | 906776e | 2023-03-03 10:30:06 +0000 | [diff] [blame] | 41 | #else |
| 42 | static inline void amu_enable(bool el2_unused) |
| 43 | { |
| 44 | } |
Elizabeth Ho | 4fc00d2 | 2023-07-18 14:10:25 +0100 | [diff] [blame] | 45 | #endif /*__aarch64__ */ |
| 46 | #endif /* ENABLE_FEAT_AMU */ |
Dimitris Papastamos | e08005a | 2017-10-12 13:02:29 +0100 | [diff] [blame] | 47 | |
Chris Kay | f11909f | 2021-08-19 11:21:52 +0100 | [diff] [blame] | 48 | #if ENABLE_AMU_AUXILIARY_COUNTERS |
| 49 | /* |
| 50 | * AMU data for a single core. |
| 51 | */ |
| 52 | struct amu_core { |
| 53 | uint16_t enable; /* Mask of auxiliary counters to enable */ |
| 54 | }; |
| 55 | |
| 56 | /* |
| 57 | * Topological platform data specific to the AMU. |
| 58 | */ |
| 59 | struct 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 | */ |
| 68 | const struct amu_topology *plat_amu_topology(void); |
| 69 | #endif /* ENABLE_AMU_FCONF */ |
| 70 | #endif /* ENABLE_AMU_AUXILIARY_COUNTERS */ |
| 71 | |
Antonio Nino Diaz | 033b4bb | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 72 | #endif /* AMU_H */ |