mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-23 10:14:55 +00:00
Add a tc_ prefix to struct timecounter members.
Urged by: bde
This commit is contained in:
parent
1afde994e9
commit
a58f0f8e66
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=36810
|
@ -34,7 +34,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $
|
||||
* $Id: clock.c,v 1.123 1998/06/07 20:36:39 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -276,7 +276,7 @@ acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
|
|||
|
||||
if (rate <= 0 || rate > TIMER0_MAX_FREQ)
|
||||
return (-1);
|
||||
if (strcmp(timecounter->name, "i8254") == 0)
|
||||
if (strcmp(timecounter->tc_name, "i8254") == 0)
|
||||
return (-1);
|
||||
switch (timer0_state) {
|
||||
|
||||
|
@ -736,7 +736,7 @@ startrtclock()
|
|||
}
|
||||
|
||||
set_timer_freq(timer_freq, hz);
|
||||
i8254_timecounter[0].frequency = timer_freq;
|
||||
i8254_timecounter[0].tc_frequency = timer_freq;
|
||||
init_timecounter(i8254_timecounter);
|
||||
|
||||
#ifndef CLK_USE_TSC_CALIBRATION
|
||||
|
@ -786,7 +786,7 @@ startrtclock()
|
|||
#endif /* NAPM > 0 */
|
||||
|
||||
if (tsc_present && tsc_freq != 0) {
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
init_timecounter(tsc_timecounter);
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
|
|||
if (timer0_state != RELEASED)
|
||||
return (EBUSY); /* too much trouble to handle */
|
||||
set_timer_freq(freq, hz);
|
||||
i8254_timecounter[0].frequency = freq;
|
||||
i8254_timecounter[0].tc_frequency = freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
@ -1123,7 +1123,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
|||
error = sysctl_handle_opaque(oidp, &freq, sizeof freq, req);
|
||||
if (error == 0 && req->newptr != NULL) {
|
||||
tsc_freq = freq;
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $
|
||||
* $Id: clock.c,v 1.123 1998/06/07 20:36:39 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -276,7 +276,7 @@ acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
|
|||
|
||||
if (rate <= 0 || rate > TIMER0_MAX_FREQ)
|
||||
return (-1);
|
||||
if (strcmp(timecounter->name, "i8254") == 0)
|
||||
if (strcmp(timecounter->tc_name, "i8254") == 0)
|
||||
return (-1);
|
||||
switch (timer0_state) {
|
||||
|
||||
|
@ -736,7 +736,7 @@ startrtclock()
|
|||
}
|
||||
|
||||
set_timer_freq(timer_freq, hz);
|
||||
i8254_timecounter[0].frequency = timer_freq;
|
||||
i8254_timecounter[0].tc_frequency = timer_freq;
|
||||
init_timecounter(i8254_timecounter);
|
||||
|
||||
#ifndef CLK_USE_TSC_CALIBRATION
|
||||
|
@ -786,7 +786,7 @@ startrtclock()
|
|||
#endif /* NAPM > 0 */
|
||||
|
||||
if (tsc_present && tsc_freq != 0) {
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
init_timecounter(tsc_timecounter);
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
|
|||
if (timer0_state != RELEASED)
|
||||
return (EBUSY); /* too much trouble to handle */
|
||||
set_timer_freq(freq, hz);
|
||||
i8254_timecounter[0].frequency = freq;
|
||||
i8254_timecounter[0].tc_frequency = freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
@ -1123,7 +1123,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
|||
error = sysctl_handle_opaque(oidp, &freq, sizeof freq, req);
|
||||
if (error == 0 && req->newptr != NULL) {
|
||||
tsc_freq = freq;
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $
|
||||
* $Id: clock.c,v 1.123 1998/06/07 20:36:39 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -276,7 +276,7 @@ acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
|
|||
|
||||
if (rate <= 0 || rate > TIMER0_MAX_FREQ)
|
||||
return (-1);
|
||||
if (strcmp(timecounter->name, "i8254") == 0)
|
||||
if (strcmp(timecounter->tc_name, "i8254") == 0)
|
||||
return (-1);
|
||||
switch (timer0_state) {
|
||||
|
||||
|
@ -736,7 +736,7 @@ startrtclock()
|
|||
}
|
||||
|
||||
set_timer_freq(timer_freq, hz);
|
||||
i8254_timecounter[0].frequency = timer_freq;
|
||||
i8254_timecounter[0].tc_frequency = timer_freq;
|
||||
init_timecounter(i8254_timecounter);
|
||||
|
||||
#ifndef CLK_USE_TSC_CALIBRATION
|
||||
|
@ -786,7 +786,7 @@ startrtclock()
|
|||
#endif /* NAPM > 0 */
|
||||
|
||||
if (tsc_present && tsc_freq != 0) {
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
init_timecounter(tsc_timecounter);
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
|
|||
if (timer0_state != RELEASED)
|
||||
return (EBUSY); /* too much trouble to handle */
|
||||
set_timer_freq(freq, hz);
|
||||
i8254_timecounter[0].frequency = freq;
|
||||
i8254_timecounter[0].tc_frequency = freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
@ -1123,7 +1123,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
|||
error = sysctl_handle_opaque(oidp, &freq, sizeof freq, req);
|
||||
if (error == 0 && req->newptr != NULL) {
|
||||
tsc_freq = freq;
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $
|
||||
* $Id: clock.c,v 1.123 1998/06/07 20:36:39 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -276,7 +276,7 @@ acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
|
|||
|
||||
if (rate <= 0 || rate > TIMER0_MAX_FREQ)
|
||||
return (-1);
|
||||
if (strcmp(timecounter->name, "i8254") == 0)
|
||||
if (strcmp(timecounter->tc_name, "i8254") == 0)
|
||||
return (-1);
|
||||
switch (timer0_state) {
|
||||
|
||||
|
@ -736,7 +736,7 @@ startrtclock()
|
|||
}
|
||||
|
||||
set_timer_freq(timer_freq, hz);
|
||||
i8254_timecounter[0].frequency = timer_freq;
|
||||
i8254_timecounter[0].tc_frequency = timer_freq;
|
||||
init_timecounter(i8254_timecounter);
|
||||
|
||||
#ifndef CLK_USE_TSC_CALIBRATION
|
||||
|
@ -786,7 +786,7 @@ startrtclock()
|
|||
#endif /* NAPM > 0 */
|
||||
|
||||
if (tsc_present && tsc_freq != 0) {
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
init_timecounter(tsc_timecounter);
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
|
|||
if (timer0_state != RELEASED)
|
||||
return (EBUSY); /* too much trouble to handle */
|
||||
set_timer_freq(freq, hz);
|
||||
i8254_timecounter[0].frequency = freq;
|
||||
i8254_timecounter[0].tc_frequency = freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
@ -1123,7 +1123,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
|||
error = sysctl_handle_opaque(oidp, &freq, sizeof freq, req);
|
||||
if (error == 0 && req->newptr != NULL) {
|
||||
tsc_freq = freq;
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* random_machdep.c -- A strong random number generator
|
||||
*
|
||||
* $Id: random_machdep.c,v 1.25 1998/04/15 17:45:44 bde Exp $
|
||||
* $Id: random_machdep.c,v 1.26 1998/06/07 08:40:25 phk Exp $
|
||||
*
|
||||
* Version 0.95, last modified 18-Oct-95
|
||||
*
|
||||
|
@ -184,7 +184,7 @@ add_timer_randomness(struct random_bucket *r, struct timer_rand_state *state,
|
|||
u_int nbits;
|
||||
u_int32_t time;
|
||||
|
||||
num ^= timecounter->get_timecount(timecounter) << 16;
|
||||
num ^= timecounter->tc_get_timecount(timecounter) << 16;
|
||||
r->entropy_count += 2;
|
||||
|
||||
time = ticks;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.122 1998/06/07 08:40:23 phk Exp $
|
||||
* $Id: clock.c,v 1.123 1998/06/07 20:36:39 phk Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -276,7 +276,7 @@ acquire_timer0(int rate, void (*function) __P((struct clockframe *frame)))
|
|||
|
||||
if (rate <= 0 || rate > TIMER0_MAX_FREQ)
|
||||
return (-1);
|
||||
if (strcmp(timecounter->name, "i8254") == 0)
|
||||
if (strcmp(timecounter->tc_name, "i8254") == 0)
|
||||
return (-1);
|
||||
switch (timer0_state) {
|
||||
|
||||
|
@ -736,7 +736,7 @@ startrtclock()
|
|||
}
|
||||
|
||||
set_timer_freq(timer_freq, hz);
|
||||
i8254_timecounter[0].frequency = timer_freq;
|
||||
i8254_timecounter[0].tc_frequency = timer_freq;
|
||||
init_timecounter(i8254_timecounter);
|
||||
|
||||
#ifndef CLK_USE_TSC_CALIBRATION
|
||||
|
@ -786,7 +786,7 @@ startrtclock()
|
|||
#endif /* NAPM > 0 */
|
||||
|
||||
if (tsc_present && tsc_freq != 0) {
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
init_timecounter(tsc_timecounter);
|
||||
}
|
||||
|
||||
|
@ -1103,7 +1103,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS
|
|||
if (timer0_state != RELEASED)
|
||||
return (EBUSY); /* too much trouble to handle */
|
||||
set_timer_freq(freq, hz);
|
||||
i8254_timecounter[0].frequency = freq;
|
||||
i8254_timecounter[0].tc_frequency = freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
@ -1123,7 +1123,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS
|
|||
error = sysctl_handle_opaque(oidp, &freq, sizeof freq, req);
|
||||
if (error == 0 && req->newptr != NULL) {
|
||||
tsc_freq = freq;
|
||||
tsc_timecounter[0].frequency = tsc_freq;
|
||||
tsc_timecounter[0].tc_frequency = tsc_freq;
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
|
|
@ -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.71 1998/06/07 08:40:41 phk Exp $
|
||||
* $Id: kern_clock.c,v 1.72 1998/06/07 20:36:54 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -73,7 +73,7 @@ SYSINIT(clocks, SI_SUB_CLOCKS, SI_ORDER_FIRST, initclocks, NULL)
|
|||
|
||||
static void tco_forward __P((void));
|
||||
static void tco_setscales __P((struct timecounter *tc));
|
||||
static __inline unsigned tco_getdelta __P((struct timecounter *tc));
|
||||
static __inline unsigned tco_delta __P((struct timecounter *tc));
|
||||
|
||||
/* Some of these don't belong here, but it's easiest to concentrate them. */
|
||||
#if defined(SMP) && defined(BETTER_CLOCK)
|
||||
|
@ -495,10 +495,11 @@ SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD,
|
|||
0, 0, sysctl_kern_clockrate, "S,clockinfo","");
|
||||
|
||||
static __inline unsigned
|
||||
tco_getdelta(struct timecounter *tc)
|
||||
tco_delta(struct timecounter *tc)
|
||||
{
|
||||
|
||||
return ((tc->get_timecount(tc) - tc->offset_count) & tc->counter_mask);
|
||||
return ((tc->tc_get_timecount(tc) - tc->tc_offset_count) &
|
||||
tc->tc_counter_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -515,7 +516,7 @@ getmicrotime(struct timeval *tvp)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = timecounter;
|
||||
*tvp = tc->microtime;
|
||||
*tvp = tc->tc_microtime;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -524,7 +525,7 @@ getnanotime(struct timespec *tsp)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = timecounter;
|
||||
*tsp = tc->nanotime;
|
||||
*tsp = tc->tc_nanotime;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -533,9 +534,9 @@ microtime(struct timeval *tv)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
tv->tv_usec = tc->offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_sec = tc->tc_offset_sec;
|
||||
tv->tv_usec = tc->tc_offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)tco_delta(tc) * tc->tc_scale_micro) >> 32;
|
||||
tv->tv_usec += boottime.tv_usec;
|
||||
tv->tv_sec += boottime.tv_sec;
|
||||
while (tv->tv_usec >= 1000000) {
|
||||
|
@ -552,12 +553,12 @@ nanotime(struct timespec *ts)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
ts->tv_sec = tc->offset_sec;
|
||||
count = tco_getdelta(tc);
|
||||
delta = tc->offset_nano;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_f);
|
||||
ts->tv_sec = tc->tc_offset_sec;
|
||||
count = tco_delta(tc);
|
||||
delta = tc->tc_offset_nano;
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_f);
|
||||
delta >>= 32;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_i);
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_i);
|
||||
delta += boottime.tv_usec * 1000;
|
||||
ts->tv_sec += boottime.tv_sec;
|
||||
while (delta >= 1000000000) {
|
||||
|
@ -574,13 +575,13 @@ timecounter_timespec(unsigned count, struct timespec *ts)
|
|||
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);
|
||||
ts->tv_sec = tc->tc_offset_sec;
|
||||
count -= tc->tc_offset_count;
|
||||
count &= tc->tc_counter_mask;
|
||||
delta = tc->tc_offset_nano;
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_f);
|
||||
delta >>= 32;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_i);
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_i);
|
||||
delta += boottime.tv_usec * 1000;
|
||||
ts->tv_sec += boottime.tv_sec;
|
||||
while (delta >= 1000000000) {
|
||||
|
@ -596,8 +597,8 @@ getmicrouptime(struct timeval *tvp)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = timecounter;
|
||||
tvp->tv_sec = tc->offset_sec;
|
||||
tvp->tv_usec = tc->offset_micro;
|
||||
tvp->tv_sec = tc->tc_offset_sec;
|
||||
tvp->tv_usec = tc->tc_offset_micro;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -606,8 +607,8 @@ getnanouptime(struct timespec *tsp)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = timecounter;
|
||||
tsp->tv_sec = tc->offset_sec;
|
||||
tsp->tv_nsec = tc->offset_nano >> 32;
|
||||
tsp->tv_sec = tc->tc_offset_sec;
|
||||
tsp->tv_nsec = tc->tc_offset_nano >> 32;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -616,9 +617,9 @@ microuptime(struct timeval *tv)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
tv->tv_usec = tc->offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_sec = tc->tc_offset_sec;
|
||||
tv->tv_usec = tc->tc_offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)tco_delta(tc) * tc->tc_scale_micro) >> 32;
|
||||
if (tv->tv_usec >= 1000000) {
|
||||
tv->tv_usec -= 1000000;
|
||||
tv->tv_sec++;
|
||||
|
@ -633,12 +634,12 @@ nanouptime(struct timespec *tv)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
count = tco_getdelta(tc);
|
||||
delta = tc->offset_nano;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_f);
|
||||
tv->tv_sec = tc->tc_offset_sec;
|
||||
count = tco_delta(tc);
|
||||
delta = tc->tc_offset_nano;
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_f);
|
||||
delta >>= 32;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_i);
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_i);
|
||||
if (delta >= 1000000000) {
|
||||
delta -= 1000000000;
|
||||
tv->tv_sec++;
|
||||
|
@ -652,14 +653,14 @@ tco_setscales(struct timecounter *tc)
|
|||
u_int64_t scale;
|
||||
|
||||
scale = 1000000000LL << 32;
|
||||
if (tc->adjustment > 0)
|
||||
scale += (tc->adjustment * 1000LL) << 10;
|
||||
if (tc->tc_adjustment > 0)
|
||||
scale += (tc->tc_adjustment * 1000LL) << 10;
|
||||
else
|
||||
scale -= (-tc->adjustment * 1000LL) << 10;
|
||||
scale /= tc->frequency;
|
||||
tc->scale_micro = scale / 1000;
|
||||
tc->scale_nano_f = scale & 0xffffffff;
|
||||
tc->scale_nano_i = scale >> 32;
|
||||
scale -= (-tc->tc_adjustment * 1000LL) << 10;
|
||||
scale /= tc->tc_frequency;
|
||||
tc->tc_scale_micro = scale / 1000;
|
||||
tc->tc_scale_nano_f = scale & 0xffffffff;
|
||||
tc->tc_scale_nano_i = scale >> 32;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -668,14 +669,14 @@ init_timecounter(struct timecounter *tc)
|
|||
struct timespec ts0, ts1;
|
||||
int i;
|
||||
|
||||
tc->adjustment = 0;
|
||||
tc->tc_adjustment = 0;
|
||||
tco_setscales(tc);
|
||||
tc->offset_count = tc->get_timecount(tc);
|
||||
tc[0].tweak = &tc[0];
|
||||
tc->tc_offset_count = tc->tc_get_timecount(tc);
|
||||
tc[0].tc_tweak = &tc[0];
|
||||
tc[2] = tc[1] = tc[0];
|
||||
tc[1].other = &tc[2];
|
||||
tc[2].other = &tc[1];
|
||||
if (!timecounter || !strcmp(timecounter->name, "dummy"))
|
||||
tc[1].tc_other = &tc[2];
|
||||
tc[2].tc_other = &tc[1];
|
||||
if (!timecounter || !strcmp(timecounter->tc_name, "dummy"))
|
||||
timecounter = &tc[2];
|
||||
tc = &tc[1];
|
||||
|
||||
|
@ -684,21 +685,21 @@ init_timecounter(struct timecounter *tc)
|
|||
*/
|
||||
nanotime(&ts0);
|
||||
for (i = 0; i < 256; i ++)
|
||||
tc->get_timecount(tc);
|
||||
tc->tc_get_timecount(tc);
|
||||
nanotime(&ts1);
|
||||
ts1.tv_sec -= ts0.tv_sec;
|
||||
tc->cost = ts1.tv_sec * 1000000000 + ts1.tv_nsec - ts0.tv_nsec;
|
||||
tc->cost >>= 8;
|
||||
if (print_tci && strcmp(tc->name, "dummy"))
|
||||
tc->tc_cost = ts1.tv_sec * 1000000000 + ts1.tv_nsec - ts0.tv_nsec;
|
||||
tc->tc_cost >>= 8;
|
||||
if (print_tci && strcmp(tc->tc_name, "dummy"))
|
||||
printf("Timecounter \"%s\" frequency %lu Hz cost %u ns\n",
|
||||
tc->name, tc->frequency, tc->cost);
|
||||
tc->tc_name, tc->tc_frequency, tc->tc_cost);
|
||||
|
||||
/* XXX: For now always start using the counter. */
|
||||
tc->offset_count = tc->get_timecount(tc);
|
||||
tc->tc_offset_count = tc->tc_get_timecount(tc);
|
||||
nanotime(&ts1);
|
||||
tc->offset_nano = (u_int64_t)ts1.tv_nsec << 32;
|
||||
tc->offset_micro = ts1.tv_nsec / 1000;
|
||||
tc->offset_sec = ts1.tv_sec;
|
||||
tc->tc_offset_nano = (u_int64_t)ts1.tv_nsec << 32;
|
||||
tc->tc_offset_micro = ts1.tv_nsec / 1000;
|
||||
tc->tc_offset_sec = ts1.tv_sec;
|
||||
timecounter = tc;
|
||||
}
|
||||
|
||||
|
@ -729,15 +730,15 @@ switch_timecounter(struct timecounter *newtc)
|
|||
|
||||
s = splclock();
|
||||
tc = timecounter;
|
||||
if (newtc == tc || newtc == tc->other) {
|
||||
if (newtc == tc || newtc == tc->tc_other) {
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
nanotime(&ts);
|
||||
newtc->offset_sec = ts.tv_sec;
|
||||
newtc->offset_nano = (u_int64_t)ts.tv_nsec << 32;
|
||||
newtc->offset_micro = ts.tv_nsec / 1000;
|
||||
newtc->offset_count = newtc->get_timecount(newtc);
|
||||
newtc->tc_offset_sec = ts.tv_sec;
|
||||
newtc->tc_offset_nano = (u_int64_t)ts.tv_nsec << 32;
|
||||
newtc->tc_offset_micro = ts.tv_nsec / 1000;
|
||||
newtc->tc_offset_count = newtc->tc_get_timecount(newtc);
|
||||
timecounter = newtc;
|
||||
splx(s);
|
||||
}
|
||||
|
@ -749,17 +750,17 @@ sync_other_counter(void)
|
|||
struct timecounter *tc, *tco;
|
||||
unsigned delta;
|
||||
|
||||
if (timecounter->poll_pps)
|
||||
timecounter->poll_pps(timecounter);
|
||||
tc = timecounter->other;
|
||||
tco = tc->other;
|
||||
if (timecounter->tc_poll_pps)
|
||||
timecounter->tc_poll_pps(timecounter);
|
||||
tc = timecounter->tc_other;
|
||||
tco = tc->tc_other;
|
||||
*tc = *timecounter;
|
||||
tc->other = tco;
|
||||
delta = tco_getdelta(tc);
|
||||
tc->offset_count += delta;
|
||||
tc->offset_count &= tc->counter_mask;
|
||||
tc->offset_nano += (u_int64_t)delta * tc->scale_nano_f;
|
||||
tc->offset_nano += (u_int64_t)delta * tc->scale_nano_i << 32;
|
||||
tc->tc_other = tco;
|
||||
delta = tco_delta(tc);
|
||||
tc->tc_offset_count += delta;
|
||||
tc->tc_offset_count &= tc->tc_counter_mask;
|
||||
tc->tc_offset_nano += (u_int64_t)delta * tc->tc_scale_nano_f;
|
||||
tc->tc_offset_nano += (u_int64_t)delta * tc->tc_scale_nano_i << 32;
|
||||
return (tc);
|
||||
}
|
||||
|
||||
|
@ -770,31 +771,32 @@ tco_forward(void)
|
|||
|
||||
tc = sync_other_counter();
|
||||
if (timedelta != 0) {
|
||||
tc->offset_nano += (u_int64_t)(tickdelta * 1000) << 32;
|
||||
tc->tc_offset_nano += (u_int64_t)(tickdelta * 1000) << 32;
|
||||
timedelta -= tickdelta;
|
||||
}
|
||||
|
||||
while (tc->offset_nano >= 1000000000ULL << 32) {
|
||||
tc->offset_nano -= 1000000000ULL << 32;
|
||||
tc->offset_sec++;
|
||||
tc->frequency = tc->tweak->frequency;
|
||||
tc->adjustment = tc->tweak->adjustment;
|
||||
while (tc->tc_offset_nano >= 1000000000ULL << 32) {
|
||||
tc->tc_offset_nano -= 1000000000ULL << 32;
|
||||
tc->tc_offset_sec++;
|
||||
tc->tc_frequency = tc->tc_tweak->tc_frequency;
|
||||
tc->tc_adjustment = tc->tc_tweak->tc_adjustment;
|
||||
ntp_update_second(tc); /* XXX only needed if xntpd runs */
|
||||
tco_setscales(tc);
|
||||
}
|
||||
|
||||
tc->offset_micro = (tc->offset_nano / 1000) >> 32;
|
||||
tc->tc_offset_micro = (tc->tc_offset_nano / 1000) >> 32;
|
||||
|
||||
/* Figure out the wall-clock time */
|
||||
tc->nanotime.tv_sec = tc->offset_sec + boottime.tv_sec;
|
||||
tc->nanotime.tv_nsec = (tc->offset_nano >> 32) + boottime.tv_usec * 1000;
|
||||
tc->microtime.tv_usec = tc->offset_micro + boottime.tv_usec;
|
||||
if (tc->nanotime.tv_nsec >= 1000000000) {
|
||||
tc->nanotime.tv_nsec -= 1000000000;
|
||||
tc->microtime.tv_usec -= 1000000;
|
||||
tc->nanotime.tv_sec++;
|
||||
tc->tc_nanotime.tv_sec = tc->tc_offset_sec + boottime.tv_sec;
|
||||
tc->tc_nanotime.tv_nsec =
|
||||
(tc->tc_offset_nano >> 32) + boottime.tv_usec * 1000;
|
||||
tc->tc_microtime.tv_usec = tc->tc_offset_micro + boottime.tv_usec;
|
||||
if (tc->tc_nanotime.tv_nsec >= 1000000000) {
|
||||
tc->tc_nanotime.tv_nsec -= 1000000000;
|
||||
tc->tc_microtime.tv_usec -= 1000000;
|
||||
tc->tc_nanotime.tv_sec++;
|
||||
}
|
||||
time_second = tc->microtime.tv_sec = tc->nanotime.tv_sec;
|
||||
time_second = tc->tc_microtime.tv_sec = tc->tc_nanotime.tv_sec;
|
||||
|
||||
timecounter = tc;
|
||||
}
|
||||
|
@ -803,16 +805,18 @@ static int
|
|||
sysctl_kern_timecounter_frequency SYSCTL_HANDLER_ARGS
|
||||
{
|
||||
|
||||
return (sysctl_handle_opaque(oidp, &timecounter->tweak->frequency,
|
||||
sizeof(timecounter->tweak->frequency), req));
|
||||
return (sysctl_handle_opaque(oidp,
|
||||
&timecounter->tc_tweak->tc_frequency,
|
||||
sizeof(timecounter->tc_tweak->tc_frequency), req));
|
||||
}
|
||||
|
||||
static int
|
||||
sysctl_kern_timecounter_adjustment SYSCTL_HANDLER_ARGS
|
||||
{
|
||||
|
||||
return (sysctl_handle_opaque(oidp, &timecounter->tweak->adjustment,
|
||||
sizeof(timecounter->tweak->adjustment), req));
|
||||
return (sysctl_handle_opaque(oidp,
|
||||
&timecounter->tc_tweak->tc_adjustment,
|
||||
sizeof(timecounter->tc_tweak->tc_adjustment), req));
|
||||
}
|
||||
|
||||
SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW, 0, "");
|
||||
|
|
|
@ -307,7 +307,7 @@ ntp_update_second(struct timecounter *tc)
|
|||
if (!time_daemon)
|
||||
return;
|
||||
|
||||
newsec = &tc->offset_sec;
|
||||
newsec = &tc->tc_offset_sec;
|
||||
time_maxerror += time_tolerance >> SHIFT_USEC;
|
||||
|
||||
/*
|
||||
|
@ -361,7 +361,7 @@ ntp_update_second(struct timecounter *tc)
|
|||
else
|
||||
time_adj += ltemp << (SHIFT_SCALE - SHIFT_USEC);
|
||||
|
||||
tc->adjustment = time_adj;
|
||||
tc->tc_adjustment = time_adj;
|
||||
|
||||
/* XXX - this is really bogus, but can't be fixed until
|
||||
xntpd's idea of the system clock is fixed to know how
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* random_machdep.c -- A strong random number generator
|
||||
*
|
||||
* $Id: random_machdep.c,v 1.25 1998/04/15 17:45:44 bde Exp $
|
||||
* $Id: random_machdep.c,v 1.26 1998/06/07 08:40:25 phk Exp $
|
||||
*
|
||||
* Version 0.95, last modified 18-Oct-95
|
||||
*
|
||||
|
@ -184,7 +184,7 @@ add_timer_randomness(struct random_bucket *r, struct timer_rand_state *state,
|
|||
u_int nbits;
|
||||
u_int32_t time;
|
||||
|
||||
num ^= timecounter->get_timecount(timecounter) << 16;
|
||||
num ^= timecounter->tc_get_timecount(timecounter) << 16;
|
||||
r->entropy_count += 2;
|
||||
|
||||
time = ticks;
|
||||
|
|
|
@ -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.71 1998/06/07 08:40:41 phk Exp $
|
||||
* $Id: kern_clock.c,v 1.72 1998/06/07 20:36:54 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -73,7 +73,7 @@ SYSINIT(clocks, SI_SUB_CLOCKS, SI_ORDER_FIRST, initclocks, NULL)
|
|||
|
||||
static void tco_forward __P((void));
|
||||
static void tco_setscales __P((struct timecounter *tc));
|
||||
static __inline unsigned tco_getdelta __P((struct timecounter *tc));
|
||||
static __inline unsigned tco_delta __P((struct timecounter *tc));
|
||||
|
||||
/* Some of these don't belong here, but it's easiest to concentrate them. */
|
||||
#if defined(SMP) && defined(BETTER_CLOCK)
|
||||
|
@ -495,10 +495,11 @@ SYSCTL_PROC(_kern, KERN_CLOCKRATE, clockrate, CTLTYPE_STRUCT|CTLFLAG_RD,
|
|||
0, 0, sysctl_kern_clockrate, "S,clockinfo","");
|
||||
|
||||
static __inline unsigned
|
||||
tco_getdelta(struct timecounter *tc)
|
||||
tco_delta(struct timecounter *tc)
|
||||
{
|
||||
|
||||
return ((tc->get_timecount(tc) - tc->offset_count) & tc->counter_mask);
|
||||
return ((tc->tc_get_timecount(tc) - tc->tc_offset_count) &
|
||||
tc->tc_counter_mask);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -515,7 +516,7 @@ getmicrotime(struct timeval *tvp)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = timecounter;
|
||||
*tvp = tc->microtime;
|
||||
*tvp = tc->tc_microtime;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -524,7 +525,7 @@ getnanotime(struct timespec *tsp)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = timecounter;
|
||||
*tsp = tc->nanotime;
|
||||
*tsp = tc->tc_nanotime;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -533,9 +534,9 @@ microtime(struct timeval *tv)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
tv->tv_usec = tc->offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_sec = tc->tc_offset_sec;
|
||||
tv->tv_usec = tc->tc_offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)tco_delta(tc) * tc->tc_scale_micro) >> 32;
|
||||
tv->tv_usec += boottime.tv_usec;
|
||||
tv->tv_sec += boottime.tv_sec;
|
||||
while (tv->tv_usec >= 1000000) {
|
||||
|
@ -552,12 +553,12 @@ nanotime(struct timespec *ts)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
ts->tv_sec = tc->offset_sec;
|
||||
count = tco_getdelta(tc);
|
||||
delta = tc->offset_nano;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_f);
|
||||
ts->tv_sec = tc->tc_offset_sec;
|
||||
count = tco_delta(tc);
|
||||
delta = tc->tc_offset_nano;
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_f);
|
||||
delta >>= 32;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_i);
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_i);
|
||||
delta += boottime.tv_usec * 1000;
|
||||
ts->tv_sec += boottime.tv_sec;
|
||||
while (delta >= 1000000000) {
|
||||
|
@ -574,13 +575,13 @@ timecounter_timespec(unsigned count, struct timespec *ts)
|
|||
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);
|
||||
ts->tv_sec = tc->tc_offset_sec;
|
||||
count -= tc->tc_offset_count;
|
||||
count &= tc->tc_counter_mask;
|
||||
delta = tc->tc_offset_nano;
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_f);
|
||||
delta >>= 32;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_i);
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_i);
|
||||
delta += boottime.tv_usec * 1000;
|
||||
ts->tv_sec += boottime.tv_sec;
|
||||
while (delta >= 1000000000) {
|
||||
|
@ -596,8 +597,8 @@ getmicrouptime(struct timeval *tvp)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = timecounter;
|
||||
tvp->tv_sec = tc->offset_sec;
|
||||
tvp->tv_usec = tc->offset_micro;
|
||||
tvp->tv_sec = tc->tc_offset_sec;
|
||||
tvp->tv_usec = tc->tc_offset_micro;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -606,8 +607,8 @@ getnanouptime(struct timespec *tsp)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = timecounter;
|
||||
tsp->tv_sec = tc->offset_sec;
|
||||
tsp->tv_nsec = tc->offset_nano >> 32;
|
||||
tsp->tv_sec = tc->tc_offset_sec;
|
||||
tsp->tv_nsec = tc->tc_offset_nano >> 32;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -616,9 +617,9 @@ microuptime(struct timeval *tv)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
tv->tv_usec = tc->offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)tco_getdelta(tc) * tc->scale_micro) >> 32;
|
||||
tv->tv_sec = tc->tc_offset_sec;
|
||||
tv->tv_usec = tc->tc_offset_micro;
|
||||
tv->tv_usec += ((u_int64_t)tco_delta(tc) * tc->tc_scale_micro) >> 32;
|
||||
if (tv->tv_usec >= 1000000) {
|
||||
tv->tv_usec -= 1000000;
|
||||
tv->tv_sec++;
|
||||
|
@ -633,12 +634,12 @@ nanouptime(struct timespec *tv)
|
|||
struct timecounter *tc;
|
||||
|
||||
tc = (struct timecounter *)timecounter;
|
||||
tv->tv_sec = tc->offset_sec;
|
||||
count = tco_getdelta(tc);
|
||||
delta = tc->offset_nano;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_f);
|
||||
tv->tv_sec = tc->tc_offset_sec;
|
||||
count = tco_delta(tc);
|
||||
delta = tc->tc_offset_nano;
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_f);
|
||||
delta >>= 32;
|
||||
delta += ((u_int64_t)count * tc->scale_nano_i);
|
||||
delta += ((u_int64_t)count * tc->tc_scale_nano_i);
|
||||
if (delta >= 1000000000) {
|
||||
delta -= 1000000000;
|
||||
tv->tv_sec++;
|
||||
|
@ -652,14 +653,14 @@ tco_setscales(struct timecounter *tc)
|
|||
u_int64_t scale;
|
||||
|
||||
scale = 1000000000LL << 32;
|
||||
if (tc->adjustment > 0)
|
||||
scale += (tc->adjustment * 1000LL) << 10;
|
||||
if (tc->tc_adjustment > 0)
|
||||
scale += (tc->tc_adjustment * 1000LL) << 10;
|
||||
else
|
||||
scale -= (-tc->adjustment * 1000LL) << 10;
|
||||
scale /= tc->frequency;
|
||||
tc->scale_micro = scale / 1000;
|
||||
tc->scale_nano_f = scale & 0xffffffff;
|
||||
tc->scale_nano_i = scale >> 32;
|
||||
scale -= (-tc->tc_adjustment * 1000LL) << 10;
|
||||
scale /= tc->tc_frequency;
|
||||
tc->tc_scale_micro = scale / 1000;
|
||||
tc->tc_scale_nano_f = scale & 0xffffffff;
|
||||
tc->tc_scale_nano_i = scale >> 32;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -668,14 +669,14 @@ init_timecounter(struct timecounter *tc)
|
|||
struct timespec ts0, ts1;
|
||||
int i;
|
||||
|
||||
tc->adjustment = 0;
|
||||
tc->tc_adjustment = 0;
|
||||
tco_setscales(tc);
|
||||
tc->offset_count = tc->get_timecount(tc);
|
||||
tc[0].tweak = &tc[0];
|
||||
tc->tc_offset_count = tc->tc_get_timecount(tc);
|
||||
tc[0].tc_tweak = &tc[0];
|
||||
tc[2] = tc[1] = tc[0];
|
||||
tc[1].other = &tc[2];
|
||||
tc[2].other = &tc[1];
|
||||
if (!timecounter || !strcmp(timecounter->name, "dummy"))
|
||||
tc[1].tc_other = &tc[2];
|
||||
tc[2].tc_other = &tc[1];
|
||||
if (!timecounter || !strcmp(timecounter->tc_name, "dummy"))
|
||||
timecounter = &tc[2];
|
||||
tc = &tc[1];
|
||||
|
||||
|
@ -684,21 +685,21 @@ init_timecounter(struct timecounter *tc)
|
|||
*/
|
||||
nanotime(&ts0);
|
||||
for (i = 0; i < 256; i ++)
|
||||
tc->get_timecount(tc);
|
||||
tc->tc_get_timecount(tc);
|
||||
nanotime(&ts1);
|
||||
ts1.tv_sec -= ts0.tv_sec;
|
||||
tc->cost = ts1.tv_sec * 1000000000 + ts1.tv_nsec - ts0.tv_nsec;
|
||||
tc->cost >>= 8;
|
||||
if (print_tci && strcmp(tc->name, "dummy"))
|
||||
tc->tc_cost = ts1.tv_sec * 1000000000 + ts1.tv_nsec - ts0.tv_nsec;
|
||||
tc->tc_cost >>= 8;
|
||||
if (print_tci && strcmp(tc->tc_name, "dummy"))
|
||||
printf("Timecounter \"%s\" frequency %lu Hz cost %u ns\n",
|
||||
tc->name, tc->frequency, tc->cost);
|
||||
tc->tc_name, tc->tc_frequency, tc->tc_cost);
|
||||
|
||||
/* XXX: For now always start using the counter. */
|
||||
tc->offset_count = tc->get_timecount(tc);
|
||||
tc->tc_offset_count = tc->tc_get_timecount(tc);
|
||||
nanotime(&ts1);
|
||||
tc->offset_nano = (u_int64_t)ts1.tv_nsec << 32;
|
||||
tc->offset_micro = ts1.tv_nsec / 1000;
|
||||
tc->offset_sec = ts1.tv_sec;
|
||||
tc->tc_offset_nano = (u_int64_t)ts1.tv_nsec << 32;
|
||||
tc->tc_offset_micro = ts1.tv_nsec / 1000;
|
||||
tc->tc_offset_sec = ts1.tv_sec;
|
||||
timecounter = tc;
|
||||
}
|
||||
|
||||
|
@ -729,15 +730,15 @@ switch_timecounter(struct timecounter *newtc)
|
|||
|
||||
s = splclock();
|
||||
tc = timecounter;
|
||||
if (newtc == tc || newtc == tc->other) {
|
||||
if (newtc == tc || newtc == tc->tc_other) {
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
nanotime(&ts);
|
||||
newtc->offset_sec = ts.tv_sec;
|
||||
newtc->offset_nano = (u_int64_t)ts.tv_nsec << 32;
|
||||
newtc->offset_micro = ts.tv_nsec / 1000;
|
||||
newtc->offset_count = newtc->get_timecount(newtc);
|
||||
newtc->tc_offset_sec = ts.tv_sec;
|
||||
newtc->tc_offset_nano = (u_int64_t)ts.tv_nsec << 32;
|
||||
newtc->tc_offset_micro = ts.tv_nsec / 1000;
|
||||
newtc->tc_offset_count = newtc->tc_get_timecount(newtc);
|
||||
timecounter = newtc;
|
||||
splx(s);
|
||||
}
|
||||
|
@ -749,17 +750,17 @@ sync_other_counter(void)
|
|||
struct timecounter *tc, *tco;
|
||||
unsigned delta;
|
||||
|
||||
if (timecounter->poll_pps)
|
||||
timecounter->poll_pps(timecounter);
|
||||
tc = timecounter->other;
|
||||
tco = tc->other;
|
||||
if (timecounter->tc_poll_pps)
|
||||
timecounter->tc_poll_pps(timecounter);
|
||||
tc = timecounter->tc_other;
|
||||
tco = tc->tc_other;
|
||||
*tc = *timecounter;
|
||||
tc->other = tco;
|
||||
delta = tco_getdelta(tc);
|
||||
tc->offset_count += delta;
|
||||
tc->offset_count &= tc->counter_mask;
|
||||
tc->offset_nano += (u_int64_t)delta * tc->scale_nano_f;
|
||||
tc->offset_nano += (u_int64_t)delta * tc->scale_nano_i << 32;
|
||||
tc->tc_other = tco;
|
||||
delta = tco_delta(tc);
|
||||
tc->tc_offset_count += delta;
|
||||
tc->tc_offset_count &= tc->tc_counter_mask;
|
||||
tc->tc_offset_nano += (u_int64_t)delta * tc->tc_scale_nano_f;
|
||||
tc->tc_offset_nano += (u_int64_t)delta * tc->tc_scale_nano_i << 32;
|
||||
return (tc);
|
||||
}
|
||||
|
||||
|
@ -770,31 +771,32 @@ tco_forward(void)
|
|||
|
||||
tc = sync_other_counter();
|
||||
if (timedelta != 0) {
|
||||
tc->offset_nano += (u_int64_t)(tickdelta * 1000) << 32;
|
||||
tc->tc_offset_nano += (u_int64_t)(tickdelta * 1000) << 32;
|
||||
timedelta -= tickdelta;
|
||||
}
|
||||
|
||||
while (tc->offset_nano >= 1000000000ULL << 32) {
|
||||
tc->offset_nano -= 1000000000ULL << 32;
|
||||
tc->offset_sec++;
|
||||
tc->frequency = tc->tweak->frequency;
|
||||
tc->adjustment = tc->tweak->adjustment;
|
||||
while (tc->tc_offset_nano >= 1000000000ULL << 32) {
|
||||
tc->tc_offset_nano -= 1000000000ULL << 32;
|
||||
tc->tc_offset_sec++;
|
||||
tc->tc_frequency = tc->tc_tweak->tc_frequency;
|
||||
tc->tc_adjustment = tc->tc_tweak->tc_adjustment;
|
||||
ntp_update_second(tc); /* XXX only needed if xntpd runs */
|
||||
tco_setscales(tc);
|
||||
}
|
||||
|
||||
tc->offset_micro = (tc->offset_nano / 1000) >> 32;
|
||||
tc->tc_offset_micro = (tc->tc_offset_nano / 1000) >> 32;
|
||||
|
||||
/* Figure out the wall-clock time */
|
||||
tc->nanotime.tv_sec = tc->offset_sec + boottime.tv_sec;
|
||||
tc->nanotime.tv_nsec = (tc->offset_nano >> 32) + boottime.tv_usec * 1000;
|
||||
tc->microtime.tv_usec = tc->offset_micro + boottime.tv_usec;
|
||||
if (tc->nanotime.tv_nsec >= 1000000000) {
|
||||
tc->nanotime.tv_nsec -= 1000000000;
|
||||
tc->microtime.tv_usec -= 1000000;
|
||||
tc->nanotime.tv_sec++;
|
||||
tc->tc_nanotime.tv_sec = tc->tc_offset_sec + boottime.tv_sec;
|
||||
tc->tc_nanotime.tv_nsec =
|
||||
(tc->tc_offset_nano >> 32) + boottime.tv_usec * 1000;
|
||||
tc->tc_microtime.tv_usec = tc->tc_offset_micro + boottime.tv_usec;
|
||||
if (tc->tc_nanotime.tv_nsec >= 1000000000) {
|
||||
tc->tc_nanotime.tv_nsec -= 1000000000;
|
||||
tc->tc_microtime.tv_usec -= 1000000;
|
||||
tc->tc_nanotime.tv_sec++;
|
||||
}
|
||||
time_second = tc->microtime.tv_sec = tc->nanotime.tv_sec;
|
||||
time_second = tc->tc_microtime.tv_sec = tc->tc_nanotime.tv_sec;
|
||||
|
||||
timecounter = tc;
|
||||
}
|
||||
|
@ -803,16 +805,18 @@ static int
|
|||
sysctl_kern_timecounter_frequency SYSCTL_HANDLER_ARGS
|
||||
{
|
||||
|
||||
return (sysctl_handle_opaque(oidp, &timecounter->tweak->frequency,
|
||||
sizeof(timecounter->tweak->frequency), req));
|
||||
return (sysctl_handle_opaque(oidp,
|
||||
&timecounter->tc_tweak->tc_frequency,
|
||||
sizeof(timecounter->tc_tweak->tc_frequency), req));
|
||||
}
|
||||
|
||||
static int
|
||||
sysctl_kern_timecounter_adjustment SYSCTL_HANDLER_ARGS
|
||||
{
|
||||
|
||||
return (sysctl_handle_opaque(oidp, &timecounter->tweak->adjustment,
|
||||
sizeof(timecounter->tweak->adjustment), req));
|
||||
return (sysctl_handle_opaque(oidp,
|
||||
&timecounter->tc_tweak->tc_adjustment,
|
||||
sizeof(timecounter->tc_tweak->tc_adjustment), req));
|
||||
}
|
||||
|
||||
SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW, 0, "");
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)kern_time.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: kern_time.c,v 1.56 1998/05/17 20:08:04 bde Exp $
|
||||
* $Id: kern_time.c,v 1.57 1998/05/17 20:13:01 bde Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -181,7 +181,7 @@ clock_getres(p, uap)
|
|||
error = 0;
|
||||
if (SCARG(uap, tp)) {
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1000000000 / timecounter->frequency;
|
||||
ts.tv_nsec = 1000000000 / timecounter->tc_frequency;
|
||||
error = copyout(&ts, SCARG(uap, tp), sizeof(ts));
|
||||
}
|
||||
return (error);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)time.h 8.5 (Berkeley) 5/4/95
|
||||
* $Id: time.h,v 1.31 1998/06/07 14:14:39 phk Exp $
|
||||
* $Id: time.h,v 1.32 1998/06/07 20:36:55 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TIME_H_
|
||||
|
@ -132,26 +132,26 @@ 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;
|
||||
void *priv;
|
||||
timecounter_get_t *tc_get_timecount;
|
||||
timecounter_pps_t *tc_poll_pps;
|
||||
unsigned tc_counter_mask;
|
||||
u_int32_t tc_frequency;
|
||||
char *tc_name;
|
||||
void *tc_priv;
|
||||
/* These fields will be managed by the generic code. */
|
||||
int cost;
|
||||
int32_t adjustment;
|
||||
u_int32_t scale_micro;
|
||||
u_int32_t scale_nano_i;
|
||||
u_int32_t scale_nano_f;
|
||||
unsigned offset_count;
|
||||
u_int32_t offset_sec;
|
||||
u_int32_t offset_micro;
|
||||
u_int64_t offset_nano;
|
||||
struct timeval microtime;
|
||||
struct timespec nanotime;
|
||||
struct timecounter *other;
|
||||
struct timecounter *tweak;
|
||||
int tc_cost;
|
||||
int32_t tc_adjustment;
|
||||
u_int32_t tc_scale_micro;
|
||||
u_int32_t tc_scale_nano_i;
|
||||
u_int32_t tc_scale_nano_f;
|
||||
unsigned tc_offset_count;
|
||||
u_int32_t tc_offset_sec;
|
||||
u_int32_t tc_offset_micro;
|
||||
u_int64_t tc_offset_nano;
|
||||
struct timeval tc_microtime;
|
||||
struct timespec tc_nanotime;
|
||||
struct timecounter *tc_other;
|
||||
struct timecounter *tc_tweak;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)time.h 8.5 (Berkeley) 5/4/95
|
||||
* $Id: time.h,v 1.31 1998/06/07 14:14:39 phk Exp $
|
||||
* $Id: time.h,v 1.32 1998/06/07 20:36:55 phk Exp $
|
||||
*/
|
||||
|
||||
#ifndef _SYS_TIME_H_
|
||||
|
@ -132,26 +132,26 @@ 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;
|
||||
void *priv;
|
||||
timecounter_get_t *tc_get_timecount;
|
||||
timecounter_pps_t *tc_poll_pps;
|
||||
unsigned tc_counter_mask;
|
||||
u_int32_t tc_frequency;
|
||||
char *tc_name;
|
||||
void *tc_priv;
|
||||
/* These fields will be managed by the generic code. */
|
||||
int cost;
|
||||
int32_t adjustment;
|
||||
u_int32_t scale_micro;
|
||||
u_int32_t scale_nano_i;
|
||||
u_int32_t scale_nano_f;
|
||||
unsigned offset_count;
|
||||
u_int32_t offset_sec;
|
||||
u_int32_t offset_micro;
|
||||
u_int64_t offset_nano;
|
||||
struct timeval microtime;
|
||||
struct timespec nanotime;
|
||||
struct timecounter *other;
|
||||
struct timecounter *tweak;
|
||||
int tc_cost;
|
||||
int32_t tc_adjustment;
|
||||
u_int32_t tc_scale_micro;
|
||||
u_int32_t tc_scale_nano_i;
|
||||
u_int32_t tc_scale_nano_f;
|
||||
unsigned tc_offset_count;
|
||||
u_int32_t tc_offset_sec;
|
||||
u_int32_t tc_offset_micro;
|
||||
u_int64_t tc_offset_nano;
|
||||
struct timeval tc_microtime;
|
||||
struct timespec tc_nanotime;
|
||||
struct timecounter *tc_other;
|
||||
struct timecounter *tc_tweak;
|
||||
};
|
||||
|
||||
#ifdef KERNEL
|
||||
|
|
Loading…
Reference in a new issue