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.
This commit is contained in:
parent
d6ed3c374d
commit
9350db19e7
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user