1607ca46eSDavid Howells /***************************************************************************** 2607ca46eSDavid Howells * * 3607ca46eSDavid Howells * Copyright (c) David L. Mills 1993 * 4607ca46eSDavid Howells * * 5607ca46eSDavid Howells * Permission to use, copy, modify, and distribute this software and its * 6607ca46eSDavid Howells * documentation for any purpose and without fee is hereby granted, provided * 7607ca46eSDavid Howells * that the above copyright notice appears in all copies and that both the * 8607ca46eSDavid Howells * copyright notice and this permission notice appear in supporting * 9607ca46eSDavid Howells * documentation, and that the name University of Delaware not be used in * 10607ca46eSDavid Howells * advertising or publicity pertaining to distribution of the software * 11607ca46eSDavid Howells * without specific, written prior permission. The University of Delaware * 12607ca46eSDavid Howells * makes no representations about the suitability this software for any * 13607ca46eSDavid Howells * purpose. It is provided "as is" without express or implied warranty. * 14607ca46eSDavid Howells * * 15607ca46eSDavid Howells *****************************************************************************/ 16607ca46eSDavid Howells 17607ca46eSDavid Howells /* 18607ca46eSDavid Howells * Modification history timex.h 19607ca46eSDavid Howells * 20607ca46eSDavid Howells * 29 Dec 97 Russell King 21607ca46eSDavid Howells * Moved CLOCK_TICK_RATE, CLOCK_TICK_FACTOR and FINETUNE to asm/timex.h 22607ca46eSDavid Howells * for ARM machines 23607ca46eSDavid Howells * 24607ca46eSDavid Howells * 9 Jan 97 Adrian Sun 25607ca46eSDavid Howells * Shifted LATCH define to allow access to alpha machines. 26607ca46eSDavid Howells * 27607ca46eSDavid Howells * 26 Sep 94 David L. Mills 28607ca46eSDavid Howells * Added defines for hybrid phase/frequency-lock loop. 29607ca46eSDavid Howells * 30607ca46eSDavid Howells * 19 Mar 94 David L. Mills 31607ca46eSDavid Howells * Moved defines from kernel routines to header file and added new 32607ca46eSDavid Howells * defines for PPS phase-lock loop. 33607ca46eSDavid Howells * 34607ca46eSDavid Howells * 20 Feb 94 David L. Mills 35607ca46eSDavid Howells * Revised status codes and structures for external clock and PPS 36607ca46eSDavid Howells * signal discipline. 37607ca46eSDavid Howells * 38607ca46eSDavid Howells * 28 Nov 93 David L. Mills 39607ca46eSDavid Howells * Adjusted parameters to improve stability and increase poll 40607ca46eSDavid Howells * interval. 41607ca46eSDavid Howells * 42607ca46eSDavid Howells * 17 Sep 93 David L. Mills 43607ca46eSDavid Howells * Created file $NTP/include/sys/timex.h 44607ca46eSDavid Howells * 07 Oct 93 Torsten Duwe 45607ca46eSDavid Howells * Derived linux/timex.h 46607ca46eSDavid Howells * 1995-08-13 Torsten Duwe 47607ca46eSDavid Howells * kernel PLL updated to 1994-12-13 specs (rfc-1589) 48607ca46eSDavid Howells * 1997-08-30 Ulrich Windl 49607ca46eSDavid Howells * Added new constant NTP_PHASE_LIMIT 50607ca46eSDavid Howells * 2004-08-12 Christoph Lameter 51607ca46eSDavid Howells * Reworked time interpolation logic 52607ca46eSDavid Howells */ 53607ca46eSDavid Howells #ifndef _UAPI_LINUX_TIMEX_H 54607ca46eSDavid Howells #define _UAPI_LINUX_TIMEX_H 55607ca46eSDavid Howells 56607ca46eSDavid Howells #include <linux/time.h> 57607ca46eSDavid Howells 58607ca46eSDavid Howells #define NTP_API 4 /* NTP API version */ 59607ca46eSDavid Howells 60*251ec1c1SArnd Bergmann #ifndef __KERNEL__ 61607ca46eSDavid Howells /* 62607ca46eSDavid Howells * syscall interface - used (mainly by NTP daemon) 63607ca46eSDavid Howells * to discipline kernel clock oscillator 64607ca46eSDavid Howells */ 65607ca46eSDavid Howells struct timex { 66607ca46eSDavid Howells unsigned int modes; /* mode selector */ 677fb30128SH.J. Lu __kernel_long_t offset; /* time offset (usec) */ 687fb30128SH.J. Lu __kernel_long_t freq; /* frequency offset (scaled ppm) */ 697fb30128SH.J. Lu __kernel_long_t maxerror;/* maximum error (usec) */ 707fb30128SH.J. Lu __kernel_long_t esterror;/* estimated error (usec) */ 71607ca46eSDavid Howells int status; /* clock command/status */ 727fb30128SH.J. Lu __kernel_long_t constant;/* pll time constant */ 737fb30128SH.J. Lu __kernel_long_t precision;/* clock precision (usec) (read only) */ 747fb30128SH.J. Lu __kernel_long_t tolerance;/* clock frequency tolerance (ppm) 75607ca46eSDavid Howells * (read only) 76607ca46eSDavid Howells */ 77607ca46eSDavid Howells struct timeval time; /* (read only, except for ADJ_SETOFFSET) */ 787fb30128SH.J. Lu __kernel_long_t tick; /* (modified) usecs between clock ticks */ 79607ca46eSDavid Howells 807fb30128SH.J. Lu __kernel_long_t ppsfreq;/* pps frequency (scaled ppm) (ro) */ 817fb30128SH.J. Lu __kernel_long_t jitter; /* pps jitter (us) (ro) */ 82607ca46eSDavid Howells int shift; /* interval duration (s) (shift) (ro) */ 837fb30128SH.J. Lu __kernel_long_t stabil; /* pps stability (scaled ppm) (ro) */ 847fb30128SH.J. Lu __kernel_long_t jitcnt; /* jitter limit exceeded (ro) */ 857fb30128SH.J. Lu __kernel_long_t calcnt; /* calibration intervals (ro) */ 867fb30128SH.J. Lu __kernel_long_t errcnt; /* calibration errors (ro) */ 877fb30128SH.J. Lu __kernel_long_t stbcnt; /* stability limit exceeded (ro) */ 88607ca46eSDavid Howells 89607ca46eSDavid Howells int tai; /* TAI offset (ro) */ 90607ca46eSDavid Howells 91607ca46eSDavid Howells int :32; int :32; int :32; int :32; 92607ca46eSDavid Howells int :32; int :32; int :32; int :32; 93607ca46eSDavid Howells int :32; int :32; int :32; 94607ca46eSDavid Howells }; 95*251ec1c1SArnd Bergmann #endif 96607ca46eSDavid Howells 972c620ff9SDeepa Dinamani struct __kernel_timex_timeval { 982c620ff9SDeepa Dinamani __kernel_time64_t tv_sec; 992c620ff9SDeepa Dinamani long long tv_usec; 1002c620ff9SDeepa Dinamani }; 1012c620ff9SDeepa Dinamani 1022c620ff9SDeepa Dinamani struct __kernel_timex { 1032c620ff9SDeepa Dinamani unsigned int modes; /* mode selector */ 1042c620ff9SDeepa Dinamani int :32; /* pad */ 1052c620ff9SDeepa Dinamani long long offset; /* time offset (usec) */ 1062c620ff9SDeepa Dinamani long long freq; /* frequency offset (scaled ppm) */ 1072c620ff9SDeepa Dinamani long long maxerror;/* maximum error (usec) */ 1082c620ff9SDeepa Dinamani long long esterror;/* estimated error (usec) */ 1092c620ff9SDeepa Dinamani int status; /* clock command/status */ 1102c620ff9SDeepa Dinamani int :32; /* pad */ 1112c620ff9SDeepa Dinamani long long constant;/* pll time constant */ 1122c620ff9SDeepa Dinamani long long precision;/* clock precision (usec) (read only) */ 1132c620ff9SDeepa Dinamani long long tolerance;/* clock frequency tolerance (ppm) 1142c620ff9SDeepa Dinamani * (read only) 1152c620ff9SDeepa Dinamani */ 1162c620ff9SDeepa Dinamani struct __kernel_timex_timeval time; /* (read only, except for ADJ_SETOFFSET) */ 1172c620ff9SDeepa Dinamani long long tick; /* (modified) usecs between clock ticks */ 1182c620ff9SDeepa Dinamani 1192c620ff9SDeepa Dinamani long long ppsfreq;/* pps frequency (scaled ppm) (ro) */ 1202c620ff9SDeepa Dinamani long long jitter; /* pps jitter (us) (ro) */ 1212c620ff9SDeepa Dinamani int shift; /* interval duration (s) (shift) (ro) */ 1222c620ff9SDeepa Dinamani int :32; /* pad */ 1232c620ff9SDeepa Dinamani long long stabil; /* pps stability (scaled ppm) (ro) */ 1242c620ff9SDeepa Dinamani long long jitcnt; /* jitter limit exceeded (ro) */ 1252c620ff9SDeepa Dinamani long long calcnt; /* calibration intervals (ro) */ 1262c620ff9SDeepa Dinamani long long errcnt; /* calibration errors (ro) */ 1272c620ff9SDeepa Dinamani long long stbcnt; /* stability limit exceeded (ro) */ 1282c620ff9SDeepa Dinamani 1292c620ff9SDeepa Dinamani int tai; /* TAI offset (ro) */ 1302c620ff9SDeepa Dinamani 1312c620ff9SDeepa Dinamani int :32; int :32; int :32; int :32; 1322c620ff9SDeepa Dinamani int :32; int :32; int :32; int :32; 1332c620ff9SDeepa Dinamani int :32; int :32; int :32; 1342c620ff9SDeepa Dinamani }; 1352c620ff9SDeepa Dinamani 136607ca46eSDavid Howells /* 137607ca46eSDavid Howells * Mode codes (timex.mode) 138607ca46eSDavid Howells */ 139607ca46eSDavid Howells #define ADJ_OFFSET 0x0001 /* time offset */ 140607ca46eSDavid Howells #define ADJ_FREQUENCY 0x0002 /* frequency offset */ 141607ca46eSDavid Howells #define ADJ_MAXERROR 0x0004 /* maximum time error */ 142607ca46eSDavid Howells #define ADJ_ESTERROR 0x0008 /* estimated time error */ 143607ca46eSDavid Howells #define ADJ_STATUS 0x0010 /* clock status */ 144607ca46eSDavid Howells #define ADJ_TIMECONST 0x0020 /* pll time constant */ 145607ca46eSDavid Howells #define ADJ_TAI 0x0080 /* set TAI offset */ 146607ca46eSDavid Howells #define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */ 147607ca46eSDavid Howells #define ADJ_MICRO 0x1000 /* select microsecond resolution */ 148607ca46eSDavid Howells #define ADJ_NANO 0x2000 /* select nanosecond resolution */ 149607ca46eSDavid Howells #define ADJ_TICK 0x4000 /* tick value */ 150607ca46eSDavid Howells 151607ca46eSDavid Howells #ifndef __KERNEL__ 152607ca46eSDavid Howells #define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ 153607ca46eSDavid Howells #define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ 154607ca46eSDavid Howells #endif 155607ca46eSDavid Howells 156607ca46eSDavid Howells /* NTP userland likes the MOD_ prefix better */ 157607ca46eSDavid Howells #define MOD_OFFSET ADJ_OFFSET 158607ca46eSDavid Howells #define MOD_FREQUENCY ADJ_FREQUENCY 159607ca46eSDavid Howells #define MOD_MAXERROR ADJ_MAXERROR 160607ca46eSDavid Howells #define MOD_ESTERROR ADJ_ESTERROR 161607ca46eSDavid Howells #define MOD_STATUS ADJ_STATUS 162607ca46eSDavid Howells #define MOD_TIMECONST ADJ_TIMECONST 163607ca46eSDavid Howells #define MOD_TAI ADJ_TAI 164607ca46eSDavid Howells #define MOD_MICRO ADJ_MICRO 165607ca46eSDavid Howells #define MOD_NANO ADJ_NANO 166607ca46eSDavid Howells 167607ca46eSDavid Howells 168607ca46eSDavid Howells /* 169607ca46eSDavid Howells * Status codes (timex.status) 170607ca46eSDavid Howells */ 171607ca46eSDavid Howells #define STA_PLL 0x0001 /* enable PLL updates (rw) */ 172607ca46eSDavid Howells #define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ 173607ca46eSDavid Howells #define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ 174607ca46eSDavid Howells #define STA_FLL 0x0008 /* select frequency-lock mode (rw) */ 175607ca46eSDavid Howells 176607ca46eSDavid Howells #define STA_INS 0x0010 /* insert leap (rw) */ 177607ca46eSDavid Howells #define STA_DEL 0x0020 /* delete leap (rw) */ 178607ca46eSDavid Howells #define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ 179607ca46eSDavid Howells #define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ 180607ca46eSDavid Howells 181607ca46eSDavid Howells #define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ 182607ca46eSDavid Howells #define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ 183607ca46eSDavid Howells #define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ 184607ca46eSDavid Howells #define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ 185607ca46eSDavid Howells 186607ca46eSDavid Howells #define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ 187607ca46eSDavid Howells #define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ 188607ca46eSDavid Howells #define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ 189607ca46eSDavid Howells #define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ 190607ca46eSDavid Howells 191607ca46eSDavid Howells /* read-only bits */ 192607ca46eSDavid Howells #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \ 193607ca46eSDavid Howells STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) 194607ca46eSDavid Howells 195607ca46eSDavid Howells /* 196607ca46eSDavid Howells * Clock states (time_state) 197607ca46eSDavid Howells */ 198607ca46eSDavid Howells #define TIME_OK 0 /* clock synchronized, no leap second */ 199607ca46eSDavid Howells #define TIME_INS 1 /* insert leap second */ 200607ca46eSDavid Howells #define TIME_DEL 2 /* delete leap second */ 201607ca46eSDavid Howells #define TIME_OOP 3 /* leap second in progress */ 202607ca46eSDavid Howells #define TIME_WAIT 4 /* leap second has occurred */ 203607ca46eSDavid Howells #define TIME_ERROR 5 /* clock not synchronized */ 204607ca46eSDavid Howells #define TIME_BAD TIME_ERROR /* bw compat */ 205607ca46eSDavid Howells 206607ca46eSDavid Howells 207607ca46eSDavid Howells #endif /* _UAPI_LINUX_TIMEX_H */ 208