aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h
blob: 29e92da2a83d183946146efa7dc8175e345317bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright (c) 2021 Nokia
 */

#ifndef ODP_API_ABI_TIME_CPU_H_
#define ODP_API_ABI_TIME_CPU_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdint.h>

static inline uint64_t _odp_time_cpu_global(void)
{
	uint64_t cntvct;

	__asm__ volatile("mrs %0, cntvct_el0" : "=r"(cntvct) : : "memory");

	return cntvct;
}

static inline uint64_t _odp_time_cpu_global_strict(void)
{
	uint64_t cntvct;

	__asm__ volatile("isb" ::: "memory");
	__asm__ volatile("mrs %0, cntvct_el0" : "=r"(cntvct) : : "memory");

	return cntvct;
}

static inline uint64_t _odp_time_cpu_global_freq(void)
{
	uint64_t cntfrq;

	__asm__ volatile("mrs %0, cntfrq_el0" : "=r"(cntfrq) : : );

	return cntfrq;
}

static inline int _odp_time_cpu_global_freq_is_const(void)
{
	return 1;
}

#ifdef __cplusplus
}
#endif

#endif