Kshitij Sisodia | da2ec06 | 2022-04-01 14:43:53 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2022 Arm Limited. All rights reserved. |
| 3 | * SPDX-License-Identifier: Apache-2.0 |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | #ifndef PLATFORM_PMU_INTERFACE_H |
| 18 | #define PLATFORM_PMU_INTERFACE_H |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | #include <stdint.h> |
| 25 | #include <stdbool.h> |
| 26 | |
| 27 | #define NUM_PMU_COUNTERS (10) /**< Maximum number of available counters. */ |
| 28 | |
| 29 | /** |
| 30 | * @brief Container for a single unit for a PMU counter. |
| 31 | */ |
| 32 | typedef struct _pmu_counter_unit { |
| 33 | uint64_t value; /**< Value of the counter expressed as 64 bits unsigned integer. */ |
| 34 | const char* name; /**< Name for the counter. */ |
| 35 | const char* unit; /**< Unit that the counter value represents (like cycles, beats, or milliseconds). */ |
| 36 | } pmu_counter_unit; |
| 37 | |
| 38 | /** |
| 39 | * @brief Container for a an array of counters |
| 40 | */ |
| 41 | typedef struct _pmu_counters { |
| 42 | pmu_counter_unit counters[NUM_PMU_COUNTERS]; /**< Counter array. */ |
| 43 | uint32_t num_counters; /**< Number of valid counters. */ |
| 44 | bool initialised; /**< Initialised or not. */ |
| 45 | } pmu_counters; |
| 46 | |
| 47 | /** |
| 48 | * @brief Resets the counters. |
| 49 | */ |
| 50 | void platform_reset_counters(void); |
| 51 | |
| 52 | /** |
| 53 | * @brief Gets the current counter values. |
| 54 | * @returns A populated instance of pmu_counters struct. |
| 55 | **/ |
| 56 | pmu_counters platform_get_counters(void); |
| 57 | |
| 58 | #ifdef __cplusplus |
| 59 | } |
| 60 | #endif |
| 61 | |
| 62 | #endif /* PLATFORM_PMU_INTERFACE_H */ |