1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_VDSO_GETTIMEOFDAY_H
3 #define __ASM_VDSO_GETTIMEOFDAY_H
7 #include <asm/barrier.h>
8 #include <asm/unistd.h>
10 #include <uapi/linux/time.h>
12 #define VDSO_HAS_CLOCK_GETRES 1
14 static __always_inline
15 int gettimeofday_fallback(struct __kernel_old_timeval
*_tv
,
18 register struct __kernel_old_timeval
*tv
asm("a0") = _tv
;
19 register struct timezone
*tz
asm("a1") = _tz
;
20 register long ret
asm("a0");
21 register long nr
asm("a7") = __NR_gettimeofday
;
23 asm volatile ("ecall\n"
25 : "r"(tv
), "r"(tz
), "r"(nr
)
31 static __always_inline
32 long clock_gettime_fallback(clockid_t _clkid
, struct __kernel_timespec
*_ts
)
34 register clockid_t clkid
asm("a0") = _clkid
;
35 register struct __kernel_timespec
*ts
asm("a1") = _ts
;
36 register long ret
asm("a0");
37 register long nr
asm("a7") = __NR_clock_gettime
;
39 asm volatile ("ecall\n"
41 : "r"(clkid
), "r"(ts
), "r"(nr
)
47 static __always_inline
48 int clock_getres_fallback(clockid_t _clkid
, struct __kernel_timespec
*_ts
)
50 register clockid_t clkid
asm("a0") = _clkid
;
51 register struct __kernel_timespec
*ts
asm("a1") = _ts
;
52 register long ret
asm("a0");
53 register long nr
asm("a7") = __NR_clock_getres
;
55 asm volatile ("ecall\n"
57 : "r"(clkid
), "r"(ts
), "r"(nr
)
63 static __always_inline u64
__arch_get_hw_counter(s32 clock_mode
,
64 const struct vdso_data
*vd
)
67 * The purpose of csr_read(CSR_TIME) is to trap the system into
68 * M-mode to obtain the value of CSR_TIME. Hence, unlike other
69 * architecture, no fence instructions surround the csr_read()
71 return csr_read(CSR_TIME
);
74 static __always_inline
const struct vdso_data
*__arch_get_vdso_data(void)
79 #endif /* !__ASSEMBLY__ */
81 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */