diff options
Diffstat (limited to 'platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h')
-rw-r--r-- | platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h b/platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h new file mode 100644 index 000000000..aba2799c7 --- /dev/null +++ b/platform/linux-generic/arch/aarch64/odp/api/abi/time_cpu.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2021, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#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 |