1 /*
2 * Copyright (c) David L. Mills 1993, 1994
3 *
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appears in all copies and that both the
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name University of Delaware not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The University of Delaware
11 * makes no representations about the suitability this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
13 */
14
15 /*
16 * Copyright 1996-1997, 2002 Sun Microsystems, Inc. All rights reserved.
17 * Use is subject to license terms.
18 */
19
20 #ifndef _SYS_TIMEX_H
21 #define _SYS_TIMEX_H
22
23 #pragma ident "%Z%%M% %I% %E% SMI"
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <sys/types.h>
30 #include <sys/time.h>
31 #include <sys/syscall.h>
32 #include <sys/inttypes.h>
33
34 /*
35 * The following defines establish the engineering parameters of the
36 * phase-lock loop (PLL) model used in the kernel implementation. These
37 * parameters have been carefully chosen by analysis for good stability
38 * and wide dynamic range.
39 *
40 * The hz variable is defined in the kernel build environment. It
41 * establishes the timer interrupt frequency.
42 *
43 * SCALE_KG and SCALE_KF establish the damping of the PLL and are chosen
44 * for a slightly underdamped convergence characteristic. SCALE_KH
220 struct timex {
221 uint32_t modes; /* clock mode bits (wo) */
222 int32_t offset; /* time offset (us) (rw) */
223 int32_t freq; /* frequency offset (scaled ppm) (rw) */
224 int32_t maxerror; /* maximum error (us) (rw) */
225 int32_t esterror; /* estimated error (us) (rw) */
226 int32_t status; /* clock status bits (rw) */
227 int32_t constant; /* pll time constant (rw) */
228 int32_t precision; /* clock precision (us) (ro) */
229 int32_t tolerance; /* clock freq tolerance (scaled ppm) (ro) */
230 int32_t ppsfreq; /* pps frequency (scaled ppm) (ro) */
231 int32_t jitter; /* pps jitter (us) (ro) */
232 int32_t shift; /* interval duration (s) (shift) (ro) */
233 int32_t stabil; /* pps stability (scaled ppm) (ro) */
234 int32_t jitcnt; /* jitter limit exceeded (ro) */
235 int32_t calcnt; /* calibration intervals (ro) */
236 int32_t errcnt; /* calibration errors (ro) */
237 int32_t stbcnt; /* stability limit exceeded (ro) */
238 };
239
240 #if defined(__STDC__)
241 /*
242 * NTP syscalls
243 */
244 int ntp_gettime(struct ntptimeval *);
245 int ntp_adjtime(struct timex *);
246 #else
247 int ntp_gettime();
248 int ntp_adjtime();
249 #endif /* __STDC__ */
250
251 #ifdef _KERNEL
252
253 extern int32_t time_state; /* clock state */
254 extern int32_t time_status; /* clock status bits */
255 extern int32_t time_offset; /* time adjustment (us) */
256 extern int32_t time_freq; /* frequency offset (scaled ppm) */
257 extern int32_t time_maxerror; /* maximum error (us) */
258 extern int32_t time_esterror; /* estimated error (us) */
259 extern int32_t time_constant; /* pll time constant */
260 extern int32_t time_precision; /* clock precision (us) */
261 extern int32_t time_tolerance; /* frequency tolerance (scaled ppm) */
262 extern int32_t pps_shift; /* interval duration (s) (shift) */
263 extern int32_t pps_freq; /* pps frequency offset (scaled ppm) */
264 extern int32_t pps_jitter; /* pps jitter (us) */
265 extern int32_t pps_stabil; /* pps stability (scaled ppm) */
266 extern int32_t pps_jitcnt; /* jitter limit exceeded */
267 extern int32_t pps_calcnt; /* calibration intervals */
268 extern int32_t pps_errcnt; /* calibration errors */
269 extern int32_t pps_stbcnt; /* stability limit exceeded */
|
1 /*
2 * Copyright (c) David L. Mills 1993, 1994
3 *
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appears in all copies and that both the
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name University of Delaware not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The University of Delaware
11 * makes no representations about the suitability this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
13 */
14
15 /*
16 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
17 *
18 * Copyright 1996-1997, 2002 Sun Microsystems, Inc. All rights reserved.
19 * Use is subject to license terms.
20 */
21
22 #ifndef _SYS_TIMEX_H
23 #define _SYS_TIMEX_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <sys/types.h>
30 #include <sys/time.h>
31 #include <sys/syscall.h>
32 #include <sys/inttypes.h>
33
34 /*
35 * The following defines establish the engineering parameters of the
36 * phase-lock loop (PLL) model used in the kernel implementation. These
37 * parameters have been carefully chosen by analysis for good stability
38 * and wide dynamic range.
39 *
40 * The hz variable is defined in the kernel build environment. It
41 * establishes the timer interrupt frequency.
42 *
43 * SCALE_KG and SCALE_KF establish the damping of the PLL and are chosen
44 * for a slightly underdamped convergence characteristic. SCALE_KH
220 struct timex {
221 uint32_t modes; /* clock mode bits (wo) */
222 int32_t offset; /* time offset (us) (rw) */
223 int32_t freq; /* frequency offset (scaled ppm) (rw) */
224 int32_t maxerror; /* maximum error (us) (rw) */
225 int32_t esterror; /* estimated error (us) (rw) */
226 int32_t status; /* clock status bits (rw) */
227 int32_t constant; /* pll time constant (rw) */
228 int32_t precision; /* clock precision (us) (ro) */
229 int32_t tolerance; /* clock freq tolerance (scaled ppm) (ro) */
230 int32_t ppsfreq; /* pps frequency (scaled ppm) (ro) */
231 int32_t jitter; /* pps jitter (us) (ro) */
232 int32_t shift; /* interval duration (s) (shift) (ro) */
233 int32_t stabil; /* pps stability (scaled ppm) (ro) */
234 int32_t jitcnt; /* jitter limit exceeded (ro) */
235 int32_t calcnt; /* calibration intervals (ro) */
236 int32_t errcnt; /* calibration errors (ro) */
237 int32_t stbcnt; /* stability limit exceeded (ro) */
238 };
239
240 /*
241 * NTP syscalls
242 */
243 int ntp_gettime(struct ntptimeval *);
244 int ntp_adjtime(struct timex *);
245
246 #ifdef _KERNEL
247
248 extern int32_t time_state; /* clock state */
249 extern int32_t time_status; /* clock status bits */
250 extern int32_t time_offset; /* time adjustment (us) */
251 extern int32_t time_freq; /* frequency offset (scaled ppm) */
252 extern int32_t time_maxerror; /* maximum error (us) */
253 extern int32_t time_esterror; /* estimated error (us) */
254 extern int32_t time_constant; /* pll time constant */
255 extern int32_t time_precision; /* clock precision (us) */
256 extern int32_t time_tolerance; /* frequency tolerance (scaled ppm) */
257 extern int32_t pps_shift; /* interval duration (s) (shift) */
258 extern int32_t pps_freq; /* pps frequency offset (scaled ppm) */
259 extern int32_t pps_jitter; /* pps jitter (us) */
260 extern int32_t pps_stabil; /* pps stability (scaled ppm) */
261 extern int32_t pps_jitcnt; /* jitter limit exceeded */
262 extern int32_t pps_calcnt; /* calibration intervals */
263 extern int32_t pps_errcnt; /* calibration errors */
264 extern int32_t pps_stbcnt; /* stability limit exceeded */
|