diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c index 9467e2d9f4ab..dc02dea82ccc 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.130 1999/04/21 07:26:27 peter Exp $ + * $Id: clock.c,v 1.131 1999/04/21 07:41:40 peter Exp $ */ /* @@ -1115,6 +1115,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS return (EBUSY); /* too much trouble to handle */ set_timer_freq(freq, hz); i8254_timecounter.tc_frequency = freq; + update_timecounter(&i8254_timecounter); } return (error); } @@ -1135,6 +1136,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS if (error == 0 && req->newptr != NULL) { tsc_freq = freq; tsc_timecounter.tc_frequency = tsc_freq; + update_timecounter(&tsc_timecounter); } return (error); } diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 9467e2d9f4ab..dc02dea82ccc 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.130 1999/04/21 07:26:27 peter Exp $ + * $Id: clock.c,v 1.131 1999/04/21 07:41:40 peter Exp $ */ /* @@ -1115,6 +1115,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS return (EBUSY); /* too much trouble to handle */ set_timer_freq(freq, hz); i8254_timecounter.tc_frequency = freq; + update_timecounter(&i8254_timecounter); } return (error); } @@ -1135,6 +1136,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS if (error == 0 && req->newptr != NULL) { tsc_freq = freq; tsc_timecounter.tc_frequency = tsc_freq; + update_timecounter(&tsc_timecounter); } return (error); } diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c index 9467e2d9f4ab..dc02dea82ccc 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.130 1999/04/21 07:26:27 peter Exp $ + * $Id: clock.c,v 1.131 1999/04/21 07:41:40 peter Exp $ */ /* @@ -1115,6 +1115,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS return (EBUSY); /* too much trouble to handle */ set_timer_freq(freq, hz); i8254_timecounter.tc_frequency = freq; + update_timecounter(&i8254_timecounter); } return (error); } @@ -1135,6 +1136,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS if (error == 0 && req->newptr != NULL) { tsc_freq = freq; tsc_timecounter.tc_frequency = tsc_freq; + update_timecounter(&tsc_timecounter); } return (error); } diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 9467e2d9f4ab..dc02dea82ccc 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.130 1999/04/21 07:26:27 peter Exp $ + * $Id: clock.c,v 1.131 1999/04/21 07:41:40 peter Exp $ */ /* @@ -1115,6 +1115,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS return (EBUSY); /* too much trouble to handle */ set_timer_freq(freq, hz); i8254_timecounter.tc_frequency = freq; + update_timecounter(&i8254_timecounter); } return (error); } @@ -1135,6 +1136,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS if (error == 0 && req->newptr != NULL) { tsc_freq = freq; tsc_timecounter.tc_frequency = tsc_freq; + update_timecounter(&tsc_timecounter); } return (error); } diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index 9467e2d9f4ab..dc02dea82ccc 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.130 1999/04/21 07:26:27 peter Exp $ + * $Id: clock.c,v 1.131 1999/04/21 07:41:40 peter Exp $ */ /* @@ -1115,6 +1115,7 @@ sysctl_machdep_i8254_freq SYSCTL_HANDLER_ARGS return (EBUSY); /* too much trouble to handle */ set_timer_freq(freq, hz); i8254_timecounter.tc_frequency = freq; + update_timecounter(&i8254_timecounter); } return (error); } @@ -1135,6 +1136,7 @@ sysctl_machdep_tsc_freq SYSCTL_HANDLER_ARGS if (error == 0 && req->newptr != NULL) { tsc_freq = freq; tsc_timecounter.tc_frequency = tsc_freq; + update_timecounter(&tsc_timecounter); } return (error); } diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 114a5926a0f3..a1b7727d3885 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.92 1999/03/12 21:58:54 phk Exp $ + * $Id: kern_clock.c,v 1.93 1999/04/02 13:57:21 phk Exp $ */ #include "opt_ntp.h" @@ -656,12 +656,18 @@ tco_setscales(struct timecounter *tc) scale = 1000000000LL << 32; scale += tc->tc_adjustment; - scale /= tc->tc_frequency; + scale /= tc->tc_tweak->tc_frequency; tc->tc_scale_micro = scale / 1000; tc->tc_scale_nano_f = scale & 0xffffffff; tc->tc_scale_nano_i = scale >> 32; } +void +update_timecounter(struct timecounter *tc) +{ + tco_setscales(tc); +} + void init_timecounter(struct timecounter *tc) { @@ -670,9 +676,9 @@ init_timecounter(struct timecounter *tc) int i; tc->tc_adjustment = 0; + tc->tc_tweak = tc; tco_setscales(tc); tc->tc_offset_count = tc->tc_get_timecount(tc); - tc->tc_tweak = tc; MALLOC(t1, struct timecounter *, sizeof *t1, M_TIMECOUNTER, M_WAITOK); *t1 = *tc; t2 = t1; diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 114a5926a0f3..a1b7727d3885 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * @(#)kern_clock.c 8.5 (Berkeley) 1/21/94 - * $Id: kern_clock.c,v 1.92 1999/03/12 21:58:54 phk Exp $ + * $Id: kern_clock.c,v 1.93 1999/04/02 13:57:21 phk Exp $ */ #include "opt_ntp.h" @@ -656,12 +656,18 @@ tco_setscales(struct timecounter *tc) scale = 1000000000LL << 32; scale += tc->tc_adjustment; - scale /= tc->tc_frequency; + scale /= tc->tc_tweak->tc_frequency; tc->tc_scale_micro = scale / 1000; tc->tc_scale_nano_f = scale & 0xffffffff; tc->tc_scale_nano_i = scale >> 32; } +void +update_timecounter(struct timecounter *tc) +{ + tco_setscales(tc); +} + void init_timecounter(struct timecounter *tc) { @@ -670,9 +676,9 @@ init_timecounter(struct timecounter *tc) int i; tc->tc_adjustment = 0; + tc->tc_tweak = tc; tco_setscales(tc); tc->tc_offset_count = tc->tc_get_timecount(tc); - tc->tc_tweak = tc; MALLOC(t1, struct timecounter *, sizeof *t1, M_TIMECOUNTER, M_WAITOK); *t1 = *tc; t2 = t1; diff --git a/sys/sys/time.h b/sys/sys/time.h index 712fffe12fa5..43821b638edd 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.36 1999/03/08 12:36:14 phk Exp $ + * $Id: time.h,v 1.37 1999/03/11 15:09:41 phk Exp $ */ #ifndef _SYS_TIME_H_ @@ -280,6 +280,7 @@ void set_timecounter __P((struct timespec *ts)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); int tvtohz __P((struct timeval *)); +void update_timecounter __P((struct timecounter *tc)); #else /* !KERNEL */ #include diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h index 712fffe12fa5..43821b638edd 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.36 1999/03/08 12:36:14 phk Exp $ + * $Id: time.h,v 1.37 1999/03/11 15:09:41 phk Exp $ */ #ifndef _SYS_TIME_H_ @@ -280,6 +280,7 @@ void set_timecounter __P((struct timespec *ts)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); int tvtohz __P((struct timeval *)); +void update_timecounter __P((struct timecounter *tc)); #else /* !KERNEL */ #include