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.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
* 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"
|
#include "npx.h"
|
||||||
@ -493,7 +493,6 @@ identifycpu()
|
|||||||
#if defined(I586_CPU)
|
#if defined(I586_CPU)
|
||||||
if(cpu_class == CPUCLASS_586) {
|
if(cpu_class == CPUCLASS_586) {
|
||||||
calibrate_cyclecounter();
|
calibrate_cyclecounter();
|
||||||
printf("%d-MHz ", pentium_mhz);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(I486_CPU) || defined(I586_CPU)
|
#if defined(I486_CPU) || defined(I586_CPU)
|
||||||
@ -513,7 +512,7 @@ identifycpu()
|
|||||||
strcat(cpu_model, "i486 ");
|
strcat(cpu_model, "i486 ");
|
||||||
#if defined(I586_CPU)
|
#if defined(I586_CPU)
|
||||||
} else if ((cpu_id & 0xf00) == 0x500) {
|
} else if ((cpu_id & 0xf00) == 0x500) {
|
||||||
strcat(cpu_model, "Pentium ");
|
strcat(cpu_model, "Pentium"); /* nb no space */
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
strcat(cpu_model, "unknown ");
|
strcat(cpu_model, "unknown ");
|
||||||
@ -539,22 +538,14 @@ identifycpu()
|
|||||||
strcat(cpu_model, "DX4"); break;
|
strcat(cpu_model, "DX4"); break;
|
||||||
#if defined(I586_CPU)
|
#if defined(I586_CPU)
|
||||||
case 0x510:
|
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:
|
case 0x520:
|
||||||
if (pentium_mhz == 90) {
|
/*
|
||||||
strcat(cpu_model, "735\\90");
|
* We used to do all sorts of nonsense here
|
||||||
} else if (pentium_mhz == 100) {
|
* to print out iCOMP numbers. Since these
|
||||||
strcat(cpu_model, "815\\100");
|
* are meaningless except to Intel
|
||||||
} else {
|
* marketroids, there seems to be little
|
||||||
strcat(cpu_model,"735\\90 or 815\\100");
|
* sense in doing so.
|
||||||
}
|
*/
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -578,7 +569,10 @@ identifycpu()
|
|||||||
#endif
|
#endif
|
||||||
#if defined(I586_CPU)
|
#if defined(I586_CPU)
|
||||||
case CPUCLASS_586:
|
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;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
* 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 */
|
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
|
||||||
u_int idelayed;
|
u_int idelayed;
|
||||||
#ifdef I586_CPU
|
#ifdef I586_CPU
|
||||||
int pentium_mhz;
|
unsigned i586_ctr_rate;
|
||||||
long long i586_ctr_bias;
|
long long i586_ctr_bias;
|
||||||
long long i586_last_tick;
|
long long i586_last_tick;
|
||||||
#endif
|
#endif
|
||||||
@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
|
|||||||
*/
|
*/
|
||||||
unsigned long long count;
|
unsigned long long count;
|
||||||
|
|
||||||
|
#define howlong ((unsigned)4*tick)
|
||||||
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
||||||
DELAY(1000000);
|
DELAY(howlong);
|
||||||
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
||||||
/*
|
|
||||||
* XX lose if the clock rate is not nearly a multiple of 1000000.
|
i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
|
||||||
*/
|
#undef howlong
|
||||||
pentium_mhz = (count + 500000) / 1000000;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ cpu_initclocks()
|
|||||||
/*
|
/*
|
||||||
* Finish setting up anti-jitter measures.
|
* Finish setting up anti-jitter measures.
|
||||||
*/
|
*/
|
||||||
if (pentium_mhz) {
|
if (i586_ctr_rate) {
|
||||||
I586_CYCLECTR(i586_last_tick);
|
I586_CYCLECTR(i586_last_tick);
|
||||||
i586_ctr_bias = i586_last_tick;
|
i586_ctr_bias = i586_last_tick;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
* Kernel interface to machine-dependent clock driver.
|
* Kernel interface to machine-dependent clock driver.
|
||||||
* Garrett Wollman, September 1994.
|
* Garrett Wollman, September 1994.
|
||||||
* This file is in the public domain.
|
* This file is in the public domain.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MACHINE_CLOCK_H_
|
#ifndef _MACHINE_CLOCK_H_
|
||||||
@ -22,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
#define CPU_CLOCKUPDATE(otime, ntime) \
|
#define CPU_CLOCKUPDATE(otime, ntime) \
|
||||||
do { \
|
do { \
|
||||||
if(pentium_mhz) { \
|
if(i586_ctr_rate) { \
|
||||||
disable_intr(); \
|
disable_intr(); \
|
||||||
i586_ctr_bias = i586_last_tick; \
|
i586_ctr_bias = i586_last_tick; \
|
||||||
*(otime) = *(ntime); \
|
*(otime) = *(ntime); \
|
||||||
@ -39,6 +41,8 @@
|
|||||||
#define CPU_THISTICKLEN(dflt) dflt
|
#define CPU_THISTICKLEN(dflt) dflt
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define I586_CTR_RATE_SHIFT 8
|
||||||
|
|
||||||
#if defined(KERNEL) && !defined(LOCORE)
|
#if defined(KERNEL) && !defined(LOCORE)
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <machine/frame.h>
|
#include <machine/frame.h>
|
||||||
@ -51,7 +55,7 @@
|
|||||||
extern int adjkerntz;
|
extern int adjkerntz;
|
||||||
extern int disable_rtc_set;
|
extern int disable_rtc_set;
|
||||||
#ifdef I586_CPU
|
#ifdef I586_CPU
|
||||||
extern int pentium_mhz;
|
extern unsigned i586_ctr_rate; /* fixed point */
|
||||||
extern long long i586_last_tick;
|
extern long long i586_last_tick;
|
||||||
extern long long i586_ctr_bias;
|
extern long long i586_ctr_bias;
|
||||||
#endif
|
#endif
|
||||||
@ -72,10 +76,11 @@ cpu_thisticklen(u_long dflt)
|
|||||||
long long old;
|
long long old;
|
||||||
long rv;
|
long rv;
|
||||||
|
|
||||||
if (pentium_mhz) {
|
if (i586_ctr_rate) {
|
||||||
old = i586_last_tick;
|
old = i586_last_tick;
|
||||||
I586_CYCLECTR(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 {
|
} else {
|
||||||
rv = dflt;
|
rv = dflt;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
* 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 */
|
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
|
||||||
u_int idelayed;
|
u_int idelayed;
|
||||||
#ifdef I586_CPU
|
#ifdef I586_CPU
|
||||||
int pentium_mhz;
|
unsigned i586_ctr_rate;
|
||||||
long long i586_ctr_bias;
|
long long i586_ctr_bias;
|
||||||
long long i586_last_tick;
|
long long i586_last_tick;
|
||||||
#endif
|
#endif
|
||||||
@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
|
|||||||
*/
|
*/
|
||||||
unsigned long long count;
|
unsigned long long count;
|
||||||
|
|
||||||
|
#define howlong ((unsigned)4*tick)
|
||||||
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
||||||
DELAY(1000000);
|
DELAY(howlong);
|
||||||
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
||||||
/*
|
|
||||||
* XX lose if the clock rate is not nearly a multiple of 1000000.
|
i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
|
||||||
*/
|
#undef howlong
|
||||||
pentium_mhz = (count + 500000) / 1000000;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ cpu_initclocks()
|
|||||||
/*
|
/*
|
||||||
* Finish setting up anti-jitter measures.
|
* Finish setting up anti-jitter measures.
|
||||||
*/
|
*/
|
||||||
if (pentium_mhz) {
|
if (i586_ctr_rate) {
|
||||||
I586_CYCLECTR(i586_last_tick);
|
I586_CYCLECTR(i586_last_tick);
|
||||||
i586_ctr_bias = i586_last_tick;
|
i586_ctr_bias = i586_last_tick;
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
* 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"
|
#include "npx.h"
|
||||||
@ -493,7 +493,6 @@ identifycpu()
|
|||||||
#if defined(I586_CPU)
|
#if defined(I586_CPU)
|
||||||
if(cpu_class == CPUCLASS_586) {
|
if(cpu_class == CPUCLASS_586) {
|
||||||
calibrate_cyclecounter();
|
calibrate_cyclecounter();
|
||||||
printf("%d-MHz ", pentium_mhz);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(I486_CPU) || defined(I586_CPU)
|
#if defined(I486_CPU) || defined(I586_CPU)
|
||||||
@ -513,7 +512,7 @@ identifycpu()
|
|||||||
strcat(cpu_model, "i486 ");
|
strcat(cpu_model, "i486 ");
|
||||||
#if defined(I586_CPU)
|
#if defined(I586_CPU)
|
||||||
} else if ((cpu_id & 0xf00) == 0x500) {
|
} else if ((cpu_id & 0xf00) == 0x500) {
|
||||||
strcat(cpu_model, "Pentium ");
|
strcat(cpu_model, "Pentium"); /* nb no space */
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
strcat(cpu_model, "unknown ");
|
strcat(cpu_model, "unknown ");
|
||||||
@ -539,22 +538,14 @@ identifycpu()
|
|||||||
strcat(cpu_model, "DX4"); break;
|
strcat(cpu_model, "DX4"); break;
|
||||||
#if defined(I586_CPU)
|
#if defined(I586_CPU)
|
||||||
case 0x510:
|
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:
|
case 0x520:
|
||||||
if (pentium_mhz == 90) {
|
/*
|
||||||
strcat(cpu_model, "735\\90");
|
* We used to do all sorts of nonsense here
|
||||||
} else if (pentium_mhz == 100) {
|
* to print out iCOMP numbers. Since these
|
||||||
strcat(cpu_model, "815\\100");
|
* are meaningless except to Intel
|
||||||
} else {
|
* marketroids, there seems to be little
|
||||||
strcat(cpu_model,"735\\90 or 815\\100");
|
* sense in doing so.
|
||||||
}
|
*/
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -578,7 +569,10 @@ identifycpu()
|
|||||||
#endif
|
#endif
|
||||||
#if defined(I586_CPU)
|
#if defined(I586_CPU)
|
||||||
case CPUCLASS_586:
|
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;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
/*-
|
/* -*- Fundamental -*- keep Emacs from f***ing up the formatting */
|
||||||
|
/*
|
||||||
* Copyright (c) 1993 The Regents of the University of California.
|
* Copyright (c) 1993 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@ -31,10 +32,11 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: Steve McCanne's microtime code
|
* 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/asmacros.h>
|
||||||
|
#include <machine/clock.h>
|
||||||
|
|
||||||
#include <i386/isa/icu.h>
|
#include <i386/isa/icu.h>
|
||||||
#include <i386/isa/isa.h>
|
#include <i386/isa/isa.h>
|
||||||
@ -43,7 +45,7 @@
|
|||||||
ENTRY(microtime)
|
ENTRY(microtime)
|
||||||
|
|
||||||
#ifdef I586_CPU
|
#ifdef I586_CPU
|
||||||
movl _pentium_mhz, %ecx
|
movl _i586_ctr_rate, %ecx
|
||||||
testl %ecx, %ecx
|
testl %ecx, %ecx
|
||||||
jne pentium_microtime
|
jne pentium_microtime
|
||||||
#else
|
#else
|
||||||
@ -180,6 +182,8 @@ pentium_microtime:
|
|||||||
.byte 0x0f, 0x31 # RDTSC
|
.byte 0x0f, 0x31 # RDTSC
|
||||||
subl _i586_ctr_bias, %eax
|
subl _i586_ctr_bias, %eax
|
||||||
sbbl _i586_ctr_bias+4, %edx
|
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
|
divl %ecx # get value in usec
|
||||||
jmp common_microtime
|
jmp common_microtime
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
* 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 */
|
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
|
||||||
u_int idelayed;
|
u_int idelayed;
|
||||||
#ifdef I586_CPU
|
#ifdef I586_CPU
|
||||||
int pentium_mhz;
|
unsigned i586_ctr_rate;
|
||||||
long long i586_ctr_bias;
|
long long i586_ctr_bias;
|
||||||
long long i586_last_tick;
|
long long i586_last_tick;
|
||||||
#endif
|
#endif
|
||||||
@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
|
|||||||
*/
|
*/
|
||||||
unsigned long long count;
|
unsigned long long count;
|
||||||
|
|
||||||
|
#define howlong ((unsigned)4*tick)
|
||||||
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
||||||
DELAY(1000000);
|
DELAY(howlong);
|
||||||
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
||||||
/*
|
|
||||||
* XX lose if the clock rate is not nearly a multiple of 1000000.
|
i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
|
||||||
*/
|
#undef howlong
|
||||||
pentium_mhz = (count + 500000) / 1000000;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ cpu_initclocks()
|
|||||||
/*
|
/*
|
||||||
* Finish setting up anti-jitter measures.
|
* Finish setting up anti-jitter measures.
|
||||||
*/
|
*/
|
||||||
if (pentium_mhz) {
|
if (i586_ctr_rate) {
|
||||||
I586_CYCLECTR(i586_last_tick);
|
I586_CYCLECTR(i586_last_tick);
|
||||||
i586_ctr_bias = i586_last_tick;
|
i586_ctr_bias = i586_last_tick;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
* Kernel interface to machine-dependent clock driver.
|
* Kernel interface to machine-dependent clock driver.
|
||||||
* Garrett Wollman, September 1994.
|
* Garrett Wollman, September 1994.
|
||||||
* This file is in the public domain.
|
* This file is in the public domain.
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _MACHINE_CLOCK_H_
|
#ifndef _MACHINE_CLOCK_H_
|
||||||
@ -22,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
#define CPU_CLOCKUPDATE(otime, ntime) \
|
#define CPU_CLOCKUPDATE(otime, ntime) \
|
||||||
do { \
|
do { \
|
||||||
if(pentium_mhz) { \
|
if(i586_ctr_rate) { \
|
||||||
disable_intr(); \
|
disable_intr(); \
|
||||||
i586_ctr_bias = i586_last_tick; \
|
i586_ctr_bias = i586_last_tick; \
|
||||||
*(otime) = *(ntime); \
|
*(otime) = *(ntime); \
|
||||||
@ -39,6 +41,8 @@
|
|||||||
#define CPU_THISTICKLEN(dflt) dflt
|
#define CPU_THISTICKLEN(dflt) dflt
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define I586_CTR_RATE_SHIFT 8
|
||||||
|
|
||||||
#if defined(KERNEL) && !defined(LOCORE)
|
#if defined(KERNEL) && !defined(LOCORE)
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <machine/frame.h>
|
#include <machine/frame.h>
|
||||||
@ -51,7 +55,7 @@
|
|||||||
extern int adjkerntz;
|
extern int adjkerntz;
|
||||||
extern int disable_rtc_set;
|
extern int disable_rtc_set;
|
||||||
#ifdef I586_CPU
|
#ifdef I586_CPU
|
||||||
extern int pentium_mhz;
|
extern unsigned i586_ctr_rate; /* fixed point */
|
||||||
extern long long i586_last_tick;
|
extern long long i586_last_tick;
|
||||||
extern long long i586_ctr_bias;
|
extern long long i586_ctr_bias;
|
||||||
#endif
|
#endif
|
||||||
@ -72,10 +76,11 @@ cpu_thisticklen(u_long dflt)
|
|||||||
long long old;
|
long long old;
|
||||||
long rv;
|
long rv;
|
||||||
|
|
||||||
if (pentium_mhz) {
|
if (i586_ctr_rate) {
|
||||||
old = i586_last_tick;
|
old = i586_last_tick;
|
||||||
I586_CYCLECTR(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 {
|
} else {
|
||||||
rv = dflt;
|
rv = dflt;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
* 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 */
|
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
|
||||||
u_int idelayed;
|
u_int idelayed;
|
||||||
#ifdef I586_CPU
|
#ifdef I586_CPU
|
||||||
int pentium_mhz;
|
unsigned i586_ctr_rate;
|
||||||
long long i586_ctr_bias;
|
long long i586_ctr_bias;
|
||||||
long long i586_last_tick;
|
long long i586_last_tick;
|
||||||
#endif
|
#endif
|
||||||
@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
|
|||||||
*/
|
*/
|
||||||
unsigned long long count;
|
unsigned long long count;
|
||||||
|
|
||||||
|
#define howlong ((unsigned)4*tick)
|
||||||
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
||||||
DELAY(1000000);
|
DELAY(howlong);
|
||||||
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
||||||
/*
|
|
||||||
* XX lose if the clock rate is not nearly a multiple of 1000000.
|
i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
|
||||||
*/
|
#undef howlong
|
||||||
pentium_mhz = (count + 500000) / 1000000;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ cpu_initclocks()
|
|||||||
/*
|
/*
|
||||||
* Finish setting up anti-jitter measures.
|
* Finish setting up anti-jitter measures.
|
||||||
*/
|
*/
|
||||||
if (pentium_mhz) {
|
if (i586_ctr_rate) {
|
||||||
I586_CYCLECTR(i586_last_tick);
|
I586_CYCLECTR(i586_last_tick);
|
||||||
i586_ctr_bias = i586_last_tick;
|
i586_ctr_bias = i586_last_tick;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
* 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 */
|
int disable_rtc_set = 0; /* disable resettodr() if != 0 */
|
||||||
u_int idelayed;
|
u_int idelayed;
|
||||||
#ifdef I586_CPU
|
#ifdef I586_CPU
|
||||||
int pentium_mhz;
|
unsigned i586_ctr_rate;
|
||||||
long long i586_ctr_bias;
|
long long i586_ctr_bias;
|
||||||
long long i586_last_tick;
|
long long i586_last_tick;
|
||||||
#endif
|
#endif
|
||||||
@ -295,13 +295,13 @@ calibrate_cyclecounter(void)
|
|||||||
*/
|
*/
|
||||||
unsigned long long count;
|
unsigned long long count;
|
||||||
|
|
||||||
|
#define howlong ((unsigned)4*tick)
|
||||||
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
__asm __volatile(".byte 0x0f, 0x30" : : "A"(0LL), "c" (0x10));
|
||||||
DELAY(1000000);
|
DELAY(howlong);
|
||||||
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
__asm __volatile(".byte 0xf,0x31" : "=A" (count));
|
||||||
/*
|
|
||||||
* XX lose if the clock rate is not nearly a multiple of 1000000.
|
i586_ctr_rate = (count << I586_CTR_RATE_SHIFT) / howlong;
|
||||||
*/
|
#undef howlong
|
||||||
pentium_mhz = (count + 500000) / 1000000;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ cpu_initclocks()
|
|||||||
/*
|
/*
|
||||||
* Finish setting up anti-jitter measures.
|
* Finish setting up anti-jitter measures.
|
||||||
*/
|
*/
|
||||||
if (pentium_mhz) {
|
if (i586_ctr_rate) {
|
||||||
I586_CYCLECTR(i586_last_tick);
|
I586_CYCLECTR(i586_last_tick);
|
||||||
i586_ctr_bias = i586_last_tick;
|
i586_ctr_bias = i586_last_tick;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user