1 /*
2  * Copyright 2014, General Dynamics C4 Systems
3  *
4  * SPDX-License-Identifier: GPL-2.0-only
5  */
6 
7 #include <benchmark/benchmark.h>
8 #include <arch/benchmark.h>
9 
10 #if CONFIG_MAX_NUM_TRACE_POINTS > 0
11 timestamp_t ksEntries[CONFIG_MAX_NUM_TRACE_POINTS];
12 bool_t ksStarted[CONFIG_MAX_NUM_TRACE_POINTS];
13 timestamp_t ksExit;
14 seL4_Word ksLogIndex = 0;
15 seL4_Word ksLogIndexFinalized = 0;
16 #endif /* CONFIG_MAX_NUM_TRACE_POINTS > 0 */
17 
18 #ifdef CONFIG_ARM_ENABLE_PMU_OVERFLOW_INTERRUPT
19 UP_STATE_DEFINE(uint64_t, ccnt_num_overflows);
20 #endif /* CONFIG_ARM_ENABLE_PMU_OVERFLOW_INTERRUPT */
21 
22 #ifdef CONFIG_ENABLE_BENCHMARKS
arm_init_ccnt(void)23 void arm_init_ccnt(void)
24 {
25 
26     uint32_t val = (BIT(PMCR_ENABLE) | BIT(PMCR_CCNT_RESET) | BIT(PMCR_ECNT_RESET));
27     SYSTEM_WRITE_WORD(PMCR, val);
28 
29 #ifdef PMCNTENSET
30     /* turn on the cycle counter */
31     SYSTEM_WRITE_WORD(PMCNTENSET, BIT(CCNT_INDEX));
32 #endif
33 
34 #ifdef CONFIG_ARM_ENABLE_PMU_OVERFLOW_INTERRUPT
35     armv_enableOverflowIRQ();
36 #endif /* CONFIG_ARM_ENABLE_PMU_OVERFLOW_INTERRUPT */
37 }
38 #endif
39