diff options
author | phk <phk@FreeBSD.org> | 1998-06-07 20:36:55 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1998-06-07 20:36:55 +0000 |
commit | 8c3dc868d38f3bd0cfe972fe736d59942d9a2251 (patch) | |
tree | e84bebaaf18b9e9e7e2e10003bfd0e527180c8ea | |
parent | 8ccd49e34b242ceac1a333b2fbd3fc058b29da24 (diff) | |
download | FreeBSD-src-8c3dc868d38f3bd0cfe972fe736d59942d9a2251.zip FreeBSD-src-8c3dc868d38f3bd0cfe972fe736d59942d9a2251.tar.gz |
Add a member function more to the timecounters, this one is for use
with latch based PPS implementations. The client that uses it will
be committed after more testing.
-rw-r--r-- | sys/amd64/amd64/tsc.c | 4 | ||||
-rw-r--r-- | sys/amd64/isa/clock.c | 4 | ||||
-rw-r--r-- | sys/i386/i386/tsc.c | 4 | ||||
-rw-r--r-- | sys/i386/isa/clock.c | 4 | ||||
-rw-r--r-- | sys/i386/isa/loran.c | 3 | ||||
-rw-r--r-- | sys/isa/atrtc.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_clock.c | 38 | ||||
-rw-r--r-- | sys/kern/kern_tc.c | 38 | ||||
-rw-r--r-- | sys/sys/time.h | 5 | ||||
-rw-r--r-- | sys/sys/timetc.h | 5 |
10 files changed, 89 insertions, 20 deletions
diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c index 9c8e44f..0cc4bc2 100644 --- a/sys/amd64/amd64/tsc.c +++ b/sys/amd64/amd64/tsc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $ + * $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $ */ /* @@ -175,6 +175,7 @@ static void set_timer_freq(u_int freq, int intr_freq); static struct timecounter tsc_timecounter[3] = { tsc_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "TSC" /* name */ @@ -185,6 +186,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD, static struct timecounter i8254_timecounter[3] = { i8254_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "i8254" /* name */ diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 9c8e44f..0cc4bc2 100644 --- a/sys/amd64/isa/clock.c +++ b/sys/amd64/isa/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $ + * $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $ */ /* @@ -175,6 +175,7 @@ static void set_timer_freq(u_int freq, int intr_freq); static struct timecounter tsc_timecounter[3] = { tsc_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "TSC" /* name */ @@ -185,6 +186,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD, static struct timecounter i8254_timecounter[3] = { i8254_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "i8254" /* name */ diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c index 9c8e44f..0cc4bc2 100644 --- a/sys/i386/i386/tsc.c +++ b/sys/i386/i386/tsc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $ + * $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $ */ /* @@ -175,6 +175,7 @@ static void set_timer_freq(u_int freq, int intr_freq); static struct timecounter tsc_timecounter[3] = { tsc_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "TSC" /* name */ @@ -185,6 +186,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD, static struct timecounter i8254_timecounter[3] = { i8254_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "i8254" /* name */ diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 9c8e44f..0cc4bc2 100644 --- a/sys/i386/isa/clock.c +++ b/sys/i386/isa/clock.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $ + * $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $ */ /* @@ -175,6 +175,7 @@ static void set_timer_freq(u_int freq, int intr_freq); static struct timecounter tsc_timecounter[3] = { tsc_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "TSC" /* name */ @@ -185,6 +186,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD, static struct timecounter i8254_timecounter[3] = { i8254_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "i8254" /* name */ diff --git a/sys/i386/isa/loran.c b/sys/i386/isa/loran.c index 9e8aa93..f58f062 100644 --- a/sys/i386/isa/loran.c +++ b/sys/i386/isa/loran.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: loran.c,v 1.4 1998/04/19 15:36:12 bde Exp $ + * $Id: loran.c,v 1.5 1998/05/29 08:04:44 phk Exp $ * * This device-driver helps the userland controlprogram for a LORAN-C * receiver avoid monopolizing the CPU. @@ -566,6 +566,7 @@ loran_get_timecount(void) static struct timecounter loran_timecounter[3] = { loran_get_timecount, /* get_timecount */ + 0, /* no pps_poll */ 0xffff, /* counter_mask */ 5000000, /* frequency */ "loran" /* name */ diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index 9c8e44f..0cc4bc2 100644 --- a/sys/isa/atrtc.c +++ b/sys/isa/atrtc.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * from: @(#)clock.c 7.2 (Berkeley) 5/12/91 - * $Id: clock.c,v 1.121 1998/05/28 09:30:06 phk Exp $ + * $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $ */ /* @@ -175,6 +175,7 @@ static void set_timer_freq(u_int freq, int intr_freq); static struct timecounter tsc_timecounter[3] = { tsc_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "TSC" /* name */ @@ -185,6 +186,7 @@ SYSCTL_OPAQUE(_debug, OID_AUTO, tsc_timecounter, CTLFLAG_RD, static struct timecounter i8254_timecounter[3] = { i8254_get_timecount, /* get_timecount */ + 0, /* no poll_pps */ ~0u, /* counter_mask */ 0, /* frequency */ "i8254" /* name */ diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index bba8ef7..2316b80 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -39,7 +39,7 @@ static volatile int print_tci = 1; * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.70 1998/05/28 09:30:16 phk Exp $ + * $Id: kern_clock.c,v 1.71 1998/06/07 08:40:41 phk Exp $ */ #include <sys/param.h> @@ -545,26 +545,49 @@ microtime(struct timeval *tv) } void -nanotime(struct timespec *tv) +nanotime(struct timespec *ts) { unsigned count; u_int64_t delta; struct timecounter *tc; tc = (struct timecounter *)timecounter; - tv->tv_sec = tc->offset_sec; + ts->tv_sec = tc->offset_sec; count = tco_getdelta(tc); delta = tc->offset_nano; delta += ((u_int64_t)count * tc->scale_nano_f); delta >>= 32; delta += ((u_int64_t)count * tc->scale_nano_i); delta += boottime.tv_usec * 1000; - tv->tv_sec += boottime.tv_sec; + ts->tv_sec += boottime.tv_sec; while (delta >= 1000000000) { delta -= 1000000000; - tv->tv_sec++; + ts->tv_sec++; } - tv->tv_nsec = delta; + ts->tv_nsec = delta; +} + +void +timecounter_timespec(unsigned count, struct timespec *ts) +{ + u_int64_t delta; + struct timecounter *tc; + + tc = (struct timecounter *)timecounter; + ts->tv_sec = tc->offset_sec; + count -= tc->offset_count; + count &= tc->counter_mask; + delta = tc->offset_nano; + delta += ((u_int64_t)count * tc->scale_nano_f); + delta >>= 32; + delta += ((u_int64_t)count * tc->scale_nano_i); + delta += boottime.tv_usec * 1000; + ts->tv_sec += boottime.tv_sec; + while (delta >= 1000000000) { + delta -= 1000000000; + ts->tv_sec++; + } + ts->tv_nsec = delta; } void @@ -726,6 +749,8 @@ sync_other_counter(void) struct timecounter *tc, *tco; unsigned delta; + if (timecounter->poll_pps) + timecounter->poll_pps(timecounter); tc = timecounter->other; tco = tc->other; *tc = *timecounter; @@ -814,6 +839,7 @@ dummy_get_timecount(void *tc) static struct timecounter dummy_timecounter[3] = { { dummy_get_timecount, + 0, ~0u, 1000000, "dummy" diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index bba8ef7..2316b80 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -39,7 +39,7 @@ static volatile int print_tci = 1; * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.70 1998/05/28 09:30:16 phk Exp $ + * $Id: kern_clock.c,v 1.71 1998/06/07 08:40:41 phk Exp $ */ #include <sys/param.h> @@ -545,26 +545,49 @@ microtime(struct timeval *tv) } void -nanotime(struct timespec *tv) +nanotime(struct timespec *ts) { unsigned count; u_int64_t delta; struct timecounter *tc; tc = (struct timecounter *)timecounter; - tv->tv_sec = tc->offset_sec; + ts->tv_sec = tc->offset_sec; count = tco_getdelta(tc); delta = tc->offset_nano; delta += ((u_int64_t)count * tc->scale_nano_f); delta >>= 32; delta += ((u_int64_t)count * tc->scale_nano_i); delta += boottime.tv_usec * 1000; - tv->tv_sec += boottime.tv_sec; + ts->tv_sec += boottime.tv_sec; while (delta >= 1000000000) { delta -= 1000000000; - tv->tv_sec++; + ts->tv_sec++; } - tv->tv_nsec = delta; + ts->tv_nsec = delta; +} + +void +timecounter_timespec(unsigned count, struct timespec *ts) +{ + u_int64_t delta; + struct timecounter *tc; + + tc = (struct timecounter *)timecounter; + ts->tv_sec = tc->offset_sec; + count -= tc->offset_count; + count &= tc->counter_mask; + delta = tc->offset_nano; + delta += ((u_int64_t)count * tc->scale_nano_f); + delta >>= 32; + delta += ((u_int64_t)count * tc->scale_nano_i); + delta += boottime.tv_usec * 1000; + ts->tv_sec += boottime.tv_sec; + while (delta >= 1000000000) { + delta -= 1000000000; + ts->tv_sec++; + } + ts->tv_nsec = delta; } void @@ -726,6 +749,8 @@ sync_other_counter(void) struct timecounter *tc, *tco; unsigned delta; + if (timecounter->poll_pps) + timecounter->poll_pps(timecounter); tc = timecounter->other; tco = tc->other; *tc = *timecounter; @@ -814,6 +839,7 @@ dummy_get_timecount(void *tc) static struct timecounter dummy_timecounter[3] = { { dummy_get_timecount, + 0, ~0u, 1000000, "dummy" diff --git a/sys/sys/time.h b/sys/sys/time.h index b31b7d7..164ae86 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $Id: time.h,v 1.30 1998/06/07 08:40:53 phk Exp $ + * $Id: time.h,v 1.31 1998/06/07 14:14:39 phk Exp $ */ #ifndef _SYS_TIME_H_ @@ -128,10 +128,12 @@ struct timezone { struct timecounter; typedef unsigned timecounter_get_t __P((struct timecounter *)); +typedef void timecounter_pps_t __P((struct timecounter *)); struct timecounter { /* These fields must be initialized by the driver. */ timecounter_get_t *get_timecount; + timecounter_pps_t *poll_pps; unsigned counter_mask; u_int32_t frequency; char *name; @@ -274,6 +276,7 @@ void microtime __P((struct timeval *tv)); void nanouptime __P((struct timespec *ts)); void nanotime __P((struct timespec *ts)); void set_timecounter __P((struct timespec *ts)); +void timecounter_timespec __P((unsigned count, struct timespec *ts)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); int tvtohz __P((struct timeval *)); diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h index b31b7d7..164ae86 100644 --- a/sys/sys/timetc.h +++ b/sys/sys/timetc.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)time.h 8.5 (Berkeley) 5/4/95 - * $Id: time.h,v 1.30 1998/06/07 08:40:53 phk Exp $ + * $Id: time.h,v 1.31 1998/06/07 14:14:39 phk Exp $ */ #ifndef _SYS_TIME_H_ @@ -128,10 +128,12 @@ struct timezone { struct timecounter; typedef unsigned timecounter_get_t __P((struct timecounter *)); +typedef void timecounter_pps_t __P((struct timecounter *)); struct timecounter { /* These fields must be initialized by the driver. */ timecounter_get_t *get_timecount; + timecounter_pps_t *poll_pps; unsigned counter_mask; u_int32_t frequency; char *name; @@ -274,6 +276,7 @@ void microtime __P((struct timeval *tv)); void nanouptime __P((struct timespec *ts)); void nanotime __P((struct timespec *ts)); void set_timecounter __P((struct timespec *ts)); +void timecounter_timespec __P((unsigned count, struct timespec *ts)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); int tvtohz __P((struct timeval *)); |