1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2018 ARM Limited
5 #ifndef __ASM_VDSO_GETTIMEOFDAY_H
6 #define __ASM_VDSO_GETTIMEOFDAY_H
10 #include <asm/barrier.h>
11 #include <asm/unistd.h>
13 #define VDSO_HAS_CLOCK_GETRES 1
15 static __always_inline
16 int gettimeofday_fallback(struct __kernel_old_timeval *_tv,
19 register struct timezone *tz asm("x1") = _tz;
20 register struct __kernel_old_timeval *tv asm("x0") = _tv;
21 register long ret asm ("x0");
22 register long nr asm("x8") = __NR_gettimeofday;
27 : "r" (tv), "r" (tz), "r" (nr)
33 static __always_inline
34 long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
36 register struct __kernel_timespec *ts asm("x1") = _ts;
37 register clockid_t clkid asm("x0") = _clkid;
38 register long ret asm ("x0");
39 register long nr asm("x8") = __NR_clock_gettime;
44 : "r" (clkid), "r" (ts), "r" (nr)
50 static __always_inline
51 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
53 register struct __kernel_timespec *ts asm("x1") = _ts;
54 register clockid_t clkid asm("x0") = _clkid;
55 register long ret asm ("x0");
56 register long nr asm("x8") = __NR_clock_getres;
61 : "r" (clkid), "r" (ts), "r" (nr)
67 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
68 const struct vdso_data *vd)
73 * Core checks for mode already, so this raced against a concurrent
74 * update. Return something. Core will do another round and then
75 * see the mode change and fallback to the syscall.
77 if (clock_mode == VDSO_CLOCKMODE_NONE)
81 * This isb() is required to prevent that the counter value
85 asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory");
86 arch_counter_enforce_ordering(res);
91 static __always_inline
92 const struct vdso_data *__arch_get_vdso_data(void)
98 static __always_inline
99 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
105 #endif /* !__ASSEMBLY__ */
107 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */