1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12#pragma once
13
14#include <sel4bench/cpu/sel4bench.h>
15
16#define SEL4BENCH_READ_CCNT(var) do { \
17    asm volatile("b 2f\n\
18                1:mrc p15, 0, %[counter], c15, c12," SEL4BENCH_ARM1136_COUNTER_CCNT "\n\
19                  bx lr\n\
20                2:sub r8, pc, #16\n\
21                  .word 0xe7f000f0" \
22        : [counter] "=r"(var) \
23        : \
24        : "r8", "lr"); \
25} while(0)
26