diff options
author | Alexander Yurchenko <grange@cvs.openbsd.org> | 2004-02-14 15:09:23 +0000 |
---|---|---|
committer | Alexander Yurchenko <grange@cvs.openbsd.org> | 2004-02-14 15:09:23 +0000 |
commit | ada8886100a78040c259db734cf7818b49c81fdc (patch) | |
tree | fd6c08ced5d0defd52f55f0689aca67fb6fc5c8a /sys/arch/i386 | |
parent | 64cb8174cb06ff3dc1a2b319a1dbc1fa94832a87 (diff) |
Simplify hw.{cpuspeed,setperf} api moving all the sysctl stuff
from the underlying callbacks.
Testing hppa mickey@, ppc drahn@
Ok markus@ tedu@
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/est.c | 22 | ||||
-rw-r--r-- | sys/arch/i386/i386/longrun.c | 19 | ||||
-rw-r--r-- | sys/arch/i386/i386/p4tcc.c | 22 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 12 | ||||
-rw-r--r-- | sys/arch/i386/pci/elan520.c | 20 |
5 files changed, 28 insertions, 67 deletions
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, |