Dimitris Papastamos | 0767d50 | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 1 | /* |
johpow01 | 873d424 | 2020-10-02 13:41:11 -0500 | [diff] [blame] | 2 | * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved. |
Dimitris Papastamos | 0767d50 | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 40daecc | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 7 | #ifndef AMU_PRIVATE_H |
| 8 | #define AMU_PRIVATE_H |
Dimitris Papastamos | 0767d50 | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 9 | |
| 10 | #include <stdint.h> |
| 11 | |
Chris Kay | b4b726e | 2021-05-24 21:00:07 +0100 | [diff] [blame] | 12 | #include <lib/cassert.h> |
| 13 | #include <lib/extensions/amu.h> |
| 14 | #include <lib/utils_def.h> |
| 15 | |
| 16 | #include <platform_def.h> |
| 17 | |
Chris Kay | 81e2ff1 | 2021-05-25 12:33:18 +0100 | [diff] [blame] | 18 | #define AMU_GROUP0_MAX_COUNTERS U(16) |
Chris Kay | 31d3cc2 | 2021-05-25 15:24:18 +0100 | [diff] [blame^] | 19 | #define AMU_GROUP1_MAX_COUNTERS U(16) |
Chris Kay | b4b726e | 2021-05-24 21:00:07 +0100 | [diff] [blame] | 20 | |
Chris Kay | 1fd685a | 2021-05-25 10:42:56 +0100 | [diff] [blame] | 21 | #if ENABLE_AMU_AUXILIARY_COUNTERS |
Chris Kay | b4b726e | 2021-05-24 21:00:07 +0100 | [diff] [blame] | 22 | #define AMU_GROUP1_COUNTERS_MASK U(0) |
Chris Kay | 1fd685a | 2021-05-25 10:42:56 +0100 | [diff] [blame] | 23 | #endif |
Chris Kay | b4b726e | 2021-05-24 21:00:07 +0100 | [diff] [blame] | 24 | |
| 25 | struct amu_ctx { |
Chris Kay | 81e2ff1 | 2021-05-25 12:33:18 +0100 | [diff] [blame] | 26 | uint64_t group0_cnts[AMU_GROUP0_MAX_COUNTERS]; |
Chris Kay | b4b726e | 2021-05-24 21:00:07 +0100 | [diff] [blame] | 27 | #if __aarch64__ |
| 28 | /* Architected event counter 1 does not have an offset register. */ |
Chris Kay | 81e2ff1 | 2021-05-25 12:33:18 +0100 | [diff] [blame] | 29 | uint64_t group0_voffsets[AMU_GROUP0_MAX_COUNTERS-1]; |
Chris Kay | b4b726e | 2021-05-24 21:00:07 +0100 | [diff] [blame] | 30 | #endif |
| 31 | |
Chris Kay | 1fd685a | 2021-05-25 10:42:56 +0100 | [diff] [blame] | 32 | #if ENABLE_AMU_AUXILIARY_COUNTERS |
Chris Kay | 31d3cc2 | 2021-05-25 15:24:18 +0100 | [diff] [blame^] | 33 | uint64_t group1_cnts[AMU_GROUP1_MAX_COUNTERS]; |
Chris Kay | b4b726e | 2021-05-24 21:00:07 +0100 | [diff] [blame] | 34 | #if __aarch64__ |
Chris Kay | 31d3cc2 | 2021-05-25 15:24:18 +0100 | [diff] [blame^] | 35 | uint64_t group1_voffsets[AMU_GROUP1_MAX_COUNTERS]; |
Chris Kay | b4b726e | 2021-05-24 21:00:07 +0100 | [diff] [blame] | 36 | #endif |
| 37 | #endif |
| 38 | }; |
| 39 | |
Alexei Fedorov | f3ccf03 | 2020-07-14 08:17:56 +0100 | [diff] [blame] | 40 | uint64_t amu_group0_cnt_read_internal(unsigned int idx); |
| 41 | void amu_group0_cnt_write_internal(unsigned int idx, uint64_t val); |
Dimitris Papastamos | 0767d50 | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 42 | |
Chris Kay | 1fd685a | 2021-05-25 10:42:56 +0100 | [diff] [blame] | 43 | #if ENABLE_AMU_AUXILIARY_COUNTERS |
Alexei Fedorov | f3ccf03 | 2020-07-14 08:17:56 +0100 | [diff] [blame] | 44 | uint64_t amu_group1_cnt_read_internal(unsigned int idx); |
| 45 | void amu_group1_cnt_write_internal(unsigned int idx, uint64_t val); |
| 46 | void amu_group1_set_evtype_internal(unsigned int idx, unsigned int val); |
Chris Kay | 1fd685a | 2021-05-25 10:42:56 +0100 | [diff] [blame] | 47 | #endif |
Dimitris Papastamos | 0767d50 | 2017-11-13 09:49:45 +0000 | [diff] [blame] | 48 | |
johpow01 | 873d424 | 2020-10-02 13:41:11 -0500 | [diff] [blame] | 49 | #if __aarch64__ |
| 50 | uint64_t amu_group0_voffset_read_internal(unsigned int idx); |
| 51 | void amu_group0_voffset_write_internal(unsigned int idx, uint64_t val); |
| 52 | |
Chris Kay | 1fd685a | 2021-05-25 10:42:56 +0100 | [diff] [blame] | 53 | #if ENABLE_AMU_AUXILIARY_COUNTERS |
johpow01 | 873d424 | 2020-10-02 13:41:11 -0500 | [diff] [blame] | 54 | uint64_t amu_group1_voffset_read_internal(unsigned int idx); |
| 55 | void amu_group1_voffset_write_internal(unsigned int idx, uint64_t val); |
| 56 | #endif |
Chris Kay | 1fd685a | 2021-05-25 10:42:56 +0100 | [diff] [blame] | 57 | #endif |
johpow01 | 873d424 | 2020-10-02 13:41:11 -0500 | [diff] [blame] | 58 | |
Antonio Nino Diaz | 40daecc | 2018-10-25 16:52:26 +0100 | [diff] [blame] | 59 | #endif /* AMU_PRIVATE_H */ |