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.
This commit is contained in:
parent
d287aa098c
commit
48115288df
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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 *));
|
||||
|
@ -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 *));
|
||||
|
Loading…
Reference in New Issue
Block a user