The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/timex.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: timex.h,v 1.12 2006/06/07 22:34:18 kardel Exp $        */
    2 
    3 #ifdef __HAVE_TIMECOUNTER
    4 /*-
    5  ***********************************************************************
    6  *                                                                     *
    7  * Copyright (c) David L. Mills 1993-2001                              *
    8  *                                                                     *
    9  * Permission to use, copy, modify, and distribute this software and   *
   10  * its documentation for any purpose and without fee is hereby         *
   11  * granted, provided that the above copyright notice appears in all    *
   12  * copies and that both the copyright notice and this permission       *
   13  * notice appear in supporting documentation, and that the name        *
   14  * University of Delaware not be used in advertising or publicity      *
   15  * pertaining to distribution of the software without specific,        *
   16  * written prior permission. The University of Delaware makes no       *
   17  * representations about the suitability this software for any         *
   18  * purpose. It is provided "as is" without express or implied          *
   19  * warranty.                                                           *
   20  *                                                                     *
   21  **********************************************************************/
   22 
   23 /*
   24  * Modification history timex.h
   25  *
   26  * 16 Aug 00    David L. Mills
   27  *      API Version 4. Added MOD_TAI and tai member of ntptimeval
   28  *      structure.
   29  *
   30  * 17 Nov 98    David L. Mills
   31  *      Revised for nanosecond kernel and user interface.
   32  *
   33  * 26 Sep 94    David L. Mills
   34  *      Added defines for hybrid phase/frequency-lock loop.
   35  *
   36  * 19 Mar 94    David L. Mills
   37  *      Moved defines from kernel routines to header file and added new
   38  *      defines for PPS phase-lock loop.
   39  *
   40  * 20 Feb 94    David L. Mills
   41  *      Revised status codes and structures for external clock and PPS
   42  *      signal discipline.
   43  *
   44  * 28 Nov 93    David L. Mills
   45  *      Adjusted parameters to improve stability and increase poll
   46  *      interval.
   47  *
   48  * 17 Sep 93    David L. Mills
   49  *      Created file
   50  *
   51  * $FreeBSD: src/sys/sys/timex.h,v 1.18 2005/01/07 02:29:24 imp Exp $
   52  */
   53 /*
   54  * This header file defines the Network Time Protocol (NTP) interfaces
   55  * for user and daemon application programs. These are implemented using
   56  * defined syscalls and data structures and require specific kernel
   57  * support.
   58  *
   59  * The original precision time kernels developed from 1993 have an
   60  * ultimate resolution of one microsecond; however, the most recent
   61  * kernels have an ultimate resolution of one nanosecond. In these
   62  * kernels, a ntp_adjtime() syscalls can be used to determine which
   63  * resolution is in use and to select either one at any time. The
   64  * resolution selected affects the scaling of certain fields in the
   65  * ntp_gettime() and ntp_adjtime() syscalls, as described below.
   66  *
   67  * NAME
   68  *      ntp_gettime - NTP user application interface
   69  *
   70  * SYNOPSIS
   71  *      #include <sys/timex.h>
   72  *
   73  *      int ntp_gettime(struct ntptimeval *ntv);
   74  *
   75  * DESCRIPTION
   76  *      The time returned by ntp_gettime() is in a timespec structure,
   77  *      but may be in either microsecond (seconds and microseconds) or
   78  *      nanosecond (seconds and nanoseconds) format. The particular
   79  *      format in use is determined by the STA_NANO bit of the status
   80  *      word returned by the ntp_adjtime() syscall.
   81  *
   82  * NAME
   83  *      ntp_adjtime - NTP daemon application interface
   84  *
   85  * SYNOPSIS
   86  *      #include <sys/timex.h>
   87  *      #include <sys/syscall.h>
   88  *
   89  *      int syscall(SYS_ntp_adjtime, tptr);
   90  *      int SYS_ntp_adjtime;
   91  *      struct timex *tptr;
   92  *
   93  * DESCRIPTION
   94  *      Certain fields of the timex structure are interpreted in either
   95  *      microseconds or nanoseconds according to the state of the
   96  *      STA_NANO bit in the status word. See the description below for
   97  *      further information.
   98  */
   99 #ifndef _SYS_TIMEX_H_
  100 #define _SYS_TIMEX_H_ 1
  101 #define NTP_API         4       /* NTP API version */
  102 
  103 #ifndef MSDOS                   /* Microsoft specific */
  104 #include <sys/syscall.h>
  105 #endif /* MSDOS */
  106 
  107 /*
  108  * The following defines establish the performance envelope of the
  109  * kernel discipline loop. Phase or frequency errors greater than
  110  * NAXPHASE or MAXFREQ are clamped to these maxima. For update intervals
  111  * less than MINSEC, the loop always operates in PLL mode; while, for
  112  * update intervals greater than MAXSEC, the loop always operates in FLL
  113  * mode. Between these two limits the operating mode is selected by the
  114  * STA_FLL bit in the status word.
  115  */
  116 #define MAXPHASE        500000000L /* max phase error (ns) */
  117 #define MAXFREQ         500000L /* max freq error (ns/s) */
  118 #define MINSEC          256     /* min FLL update interval (s) */
  119 #define MAXSEC          2048    /* max PLL update interval (s) */
  120 #define NANOSECOND      1000000000L /* nanoseconds in one second */
  121 #define SCALE_PPM       (65536 / 1000) /* crude ns/s to scaled PPM */
  122 #define MAXTC           10      /* max time constant */
  123 
  124 /*
  125  * The following defines and structures define the user interface for
  126  * the ntp_gettime() and ntp_adjtime() syscalls.
  127  *
  128  * Control mode codes (timex.modes)
  129  */
  130 #define MOD_OFFSET      0x0001  /* set time offset */
  131 #define MOD_FREQUENCY   0x0002  /* set frequency offset */
  132 #define MOD_MAXERROR    0x0004  /* set maximum time error */
  133 #define MOD_ESTERROR    0x0008  /* set estimated time error */
  134 #define MOD_STATUS      0x0010  /* set clock status bits */
  135 #define MOD_TIMECONST   0x0020  /* set PLL time constant */
  136 #define MOD_PPSMAX      0x0040  /* set PPS maximum averaging time */
  137 #define MOD_TAI         0x0080  /* set TAI offset */
  138 #define MOD_MICRO       0x1000  /* select microsecond resolution */
  139 #define MOD_NANO        0x2000  /* select nanosecond resolution */
  140 #define MOD_CLKB        0x4000  /* select clock B */
  141 #define MOD_CLKA        0x8000  /* select clock A */
  142 
  143 /*
  144  * Status codes (timex.status)
  145  */
  146 #define STA_PLL         0x0001  /* enable PLL updates (rw) */
  147 #define STA_PPSFREQ     0x0002  /* enable PPS freq discipline (rw) */
  148 #define STA_PPSTIME     0x0004  /* enable PPS time discipline (rw) */
  149 #define STA_FLL         0x0008  /* enable FLL mode (rw) */
  150 #define STA_INS         0x0010  /* insert leap (rw) */
  151 #define STA_DEL         0x0020  /* delete leap (rw) */
  152 #define STA_UNSYNC      0x0040  /* clock unsynchronized (rw) */
  153 #define STA_FREQHOLD    0x0080  /* hold frequency (rw) */
  154 #define STA_PPSSIGNAL   0x0100  /* PPS signal present (ro) */
  155 #define STA_PPSJITTER   0x0200  /* PPS signal jitter exceeded (ro) */
  156 #define STA_PPSWANDER   0x0400  /* PPS signal wander exceeded (ro) */
  157 #define STA_PPSERROR    0x0800  /* PPS signal calibration error (ro) */
  158 #define STA_CLOCKERR    0x1000  /* clock hardware fault (ro) */
  159 #define STA_NANO        0x2000  /* resolution (0 = us, 1 = ns) (ro) */
  160 #define STA_MODE        0x4000  /* mode (0 = PLL, 1 = FLL) (ro) */
  161 #define STA_CLK         0x8000  /* clock source (0 = A, 1 = B) (ro) */
  162 
  163 #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
  164     STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
  165 
  166 /*
  167  * Clock states (time_state)
  168  */
  169 #define TIME_OK         0       /* no leap second warning */
  170 #define TIME_INS        1       /* insert leap second warning */
  171 #define TIME_DEL        2       /* delete leap second warning */
  172 #define TIME_OOP        3       /* leap second in progress */
  173 #define TIME_WAIT       4       /* leap second has occured */
  174 #define TIME_ERROR      5       /* error (see status word) */
  175 
  176 /*
  177  * NTP user interface (ntp_gettime()) - used to read kernel clock values
  178  *
  179  * Note: The time member is in microseconds if STA_NANO is zero and
  180  * nanoseconds if not.
  181  */
  182 struct ntptimeval {
  183         struct timespec time;   /* current time (ns) (ro) */
  184         long maxerror;          /* maximum error (us) (ro) */
  185         long esterror;          /* estimated error (us) (ro) */
  186         long tai;               /* TAI offset */
  187         int time_state;         /* time status */
  188 };
  189 
  190 /*
  191  * NTP daemon interface (ntp_adjtime()) - used to discipline CPU clock
  192  * oscillator and determine status.
  193  *
  194  * Note: The offset, precision and jitter members are in microseconds if
  195  * STA_NANO is zero and nanoseconds if not.
  196  */
  197 struct timex {
  198         unsigned int modes;     /* clock mode bits (wo) */
  199         long    offset;         /* time offset (ns/us) (rw) */
  200         long    freq;           /* frequency offset (scaled PPM) (rw) */
  201         long    maxerror;       /* maximum error (us) (rw) */
  202         long    esterror;       /* estimated error (us) (rw) */
  203         int     status;         /* clock status bits (rw) */
  204         long    constant;       /* poll interval (log2 s) (rw) */
  205         long    precision;      /* clock precision (ns/us) (ro) */
  206         long    tolerance;      /* clock frequency tolerance (scaled
  207                                  * PPM) (ro) */
  208         /*
  209          * The following read-only structure members are implemented
  210          * only if the PPS signal discipline is configured in the
  211          * kernel. They are included in all configurations to insure
  212          * portability.
  213          */
  214         long    ppsfreq;        /* PPS frequency (scaled PPM) (ro) */
  215         long    jitter;         /* PPS jitter (ns/us) (ro) */
  216         int     shift;          /* interval duration (s) (shift) (ro) */
  217         long    stabil;         /* PPS stability (scaled PPM) (ro) */
  218         long    jitcnt;         /* jitter limit exceeded (ro) */
  219         long    calcnt;         /* calibration intervals (ro) */
  220         long    errcnt;         /* calibration errors (ro) */
  221         long    stbcnt;         /* stability limit exceeded (ro) */
  222 };
  223 
  224 #if defined(__FreeBSD__) || defined(__NetBSD__)
  225 
  226 #ifdef _KERNEL
  227 void    ntp_update_second(int64_t *adjustment, time_t *newsec);
  228 #ifdef __NetBSD__
  229 void    ntp_adjtime1(struct timex *);
  230 void    ntp_gettime(struct ntptimeval *);
  231 int ntp_timestatus(void);
  232 #endif /* __NetBSD__ */
  233 #else /* !_KERNEL */
  234 #include <sys/cdefs.h>
  235 
  236 __BEGIN_DECLS
  237 #ifdef __NetBSD__
  238 #ifndef __LIBC12_SOURCE__
  239 int ntp_gettime(struct ntptimeval *) __RENAME(__ntp_gettime30);
  240 #endif
  241 #else
  242 int ntp_gettime(struct ntptimeval *);
  243 #endif
  244 int ntp_adjtime(struct timex *);
  245 __END_DECLS
  246 #endif /* _KERNEL */
  247 
  248 #endif /* __FreeBSD__ || __NetBSD__ */
  249 
  250 #endif /* _SYS_TIMEX_H_ */
  251 #else /* !__HAVE_TIMECOUNTER */
  252 /******************************************************************************
  253  *                                                                            *
  254  * Copyright (c) David L. Mills 1993, 1994                                    *
  255  *                                                                            *
  256  * Permission to use, copy, modify, and distribute this software and its      *
  257  * documentation for any purpose and without fee is hereby granted, provided  *
  258  * that the above copyright notice appears in all copies and that both the    *
  259  * copyright notice and this permission notice appear in supporting           *
  260  * documentation, and that the name University of Delaware not be used in     *
  261  * advertising or publicity pertaining to distribution of the software        *
  262  * without specific, written prior permission.  The University of Delaware    *
  263  * makes no representations about the suitability this software for any       *
  264  * purpose.  It is provided "as is" without express or implied warranty.      *
  265  *                                                                            *
  266  ******************************************************************************/
  267 
  268 /*
  269  * Modification history timex.h
  270  *
  271  * 26 Sep 94    David L. Mills
  272  *      Added defines for hybrid phase/frequency-lock loop.
  273  *
  274  * 19 Mar 94    David L. Mills
  275  *      Moved defines from kernel routines to header file and added new
  276  *      defines for PPS phase-lock loop.
  277  *
  278  * 20 Feb 94    David L. Mills
  279  *      Revised status codes and structures for external clock and PPS
  280  *      signal discipline.
  281  *
  282  * 28 Nov 93    David L. Mills
  283  *      Adjusted parameters to improve stability and increase poll
  284  *      interval.
  285  *
  286  * 17 Sep 93    David L. Mills
  287  *      Created file
  288  */
  289 /*
  290  * This header file defines the Network Time Protocol (NTP) interfaces
  291  * for user and daemon application programs. These are implemented using
  292  * private syscalls and data structures and require specific kernel
  293  * support.
  294  *
  295  * NAME
  296  *      ntp_gettime - NTP user application interface
  297  *
  298  * SYNOPSIS
  299  *      #include <sys/timex.h>
  300  *
  301  *      int syscall(SYS_ntp_gettime, tptr)
  302  *
  303  *      int SYS_ntp_gettime             defined in syscall.h header file
  304  *      struct ntptimeval *tptr         pointer to ntptimeval structure
  305  *
  306  * NAME
  307  *      ntp_adjtime - NTP daemon application interface
  308  *
  309  * SYNOPSIS
  310  *      #include <sys/timex.h>
  311  *
  312  *      int syscall(SYS_ntp_adjtime, mode, tptr)
  313  *
  314  *      int SYS_ntp_adjtime             defined in syscall.h header file
  315  *      struct timex *tptr              pointer to timex structure
  316  *
  317  */
  318 #ifndef _SYS_TIMEX_H_
  319 #define _SYS_TIMEX_H_
  320 
  321 #ifndef MSDOS                   /* Microsoft specific */
  322 #include <sys/syscall.h>
  323 #endif /* MSDOS */
  324 
  325 /*
  326  * The following defines establish the engineering parameters of the
  327  * phase-lock loop (PLL) model used in the kernel implementation. These
  328  * parameters have been carefully chosen by analysis for good stability
  329  * and wide dynamic range.
  330  *
  331  * The hz variable is defined in the kernel build environment. It
  332  * establishes the timer interrupt frequency, 100 Hz for the SunOS
  333  * kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the OSF/1
  334  * kernel. SHIFT_HZ expresses the same value as the nearest power of two
  335  * in order to avoid hardware multiply operations.
  336  *
  337  * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
  338  * for a slightly underdamped convergence characteristic. SHIFT_KH
  339  * establishes the damping of the FLL and is chosen by wisdom and black
  340  * art.
  341  *
  342  * MAXTC establishes the maximum time constant of the PLL. With the
  343  * SHIFT_KG and SHIFT_KF values given and a time constant range from
  344  * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
  345  * respectively.
  346  */
  347 
  348 
  349 #define SHIFT_KG 6              /* phase factor (shift) */
  350 #define SHIFT_KF 16             /* PLL frequency factor (shift) */
  351 #define SHIFT_KH 2              /* FLL frequency factor (shift) */
  352 #define MAXTC 6                 /* maximum time constant (shift) */
  353 
  354 /*
  355  * The following defines establish the scaling of the various variables
  356  * used by the PLL. They are chosen to allow the greatest precision
  357  * possible without overflow of a 32-bit word.
  358  *
  359  * SHIFT_SCALE defines the scaling (shift) of the time_phase variable,
  360  * which serves as a an extension to the low-order bits of the system
  361  * clock variable time.tv_usec.
  362  *
  363  * SHIFT_UPDATE defines the scaling (shift) of the time_offset variable,
  364  * which represents the current time offset with respect to standard
  365  * time.
  366  *
  367  * SHIFT_USEC defines the scaling (shift) of the time_freq and
  368  * time_tolerance variables, which represent the current frequency
  369  * offset and maximum frequency tolerance.
  370  *
  371  * FINEUSEC is 1 us in SHIFT_UPDATE units of the time_phase variable.
  372  */
  373 #define SHIFT_SCALE 22          /* phase scale (shift) */
  374 #define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */
  375 #define SHIFT_USEC 16           /* frequency offset scale (shift) */
  376 #define FINEUSEC (1L << SHIFT_SCALE) /* 1 us in phase units */
  377 
  378 /*
  379  * The following defines establish the performance envelope of the PLL.
  380  * They insure it operates within predefined limits, in order to satisfy
  381  * correctness assertions. An excursion which exceeds these bounds is
  382  * clamped to the bound and operation proceeds accordingly. In practice,
  383  * this can occur only if something has failed or is operating out of
  384  * tolerance, but otherwise the PLL continues to operate in a stable
  385  * mode.
  386  *
  387  * MAXPHASE must be set greater than or equal to CLOCK.MAX (128 ms), as
  388  * defined in the NTP specification. CLOCK.MAX establishes the maximum
  389  * time offset allowed before the system time is reset, rather than
  390  * incrementally adjusted. Here, the maximum offset is clamped to
  391  * MAXPHASE only in order to prevent overflow errors due to defective
  392  * protocol implementations.
  393  *
  394  * MAXFREQ is the maximum frequency tolerance of the CPU clock
  395  * oscillator plus the maximum slew rate allowed by the protocol. It
  396  * should be set to at least the frequency tolerance of the oscillator
  397  * plus 100 ppm for vernier frequency adjustments. If the kernel
  398  * PPS discipline code is configured (PPS_SYNC), the oscillator time and
  399  * frequency are disciplined to an external source, presumably with
  400  * negligible time and frequency error relative to UTC, and MAXFREQ can
  401  * be reduced.
  402  *
  403  * MAXTIME is the maximum jitter tolerance of the PPS signal if the
  404  * kernel PPS discipline code is configured (PPS_SYNC).
  405  *
  406  * MINSEC and MAXSEC define the lower and upper bounds on the interval
  407  * between protocol updates.
  408  */
  409 #define MAXPHASE 512000L        /* max phase error (us) */
  410 #ifdef PPS_SYNC
  411 #define MAXFREQ (512L << SHIFT_USEC) /* max freq error (100 ppm) */
  412 #define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */
  413 #else
  414 #define MAXFREQ (512L << SHIFT_USEC) /* max freq error (200 ppm) */
  415 #endif /* PPS_SYNC */
  416 #define MINSEC 16L              /* min interval between updates (s) */
  417 #define MAXSEC 1200L            /* max interval between updates (s) */
  418 
  419 #ifdef PPS_SYNC
  420 /*
  421  * The following defines are used only if a pulse-per-second (PPS)
  422  * signal is available and connected via a modem control lead, such as
  423  * produced by the optional ppsclock feature incorporated in the Sun
  424  * asynch driver. They establish the design parameters of the frequency-
  425  * lock loop used to discipline the CPU clock oscillator to the PPS
  426  * signal.
  427  *
  428  * PPS_AVG is the averaging factor for the frequency loop, as well as
  429  * the time and frequency dispersion.
  430  *
  431  * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum
  432  * calibration intervals, respectively, in seconds as a power of two.
  433  *
  434  * PPS_VALID is the maximum interval before the PPS signal is considered
  435  * invalid and protocol updates used directly instead.
  436  *
  437  * MAXGLITCH is the maximum interval before a time offset of more than
  438  * MAXTIME is believed.
  439  */
  440 #define PPS_AVG 2               /* pps averaging constant (shift) */
  441 #define PPS_SHIFT 2             /* min interval duration (s) (shift) */
  442 #define PPS_SHIFTMAX 8          /* max interval duration (s) (shift) */
  443 #define PPS_VALID 120           /* pps signal watchdog max (s) */
  444 #define MAXGLITCH 30            /* pps signal glitch max (s) */
  445 #endif /* PPS_SYNC */
  446 
  447 /*
  448  * The following defines and structures define the user interface for
  449  * the ntp_gettime() and ntp_adjtime() system calls.
  450  *
  451  * Control mode codes (timex.modes)
  452  */
  453 #define MOD_OFFSET      0x0001  /* set time offset */
  454 #define MOD_FREQUENCY   0x0002  /* set frequency offset */
  455 #define MOD_MAXERROR    0x0004  /* set maximum time error */
  456 #define MOD_ESTERROR    0x0008  /* set estimated time error */
  457 #define MOD_STATUS      0x0010  /* set clock status bits */
  458 #define MOD_TIMECONST   0x0020  /* set pll time constant */
  459 #define MOD_CLKB        0x4000  /* set clock B */
  460 #define MOD_CLKA        0x8000  /* set clock A */
  461 
  462 /*
  463  * Status codes (timex.status)
  464  */
  465 #define STA_PLL         0x0001  /* enable PLL updates (rw) */
  466 #define STA_PPSFREQ     0x0002  /* enable PPS freq discipline (rw) */
  467 #define STA_PPSTIME     0x0004  /* enable PPS time discipline (rw) */
  468 #define STA_FLL         0x0008  /* select frequency-lock mode (rw) */
  469 
  470 #define STA_INS         0x0010  /* insert leap (rw) */
  471 #define STA_DEL         0x0020  /* delete leap (rw) */
  472 #define STA_UNSYNC      0x0040  /* clock unsynchronized (rw) */
  473 #define STA_FREQHOLD    0x0080  /* hold frequency (rw) */
  474 
  475 #define STA_PPSSIGNAL   0x0100  /* PPS signal present (ro) */
  476 #define STA_PPSJITTER   0x0200  /* PPS signal jitter exceeded (ro) */
  477 #define STA_PPSWANDER   0x0400  /* PPS signal wander exceeded (ro) */
  478 #define STA_PPSERROR    0x0800  /* PPS signal calibration error (ro) */
  479 
  480 #define STA_CLOCKERR    0x1000  /* clock hardware fault (ro) */
  481 
  482 #define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
  483     STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
  484 
  485 /*
  486  * Clock states (time_state)
  487  */
  488 #define TIME_OK         0       /* no leap second warning */
  489 #define TIME_INS        1       /* insert leap second warning */
  490 #define TIME_DEL        2       /* delete leap second warning */
  491 #define TIME_OOP        3       /* leap second in progress */
  492 #define TIME_WAIT       4       /* leap second has occurred */
  493 #define TIME_ERROR      5       /* clock not synchronized */
  494 
  495 /*
  496  * NTP user interface (ntp_gettime()) - used to read kernel clock values
  497  *
  498  * Note: maximum error = NTP synch distance = dispersion + delay / 2;
  499  * estimated error = NTP dispersion.
  500  */
  501 struct ntptimeval {
  502         struct timespec time;   /* current time (ro) */
  503         long maxerror;          /* maximum error (us) (ro) */
  504         long esterror;          /* estimated error (us) (ro) */
  505 
  506         /* the following are placeholders for now */
  507         long tai;               /* TAI offset */
  508         int time_state;         /* time status */
  509 };
  510 
  511 /*
  512  * NTP daemon interface - (ntp_adjtime()) used to discipline CPU clock
  513  * oscillator
  514  */
  515 struct timex {
  516         unsigned int modes;     /* clock mode bits (wo) */
  517         long offset;            /* time offset (us) (rw) */
  518         long freq;              /* frequency offset (scaled ppm) (rw) */
  519         long maxerror;          /* maximum error (us) (rw) */
  520         long esterror;          /* estimated error (us) (rw) */
  521         int status;             /* clock status bits (rw) */
  522         long constant;          /* pll time constant (rw) */
  523         long precision;         /* clock precision (us) (ro) */
  524         long tolerance;         /* clock frequency tolerance (scaled
  525                                  * ppm) (ro) */
  526         /*
  527          * The following read-only structure members are implemented
  528          * only if the PPS signal discipline is configured in the
  529          * kernel.
  530          */
  531         long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
  532         long jitter;            /* pps jitter (us) (ro) */
  533         int shift;              /* interval duration (s) (shift) (ro) */
  534         long stabil;            /* pps stability (scaled ppm) (ro) */
  535         long jitcnt;            /* jitter limit exceeded (ro) */
  536         long calcnt;            /* calibration intervals (ro) */
  537         long errcnt;            /* calibration errors (ro) */
  538         long stbcnt;            /* stability limit exceeded (ro) */
  539 
  540 };
  541 
  542 #if defined(__FreeBSD__) || defined(__NetBSD__)
  543 
  544 #ifndef _KERNEL
  545 #include <sys/cdefs.h>
  546 
  547 __BEGIN_DECLS
  548 #ifdef __NetBSD__
  549 #ifndef __LIBC12_SOURCE__
  550 int ntp_gettime(struct ntptimeval *) __RENAME(__ntp_gettime30);
  551 #endif
  552 #else
  553 int ntp_gettime(struct ntptimeval *);
  554 #endif
  555 int ntp_adjtime(struct timex *);
  556 __END_DECLS
  557 
  558 #endif /* not _KERNEL */
  559 
  560 #endif /* __FreeBSD__ || __NetBSD__ */
  561 
  562 #ifdef __NetBSD__
  563 #ifdef _KERNEL
  564 __BEGIN_DECLS
  565 void ntp_gettime(struct ntptimeval *);
  566 int ntp_timestatus(void);
  567 void ntp_adjtime1(struct timex *);
  568 __END_DECLS
  569 #endif /* _KERNEL */
  570 #endif /* __NetBSD__ */
  571 #endif /* _SYS_TIMEX_H_ */
  572 #endif /* !__HAVE_TIMECOUNTER */

Cache object: f34ab389a8b63699b516efee7c841507


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.