summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorGordon Willem Klok <gwk@cvs.openbsd.org>2006-08-20 01:42:52 +0000
committerGordon Willem Klok <gwk@cvs.openbsd.org>2006-08-20 01:42:52 +0000
commitf27615505a0fb101579871843e04c72866a4c8f3 (patch)
tree2d1697787f4e97155508ca5340ae7f5b9174b45c /sys
parent2551c43a8846d5f5e767e9b4c41692c67de78ebc (diff)
When using p4tcc supply a cpu_cpuspeed function to provide an estimated
hw.cpuspeed. If cpu_cpuspeed is not null in identifycpu() don't overwrite what it points to with pentium_cpuspeed. lots of thanks to todd@ for testing, ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/i386/machdep.c4
-rw-r--r--sys/arch/i386/i386/p4tcc.c17
2 files changed, 18 insertions, 3 deletions
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 30e054182a2..220cca8ea48 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.363 2006/08/18 16:08:44 dim Exp $ */
+/* $OpenBSD: machdep.c,v 1.364 2006/08/20 01:42:51 gwk Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -1860,7 +1860,7 @@ identifycpu(struct cpu_info *ci)
#ifndef SMALL_KERNEL
#if defined(I586_CPU) || defined(I686_CPU)
- if (pentium_mhz != 0)
+ if (pentium_mhz != 0 && cpu_cpuspeed == NULL)
cpu_cpuspeed = pentium_cpuspeed;
#endif
#endif
diff --git a/sys/arch/i386/i386/p4tcc.c b/sys/arch/i386/i386/p4tcc.c
index 4b148839da7..7680ac3d060 100644
--- a/sys/arch/i386/i386/p4tcc.c
+++ b/sys/arch/i386/i386/p4tcc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: p4tcc.c,v 1.10 2006/06/17 18:22:13 dim Exp $ */
+/* $OpenBSD: p4tcc.c,v 1.11 2006/08/20 01:42:51 gwk Exp $ */
/*
* Copyright (c) 2003 Ted Unangst
* All rights reserved.
@@ -60,6 +60,9 @@ static struct {
#define TCC_LEVELS sizeof(tcc) / sizeof(tcc[0])
extern int setperf_prio;
+int p4tcc_level;
+
+int p4tcc_cpuspeed(int *);
void
p4tcc_init(int family, int step)
@@ -90,11 +93,21 @@ p4tcc_init(int family, int step)
break;
}
+ p4tcc_level = tcc[0].level;
cpu_setperf = p4tcc_setperf;
+ cpu_cpuspeed = p4tcc_cpuspeed;
setperf_prio = 1;
}
int
+p4tcc_cpuspeed(int *speed)
+{
+ *speed = pentium_mhz / 100 * (p4tcc_level + 12);
+
+ return 0;
+}
+
+int
p4tcc_setperf(int level)
{
int i;
@@ -114,6 +127,8 @@ p4tcc_setperf(int level)
if ((vet & 0x1e) != (msreg & 0x1e))
printf("p4_tcc: cpu did not honor request\n");
+ else
+ p4tcc_level = tcc[i].level;
return (0);
}