summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2004-01-06 21:09:21 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2004-01-06 21:09:21 +0000
commit535d3cd65f525a3a9c82bd96fa5e934d961a08f7 (patch)
tree02c7b5b111b19564a0ff55f8a3f4d0a8175eb182 /sys/arch/i386
parentcfa161bf00156fc2582ed480c796b3094a768b4e (diff)
adjust pentium_mhz when cpu speed changes. ok deraadt
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/i386/est.c6
-rw-r--r--sys/arch/i386/i386/longrun.c38
-rw-r--r--sys/arch/i386/i386/machdep.c8
-rw-r--r--sys/arch/i386/include/cpu.h3
4 files changed, 38 insertions, 17 deletions
diff --git a/sys/arch/i386/i386/est.c b/sys/arch/i386/i386/est.c
index aac08c6d8e0..cde0265018e 100644
--- a/sys/arch/i386/i386/est.c
+++ b/sys/arch/i386/i386/est.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: est.c,v 1.3 2003/12/19 22:42:13 tedu Exp $ */
+/* $OpenBSD: est.c,v 1.4 2004/01/06 21:09:20 tedu Exp $ */
/*
* Copyright (c) 2003 Michael Eriksson.
* All rights reserved.
@@ -191,9 +191,6 @@ static const struct est_cpu est_cpus[] = {
static const struct fqlist *est_fqlist;
-extern int (*cpu_cpuspeed)(void *, size_t *, void *, size_t);
-extern int (*cpu_setperf)(void *, size_t *, void *, size_t);
-
void
est_init(const char *cpu_device)
{
@@ -287,6 +284,7 @@ est_setperf(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
msr = (rdmsr(MSR_PERF_CTL) & ~0xffffULL) |
MSRVALUE(est_fqlist->table[i].mhz, est_fqlist->table[i].mv);
wrmsr(MSR_PERF_CTL, msr);
+ pentium_mhz = est_fqlist->table[i].mhz;
return (0);
}
diff --git a/sys/arch/i386/i386/longrun.c b/sys/arch/i386/i386/longrun.c
index 9872eefb910..e6686b53841 100644
--- a/sys/arch/i386/i386/longrun.c
+++ b/sys/arch/i386/i386/longrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: longrun.c,v 1.6 2003/12/18 23:46:19 tedu Exp $ */
+/* $OpenBSD: longrun.c,v 1.7 2004/01/06 21:09:20 tedu Exp $ */
/*
* Copyright (c) 2003 Ted Unangst
* Copyright (c) 2001 Tamotsu Hattori
@@ -30,7 +30,12 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/kernel.h>
#include <sys/sysctl.h>
+#include <sys/timeout.h>
+#include <sys/sensors.h>
+
+
#include <machine/cpufunc.h>
union msrinfo {
@@ -48,6 +53,20 @@ union msrinfo {
#define LONGRUN_MODE_RESERVED(x) ((x) & 0xffffff80)
#define LONGRUN_MODE_WRITE(x, y) (LONGRUN_MODE_RESERVED(x) | LONGRUN_MODE_MASK(y))
+void longrun_update(void *);
+
+struct timeout longrun_timo;
+
+void
+longrun_init(void)
+{
+ cpu_cpuspeed = longrun_cpuspeed;
+ cpu_setperf = longrun_setperf;
+
+ timeout_set(&longrun_timo, longrun_update, NULL);
+ timeout_add(&longrun_timo, hz);
+}
+
/*
* These are the instantaneous values used by the CPU.
* regs[0] = Frequency is self-evident.
@@ -55,10 +74,10 @@ union msrinfo {
* regs[2] = Percent is amount of performance window being used, not
* percentage of top megahertz. (0 values are typical.)
*/
-int
-longrun_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+void
+longrun_update(void *arg)
{
- uint32_t eflags, freq, regs[4];
+ uint32_t eflags, regs[4];
eflags = read_eflags();
disable_intr();
@@ -66,9 +85,16 @@ longrun_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
enable_intr();
write_eflags(eflags);
- freq = regs[0];
+ pentium_mhz = regs[0];
+
+ timeout_add(&longrun_timo, hz);
+}
- return (sysctl_rdint(oldp, oldlenp, newp, freq));
+int
+longrun_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+{
+ longrun_update(NULL); /* force update */
+ return (sysctl_rdint(oldp, oldlenp, newp, pentium_mhz));
}
/*
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 02658995db8..bf5d19fb34c 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.259 2004/01/03 15:17:48 markus Exp $ */
+/* $OpenBSD: machdep.c,v 1.260 2004/01/06 21:09:20 tedu Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -277,9 +277,6 @@ int bus_mem_add_mapping(bus_addr_t, bus_size_t,
int _bus_dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *,
bus_size_t, struct proc *, int, paddr_t *, int *, int);
-extern int (*cpu_cpuspeed)(void *, size_t *, void *, size_t);
-extern int (*cpu_setperf)(void *, size_t *, void *, size_t);
-
#ifdef KGDB
#ifndef KGDB_DEVNAME
#ifdef __i386__
@@ -1701,8 +1698,7 @@ tm86_cpu_setup(cpu_device, model, step)
int model, step;
{
#if !defined(SMALL_KERNEL) && defined (I586_CPU)
- cpu_cpuspeed = longrun_cpuspeed;
- cpu_setperf = longrun_setperf;
+ longrun_init();
#endif
}
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index 482815dd27b..39fafba22de 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.54 2003/12/20 18:23:18 tedu Exp $ */
+/* $OpenBSD: cpu.h,v 1.55 2004/01/06 21:09:20 tedu Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -193,6 +193,7 @@ int est_setperf(void *, size_t *, void *, size_t);
/* longrun.c */
#if !defined(SMALL_KERNEL) && defined(I586_CPU)
+void longrun_init(void);
int longrun_cpuspeed(void *, size_t *, void *, size_t);
int longrun_setperf(void *, size_t *, void *, size_t);
#endif