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/unistd.h>
11 #include <uapi/linux/time.h>
13 #define __VDSO_USE_SYSCALL ULLONG_MAX
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
)
74 * clock_mode == 0 implies that vDSO are enabled otherwise
75 * fallback on syscall.
78 return __VDSO_USE_SYSCALL
;
81 * This isb() is required to prevent that the counter value
85 asm volatile("mrs %0, cntvct_el0" : "=r" (res
) :: "memory");
87 * This isb() is required to prevent that the seq lock is
95 static __always_inline
96 const struct vdso_data
*__arch_get_vdso_data(void)
101 #endif /* !__ASSEMBLY__ */
103 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */