summaryrefslogtreecommitdiffstats
path: root/sys/i386/include/clock.h
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1996-05-01 08:39:02 +0000
committerbde <bde@FreeBSD.org>1996-05-01 08:39:02 +0000
commitca8106a4ee34cb61e26e28ea80d9f6589caa51a6 (patch)
tree95750958823ac0fa9fa014498439a90f6aa982ee /sys/i386/include/clock.h
parent00b2015fb5a605103d9ba4381b6f2884ee87d5f3 (diff)
downloadFreeBSD-src-ca8106a4ee34cb61e26e28ea80d9f6589caa51a6.zip
FreeBSD-src-ca8106a4ee34cb61e26e28ea80d9f6589caa51a6.tar.gz
Added calibration the i8254 and the i586 clocks agains the RTC at boot
time. The results are currently ignored unless certain temporary options are used. Added sysctls to support reading and writing the clock frequency variables (not the frequencies themselves). Writing is supposed to atomically adjust all related variables. machdep.c: Fixed spelling of a function name in a comment so that I can log this message which should have been with the previous commit. Initialize `cpu_class' earlier so that it can be used in startrtclock() instead of in calibrate_cyclecounter() (which no longer exists). Removed range checking of `cpu'. It is always initialized to CPU_XXX so it is less likely to be out of bounds than most variables. clock.h: Removed I586_CYCLECTR(). Use rdtsc() instead. clock.c: TIMER_FREQ is now a variable timer_freq that defaults to the old value of TIMER_FREQ. #define'ing TIMER_FREQ should still work and may be the best way of setting the frequency. Calibration involves counting cycles while watching the RTC for one second. This gives values correct to within (a few ppm) + (the innaccuracy of the RTC) on my systems.
Diffstat (limited to 'sys/i386/include/clock.h')
-rw-r--r--sys/i386/include/clock.h13
1 files changed, 4 insertions, 9 deletions
diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h
index b624a61..1467e4e 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.11 1996/04/05 03:36:20 ache Exp $
+ * $Id: clock.h,v 1.12 1996/04/22 19:40:27 nate Exp $
*/
#ifndef _MACHINE_CLOCK_H_
@@ -11,9 +11,6 @@
#if defined(I586_CPU) || defined(I686_CPU)
-#define I586_CYCLECTR(x) \
- __asm __volatile(".byte 0x0f, 0x31" : "=A" (x))
-
/*
* When we update the clock, we also update this bias value which is
* automatically subtracted in microtime(). We assume that CPU_THISTICKLEN()
@@ -58,6 +55,7 @@ extern int statclock_disable;
extern int wall_cmos_clock;
#if defined(I586_CPU) || defined(I686_CPU)
+extern unsigned i586_ctr_freq;
extern unsigned i586_ctr_rate; /* fixed point */
extern long long i586_last_tick;
extern long long i586_ctr_bias;
@@ -67,9 +65,6 @@ extern int timer0_max_count;
extern u_int timer0_overflow_threshold;
extern u_int timer0_prescaler_count;
-#if defined(I586_CPU) || defined(I686_CPU)
-void calibrate_cyclecounter __P((void));
-#endif
#if defined(I586_CPU) || defined(I686_CPU)
static __inline u_long
@@ -77,10 +72,10 @@ cpu_thisticklen(u_long dflt)
{
long long old;
long len;
-
+
if (i586_ctr_rate) {
old = i586_last_tick;
- I586_CYCLECTR(i586_last_tick);
+ i586_last_tick = rdtsc();
len = ((i586_last_tick - old) << I586_CTR_RATE_SHIFT)
/ i586_ctr_rate;
i586_avg_tick = i586_avg_tick * 15 / 16 + len / 16;
OpenPOWER on IntegriCloud