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

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

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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_POWERPC_VDSO_GETTIMEOFDAY_H
  3 #define _ASM_POWERPC_VDSO_GETTIMEOFDAY_H
  4 
  5 #ifndef __ASSEMBLY__
  6 
  7 #include <asm/vdso/timebase.h>
  8 #include <asm/barrier.h>
  9 #include <asm/unistd.h>
 10 #include <uapi/linux/time.h>
 11 
 12 #define VDSO_HAS_CLOCK_GETRES           1
 13 
 14 #define VDSO_HAS_TIME                   1
 15 
 16 /*
 17  * powerpc specific delta calculation.
 18  *
 19  * This variant removes the masking of the subtraction because the
 20  * clocksource mask of all VDSO capable clocksources on powerpc is U64_MAX
 21  * which would result in a pointless operation. The compiler cannot
 22  * optimize it away as the mask comes from the vdso data and is not compile
 23  * time constant.
 24  */
 25 #define VDSO_DELTA_NOMASK               1
 26 
 27 static __always_inline int do_syscall_2(const unsigned long _r0, const unsigned long _r3,
 28                                         const unsigned long _r4)
 29 {
 30         register long r0 asm("r0") = _r0;
 31         register unsigned long r3 asm("r3") = _r3;
 32         register unsigned long r4 asm("r4") = _r4;
 33         register int ret asm ("r3");
 34 
 35         asm volatile(
 36                 "       sc\n"
 37                 "       bns+    1f\n"
 38                 "       neg     %0, %0\n"
 39                 "1:\n"
 40         : "=r" (ret), "+r" (r4), "+r" (r0)
 41         : "r" (r3)
 42         : "memory", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "cr0", "ctr");
 43 
 44         return ret;
 45 }
 46 
 47 static __always_inline
 48 int gettimeofday_fallback(struct __kernel_old_timeval *_tv, struct timezone *_tz)
 49 {
 50         return do_syscall_2(__NR_gettimeofday, (unsigned long)_tv, (unsigned long)_tz);
 51 }
 52 
 53 #ifdef __powerpc64__
 54 
 55 static __always_inline
 56 int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 57 {
 58         return do_syscall_2(__NR_clock_gettime, _clkid, (unsigned long)_ts);
 59 }
 60 
 61 static __always_inline
 62 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 63 {
 64         return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
 65 }
 66 
 67 #else
 68 
 69 #define BUILD_VDSO32            1
 70 
 71 static __always_inline
 72 int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 73 {
 74         return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
 75 }
 76 
 77 static __always_inline
 78 int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
 79 {
 80         return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
 81 }
 82 
 83 static __always_inline
 84 int clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
 85 {
 86         return do_syscall_2(__NR_clock_gettime, _clkid, (unsigned long)_ts);
 87 }
 88 
 89 static __always_inline
 90 int clock_getres32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
 91 {
 92         return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
 93 }
 94 #endif
 95 
 96 static __always_inline u64 __arch_get_hw_counter(s32 clock_mode,
 97                                                  const struct vdso_data *vd)
 98 {
 99         return get_tb();
100 }
101 
102 const struct vdso_data *__arch_get_vdso_data(void);
103 
104 #ifdef CONFIG_TIME_NS
105 static __always_inline
106 const struct vdso_data *__arch_get_timens_vdso_data(const struct vdso_data *vd)
107 {
108         return (void *)vd + (1U << CONFIG_PAGE_SHIFT);
109 }
110 #endif
111 
112 static inline bool vdso_clocksource_ok(const struct vdso_data *vd)
113 {
114         return true;
115 }
116 #define vdso_clocksource_ok vdso_clocksource_ok
117 
118 #ifndef __powerpc64__
119 static __always_inline u64 vdso_shift_ns(u64 ns, unsigned long shift)
120 {
121         u32 hi = ns >> 32;
122         u32 lo = ns;
123 
124         lo >>= shift;
125         lo |= hi << (32 - shift);
126         hi >>= shift;
127 
128         if (likely(hi == 0))
129                 return lo;
130 
131         return ((u64)hi << 32) | lo;
132 }
133 #define vdso_shift_ns vdso_shift_ns
134 #endif
135 
136 #ifdef __powerpc64__
137 int __c_kernel_clock_gettime(clockid_t clock, struct __kernel_timespec *ts,
138                              const struct vdso_data *vd);
139 int __c_kernel_clock_getres(clockid_t clock_id, struct __kernel_timespec *res,
140                             const struct vdso_data *vd);
141 #else
142 int __c_kernel_clock_gettime(clockid_t clock, struct old_timespec32 *ts,
143                              const struct vdso_data *vd);
144 int __c_kernel_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts,
145                                const struct vdso_data *vd);
146 int __c_kernel_clock_getres(clockid_t clock_id, struct old_timespec32 *res,
147                             const struct vdso_data *vd);
148 #endif
149 int __c_kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz,
150                             const struct vdso_data *vd);
151 __kernel_old_time_t __c_kernel_time(__kernel_old_time_t *time,
152                                     const struct vdso_data *vd);
153 #endif /* __ASSEMBLY__ */
154 
155 #endif /* _ASM_POWERPC_VDSO_GETTIMEOFDAY_H */
156 

~ [ 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