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/alternative.h>
11 #include <asm/barrier.h>
12 #include <asm/unistd.h>
13 #include <asm/sysreg.h>
15 #define VDSO_HAS_CLOCK_GETRES 1
17 static __always_inline
18 int gettimeofday_fallback(struct __kernel_old_timeval *_tv,
21 register struct timezone *tz asm("x1") = _tz;
22 register struct __kernel_old_timeval *tv asm("x0") = _tv;
23 register long ret asm ("x0");
24 register long nr asm("x8") = __NR_gettimeofday;
29 : "r" (tv), "r" (tz), "r" (nr)
35 static __always_inline
36 long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
38 register struct __kernel_timespec *ts asm("x1") = _ts;
39 register clockid_t clkid asm("x0") = _clkid;
40 register long ret asm ("x0");
41 register long nr asm("x8") = __NR_clock_gettime;
46 : "r" (clkid), "r" (ts), "r" (nr)
52 static __always_inline
53 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
55 register struct __kernel_timespec *ts asm("x1") = _ts;
56 register clockid_t clkid asm("x0") = _clkid;
57 register long ret asm ("x0");
58 register long nr asm("x8") = __NR_clock_getres;
63 : "r" (clkid), "r" (ts), "r" (nr)
69 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
70 const struct vdso_data *vd)
75 * Core checks for mode already, so this raced against a concurrent
76 * update. Return something. Core will do another round and then
77 * see the mode change and fallback to the syscall.
79 if (clock_mode == VDSO_CLOCKMODE_NONE)
83 * If FEAT_ECV is available, use the self-synchronizing counter.
84 * Otherwise the isb is required to prevent that the counter value
91 __mrs_s("%0", SYS_CNTVCTSS_EL0),
97 arch_counter_enforce_ordering(res);
102 static __always_inline
103 const struct vdso_data *__arch_get_vdso_data(void)
108 #ifdef CONFIG_TIME_NS
109 static __always_inline
110 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
116 #endif /* !__ASSEMBLY__ */
118 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */