Tell Pentium users their CPU speed. (More changes to make use of this
to come later.)
This commit is contained in:
parent
9830dcf4b8
commit
a4f90f4d45
@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.48 1994/08/10 03:51:07 wollman Exp $
|
||||
* $Id: machdep.c,v 1.49 1994/08/10 03:53:33 wollman Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -179,6 +179,7 @@ cpu_startup()
|
||||
* Good {morning,afternoon,evening,night}.
|
||||
*/
|
||||
printf(version);
|
||||
startrtclock();
|
||||
identifycpu();
|
||||
printf("real memory = %d (%d pages)\n", ptoa(physmem), physmem);
|
||||
if (badpages)
|
||||
@ -387,6 +388,14 @@ identifycpu()
|
||||
printf("unknown"); /* will panic below... */
|
||||
}
|
||||
printf("-class CPU)");
|
||||
#ifdef I586_CPU
|
||||
if(cpu_class == CPUCLASS_586) {
|
||||
extern void calibrate_cyclecounter();
|
||||
extern int pentium_mhz;
|
||||
calibrate_cyclecounter();
|
||||
printf(" %d MHz", pentium_mhz);
|
||||
}
|
||||
#endif
|
||||
if(cpu_id)
|
||||
printf(" Id = 0x%x",cpu_id);
|
||||
if(*cpu_vendor)
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.6 1994/02/06 22:48:13 davidg Exp $
|
||||
* $Id: clock.c,v 1.10 1994/05/25 08:58:32 rgrimes Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -181,6 +181,28 @@ getit()
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
#ifdef I586_CPU
|
||||
int pentium_mhz = 0;
|
||||
static long long cycles_per_sec = 0;
|
||||
|
||||
void
|
||||
calibrate_cyclecounter(void)
|
||||
{
|
||||
volatile long edx, eax, lasteax, lastedx;
|
||||
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(lasteax), "=d"(lastedx) : );
|
||||
DELAY(1000000);
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(eax), "=d"(edx) : );
|
||||
|
||||
/*
|
||||
* This assumes that you will never have a clock rate higher
|
||||
* than 4GHz, probably a good assumption.
|
||||
*/
|
||||
cycles_per_sec = (long long)edx + eax;
|
||||
cycles_per_sec -= (long long)lastedx + lasteax;
|
||||
pentium_mhz = ((long)cycles_per_sec + 500000) / 1000000; /* round up */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wait "n" microseconds.
|
||||
@ -432,7 +454,6 @@ spinwait(int millisecs)
|
||||
void
|
||||
cpu_initclocks()
|
||||
{
|
||||
startrtclock();
|
||||
enablertclock();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.6 1994/02/06 22:48:13 davidg Exp $
|
||||
* $Id: clock.c,v 1.10 1994/05/25 08:58:32 rgrimes Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -181,6 +181,28 @@ getit()
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
#ifdef I586_CPU
|
||||
int pentium_mhz = 0;
|
||||
static long long cycles_per_sec = 0;
|
||||
|
||||
void
|
||||
calibrate_cyclecounter(void)
|
||||
{
|
||||
volatile long edx, eax, lasteax, lastedx;
|
||||
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(lasteax), "=d"(lastedx) : );
|
||||
DELAY(1000000);
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(eax), "=d"(edx) : );
|
||||
|
||||
/*
|
||||
* This assumes that you will never have a clock rate higher
|
||||
* than 4GHz, probably a good assumption.
|
||||
*/
|
||||
cycles_per_sec = (long long)edx + eax;
|
||||
cycles_per_sec -= (long long)lastedx + lasteax;
|
||||
pentium_mhz = ((long)cycles_per_sec + 500000) / 1000000; /* round up */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wait "n" microseconds.
|
||||
@ -432,7 +454,6 @@ spinwait(int millisecs)
|
||||
void
|
||||
cpu_initclocks()
|
||||
{
|
||||
startrtclock();
|
||||
enablertclock();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.48 1994/08/10 03:51:07 wollman Exp $
|
||||
* $Id: machdep.c,v 1.49 1994/08/10 03:53:33 wollman Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -179,6 +179,7 @@ cpu_startup()
|
||||
* Good {morning,afternoon,evening,night}.
|
||||
*/
|
||||
printf(version);
|
||||
startrtclock();
|
||||
identifycpu();
|
||||
printf("real memory = %d (%d pages)\n", ptoa(physmem), physmem);
|
||||
if (badpages)
|
||||
@ -387,6 +388,14 @@ identifycpu()
|
||||
printf("unknown"); /* will panic below... */
|
||||
}
|
||||
printf("-class CPU)");
|
||||
#ifdef I586_CPU
|
||||
if(cpu_class == CPUCLASS_586) {
|
||||
extern void calibrate_cyclecounter();
|
||||
extern int pentium_mhz;
|
||||
calibrate_cyclecounter();
|
||||
printf(" %d MHz", pentium_mhz);
|
||||
}
|
||||
#endif
|
||||
if(cpu_id)
|
||||
printf(" Id = 0x%x",cpu_id);
|
||||
if(*cpu_vendor)
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.6 1994/02/06 22:48:13 davidg Exp $
|
||||
* $Id: clock.c,v 1.10 1994/05/25 08:58:32 rgrimes Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -181,6 +181,28 @@ getit()
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
#ifdef I586_CPU
|
||||
int pentium_mhz = 0;
|
||||
static long long cycles_per_sec = 0;
|
||||
|
||||
void
|
||||
calibrate_cyclecounter(void)
|
||||
{
|
||||
volatile long edx, eax, lasteax, lastedx;
|
||||
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(lasteax), "=d"(lastedx) : );
|
||||
DELAY(1000000);
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(eax), "=d"(edx) : );
|
||||
|
||||
/*
|
||||
* This assumes that you will never have a clock rate higher
|
||||
* than 4GHz, probably a good assumption.
|
||||
*/
|
||||
cycles_per_sec = (long long)edx + eax;
|
||||
cycles_per_sec -= (long long)lastedx + lasteax;
|
||||
pentium_mhz = ((long)cycles_per_sec + 500000) / 1000000; /* round up */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wait "n" microseconds.
|
||||
@ -432,7 +454,6 @@ spinwait(int millisecs)
|
||||
void
|
||||
cpu_initclocks()
|
||||
{
|
||||
startrtclock();
|
||||
enablertclock();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.6 1994/02/06 22:48:13 davidg Exp $
|
||||
* $Id: clock.c,v 1.10 1994/05/25 08:58:32 rgrimes Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -181,6 +181,28 @@ getit()
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
#ifdef I586_CPU
|
||||
int pentium_mhz = 0;
|
||||
static long long cycles_per_sec = 0;
|
||||
|
||||
void
|
||||
calibrate_cyclecounter(void)
|
||||
{
|
||||
volatile long edx, eax, lasteax, lastedx;
|
||||
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(lasteax), "=d"(lastedx) : );
|
||||
DELAY(1000000);
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(eax), "=d"(edx) : );
|
||||
|
||||
/*
|
||||
* This assumes that you will never have a clock rate higher
|
||||
* than 4GHz, probably a good assumption.
|
||||
*/
|
||||
cycles_per_sec = (long long)edx + eax;
|
||||
cycles_per_sec -= (long long)lastedx + lasteax;
|
||||
pentium_mhz = ((long)cycles_per_sec + 500000) / 1000000; /* round up */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wait "n" microseconds.
|
||||
@ -432,7 +454,6 @@ spinwait(int millisecs)
|
||||
void
|
||||
cpu_initclocks()
|
||||
{
|
||||
startrtclock();
|
||||
enablertclock();
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)clock.c 7.2 (Berkeley) 5/12/91
|
||||
* $Id: clock.c,v 1.6 1994/02/06 22:48:13 davidg Exp $
|
||||
* $Id: clock.c,v 1.10 1994/05/25 08:58:32 rgrimes Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -181,6 +181,28 @@ getit()
|
||||
return ((high << 8) | low);
|
||||
}
|
||||
|
||||
#ifdef I586_CPU
|
||||
int pentium_mhz = 0;
|
||||
static long long cycles_per_sec = 0;
|
||||
|
||||
void
|
||||
calibrate_cyclecounter(void)
|
||||
{
|
||||
volatile long edx, eax, lasteax, lastedx;
|
||||
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(lasteax), "=d"(lastedx) : );
|
||||
DELAY(1000000);
|
||||
__asm __volatile(".byte 0x0f, 0x31" : "=a"(eax), "=d"(edx) : );
|
||||
|
||||
/*
|
||||
* This assumes that you will never have a clock rate higher
|
||||
* than 4GHz, probably a good assumption.
|
||||
*/
|
||||
cycles_per_sec = (long long)edx + eax;
|
||||
cycles_per_sec -= (long long)lastedx + lasteax;
|
||||
pentium_mhz = ((long)cycles_per_sec + 500000) / 1000000; /* round up */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wait "n" microseconds.
|
||||
@ -432,7 +454,6 @@ spinwait(int millisecs)
|
||||
void
|
||||
cpu_initclocks()
|
||||
{
|
||||
startrtclock();
|
||||
enablertclock();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user