2 * You SHOULD NOT be including this unless you're vsyscall
3 * handling code or timekeeping internal code!
6 #ifndef _LINUX_TIMEKEEPER_INTERNAL_H
7 #define _LINUX_TIMEKEEPER_INTERNAL_H
9 #include <linux/clocksource.h>
10 #include <linux/jiffies.h>
11 #include <linux/time.h>
13 /* Structure holding internal timekeeping values. */
15 /* Current clocksource used for timekeeping. */
16 struct clocksource *clock;
17 /* NTP adjusted clock multiplier */
19 /* The shift value of the current clocksource. */
21 /* Number of clock cycles in one NTP interval. */
22 cycle_t cycle_interval;
23 /* Last cycle value (also stored in clock->cycle_last) */
25 /* Number of clock shifted nano seconds in one NTP interval. */
27 /* shifted nano seconds left over when rounding cycle_interval */
29 /* Raw nano seconds accumulated per NTP interval. */
32 /* Current CLOCK_REALTIME time in seconds */
34 /* Clock shifted nano seconds */
37 /* Difference between accumulated time and NTP time in ntp
38 * shifted nano seconds. */
40 /* Shift conversion between clock shifted nano seconds and
41 * ntp shifted nano seconds. */
45 * wall_to_monotonic is what we need to add to xtime (or xtime corrected
46 * for sub jiffie times) to get to monotonic time. Monotonic is pegged
47 * at zero at system boot time, so wall_to_monotonic will be negative,
48 * however, we will ALWAYS keep the tv_nsec part positive so we can use
49 * the usual normalization.
51 * wall_to_monotonic is moved after resume from suspend for the
52 * monotonic time not to jump. We need to add total_sleep_time to
53 * wall_to_monotonic to get the real boot based time offset.
55 * - wall_to_monotonic is no longer the boot time, getboottime must be
58 struct timespec wall_to_monotonic;
59 /* Offset clock monotonic -> clock realtime */
61 /* time spent in suspend */
62 struct timespec total_sleep_time;
63 /* Offset clock monotonic -> clock boottime */
65 /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */
66 struct timespec raw_time;
67 /* The current UTC to TAI offset in seconds */
69 /* Offset clock monotonic -> clock tai */
74 static inline struct timespec tk_xtime(struct timekeeper *tk)
78 ts.tv_sec = tk->xtime_sec;
79 ts.tv_nsec = (long)(tk->xtime_nsec >> tk->shift);
84 #ifdef CONFIG_GENERIC_TIME_VSYSCALL
86 extern void update_vsyscall(struct timekeeper *tk);
87 extern void update_vsyscall_tz(void);
89 #elif defined(CONFIG_GENERIC_TIME_VSYSCALL_OLD)
91 extern void update_vsyscall_old(struct timespec *ts, struct timespec *wtm,
92 struct clocksource *c, u32 mult);
93 extern void update_vsyscall_tz(void);
95 static inline void update_vsyscall(struct timekeeper *tk)
100 update_vsyscall_old(&xt, &tk->wall_to_monotonic, tk->clock, tk->mult);
105 static inline void update_vsyscall(struct timekeeper *tk)
108 static inline void update_vsyscall_tz(void)
113 #endif /* _LINUX_TIMEKEEPER_INTERNAL_H */