summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorwollman <wollman@FreeBSD.org>1995-11-29 19:57:22 +0000
committerwollman <wollman@FreeBSD.org>1995-11-29 19:57:22 +0000
commit0b986693ce58208f4c247762f09f25d55ea20507 (patch)
tree0c68faafac80cd0928f1570233bb01cf233b1826 /sys
parent8476f980ecdc58fda564f3280af8a5f2003a5515 (diff)
downloadFreeBSD-src-0b986693ce58208f4c247762f09f25d55ea20507.zip
FreeBSD-src-0b986693ce58208f4c247762f09f25d55ea20507.tar.gz
Fix Pentium CPU rate diagnosis:
- Don't print out meaningless iCOMP numbers, those are for droids. - Use a shorter wait to determine clock rate to avoid deficiencies in DELAY(). - Use a fixed-point representation with 8 bits of fraction to store the rate and rationalize the variable name. It would be possible to use even more fraction if it turns out to be worthwhile (I rather doubt it). The question of source code arrangement remains unaddressed.
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/machdep.c32
-rw-r--r--sys/amd64/amd64/tsc.c16
-rw-r--r--sys/amd64/include/clock.h13
-rw-r--r--sys/amd64/isa/clock.c16
-rw-r--r--sys/i386/i386/machdep.c32
-rw-r--r--sys/i386/i386/microtime.s10
-rw-r--r--sys/i386/i386/tsc.c16
-rw-r--r--sys/i386/include/clock.h13
-rw-r--r--sys/i386/isa/clock.c16
-rw-r--r--sys/isa/atrtc.c16
10 files changed, 91 insertions, 89 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 77cfdb9..e5538b3 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $Id: machdep.c,v 1.151 1995/11/14 09:52:25 phk Exp $
+ * $Id: machdep.c,v 1.152 1995/11/20 12:41:24 phk Exp $
*/
#include "npx.h"
@@ -493,7 +493,6 @@ identifycpu()
#if defined(I586_CPU)
if(cpu_class == CPUCLASS_586) {
calibrate_cyclecounter();
- printf("%d-MHz ", pentium_mhz);
}
#endif
#if defined(I486_CPU) || defined(I586_CPU)
@@ -513,7 +512,7 @@ identifycpu()
strcat(cpu_model, "i486 ");
#if defined(I586_CPU)
} else if ((cpu_id & 0xf00) == 0x500) {
- strcat(cpu_model, "Pentium ");
+ strcat(cpu_model, "Pentium"); /* nb no space */
#endif
} else {
strcat(cpu_model, "unknown ");
@@ -539,22 +538,14 @@ identifycpu()
strcat(cpu_model, "DX4"); break;
#if defined(I586_CPU)
case 0x510:
- if (pentium_mhz == 60) {
- strcat(cpu_model, "510\\60");
- } else if (pentium_mhz == 66) {
- strcat(cpu_model, "567\\66");
- } else {
- strcat(cpu_model,"510\\60 or 567\\66");
- }
- break;
case 0x520:
- if (pentium_mhz == 90) {
- strcat(cpu_model, "735\\90");
- } else if (pentium_mhz == 100) {
- strcat(cpu_model, "815\\100");
- } else {
- strcat(cpu_model,"735\\90 or 815\\100");
- }
+ /*
+ * We used to do all sorts of nonsense here
+ * to print out iCOMP numbers. Since these
+ * are meaningless except to Intel
+ * marketroids, there seems to be little
+ * sense in doing so.
+ */
break;
#endif
}
@@ -578,7 +569,10 @@ identifycpu()
#endif
#if defined(I586_CPU)
case CPUCLASS_586:
- printf("Pentium");
+ printf("%d.%02d-MHz ",
+ ((100 * i586_ctr_rate) >> I586_CTR_RATE_SHIFT) / 100,
+ ((100 * i586_ctr_rate) >> I586_CTR_RATE_SHIFT) % 100);
+ printf("586");
break;
#endif
default:
diff --git a/sys/amd64/amd64/tsc.c b/sys/amd64/amd64/tsc.c
index 7259a33..82e0b18 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.37 1995/10/12 20:39:49 wollman Exp $
+ * $Id: clock.c,v 1.38 1995/10/28 15:38:49 phk Exp $
*/
/*
@@ -94,7 +94,7 @@ int adjkerntz = 0; /* offset from CMOS clock */
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
u_int idelayed;
#ifdef I586_CPU
-int pentium_mhz;
+unsigned i586_ctr_rate;
long long i586_ctr_bias;
long long i586_last_tick;
#endif
@@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
*/
unsigned long long count;
+#define howlong ((unsigned)4*tick)
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
- DELAY(1000000);
+ DELAY(howlong);
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
- /*
- * XX lose if the clock rate is not nearly a multiple of 1000000.
- */
- pentium_mhz = (count + 500000) / 1000000;
+
+ i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
+#undef howlong
}
#endif
@@ -573,7 +573,7 @@ cpu_initclocks()
/*
* Finish setting up anti-jitter measures.
*/
- if (pentium_mhz) {
+ if (i586_ctr_rate) {
I586_CYCLECTR(i586_last_tick);
i586_ctr_bias = i586_last_tick;
}
diff --git a/sys/amd64/include/clock.h b/sys/amd64/include/clock.h
index 96476a7..c231f5e 100644
--- a/sys/amd64/include/clock.h
+++ b/sys/amd64/include/clock.h
@@ -2,6 +2,8 @@
* Kernel interface to machine-dependent clock driver.
* Garrett Wollman, September 1994.
* This file is in the public domain.
+ *
+ * $Id$
*/
#ifndef _MACHINE_CLOCK_H_
@@ -22,7 +24,7 @@
*/
#define CPU_CLOCKUPDATE(otime, ntime) \
do { \
- if(pentium_mhz) { \
+ if(i586_ctr_rate) { \
disable_intr(); \
i586_ctr_bias = i586_last_tick; \
*(otime) = *(ntime); \
@@ -39,6 +41,8 @@
#define CPU_THISTICKLEN(dflt) dflt
#endif
+#define I586_CTR_RATE_SHIFT 8
+
#if defined(KERNEL) && !defined(LOCORE)
#include <sys/cdefs.h>
#include <machine/frame.h>
@@ -51,7 +55,7 @@
extern int adjkerntz;
extern int disable_rtc_set;
#ifdef I586_CPU
-extern int pentium_mhz;
+extern unsigned i586_ctr_rate; /* fixed point */
extern long long i586_last_tick;
extern long long i586_ctr_bias;
#endif
@@ -72,10 +76,11 @@ cpu_thisticklen(u_long dflt)
long long old;
long rv;
- if (pentium_mhz) {
+ if (i586_ctr_rate) {
old = i586_last_tick;
I586_CYCLECTR(i586_last_tick);
- rv = (i586_last_tick - old) / pentium_mhz;
+ rv = ((i586_last_tick - old) << I586_CTR_RATE_SHIFT)
+ / i586_ctr_rate;
} else {
rv = dflt;
}
diff --git a/sys/amd64/isa/clock.c b/sys/amd64/isa/clock.c
index 7259a33..82e0b18 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.37 1995/10/12 20:39:49 wollman Exp $
+ * $Id: clock.c,v 1.38 1995/10/28 15:38:49 phk Exp $
*/
/*
@@ -94,7 +94,7 @@ int adjkerntz = 0; /* offset from CMOS clock */
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
u_int idelayed;
#ifdef I586_CPU
-int pentium_mhz;
+unsigned i586_ctr_rate;
long long i586_ctr_bias;
long long i586_last_tick;
#endif
@@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
*/
unsigned long long count;
+#define howlong ((unsigned)4*tick)
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
- DELAY(1000000);
+ DELAY(howlong);
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
- /*
- * XX lose if the clock rate is not nearly a multiple of 1000000.
- */
- pentium_mhz = (count + 500000) / 1000000;
+
+ i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
+#undef howlong
}
#endif
@@ -573,7 +573,7 @@ cpu_initclocks()
/*
* Finish setting up anti-jitter measures.
*/
- if (pentium_mhz) {
+ if (i586_ctr_rate) {
I586_CYCLECTR(i586_last_tick);
i586_ctr_bias = i586_last_tick;
}
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 77cfdb9..e5538b3 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
- * $Id: machdep.c,v 1.151 1995/11/14 09:52:25 phk Exp $
+ * $Id: machdep.c,v 1.152 1995/11/20 12:41:24 phk Exp $
*/
#include "npx.h"
@@ -493,7 +493,6 @@ identifycpu()
#if defined(I586_CPU)
if(cpu_class == CPUCLASS_586) {
calibrate_cyclecounter();
- printf("%d-MHz ", pentium_mhz);
}
#endif
#if defined(I486_CPU) || defined(I586_CPU)
@@ -513,7 +512,7 @@ identifycpu()
strcat(cpu_model, "i486 ");
#if defined(I586_CPU)
} else if ((cpu_id & 0xf00) == 0x500) {
- strcat(cpu_model, "Pentium ");
+ strcat(cpu_model, "Pentium"); /* nb no space */
#endif
} else {
strcat(cpu_model, "unknown ");
@@ -539,22 +538,14 @@ identifycpu()
strcat(cpu_model, "DX4"); break;
#if defined(I586_CPU)
case 0x510:
- if (pentium_mhz == 60) {
- strcat(cpu_model, "510\\60");
- } else if (pentium_mhz == 66) {
- strcat(cpu_model, "567\\66");
- } else {
- strcat(cpu_model,"510\\60 or 567\\66");
- }
- break;
case 0x520:
- if (pentium_mhz == 90) {
- strcat(cpu_model, "735\\90");
- } else if (pentium_mhz == 100) {
- strcat(cpu_model, "815\\100");
- } else {
- strcat(cpu_model,"735\\90 or 815\\100");
- }
+ /*
+ * We used to do all sorts of nonsense here
+ * to print out iCOMP numbers. Since these
+ * are meaningless except to Intel
+ * marketroids, there seems to be little
+ * sense in doing so.
+ */
break;
#endif
}
@@ -578,7 +569,10 @@ identifycpu()
#endif
#if defined(I586_CPU)
case CPUCLASS_586:
- printf("Pentium");
+ printf("%d.%02d-MHz ",
+ ((100 * i586_ctr_rate) >> I586_CTR_RATE_SHIFT) / 100,
+ ((100 * i586_ctr_rate) >> I586_CTR_RATE_SHIFT) % 100);
+ printf("586");
break;
#endif
default:
diff --git a/sys/i386/i386/microtime.s b/sys/i386/i386/microtime.s
index 7470c16..44b7e97 100644
--- a/sys/i386/i386/microtime.s
+++ b/sys/i386/i386/microtime.s
@@ -1,4 +1,5 @@
-/*-
+/* -*- Fundamental -*- keep Emacs from f***ing up the formatting */
+/*
* Copyright (c) 1993 The Regents of the University of California.
* All rights reserved.
*
@@ -31,10 +32,11 @@
* SUCH DAMAGE.
*
* from: Steve McCanne's microtime code
- * $Id: microtime.s,v 1.9 1995/10/13 19:53:25 wollman Exp $
+ * $Id: microtime.s,v 1.10 1995/10/14 04:53:49 bde Exp $
*/
#include <machine/asmacros.h>
+#include <machine/clock.h>
#include <i386/isa/icu.h>
#include <i386/isa/isa.h>
@@ -43,7 +45,7 @@
ENTRY(microtime)
#ifdef I586_CPU
- movl _pentium_mhz, %ecx
+ movl _i586_ctr_rate, %ecx
testl %ecx, %ecx
jne pentium_microtime
#else
@@ -180,6 +182,8 @@ pentium_microtime:
.byte 0x0f, 0x31 # RDTSC
subl _i586_ctr_bias, %eax
sbbl _i586_ctr_bias+4, %edx
+ shldl $I586_CTR_RATE_SHIFT, %eax, %edx # magic suggested by
+ shll $I586_CTR_RATE_SHIFT, %eax # math_emulate.c
divl %ecx # get value in usec
jmp common_microtime
#endif
diff --git a/sys/i386/i386/tsc.c b/sys/i386/i386/tsc.c
index 7259a33..82e0b18 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.37 1995/10/12 20:39:49 wollman Exp $
+ * $Id: clock.c,v 1.38 1995/10/28 15:38:49 phk Exp $
*/
/*
@@ -94,7 +94,7 @@ int adjkerntz = 0; /* offset from CMOS clock */
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
u_int idelayed;
#ifdef I586_CPU
-int pentium_mhz;
+unsigned i586_ctr_rate;
long long i586_ctr_bias;
long long i586_last_tick;
#endif
@@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
*/
unsigned long long count;
+#define howlong ((unsigned)4*tick)
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
- DELAY(1000000);
+ DELAY(howlong);
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
- /*
- * XX lose if the clock rate is not nearly a multiple of 1000000.
- */
- pentium_mhz = (count + 500000) / 1000000;
+
+ i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
+#undef howlong
}
#endif
@@ -573,7 +573,7 @@ cpu_initclocks()
/*
* Finish setting up anti-jitter measures.
*/
- if (pentium_mhz) {
+ if (i586_ctr_rate) {
I586_CYCLECTR(i586_last_tick);
i586_ctr_bias = i586_last_tick;
}
diff --git a/sys/i386/include/clock.h b/sys/i386/include/clock.h
index 96476a7..c231f5e 100644
--- a/sys/i386/include/clock.h
+++ b/sys/i386/include/clock.h
@@ -2,6 +2,8 @@
* Kernel interface to machine-dependent clock driver.
* Garrett Wollman, September 1994.
* This file is in the public domain.
+ *
+ * $Id$
*/
#ifndef _MACHINE_CLOCK_H_
@@ -22,7 +24,7 @@
*/
#define CPU_CLOCKUPDATE(otime, ntime) \
do { \
- if(pentium_mhz) { \
+ if(i586_ctr_rate) { \
disable_intr(); \
i586_ctr_bias = i586_last_tick; \
*(otime) = *(ntime); \
@@ -39,6 +41,8 @@
#define CPU_THISTICKLEN(dflt) dflt
#endif
+#define I586_CTR_RATE_SHIFT 8
+
#if defined(KERNEL) && !defined(LOCORE)
#include <sys/cdefs.h>
#include <machine/frame.h>
@@ -51,7 +55,7 @@
extern int adjkerntz;
extern int disable_rtc_set;
#ifdef I586_CPU
-extern int pentium_mhz;
+extern unsigned i586_ctr_rate; /* fixed point */
extern long long i586_last_tick;
extern long long i586_ctr_bias;
#endif
@@ -72,10 +76,11 @@ cpu_thisticklen(u_long dflt)
long long old;
long rv;
- if (pentium_mhz) {
+ if (i586_ctr_rate) {
old = i586_last_tick;
I586_CYCLECTR(i586_last_tick);
- rv = (i586_last_tick - old) / pentium_mhz;
+ rv = ((i586_last_tick - old) << I586_CTR_RATE_SHIFT)
+ / i586_ctr_rate;
} else {
rv = dflt;
}
diff --git a/sys/i386/isa/clock.c b/sys/i386/isa/clock.c
index 7259a33..82e0b18 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.37 1995/10/12 20:39:49 wollman Exp $
+ * $Id: clock.c,v 1.38 1995/10/28 15:38:49 phk Exp $
*/
/*
@@ -94,7 +94,7 @@ int adjkerntz = 0; /* offset from CMOS clock */
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
u_int idelayed;
#ifdef I586_CPU
-int pentium_mhz;
+unsigned i586_ctr_rate;
long long i586_ctr_bias;
long long i586_last_tick;
#endif
@@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
*/
unsigned long long count;
+#define howlong ((unsigned)4*tick)
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
- DELAY(1000000);
+ DELAY(howlong);
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
- /*
- * XX lose if the clock rate is not nearly a multiple of 1000000.
- */
- pentium_mhz = (count + 500000) / 1000000;
+
+ i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
+#undef howlong
}
#endif
@@ -573,7 +573,7 @@ cpu_initclocks()
/*
* Finish setting up anti-jitter measures.
*/
- if (pentium_mhz) {
+ if (i586_ctr_rate) {
I586_CYCLECTR(i586_last_tick);
i586_ctr_bias = i586_last_tick;
}
diff --git a/sys/isa/atrtc.c b/sys/isa/atrtc.c
index 7259a33..82e0b18 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.37 1995/10/12 20:39:49 wollman Exp $
+ * $Id: clock.c,v 1.38 1995/10/28 15:38:49 phk Exp $
*/
/*
@@ -94,7 +94,7 @@ int adjkerntz = 0; /* offset from CMOS clock */
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
u_int idelayed;
#ifdef I586_CPU
-int pentium_mhz;
+unsigned i586_ctr_rate;
long long i586_ctr_bias;
long long i586_last_tick;
#endif
@@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
*/
unsigned long long count;
+#define howlong ((unsigned)4*tick)
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
- DELAY(1000000);
+ DELAY(howlong);
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
- /*
- * XX lose if the clock rate is not nearly a multiple of 1000000.
- */
- pentium_mhz = (count + 500000) / 1000000;
+
+ i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
+#undef howlong
}
#endif
@@ -573,7 +573,7 @@ cpu_initclocks()
/*
* Finish setting up anti-jitter measures.
*/
- if (pentium_mhz) {
+ if (i586_ctr_rate) {
I586_CYCLECTR(i586_last_tick);
i586_ctr_bias = i586_last_tick;
}
OpenPOWER on IntegriCloud