1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Author: Huacai Chen <chenhuacai@loongson.cn>
5 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
7 #ifndef __ASM_VDSO_GETTIMEOFDAY_H
8 #define __ASM_VDSO_GETTIMEOFDAY_H
12 #include <asm/unistd.h>
13 #include <asm/vdso/vdso.h>
15 #define VDSO_HAS_CLOCK_GETRES 1
17 static __always_inline
long gettimeofday_fallback(
18 struct __kernel_old_timeval
*_tv
,
21 register struct __kernel_old_timeval
*tv
asm("a0") = _tv
;
22 register struct timezone
*tz
asm("a1") = _tz
;
23 register long nr
asm("a7") = __NR_gettimeofday
;
24 register long ret
asm("a0");
29 : "r" (nr
), "r" (tv
), "r" (tz
)
30 : "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7",
36 static __always_inline
long clock_gettime_fallback(
38 struct __kernel_timespec
*_ts
)
40 register clockid_t clkid
asm("a0") = _clkid
;
41 register struct __kernel_timespec
*ts
asm("a1") = _ts
;
42 register long nr
asm("a7") = __NR_clock_gettime
;
43 register long ret
asm("a0");
48 : "r" (nr
), "r" (clkid
), "r" (ts
)
49 : "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7",
55 static __always_inline
int clock_getres_fallback(
57 struct __kernel_timespec
*_ts
)
59 register clockid_t clkid
asm("a0") = _clkid
;
60 register struct __kernel_timespec
*ts
asm("a1") = _ts
;
61 register long nr
asm("a7") = __NR_clock_getres
;
62 register long ret
asm("a0");
67 : "r" (nr
), "r" (clkid
), "r" (ts
)
68 : "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7",
74 static __always_inline u64
__arch_get_hw_counter(s32 clock_mode
,
75 const struct vdso_data
*vd
)
80 " rdtime.d %0, $zero\n"
86 static inline bool loongarch_vdso_hres_capable(void)
90 #define __arch_vdso_hres_capable loongarch_vdso_hres_capable
92 static __always_inline
const struct vdso_data
*__arch_get_vdso_data(void)
98 static __always_inline
99 const struct vdso_data
*__arch_get_timens_vdso_data(const struct vdso_data
*vd
)
104 #endif /* !__ASSEMBLY__ */
106 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */