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/errno.h>
12 #include <asm/unistd.h>
13 #include <asm/vdso/cp15.h>
14 #include <uapi/linux/time.h>
16 #define VDSO_HAS_CLOCK_GETRES 1
18 extern struct vdso_data
*__get_datapage(void);
20 static __always_inline
int gettimeofday_fallback(
21 struct __kernel_old_timeval
*_tv
,
24 register struct timezone
*tz
asm("r1") = _tz
;
25 register struct __kernel_old_timeval
*tv
asm("r0") = _tv
;
26 register long ret
asm ("r0");
27 register long nr
asm("r7") = __NR_gettimeofday
;
32 : "r" (tv
), "r" (tz
), "r" (nr
)
38 static __always_inline
long clock_gettime_fallback(
40 struct __kernel_timespec
*_ts
)
42 register struct __kernel_timespec
*ts
asm("r1") = _ts
;
43 register clockid_t clkid
asm("r0") = _clkid
;
44 register long ret
asm ("r0");
45 register long nr
asm("r7") = __NR_clock_gettime64
;
50 : "r" (clkid
), "r" (ts
), "r" (nr
)
56 static __always_inline
long clock_gettime32_fallback(
58 struct old_timespec32
*_ts
)
60 register struct old_timespec32
*ts
asm("r1") = _ts
;
61 register clockid_t clkid
asm("r0") = _clkid
;
62 register long ret
asm ("r0");
63 register long nr
asm("r7") = __NR_clock_gettime
;
68 : "r" (clkid
), "r" (ts
), "r" (nr
)
74 static __always_inline
int clock_getres_fallback(
76 struct __kernel_timespec
*_ts
)
78 register struct __kernel_timespec
*ts
asm("r1") = _ts
;
79 register clockid_t clkid
asm("r0") = _clkid
;
80 register long ret
asm ("r0");
81 register long nr
asm("r7") = __NR_clock_getres_time64
;
86 : "r" (clkid
), "r" (ts
), "r" (nr
)
92 static __always_inline
int clock_getres32_fallback(
94 struct old_timespec32
*_ts
)
96 register struct old_timespec32
*ts
asm("r1") = _ts
;
97 register clockid_t clkid
asm("r0") = _clkid
;
98 register long ret
asm ("r0");
99 register long nr
asm("r7") = __NR_clock_getres
;
104 : "r" (clkid
), "r" (ts
), "r" (nr
)
110 static inline bool arm_vdso_hres_capable(void)
112 return IS_ENABLED(CONFIG_ARM_ARCH_TIMER
);
114 #define __arch_vdso_hres_capable arm_vdso_hres_capable
116 static __always_inline u64
__arch_get_hw_counter(int clock_mode
,
117 const struct vdso_data
*vd
)
119 #ifdef CONFIG_ARM_ARCH_TIMER
123 * Core checks for mode already, so this raced against a concurrent
124 * update. Return something. Core will do another round and then
125 * see the mode change and fallback to the syscall.
127 if (clock_mode
== VDSO_CLOCKMODE_NONE
)
131 cycle_now
= read_sysreg(CNTVCT
);
135 /* Make GCC happy. This is compiled out anyway */
140 static __always_inline
const struct vdso_data
*__arch_get_vdso_data(void)
142 return __get_datapage();
145 #endif /* !__ASSEMBLY__ */
147 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */