1/*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#pragma once
8
9#ifdef CONFIG_ENABLE_BENCHMARKS
10#include <config.h>
11
12#define PMCR "p15, 0, %0, c9, c12, 0"
13#define PMCNTENSET "p15, 0, %0, c9, c12, 1"
14#define PMOVSR "p15, 0, %0, c9, c12, 3"
15#define CCNT "p15, 0, %0, c9, c13, 0"
16#define PMINTENSET "p15, 0, %0, c9, c14, 1"
17#define CCNT_INDEX 31
18
19static inline void armv_enableOverflowIRQ(void)
20{
21    word_t val;
22    MRC(PMINTENSET, val);
23    val |= BIT(CCNT_INDEX);
24    MCR(PMINTENSET, val);
25}
26
27static inline void armv_handleOverflowIRQ(void)
28{
29    word_t val = BIT(CCNT_INDEX);
30    MCR(PMOVSR, val);
31}
32#endif /* CONFIG_ENABLE_BENCHMARKS */
33
34