logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

timex.h (7817B)


  1. /*****************************************************************************
  2. * *
  3. * Copyright (c) David L. Mills 1993 *
  4. * *
  5. * Permission to use, copy, modify, and distribute this software and its *
  6. * documentation for any purpose and without fee is hereby granted, provided *
  7. * that the above copyright notice appears in all copies and that both the *
  8. * copyright notice and this permission notice appear in supporting *
  9. * documentation, and that the name University of Delaware not be used in *
  10. * advertising or publicity pertaining to distribution of the software *
  11. * without specific, written prior permission. The University of Delaware *
  12. * makes no representations about the suitability this software for any *
  13. * purpose. It is provided "as is" without express or implied warranty. *
  14. * *
  15. *****************************************************************************/
  16. /*
  17. * Modification history timex.h
  18. *
  19. * 29 Dec 97 Russell King
  20. * Moved CLOCK_TICK_RATE, CLOCK_TICK_FACTOR and FINETUNE to asm/timex.h
  21. * for ARM machines
  22. *
  23. * 9 Jan 97 Adrian Sun
  24. * Shifted LATCH define to allow access to alpha machines.
  25. *
  26. * 26 Sep 94 David L. Mills
  27. * Added defines for hybrid phase/frequency-lock loop.
  28. *
  29. * 19 Mar 94 David L. Mills
  30. * Moved defines from kernel routines to header file and added new
  31. * defines for PPS phase-lock loop.
  32. *
  33. * 20 Feb 94 David L. Mills
  34. * Revised status codes and structures for external clock and PPS
  35. * signal discipline.
  36. *
  37. * 28 Nov 93 David L. Mills
  38. * Adjusted parameters to improve stability and increase poll
  39. * interval.
  40. *
  41. * 17 Sep 93 David L. Mills
  42. * Created file $NTP/include/sys/timex.h
  43. * 07 Oct 93 Torsten Duwe
  44. * Derived linux/timex.h
  45. * 1995-08-13 Torsten Duwe
  46. * kernel PLL updated to 1994-12-13 specs (rfc-1589)
  47. * 1997-08-30 Ulrich Windl
  48. * Added new constant NTP_PHASE_LIMIT
  49. * 2004-08-12 Christoph Lameter
  50. * Reworked time interpolation logic
  51. */
  52. #ifndef _LINUX_TIMEX_H
  53. #define _LINUX_TIMEX_H
  54. #include <linux/time.h>
  55. #define NTP_API 4 /* NTP API version */
  56. /*
  57. * syscall interface - used (mainly by NTP daemon)
  58. * to discipline kernel clock oscillator
  59. */
  60. struct timex {
  61. unsigned int modes; /* mode selector */
  62. __kernel_long_t offset; /* time offset (usec) */
  63. __kernel_long_t freq; /* frequency offset (scaled ppm) */
  64. __kernel_long_t maxerror;/* maximum error (usec) */
  65. __kernel_long_t esterror;/* estimated error (usec) */
  66. int status; /* clock command/status */
  67. __kernel_long_t constant;/* pll time constant */
  68. __kernel_long_t precision;/* clock precision (usec) (read only) */
  69. __kernel_long_t tolerance;/* clock frequency tolerance (ppm)
  70. * (read only)
  71. */
  72. struct timeval time; /* (read only, except for ADJ_SETOFFSET) */
  73. __kernel_long_t tick; /* (modified) usecs between clock ticks */
  74. __kernel_long_t ppsfreq;/* pps frequency (scaled ppm) (ro) */
  75. __kernel_long_t jitter; /* pps jitter (us) (ro) */
  76. int shift; /* interval duration (s) (shift) (ro) */
  77. __kernel_long_t stabil; /* pps stability (scaled ppm) (ro) */
  78. __kernel_long_t jitcnt; /* jitter limit exceeded (ro) */
  79. __kernel_long_t calcnt; /* calibration intervals (ro) */
  80. __kernel_long_t errcnt; /* calibration errors (ro) */
  81. __kernel_long_t stbcnt; /* stability limit exceeded (ro) */
  82. int tai; /* TAI offset (ro) */
  83. int :32; int :32; int :32; int :32;
  84. int :32; int :32; int :32; int :32;
  85. int :32; int :32; int :32;
  86. };
  87. struct __kernel_timex_timeval {
  88. __kernel_time64_t tv_sec;
  89. long long tv_usec;
  90. };
  91. struct __kernel_timex {
  92. unsigned int modes; /* mode selector */
  93. int :32; /* pad */
  94. long long offset; /* time offset (usec) */
  95. long long freq; /* frequency offset (scaled ppm) */
  96. long long maxerror;/* maximum error (usec) */
  97. long long esterror;/* estimated error (usec) */
  98. int status; /* clock command/status */
  99. int :32; /* pad */
  100. long long constant;/* pll time constant */
  101. long long precision;/* clock precision (usec) (read only) */
  102. long long tolerance;/* clock frequency tolerance (ppm)
  103. * (read only)
  104. */
  105. struct __kernel_timex_timeval time; /* (read only, except for ADJ_SETOFFSET) */
  106. long long tick; /* (modified) usecs between clock ticks */
  107. long long ppsfreq;/* pps frequency (scaled ppm) (ro) */
  108. long long jitter; /* pps jitter (us) (ro) */
  109. int shift; /* interval duration (s) (shift) (ro) */
  110. int :32; /* pad */
  111. long long stabil; /* pps stability (scaled ppm) (ro) */
  112. long long jitcnt; /* jitter limit exceeded (ro) */
  113. long long calcnt; /* calibration intervals (ro) */
  114. long long errcnt; /* calibration errors (ro) */
  115. long long stbcnt; /* stability limit exceeded (ro) */
  116. int tai; /* TAI offset (ro) */
  117. int :32; int :32; int :32; int :32;
  118. int :32; int :32; int :32; int :32;
  119. int :32; int :32; int :32;
  120. };
  121. /*
  122. * Mode codes (timex.mode)
  123. */
  124. #define ADJ_OFFSET 0x0001 /* time offset */
  125. #define ADJ_FREQUENCY 0x0002 /* frequency offset */
  126. #define ADJ_MAXERROR 0x0004 /* maximum time error */
  127. #define ADJ_ESTERROR 0x0008 /* estimated time error */
  128. #define ADJ_STATUS 0x0010 /* clock status */
  129. #define ADJ_TIMECONST 0x0020 /* pll time constant */
  130. #define ADJ_TAI 0x0080 /* set TAI offset */
  131. #define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */
  132. #define ADJ_MICRO 0x1000 /* select microsecond resolution */
  133. #define ADJ_NANO 0x2000 /* select nanosecond resolution */
  134. #define ADJ_TICK 0x4000 /* tick value */
  135. #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
  136. #define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
  137. /* NTP userland likes the MOD_ prefix better */
  138. #define MOD_OFFSET ADJ_OFFSET
  139. #define MOD_FREQUENCY ADJ_FREQUENCY
  140. #define MOD_MAXERROR ADJ_MAXERROR
  141. #define MOD_ESTERROR ADJ_ESTERROR
  142. #define MOD_STATUS ADJ_STATUS
  143. #define MOD_TIMECONST ADJ_TIMECONST
  144. #define MOD_TAI ADJ_TAI
  145. #define MOD_MICRO ADJ_MICRO
  146. #define MOD_NANO ADJ_NANO
  147. /*
  148. * Status codes (timex.status)
  149. */
  150. #define STA_PLL 0x0001 /* enable PLL updates (rw) */
  151. #define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
  152. #define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
  153. #define STA_FLL 0x0008 /* select frequency-lock mode (rw) */
  154. #define STA_INS 0x0010 /* insert leap (rw) */
  155. #define STA_DEL 0x0020 /* delete leap (rw) */
  156. #define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
  157. #define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
  158. #define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
  159. #define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
  160. #define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
  161. #define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
  162. #define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
  163. #define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
  164. #define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
  165. #define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
  166. /* read-only bits */
  167. #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
  168. STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
  169. /*
  170. * Clock states (time_state)
  171. */
  172. #define TIME_OK 0 /* clock synchronized, no leap second */
  173. #define TIME_INS 1 /* insert leap second */
  174. #define TIME_DEL 2 /* delete leap second */
  175. #define TIME_OOP 3 /* leap second in progress */
  176. #define TIME_WAIT 4 /* leap second has occurred */
  177. #define TIME_ERROR 5 /* clock not synchronized */
  178. #define TIME_BAD TIME_ERROR /* bw compat */
  179. #endif /* _LINUX_TIMEX_H */