From 20de4c116cd0e5f7dc88b7d19527503a5a9b5c2a Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 28 Dec 1997 13:36:09 +0000 Subject: [PATCH] wash, sort and put in order various nits from the i586_ctr -> tsc commit. Pointed out by: bde --- sys/amd64/amd64/tsc.c | 22 +++++++++++----------- sys/amd64/include/clock.h | 22 +++++++++++----------- sys/amd64/isa/clock.c | 22 +++++++++++----------- sys/conf/NOTES | 6 +++--- sys/conf/options.i386 | 4 ++-- sys/i386/conf/LINT | 6 +++--- sys/i386/conf/NOTES | 6 +++--- sys/i386/conf/options.i386 | 4 ++-- sys/i386/i386/microtime.s | 4 ++-- sys/i386/i386/tsc.c | 22 +++++++++++----------- sys/i386/include/asnames.h | 8 ++++---- sys/i386/include/clock.h | 22 +++++++++++----------- sys/i386/isa/clock.c | 22 +++++++++++----------- sys/isa/atrtc.c | 22 +++++++++++----------- sys/sys/time.h | 5 +++-- sys/sys/timetc.h | 5 +++-- 16 files changed, 102 insertions(+), 100 deletions(-) diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c index 8b94ff8fc912..b7b12892f094 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.104 1997/11/18 11:16:56 bde Exp $ + * $Id: clock.c,v 1.105 1997/12/26 20:42:05 phk Exp $ */ /* @@ -116,16 +116,6 @@ int adjkerntz; /* local offset from GMT in seconds */ int disable_rtc_set; /* disable resettodr() if != 0 */ u_int idelayed; -#if defined(I586_CPU) || defined(I686_CPU) -#ifndef SMP -u_int tsc_bias; -u_int tsc_comultiplier; -#endif -u_int tsc_freq; -#ifndef SMP -u_int tsc_multiplier; -#endif -#endif int statclock_disable; u_int stat_imask = SWI_CLOCK_MASK; #ifdef TIMER_FREQ @@ -136,6 +126,16 @@ u_int timer_freq = 1193182; int timer0_max_count; u_int timer0_overflow_threshold; u_int timer0_prescaler_count; +#if defined(I586_CPU) || defined(I686_CPU) +#ifndef SMP +u_int tsc_bias; +u_int tsc_comultiplier; +#endif +u_int tsc_freq; +#ifndef SMP +u_int tsc_multiplier; +#endif +#endif int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ static int beeping = 0; diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h index a4c32a0d2b27..505ea4868fe8 100644 --- a/sys/amd64/include/clock.h +++ b/sys/amd64/include/clock.h @@ -3,7 +3,7 @@ * Garrett Wollman, September 1994. * This file is in the public domain. * - * $Id: clock.h,v 1.27 1997/05/05 09:34:33 peter Exp $ + * $Id: clock.h,v 1.28 1997/12/26 20:42:01 phk Exp $ */ #ifndef _MACHINE_CLOCK_H_ @@ -28,6 +28,11 @@ */ extern int adjkerntz; extern int disable_rtc_set; +extern int statclock_disable; +extern u_int timer_freq; +extern int timer0_max_count; +extern u_int timer0_overflow_threshold; +extern u_int timer0_prescaler_count; #if defined(I586_CPU) || defined(I686_CPU) #ifndef SMP extern u_int tsc_bias; @@ -38,11 +43,6 @@ extern u_int tsc_freq; extern u_int tsc_multiplier; #endif #endif -extern int statclock_disable; -extern u_int timer_freq; -extern int timer0_max_count; -extern u_int timer0_overflow_threshold; -extern u_int timer0_prescaler_count; extern int wall_cmos_clock; /* @@ -87,9 +87,9 @@ clock_latency(void) #if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) /* - * When we update `time', on i586's we also update `tsc_bias' + * When we update `time', on we also update `tsc_bias' * atomically. `tsc_bias' is the best available approximation to - * the value of the i586 counter (mod 2^32) at the time of the i8254 + * the value of the TSC (mod 2^32) at the time of the i8254 * counter transition that caused the clock interrupt that caused the * update. clock_latency() gives the time between the transition and * the update to within a few usec provided another such transition @@ -101,13 +101,13 @@ static __inline void cpu_clockupdate(volatile struct timeval *otime, struct timeval *ntime) { if (tsc_freq != 0) { - u_int i586_count; /* truncated */ + u_int tsc_count; /* truncated */ u_int i8254_count; disable_intr(); i8254_count = clock_latency(); - i586_count = rdtsc(); - tsc_bias = i586_count + tsc_count = rdtsc(); + tsc_bias = tsc_count - (u_int) (((unsigned long long)tsc_comultiplier * i8254_count) diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c index 8b94ff8fc912..b7b12892f094 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.104 1997/11/18 11:16:56 bde Exp $ + * $Id: clock.c,v 1.105 1997/12/26 20:42:05 phk Exp $ */ /* @@ -116,16 +116,6 @@ int adjkerntz; /* local offset from GMT in seconds */ int disable_rtc_set; /* disable resettodr() if != 0 */ u_int idelayed; -#if defined(I586_CPU) || defined(I686_CPU) -#ifndef SMP -u_int tsc_bias; -u_int tsc_comultiplier; -#endif -u_int tsc_freq; -#ifndef SMP -u_int tsc_multiplier; -#endif -#endif int statclock_disable; u_int stat_imask = SWI_CLOCK_MASK; #ifdef TIMER_FREQ @@ -136,6 +126,16 @@ u_int timer_freq = 1193182; int timer0_max_count; u_int timer0_overflow_threshold; u_int timer0_prescaler_count; +#if defined(I586_CPU) || defined(I686_CPU) +#ifndef SMP +u_int tsc_bias; +u_int tsc_comultiplier; +#endif +u_int tsc_freq; +#ifndef SMP +u_int tsc_multiplier; +#endif +#endif int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ static int beeping = 0; diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 5ee684f3d47d..5285f85a9610 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.387 1997/12/26 20:41:05 phk Exp $ +# $Id: LINT,v 1.388 1997/12/28 00:28:46 jkh Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1358,14 +1358,13 @@ options GATEWAY options CLK_CALIBRATION_LOOP options "CLK_USE_I8254_CALIBRATION" -options "CLK_USE_TSC_CALIBRATION" +options CLK_USE_TSC_CALIBRATION options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG options DEVFS_ROOT options "EXT2FS" -options "TSC_GUPROF" options "I586_PMC_GUPROF=0x70000" options "IBCS2" options LOCKF_DEBUG @@ -1406,3 +1405,4 @@ options SHMSEG=9 options SI_DEBUG options SIMPLELOCK_DEBUG options SPX_HACK +options TSC_GUPROF diff --git a/sys/conf/options.i386 b/sys/conf/options.i386 index 3569db5feaa5..2f2f7ac53bd9 100644 --- a/sys/conf/options.i386 +++ b/sys/conf/options.i386 @@ -1,4 +1,4 @@ -# $Id: options.i386,v 1.64 1997/12/09 11:56:19 yokota Exp $ +# $Id: options.i386,v 1.65 1997/12/26 20:41:08 phk Exp $ BOUNCEPAGES opt_bounce.h USER_LDT @@ -24,8 +24,8 @@ COM_ESP opt_sio.h COM_MULTIPORT opt_sio.h DSI_SOFT_MODEM opt_sio.h EXTRA_SIO opt_sio.h -TSC_GUPROF opt_i586_guprof.h I586_PMC_GUPROF opt_i586_guprof.h +TSC_GUPROF opt_i586_guprof.h WLCACHE opt_wavelan.h WLDEBUG opt_wavelan.h diff --git a/sys/i386/conf/LINT b/sys/i386/conf/LINT index 5ee684f3d47d..5285f85a9610 100644 --- a/sys/i386/conf/LINT +++ b/sys/i386/conf/LINT @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.387 1997/12/26 20:41:05 phk Exp $ +# $Id: LINT,v 1.388 1997/12/28 00:28:46 jkh Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1358,14 +1358,13 @@ options GATEWAY options CLK_CALIBRATION_LOOP options "CLK_USE_I8254_CALIBRATION" -options "CLK_USE_TSC_CALIBRATION" +options CLK_USE_TSC_CALIBRATION options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG options DEVFS_ROOT options "EXT2FS" -options "TSC_GUPROF" options "I586_PMC_GUPROF=0x70000" options "IBCS2" options LOCKF_DEBUG @@ -1406,3 +1405,4 @@ options SHMSEG=9 options SI_DEBUG options SIMPLELOCK_DEBUG options SPX_HACK +options TSC_GUPROF diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 5ee684f3d47d..5285f85a9610 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -2,7 +2,7 @@ # LINT -- config file for checking all the sources, tries to pull in # as much of the source tree as it can. # -# $Id: LINT,v 1.387 1997/12/26 20:41:05 phk Exp $ +# $Id: LINT,v 1.388 1997/12/28 00:28:46 jkh Exp $ # # NB: You probably don't want to try running a kernel built from this # file. Instead, you should start from GENERIC, and add options from @@ -1358,14 +1358,13 @@ options GATEWAY options CLK_CALIBRATION_LOOP options "CLK_USE_I8254_CALIBRATION" -options "CLK_USE_TSC_CALIBRATION" +options CLK_USE_TSC_CALIBRATION options CLUSTERDEBUG options COMPAT_LINUX options CPU_UPGRADE_HW_CACHE options DEBUG options DEVFS_ROOT options "EXT2FS" -options "TSC_GUPROF" options "I586_PMC_GUPROF=0x70000" options "IBCS2" options LOCKF_DEBUG @@ -1406,3 +1405,4 @@ options SHMSEG=9 options SI_DEBUG options SIMPLELOCK_DEBUG options SPX_HACK +options TSC_GUPROF diff --git a/sys/i386/conf/options.i386 b/sys/i386/conf/options.i386 index 3569db5feaa5..2f2f7ac53bd9 100644 --- a/sys/i386/conf/options.i386 +++ b/sys/i386/conf/options.i386 @@ -1,4 +1,4 @@ -# $Id: options.i386,v 1.64 1997/12/09 11:56:19 yokota Exp $ +# $Id: options.i386,v 1.65 1997/12/26 20:41:08 phk Exp $ BOUNCEPAGES opt_bounce.h USER_LDT @@ -24,8 +24,8 @@ COM_ESP opt_sio.h COM_MULTIPORT opt_sio.h DSI_SOFT_MODEM opt_sio.h EXTRA_SIO opt_sio.h -TSC_GUPROF opt_i586_guprof.h I586_PMC_GUPROF opt_i586_guprof.h +TSC_GUPROF opt_i586_guprof.h WLCACHE opt_wavelan.h WLDEBUG opt_wavelan.h diff --git a/sys/i386/i386/microtime.s b/sys/i386/i386/microtime.s index 6a6314a7eaa3..7544102d8e6d 100644 --- a/sys/i386/i386/microtime.s +++ b/sys/i386/i386/microtime.s @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * from: Steve McCanne's microtime code - * $Id: microtime.s,v 1.36 1997/12/26 20:15:03 phk Exp $ + * $Id: microtime.s,v 1.37 1997/12/26 20:41:35 phk Exp $ */ #include @@ -58,11 +58,11 @@ ENTRY(microtime) mull _tsc_multiplier movl %edx, %eax jmp common_microtime + ALIGN_TEXT #else xorl %ecx, %ecx /* clear ecx */ #endif - ALIGN_TEXT i8254_microtime: movb $TIMER_SEL0|TIMER_LATCH, %al /* prepare to latch */ diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c index 8b94ff8fc912..b7b12892f094 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.104 1997/11/18 11:16:56 bde Exp $ + * $Id: clock.c,v 1.105 1997/12/26 20:42:05 phk Exp $ */ /* @@ -116,16 +116,6 @@ int adjkerntz; /* local offset from GMT in seconds */ int disable_rtc_set; /* disable resettodr() if != 0 */ u_int idelayed; -#if defined(I586_CPU) || defined(I686_CPU) -#ifndef SMP -u_int tsc_bias; -u_int tsc_comultiplier; -#endif -u_int tsc_freq; -#ifndef SMP -u_int tsc_multiplier; -#endif -#endif int statclock_disable; u_int stat_imask = SWI_CLOCK_MASK; #ifdef TIMER_FREQ @@ -136,6 +126,16 @@ u_int timer_freq = 1193182; int timer0_max_count; u_int timer0_overflow_threshold; u_int timer0_prescaler_count; +#if defined(I586_CPU) || defined(I686_CPU) +#ifndef SMP +u_int tsc_bias; +u_int tsc_comultiplier; +#endif +u_int tsc_freq; +#ifndef SMP +u_int tsc_multiplier; +#endif +#endif int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ static int beeping = 0; diff --git a/sys/i386/include/asnames.h b/sys/i386/include/asnames.h index 54a2c6d588ef..beca72b9af31 100644 --- a/sys/i386/include/asnames.h +++ b/sys/i386/include/asnames.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: asnames.h,v 1.12 1997/12/18 02:09:29 peter Exp $ + * $Id: asnames.h,v 1.13 1997/12/26 20:41:59 phk Exp $ */ #ifndef _MACHINE_ASNAMES_H_ @@ -234,9 +234,6 @@ #define _get_isrlock get_isrlock #define _get_mplock get_mplock #define _get_syscall_lock get_syscall_lock -#define _tsc_bias tsc_bias -#define _tsc_freq tsc_freq -#define _tsc_multiplier tsc_multiplier #define _idqs idqs #define _imen imen #define _imen_lock imen_lock @@ -346,6 +343,9 @@ #define _trap trap #define _trap_by_wrmsr trap_by_wrmsr #define _trapwrite trapwrite +#define _tsc_bias tsc_bias +#define _tsc_freq tsc_freq +#define _tsc_multiplier tsc_multiplier #define _tty_imask tty_imask #define _userconfig_from_boot userconfig_from_boot #define _vec vec diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h index a4c32a0d2b27..505ea4868fe8 100644 --- a/sys/i386/include/clock.h +++ b/sys/i386/include/clock.h @@ -3,7 +3,7 @@ * Garrett Wollman, September 1994. * This file is in the public domain. * - * $Id: clock.h,v 1.27 1997/05/05 09:34:33 peter Exp $ + * $Id: clock.h,v 1.28 1997/12/26 20:42:01 phk Exp $ */ #ifndef _MACHINE_CLOCK_H_ @@ -28,6 +28,11 @@ */ extern int adjkerntz; extern int disable_rtc_set; +extern int statclock_disable; +extern u_int timer_freq; +extern int timer0_max_count; +extern u_int timer0_overflow_threshold; +extern u_int timer0_prescaler_count; #if defined(I586_CPU) || defined(I686_CPU) #ifndef SMP extern u_int tsc_bias; @@ -38,11 +43,6 @@ extern u_int tsc_freq; extern u_int tsc_multiplier; #endif #endif -extern int statclock_disable; -extern u_int timer_freq; -extern int timer0_max_count; -extern u_int timer0_overflow_threshold; -extern u_int timer0_prescaler_count; extern int wall_cmos_clock; /* @@ -87,9 +87,9 @@ clock_latency(void) #if (defined(I586_CPU) || defined(I686_CPU)) && !defined(SMP) /* - * When we update `time', on i586's we also update `tsc_bias' + * When we update `time', on we also update `tsc_bias' * atomically. `tsc_bias' is the best available approximation to - * the value of the i586 counter (mod 2^32) at the time of the i8254 + * the value of the TSC (mod 2^32) at the time of the i8254 * counter transition that caused the clock interrupt that caused the * update. clock_latency() gives the time between the transition and * the update to within a few usec provided another such transition @@ -101,13 +101,13 @@ static __inline void cpu_clockupdate(volatile struct timeval *otime, struct timeval *ntime) { if (tsc_freq != 0) { - u_int i586_count; /* truncated */ + u_int tsc_count; /* truncated */ u_int i8254_count; disable_intr(); i8254_count = clock_latency(); - i586_count = rdtsc(); - tsc_bias = i586_count + tsc_count = rdtsc(); + tsc_bias = tsc_count - (u_int) (((unsigned long long)tsc_comultiplier * i8254_count) diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c index 8b94ff8fc912..b7b12892f094 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.104 1997/11/18 11:16:56 bde Exp $ + * $Id: clock.c,v 1.105 1997/12/26 20:42:05 phk Exp $ */ /* @@ -116,16 +116,6 @@ int adjkerntz; /* local offset from GMT in seconds */ int disable_rtc_set; /* disable resettodr() if != 0 */ u_int idelayed; -#if defined(I586_CPU) || defined(I686_CPU) -#ifndef SMP -u_int tsc_bias; -u_int tsc_comultiplier; -#endif -u_int tsc_freq; -#ifndef SMP -u_int tsc_multiplier; -#endif -#endif int statclock_disable; u_int stat_imask = SWI_CLOCK_MASK; #ifdef TIMER_FREQ @@ -136,6 +126,16 @@ u_int timer_freq = 1193182; int timer0_max_count; u_int timer0_overflow_threshold; u_int timer0_prescaler_count; +#if defined(I586_CPU) || defined(I686_CPU) +#ifndef SMP +u_int tsc_bias; +u_int tsc_comultiplier; +#endif +u_int tsc_freq; +#ifndef SMP +u_int tsc_multiplier; +#endif +#endif int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ static int beeping = 0; diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c index 8b94ff8fc912..b7b12892f094 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.104 1997/11/18 11:16:56 bde Exp $ + * $Id: clock.c,v 1.105 1997/12/26 20:42:05 phk Exp $ */ /* @@ -116,16 +116,6 @@ int adjkerntz; /* local offset from GMT in seconds */ int disable_rtc_set; /* disable resettodr() if != 0 */ u_int idelayed; -#if defined(I586_CPU) || defined(I686_CPU) -#ifndef SMP -u_int tsc_bias; -u_int tsc_comultiplier; -#endif -u_int tsc_freq; -#ifndef SMP -u_int tsc_multiplier; -#endif -#endif int statclock_disable; u_int stat_imask = SWI_CLOCK_MASK; #ifdef TIMER_FREQ @@ -136,6 +126,16 @@ u_int timer_freq = 1193182; int timer0_max_count; u_int timer0_overflow_threshold; u_int timer0_prescaler_count; +#if defined(I586_CPU) || defined(I686_CPU) +#ifndef SMP +u_int tsc_bias; +u_int tsc_comultiplier; +#endif +u_int tsc_freq; +#ifndef SMP +u_int tsc_multiplier; +#endif +#endif int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ static int beeping = 0; diff --git a/sys/sys/time.h b/sys/sys/time.h index 3f1c4c26a34f..cdb812e5f29c 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.14 1997/05/13 10:58:14 peter Exp $ + * $Id: time.h,v 1.15 1997/06/24 18:21:09 jhay Exp $ */ #ifndef _SYS_TIME_H_ @@ -141,9 +141,10 @@ struct clockinfo { void gettime __P((struct timeval *tv)); int itimerfix __P((struct timeval *tv)); int itimerdecr __P((struct itimerval *itp, int usec)); -void microtime __P((struct timeval *tv)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); +void microtime __P((struct timeval *tv)); +void nanotime __P((struct timespec *ts)); #else /* !KERNEL */ #include diff --git a/sys/sys/timetc.h b/sys/sys/timetc.h index 3f1c4c26a34f..cdb812e5f29c 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.14 1997/05/13 10:58:14 peter Exp $ + * $Id: time.h,v 1.15 1997/06/24 18:21:09 jhay Exp $ */ #ifndef _SYS_TIME_H_ @@ -141,9 +141,10 @@ struct clockinfo { void gettime __P((struct timeval *tv)); int itimerfix __P((struct timeval *tv)); int itimerdecr __P((struct itimerval *itp, int usec)); -void microtime __P((struct timeval *tv)); void timevaladd __P((struct timeval *, struct timeval *)); void timevalsub __P((struct timeval *, struct timeval *)); +void microtime __P((struct timeval *tv)); +void nanotime __P((struct timespec *ts)); #else /* !KERNEL */ #include