summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorjhay <jhay@FreeBSD.org>2003-01-16 19:22:13 +0000
committerjhay <jhay@FreeBSD.org>2003-01-16 19:22:13 +0000
commitd24749bcb4e67543035c97dc4f77cf1aa283dfa4 (patch)
tree0be3fc74e6e2995bdfc276c58dcc4c7fc32a7434 /sys/kern
parentef30ad92edb7455998fa8ffbc607d2432c24e12c (diff)
downloadFreeBSD-src-d24749bcb4e67543035c97dc4f77cf1aa283dfa4.zip
FreeBSD-src-d24749bcb4e67543035c97dc4f77cf1aa283dfa4.tar.gz
hardpps() wants the raw hardware counter value converted to nanoseconds.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_tc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index bfe154f..c954bdc 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -561,6 +561,7 @@ pps_event(struct pps_state *pps, int event)
{
struct bintime bt;
struct timespec ts, *tsp, *osp;
+ u_int64_t scale;
u_int tcount, *pcount;
int foff, fhard;
pps_seq_t *pseq;
@@ -628,19 +629,18 @@ pps_event(struct pps_state *pps, int event)
if (fhard) {
/*
* Feed the NTP PLL/FLL.
- * The FLL wants to know how many nanoseconds elapsed since
- * the previous event.
- * I have never been able to convince myself that this code
- * is actually correct: Using th_scale is bound to contain
- * a phase correction component from userland, when running
- * as FLL, so the number hardpps() gets is not meaningful IMO.
+ * The FLL wants to know how many (hardware) nanoseconds
+ * elapsed since the previous event.
*/
tcount = pps->capcount - pps->ppscount[2];
pps->ppscount[2] = pps->capcount;
tcount &= pps->capth->th_counter->tc_counter_mask;
+ scale = (u_int64_t)1 << 63;
+ scale /= pps->capth->th_counter->tc_frequency;
+ scale *= 2;
bt.sec = 0;
bt.frac = 0;
- bintime_addx(&bt, pps->capth->th_scale * tcount);
+ bintime_addx(&bt, scale * tcount);
bintime2timespec(&bt, &ts);
hardpps(tsp, ts.tv_nsec + 1000000000 * ts.tv_sec);
}
OpenPOWER on IntegriCloud