summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/hppa/hppa/machdep.c8
-rw-r--r--sys/arch/i386/i386/est.c22
-rw-r--r--sys/arch/i386/i386/longrun.c19
-rw-r--r--sys/arch/i386/i386/p4tcc.c22
-rw-r--r--sys/arch/i386/include/cpu.h12
-rw-r--r--sys/arch/i386/pci/elan520.c20
-rw-r--r--sys/arch/macppc/macppc/cpu.c8
-rw-r--r--sys/arch/pegasos/pegasos/cpu.c9
-rw-r--r--sys/arch/powerpc/include/cpu.h4
-rw-r--r--sys/kern/kern_sysctl.c24
-rw-r--r--sys/sys/sysctl.h6
11 files changed, 66 insertions, 88 deletions
diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c
index 38372504da5..f7a6d1bb5f4 100644
--- a/sys/arch/hppa/hppa/machdep.c
+++ b/sys/arch/hppa/hppa/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.123 2004/01/05 17:07:00 mickey Exp $ */
+/* $OpenBSD: machdep.c,v 1.124 2004/02/14 15:09:22 grange Exp $ */
/*
* Copyright (c) 1999-2002 Michael Shalayeff
@@ -276,11 +276,11 @@ const struct hppa_cpu_typed {
};
int
-hppa_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+hppa_cpuspeed(int *mhz)
{
- int mhz = PAGE0->mem_10msec / 10000;
+ *mhz = PAGE0->mem_10msec / 10000;
- return sysctl_rdint(oldp, oldlenp, newp, mhz);
+ return (0);
}
void
diff --git a/sys/arch/i386/i386/est.c b/sys/arch/i386/i386/est.c
index cde0265018e..0ac6b4c7137 100644
--- a/sys/arch/i386/i386/est.c
+++ b/sys/arch/i386/i386/est.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: est.c,v 1.4 2004/01/06 21:09:20 tedu Exp $ */
+/* $OpenBSD: est.c,v 1.5 2004/02/14 15:09:22 grange Exp $ */
/*
* Copyright (c) 2003 Michael Eriksson.
* All rights reserved.
@@ -259,21 +259,14 @@ est_init(const char *cpu_device)
}
int
-est_setperf(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+est_setperf(int level)
{
- static uint level = 100;
- int low, high, i, fq, error;
+ int low, high, i, fq;
uint64_t msr;
if (est_fqlist == NULL)
return (EOPNOTSUPP);
- error = sysctl_int(oldp, oldlenp, newp, newlen, &level);
- if (error)
- return (error);
-
- if (level > 100)
- level = 100;
low = est_fqlist->table[est_fqlist->n - 1].mhz;
high = est_fqlist->table[0].mhz;
fq = low + (high - low) * level / 100;
@@ -291,11 +284,8 @@ est_setperf(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
int
-est_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+est_cpuspeed(int *freq)
{
- int freq;
-
- freq = MSR2MHZ(rdmsr(MSR_PERF_STATUS));
-
- return (sysctl_rdint(oldp, oldlenp, newp, freq));
+ *freq = MSR2MHZ(rdmsr(MSR_PERF_STATUS));
+ return (0);
}
diff --git a/sys/arch/i386/i386/longrun.c b/sys/arch/i386/i386/longrun.c
index e6686b53841..8f4ef6a8793 100644
--- a/sys/arch/i386/i386/longrun.c
+++ b/sys/arch/i386/i386/longrun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: longrun.c,v 1.7 2004/01/06 21:09:20 tedu Exp $ */
+/* $OpenBSD: longrun.c,v 1.8 2004/02/14 15:09:22 grange Exp $ */
/*
* Copyright (c) 2003 Ted Unangst
* Copyright (c) 2001 Tamotsu Hattori
@@ -91,10 +91,11 @@ longrun_update(void *arg)
}
int
-longrun_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+longrun_cpuspeed(int *freq)
{
longrun_update(NULL); /* force update */
- return (sysctl_rdint(oldp, oldlenp, newp, pentium_mhz));
+ *freq = pentium_mhz;
+ return (0);
}
/*
@@ -106,20 +107,10 @@ longrun_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
* levels selectable.
*/
int
-longrun_setperf(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+longrun_setperf(int high)
{
- int error;
uint32_t eflags, mode;
union msrinfo msrinfo;
- static uint32_t high = 100;
-
- if (newp == NULL)
- return (EINVAL);
- if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &high)))
- return (error);
-
- if (high > 100)
- high = 100;
if (high >= 50)
mode = 1; /* power */
diff --git a/sys/arch/i386/i386/p4tcc.c b/sys/arch/i386/i386/p4tcc.c
index 1fc96f81423..de896265b05 100644
--- a/sys/arch/i386/i386/p4tcc.c
+++ b/sys/arch/i386/i386/p4tcc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: p4tcc.c,v 1.1 2003/12/20 18:23:18 tedu Exp $ */
+/* $OpenBSD: p4tcc.c,v 1.2 2004/02/14 15:09:22 grange Exp $ */
/*
* Copyright (c) 2003 Ted Unangst
* All rights reserved.
@@ -59,9 +59,6 @@ static struct {
#define TCC_LEVELS sizeof(tcc) / sizeof(tcc[0])
-extern int (*cpu_cpuspeed)(void *, size_t *, void *, size_t);
-extern int (*cpu_setperf)(void *, size_t *, void *, size_t);
-
void
p4tcc_init(int model, int step)
{
@@ -94,7 +91,7 @@ p4tcc_init(int model, int step)
#if 0
/* possible? not sure */
int
-p4tcc_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+p4tcc_cpuspeed(int *)
{
return EINVAL;
@@ -102,21 +99,10 @@ p4tcc_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
#endif
int
-p4tcc_setperf(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+p4tcc_setperf(int level)
{
- int i, error;
+ int i;
uint64_t msreg;
- static uint level = 100;
- uint olevel;
-
- olevel = level;
- if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &level)))
- return (error);
- if (level == olevel)
- return (0);
-
- if (level > 100)
- level = 100;
for (i = 0; i < TCC_LEVELS; i++) {
if (level >= tcc[i].level)
diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h
index ef70e5f86fc..13b9e47a513 100644
--- a/sys/arch/i386/include/cpu.h
+++ b/sys/arch/i386/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.57 2004/02/01 19:05:23 deraadt Exp $ */
+/* $OpenBSD: cpu.h,v 1.58 2004/02/14 15:09:22 grange Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
@@ -191,21 +191,21 @@ void rtcdrain(void *);
/* est.c */
#if !defined(SMALL_KERNEL) && defined(I686_CPU)
void est_init(const char *);
-int est_cpuspeed(void *, size_t *, void *, size_t);
-int est_setperf(void *, size_t *, void *, size_t);
+int est_cpuspeed(int *);
+int est_setperf(int);
#endif
/* 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);
+int longrun_cpuspeed(int *);
+int longrun_setperf(int);
#endif
/* p4tcc.c */
#if !defined(SMALL_KERNEL) && defined(I686_CPU)
void p4tcc_init(int, int);
-int p4tcc_setperf(void *, size_t *, void *, size_t);
+int p4tcc_setperf(int);
#endif
/* npx.c */
diff --git a/sys/arch/i386/pci/elan520.c b/sys/arch/i386/pci/elan520.c
index b73374524f9..2a3298691b1 100644
--- a/sys/arch/i386/pci/elan520.c
+++ b/sys/arch/i386/pci/elan520.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elan520.c,v 1.5 2003/12/24 10:35:59 markus Exp $ */
+/* $OpenBSD: elan520.c,v 1.6 2004/02/14 15:09:22 grange Exp $ */
/* $NetBSD: elan520.c,v 1.4 2002/10/02 05:47:15 thorpej Exp $ */
/*-
@@ -64,8 +64,8 @@ struct elansc_softc {
int elansc_match(struct device *, void *, void *);
void elansc_attach(struct device *, struct device *, void *);
-int elansc_cpuspeed(void *, size_t *, void *, size_t);
-int elansc_setperf(void *, size_t *, void *, size_t);
+int elansc_cpuspeed(int *);
+int elansc_setperf(int);
void elansc_wdogctl(struct elansc_softc *, int, uint16_t);
#define elansc_wdogctl_reset(sc) elansc_wdogctl(sc, 1, 0)
@@ -220,29 +220,23 @@ elansc_wdogctl_cb(void *self, int period)
}
int
-elansc_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+elansc_cpuspeed(int *freq)
{
static const int elansc_mhz[] = { 0, 100, 133, 999 };
uint8_t cpuctl;
cpuctl = bus_space_read_1(elansc->sc_memt, elansc->sc_memh,
MMCR_CPUCTL);
- return (sysctl_rdint(oldp, oldlenp, newp,
- elansc_mhz[cpuctl & CPUCTL_CPU_CLK_SPD_MASK]));
+ *freq = elansc_mhz[cpuctl & CPUCTL_CPU_CLK_SPD_MASK];
+ return (0);
}
int
-elansc_setperf(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+elansc_setperf(int level)
{
- static int level = 100;
- int error;
uint32_t eflags;
uint8_t cpuctl, speed;
- if ((error = sysctl_int(oldp, oldlenp, newp, newlen, &level)))
- return (error);
- if (newp == NULL)
- return (0);
level = (level > 50) ? 100 : 0;
cpuctl = bus_space_read_1(elansc->sc_memt, elansc->sc_memh,
diff --git a/sys/arch/macppc/macppc/cpu.c b/sys/arch/macppc/macppc/cpu.c
index e58b4b859bc..3c575285616 100644
--- a/sys/arch/macppc/macppc/cpu.c
+++ b/sys/arch/macppc/macppc/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.18 2003/12/24 05:44:37 drahn Exp $ */
+/* $OpenBSD: cpu.c,v 1.19 2004/02/14 15:09:22 grange Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -103,9 +103,11 @@ static u_int32_t ppc_curfreq;
int
-ppc_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+ppc_cpuspeed(int *freq)
{
- return (sysctl_rdint(oldp, oldlenp, newp, ppc_curfreq));
+ *freq = ppc_curfreq;
+
+ return (0);
}
diff --git a/sys/arch/pegasos/pegasos/cpu.c b/sys/arch/pegasos/pegasos/cpu.c
index 26f1ae5f97c..9c2b4bb62e2 100644
--- a/sys/arch/pegasos/pegasos/cpu.c
+++ b/sys/arch/pegasos/pegasos/cpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.c,v 1.3 2004/02/04 20:07:18 drahn Exp $ */
+/* $OpenBSD: cpu.c,v 1.4 2004/02/14 15:09:22 grange Exp $ */
/*
* Copyright (c) 1997 Per Fogelstrom
@@ -145,14 +145,15 @@ cpumatch(parent, cfdata, aux)
return (1);
}
-extern int (*cpu_cpuspeed)(void *, size_t *, void *, size_t);
static u_int32_t ppc_curfreq;
int
-ppc_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen)
+ppc_cpuspeed(int *freq)
{
- return (sysctl_rdint(oldp, oldlenp, newp, ppc_curfreq));
+ *freq = ppc_curfreq;
+
+ return (0);
}
diff --git a/sys/arch/powerpc/include/cpu.h b/sys/arch/powerpc/include/cpu.h
index 8764a885601..f80c925b2a6 100644
--- a/sys/arch/powerpc/include/cpu.h
+++ b/sys/arch/powerpc/include/cpu.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cpu.h,v 1.17 2003/12/24 00:25:42 drahn Exp $ */
+/* $OpenBSD: cpu.h,v 1.18 2004/02/14 15:09:22 grange Exp $ */
/* $NetBSD: cpu.h,v 1.1 1996/09/30 16:34:21 ws Exp $ */
/*
@@ -220,6 +220,6 @@ ppc_intr_disable(void)
return (emsr & PSL_EE);
}
-int ppc_cpuspeed(void *oldp, size_t *oldlenp, void *newp, size_t newlen);
+int ppc_cpuspeed(int *);
#endif /* _POWERPC_CPU_H_ */
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 9efc6ec6562..68685933775 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.98 2004/01/07 21:51:30 millert Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.99 2004/02/14 15:09:22 grange Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -96,8 +96,8 @@ int sysctl_intrcnt(int *, u_int, void *, size_t *);
int sysctl_sensors(int *, u_int, void *, size_t *, void *, size_t);
int sysctl_emul(int *, u_int, void *, size_t *, void *, size_t);
-int (*cpu_cpuspeed)(void *, size_t *, void *, size_t);
-int (*cpu_setperf)(void *, size_t *, void *, size_t);
+int (*cpu_cpuspeed)(int *);
+int (*cpu_setperf)(int);
/*
* Lock to avoid too many processes vslocking a large amount of memory
@@ -516,6 +516,9 @@ hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
{
extern char machine[], cpu_model[];
int err;
+ int cpuspeed;
+ static int perflevel = 100;
+ int operflevel;
/* all sysctl names at this level except sensors are terminal */
if (name[0] != HW_SENSORS && namelen != 1)
@@ -560,11 +563,22 @@ hw_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
case HW_CPUSPEED:
if (!cpu_cpuspeed)
return (EOPNOTSUPP);
- return (cpu_cpuspeed(oldp, oldlenp, newp, newlen));
+ err = cpu_cpuspeed(&cpuspeed);
+ if (err)
+ return err;
+ return (sysctl_rdint(oldp, oldlenp, newp, cpuspeed));
case HW_SETPERF:
if (!cpu_setperf)
return (EOPNOTSUPP);
- return (cpu_setperf(oldp, oldlenp, newp, newlen));
+ operflevel = perflevel;
+ err = sysctl_int(oldp, oldlenp, newp, newlen, &perflevel);
+ if (err)
+ return err;
+ if (perflevel == operflevel)
+ return (0);
+ if (perflevel > 100)
+ perflevel = 100;
+ return (cpu_setperf(perflevel));
default:
return (EOPNOTSUPP);
}
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 71b6fb329f6..c0f4de3119b 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.71 2004/01/07 21:51:30 millert Exp $ */
+/* $OpenBSD: sysctl.h,v 1.72 2004/02/14 15:09:22 grange Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -677,8 +677,8 @@ int vfs_sysctl(int *, u_int, void *, size_t *, void *, size_t,
int sysctl_sysvipc(int *, u_int, void *, size_t *);
int sysctl_wdog(int *, u_int, void *, size_t *, void *, size_t);
-extern int (*cpu_cpuspeed)(void *, size_t *, void *, size_t);
-extern int (*cpu_setperf)(void *, size_t *, void *, size_t);
+extern int (*cpu_cpuspeed)(int *);
+extern int (*cpu_setperf)(int);
void sysctl_init(void);