~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/riscv/include/asm/vdso/gettimeofday.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __ASM_VDSO_GETTIMEOFDAY_H
  3 #define __ASM_VDSO_GETTIMEOFDAY_H
  4 
  5 #ifndef __ASSEMBLY__
  6 
  7 #include <asm/barrier.h>
  8 #include <asm/unistd.h>
  9 #include <asm/csr.h>
 10 #include <uapi/linux/time.h>
 11 
 12 /*
 13  * 32-bit land is lacking generic time vsyscalls as well as the legacy 32-bit
 14  * time syscalls like gettimeofday. Skip these definitions since on 32-bit.
 15  */
 16 #ifdef CONFIG_GENERIC_TIME_VSYSCALL
 17 
 18 #define VDSO_HAS_CLOCK_GETRES   1
 19 
 20 static __always_inline
 21 int gettimeofday_fallback(struct __kernel_old_timeval *_tv,
 22                           struct timezone *_tz)
 23 {
 24         register struct __kernel_old_timeval *tv asm("a0") = _tv;
 25         register struct timezone *tz asm("a1") = _tz;
 26         register long ret asm("a0");
 27         register long nr asm("a7") = __NR_gettimeofday;
 28 
 29         asm volatile ("ecall\n"
 30                       : "=r" (ret)
 31                       : "r"(tv), "r"(tz), "r"(nr)
 32                       : "memory");
 33 
 34         return ret;
 35 }
 36 
 37 static __always_inline
 38 long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 39 {
 40         register clockid_t clkid asm("a0") = _clkid;
 41         register struct __kernel_timespec *ts asm("a1") = _ts;
 42         register long ret asm("a0");
 43         register long nr asm("a7") = __NR_clock_gettime;
 44 
 45         asm volatile ("ecall\n"
 46                       : "=r" (ret)
 47                       : "r"(clkid), "r"(ts), "r"(nr)
 48                       : "memory");
 49 
 50         return ret;
 51 }
 52 
 53 static __always_inline
 54 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 55 {
 56         register clockid_t clkid asm("a0") = _clkid;
 57         register struct __kernel_timespec *ts asm("a1") = _ts;
 58         register long ret asm("a0");
 59         register long nr asm("a7") = __NR_clock_getres;
 60 
 61         asm volatile ("ecall\n"
 62                       : "=r" (ret)
 63                       : "r"(clkid), "r"(ts), "r"(nr)
 64                       : "memory");
 65 
 66         return ret;
 67 }
 68 
 69 #endif /* CONFIG_GENERIC_TIME_VSYSCALL */
 70 
 71 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
 72                                                  const struct vdso_data *vd)
 73 {
 74         /*
 75          * The purpose of csr_read(CSR_TIME) is to trap the system into
 76          * M-mode to obtain the value of CSR_TIME. Hence, unlike other
 77          * architecture, no fence instructions surround the csr_read()
 78          */
 79         return csr_read(CSR_TIME);
 80 }
 81 
 82 static __always_inline const struct vdso_data *__arch_get_vdso_data(void)
 83 {
 84         return _vdso_data;
 85 }
 86 
 87 #ifdef CONFIG_TIME_NS
 88 static __always_inline
 89 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
 90 {
 91         return _timens_data;
 92 }
 93 #endif
 94 #endif /* !__ASSEMBLY__ */
 95 
 96 #endif /* __ASM_VDSO_GETTIMEOFDAY_H */
 97 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php