Deleted Added
sdiff udiff text old ( 94740 ) new ( 94754 )
full compact
1/***********************************************************************
2 * *
3 * Copyright (c) David L. Mills 1993-2001 *
4 * *
5 * Permission to use, copy, modify, and distribute this software and *
6 * its documentation for any purpose and without fee is hereby *
7 * granted, provided that the above copyright notice appears in all *
8 * copies and that both the copyright notice and this permission *

--- 14 unchanged lines hidden (view full) ---

23 * The 32bit version of the "LP" macros seems a bit past its "sell by"
24 * date so I have retained only the 64bit version and included it directly
25 * in this file.
26 *
27 * Only minor changes done to interface with the timecounters over in
28 * sys/kern/kern_clock.c. Some of the comments below may be (even more)
29 * confusing and/or plain wrong in that context.
30 *
31 * $FreeBSD: head/sys/kern/kern_ntptime.c 94740 2002-04-15 08:58:24Z phk $
32 */
33
34#include "opt_ntp.h"
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/sysproto.h>
39#include <sys/kernel.h>

--- 107 unchanged lines hidden (view full) ---

147static long time_maxerror = MAXPHASE / 1000; /* maximum error (us) */
148static long time_esterror = MAXPHASE / 1000; /* estimated error (us) */
149static long time_reftime; /* time at last adjustment (s) */
150static long time_tick; /* nanoseconds per tick (ns) */
151static l_fp time_offset; /* time offset (ns) */
152static l_fp time_freq; /* frequency offset (ns/s) */
153static l_fp time_adj; /* tick adjust (ns/s) */
154
155#ifdef PPS_SYNC
156/*
157 * The following variables are used when a pulse-per-second (PPS) signal
158 * is available and connected via a modem control lead. They establish
159 * the engineering parameters of the clock discipline loop when
160 * controlled by the PPS signal.
161 */
162#define PPS_FAVG 2 /* min freq avg interval (s) (shift) */

--- 269 unchanged lines hidden (view full) ---

432 * routine ntp_tick_adjust(). While these two routines are normally
433 * combined, they are separated here only for the purposes of
434 * simulation.
435 */
436void
437ntp_update_second(struct timecounter *tcp)
438{
439 u_int32_t *newsec;
440 l_fp ftemp; /* 32/64-bit temporary */
441
442 newsec = &tcp->tc_offset.sec;
443 /*
444 * On rollover of the second both the nanosecond and microsecond
445 * clocks are updated and the state machine cranked as
446 * necessary. The phase adjustment to be used for the next
447 * second is calculated and the maximum error is increased by

--- 79 unchanged lines hidden (view full) ---

527 else
528 L_RSHIFT(ftemp, SHIFT_PLL + time_constant);
529#else
530 L_RSHIFT(ftemp, SHIFT_PLL + time_constant);
531#endif /* PPS_SYNC */
532 time_adj = ftemp;
533 L_SUB(time_offset, ftemp);
534 L_ADD(time_adj, time_freq);
535 tcp->tc_adjustment = time_adj;
536#ifdef PPS_SYNC
537 if (pps_valid > 0)
538 pps_valid--;
539 else
540 time_status &= ~STA_PPSSIGNAL;
541#endif /* PPS_SYNC */
542}
543

--- 316 unchanged lines hidden (view full) ---

860 if (u_nsec > MAXFREQ)
861 L_LINT(pps_freq, MAXFREQ);
862 else if (u_nsec < -MAXFREQ)
863 L_LINT(pps_freq, -MAXFREQ);
864 if (time_status & STA_PPSFREQ)
865 time_freq = pps_freq;
866}
867#endif /* PPS_SYNC */