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/errno.h>
11 #include <asm/unistd.h>
12 #include <asm/vdso/cp15.h>
13 #include <uapi/linux/time.h>
15 #define VDSO_HAS_CLOCK_GETRES 1
17 extern struct vdso_data
*__get_datapage(void);
19 static __always_inline
int gettimeofday_fallback(
20 struct __kernel_old_timeval
*_tv
,
23 register struct timezone
*tz
asm("r1") = _tz
;
24 register struct __kernel_old_timeval
*tv
asm("r0") = _tv
;
25 register long ret
asm ("r0");
26 register long nr
asm("r7") = __NR_gettimeofday
;
31 : "r" (tv
), "r" (tz
), "r" (nr
)
37 static __always_inline
long clock_gettime_fallback(
39 struct __kernel_timespec
*_ts
)
41 register struct __kernel_timespec
*ts
asm("r1") = _ts
;
42 register clockid_t clkid
asm("r0") = _clkid
;
43 register long ret
asm ("r0");
44 register long nr
asm("r7") = __NR_clock_gettime64
;
49 : "r" (clkid
), "r" (ts
), "r" (nr
)
55 static __always_inline
long clock_gettime32_fallback(
57 struct old_timespec32
*_ts
)
59 register struct old_timespec32
*ts
asm("r1") = _ts
;
60 register clockid_t clkid
asm("r0") = _clkid
;
61 register long ret
asm ("r0");
62 register long nr
asm("r7") = __NR_clock_gettime
;
67 : "r" (clkid
), "r" (ts
), "r" (nr
)
73 static __always_inline
int clock_getres_fallback(
75 struct __kernel_timespec
*_ts
)
77 register struct __kernel_timespec
*ts
asm("r1") = _ts
;
78 register clockid_t clkid
asm("r0") = _clkid
;
79 register long ret
asm ("r0");
80 register long nr
asm("r7") = __NR_clock_getres_time64
;
85 : "r" (clkid
), "r" (ts
), "r" (nr
)
91 static __always_inline
int clock_getres32_fallback(
93 struct old_timespec32
*_ts
)
95 register struct old_timespec32
*ts
asm("r1") = _ts
;
96 register clockid_t clkid
asm("r0") = _clkid
;
97 register long ret
asm ("r0");
98 register long nr
asm("r7") = __NR_clock_getres
;
103 : "r" (clkid
), "r" (ts
), "r" (nr
)
109 static inline bool arm_vdso_hres_capable(void)
111 return IS_ENABLED(CONFIG_ARM_ARCH_TIMER
);
113 #define __arch_vdso_hres_capable arm_vdso_hres_capable
115 static __always_inline u64
__arch_get_hw_counter(int clock_mode
)
117 #ifdef CONFIG_ARM_ARCH_TIMER
121 * Core checks for mode already, so this raced against a concurrent
122 * update. Return something. Core will do another round and then
123 * see the mode change and fallback to the syscall.
125 if (clock_mode
== VDSO_CLOCKMODE_NONE
)
129 cycle_now
= read_sysreg(CNTVCT
);
133 /* Make GCC happy. This is compiled out anyway */
138 static __always_inline
const struct vdso_data
*__arch_get_vdso_data(void)
140 return __get_datapage();
143 #endif /* !__ASSEMBLY__ */
145 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */