timekeeper_internal.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * You SHOULD NOT be including this unless you're vsyscall
  3. * handling code or timekeeping internal code!
  4. */
  5. #ifndef _LINUX_TIMEKEEPER_INTERNAL_H
  6. #define _LINUX_TIMEKEEPER_INTERNAL_H
  7. #include <linux/clocksource.h>
  8. #include <linux/jiffies.h>
  9. #include <linux/time.h>
  10. /* Structure holding internal timekeeping values. */
  11. struct timekeeper {
  12. /* Current clocksource used for timekeeping. */
  13. struct clocksource *clock;
  14. /* NTP adjusted clock multiplier */
  15. u32 mult;
  16. /* The shift value of the current clocksource. */
  17. u32 shift;
  18. /* Number of clock cycles in one NTP interval. */
  19. cycle_t cycle_interval;
  20. /* Number of clock shifted nano seconds in one NTP interval. */
  21. u64 xtime_interval;
  22. /* shifted nano seconds left over when rounding cycle_interval */
  23. s64 xtime_remainder;
  24. /* Raw nano seconds accumulated per NTP interval. */
  25. u32 raw_interval;
  26. /* Current CLOCK_REALTIME time in seconds */
  27. u64 xtime_sec;
  28. /* Clock shifted nano seconds */
  29. u64 xtime_nsec;
  30. /* Difference between accumulated time and NTP time in ntp
  31. * shifted nano seconds. */
  32. s64 ntp_error;
  33. /* Shift conversion between clock shifted nano seconds and
  34. * ntp shifted nano seconds. */
  35. u32 ntp_error_shift;
  36. /*
  37. * wall_to_monotonic is what we need to add to xtime (or xtime corrected
  38. * for sub jiffie times) to get to monotonic time. Monotonic is pegged
  39. * at zero at system boot time, so wall_to_monotonic will be negative,
  40. * however, we will ALWAYS keep the tv_nsec part positive so we can use
  41. * the usual normalization.
  42. *
  43. * wall_to_monotonic is moved after resume from suspend for the
  44. * monotonic time not to jump. We need to add total_sleep_time to
  45. * wall_to_monotonic to get the real boot based time offset.
  46. *
  47. * - wall_to_monotonic is no longer the boot time, getboottime must be
  48. * used instead.
  49. */
  50. struct timespec wall_to_monotonic;
  51. /* Offset clock monotonic -> clock realtime */
  52. ktime_t offs_real;
  53. /* time spent in suspend */
  54. struct timespec total_sleep_time;
  55. /* Offset clock monotonic -> clock boottime */
  56. ktime_t offs_boot;
  57. /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */
  58. struct timespec raw_time;
  59. /* Seqlock for all timekeeper values */
  60. seqlock_t lock;
  61. };
  62. #ifdef CONFIG_GENERIC_TIME_VSYSCALL
  63. extern void
  64. update_vsyscall(struct timespec *ts, struct timespec *wtm,
  65. struct clocksource *c, u32 mult);
  66. extern void update_vsyscall_tz(void);
  67. #else
  68. static inline void update_vsyscall(struct timespec *ts, struct timespec *wtm,
  69. struct clocksource *c, u32 mult)
  70. {
  71. }
  72. static inline void update_vsyscall_tz(void)
  73. {
  74. }
  75. #endif
  76. #endif /* _LINUX_TIMEKEEPER_INTERNAL_H */