diff options
-rw-r--r-- | sys/arch/i386/i386/est.c | 11 | ||||
-rw-r--r-- | sys/arch/i386/i386/longrun.c | 13 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 65 | ||||
-rw-r--r-- | sys/arch/i386/i386/p4tcc.c | 15 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 6 | ||||
-rw-r--r-- | sys/arch/i386/pci/elan520.c | 14 | ||||
-rw-r--r-- | sys/arch/i386/pci/ichpcib.c | 5 |
7 files changed, 74 insertions, 55 deletions
diff --git a/sys/arch/i386/i386/est.c b/sys/arch/i386/i386/est.c index ecf505efce2..6c1cf14f8df 100644 --- a/sys/arch/i386/i386/est.c +++ b/sys/arch/i386/i386/est.c @@ -1,4 +1,4 @@ -/* $OpenBSD: est.c,v 1.7 2004/02/27 21:46:44 grange Exp $ */ +/* $OpenBSD: est.c,v 1.8 2004/06/06 17:34:37 grange Exp $ */ /* * Copyright (c) 2003 Michael Eriksson. * All rights reserved. @@ -260,7 +260,6 @@ est_init(const char *cpu_device) i < est_fqlist->n - 1 ? ", " : " MHz\n"); cpu_setperf = est_setperf; - cpu_cpuspeed = est_cpuspeed; setperf_prio = 3; } @@ -287,11 +286,3 @@ est_setperf(int level) return (0); } - - -int -est_cpuspeed(int *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 8f4ef6a8793..cba3c85bc39 100644 --- a/sys/arch/i386/i386/longrun.c +++ b/sys/arch/i386/i386/longrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: longrun.c,v 1.8 2004/02/14 15:09:22 grange Exp $ */ +/* $OpenBSD: longrun.c,v 1.9 2004/06/06 17:34:37 grange Exp $ */ /* * Copyright (c) 2003 Ted Unangst * Copyright (c) 2001 Tamotsu Hattori @@ -60,7 +60,6 @@ struct timeout longrun_timo; void longrun_init(void) { - cpu_cpuspeed = longrun_cpuspeed; cpu_setperf = longrun_setperf; timeout_set(&longrun_timo, longrun_update, NULL); @@ -90,14 +89,6 @@ longrun_update(void *arg) timeout_add(&longrun_timo, hz); } -int -longrun_cpuspeed(int *freq) -{ - longrun_update(NULL); /* force update */ - *freq = pentium_mhz; - return (0); -} - /* * Transmeta documentation says performance window boundries * must be between 0 and 100 or a GP0 exception is generated. @@ -132,6 +123,8 @@ longrun_setperf(int high) enable_intr(); write_eflags(eflags); + longrun_update(NULL); + return (0); } diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index f98f477bbf2..e1e30a21df0 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.294 2004/05/23 20:28:46 tedu Exp $ */ +/* $OpenBSD: machdep.c,v 1.295 2004/06/06 17:34:37 grange Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -245,8 +245,11 @@ struct vm_map *phys_map = NULL; int kbd_reset; int p4_model; +int p3_step; int setperf_prio = 0; /* for concurrent handlers */ +void (*update_cpuspeed)(void) = NULL; + /* * Extent maps to manage I/O and ISA memory hole space. Allocate * storage for 8 regions in each, initially. Later, ioport_malloc_safe @@ -327,7 +330,8 @@ void tm86_cpu_setup(const char *, int, int); char * intel686_cpu_name(int); char * cyrix3_cpu_name(int, int); char * tm86_cpu_name(int); -int p4_cpuspeed(int *); +void p4_update_cpuspeed(void); +void p3_update_cpuspeed(void); int pentium_cpuspeed(int *); #if defined(I486_CPU) || defined(I586_CPU) || defined(I686_CPU) @@ -1384,6 +1388,12 @@ intel686_cpu_setup(const char *cpu_device, int model, int step) cpu_feature &= ~CPUID_SER; cpuid_level = 2; } + +#if !defined(SMALL_KERNEL) && defined(I686_CPU) + p3_step = step; + update_cpuspeed = p3_update_cpuspeed; + update_cpuspeed(); +#endif } void @@ -1392,10 +1402,9 @@ intel686_p4_cpu_setup(const char *cpu_device, int model, int step) intel686_common_cpu_setup(cpu_device, model, step); #if !defined(SMALL_KERNEL) && defined(I686_CPU) - if (cpu_cpuspeed == NULL) { - p4_model = model; - cpu_cpuspeed = p4_cpuspeed; - } + p4_model = model; + update_cpuspeed = p4_update_cpuspeed; + update_cpuspeed(); #endif } @@ -1701,7 +1710,7 @@ identifycpu() #ifndef SMALL_KERNEL #if defined(I586_CPU) || defined(I686_CPU) - if (cpu_cpuspeed == NULL && pentium_mhz != 0) + if (pentium_mhz != 0) cpu_cpuspeed = pentium_cpuspeed; #endif #endif @@ -1799,11 +1808,11 @@ identifycpu() #ifndef SMALL_KERNEL #ifdef I686_CPU -int -p4_cpuspeed(int *freq) +void +p4_update_cpuspeed(void) { u_int64_t msr; - int bus, mult; + int bus, mult, freq; msr = rdmsr(MSR_EBC_FREQUENCY_ID); if (p4_model < 2) { @@ -1831,12 +1840,42 @@ p4_cpuspeed(int *freq) } } mult = ((msr >> 24) & 0xff); - *freq = bus * mult; + freq = bus * mult; /* 133MHz actually means 133.(3)MHz */ if (bus == 133) - *freq += mult / 3; + freq += mult / 3; - return (0); + pentium_mhz = freq; +} + +void +p3_update_cpuspeed(void) +{ + u_int64_t msr; + int bus, mult; + const u_int8_t mult_code[] = { + 50, 30, 40, 0, 55, 35, 45, 0, 0, 70, 80, 60, 0, 75, 0, 65 }; + + msr = rdmsr(MSR_EBL_CR_POWERON); + bus = (msr >> 18) & 0x3; + switch (bus) { + case 0: + bus = 66; + break; + case 1: + bus = 133; + break; + case 2: + bus = 100; + break; + } + + mult = (msr >> 22) & 0xf; + mult = mult_code[mult]; + if (p3_step > 1) + mult += ((msr >> 27) & 0x1) * 40; + + pentium_mhz = (bus * mult) / 10; } #endif /* I686_CPU */ diff --git a/sys/arch/i386/i386/p4tcc.c b/sys/arch/i386/i386/p4tcc.c index c1d7eb13c85..5e3aff1adab 100644 --- a/sys/arch/i386/i386/p4tcc.c +++ b/sys/arch/i386/i386/p4tcc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p4tcc.c,v 1.4 2004/02/27 21:46:44 grange Exp $ */ +/* $OpenBSD: p4tcc.c,v 1.5 2004/06/06 17:34:37 grange Exp $ */ /* * Copyright (c) 2003 Ted Unangst * All rights reserved. @@ -92,16 +92,6 @@ p4tcc_init(int model, int step) setperf_prio = 1; } -#if 0 -/* possible? not sure */ -int -p4tcc_cpuspeed(int *) -{ - - return EINVAL; -} -#endif - int p4tcc_setperf(int level) { @@ -119,5 +109,8 @@ p4tcc_setperf(int level) msreg |= tcc[i].reg << 1 | 1 << 4; wrmsr(MSR_THERM_CONTROL, msreg); + if (update_cpuspeed != NULL) + update_cpuspeed(); + return (0); } diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index a82def3a6ce..cc690de9219 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.59 2004/04/02 22:28:41 tedu Exp $ */ +/* $OpenBSD: cpu.h,v 1.60 2004/06/06 17:34:37 grange Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -167,6 +167,8 @@ extern int i386_use_fxsave; extern int i386_has_sse; extern int i386_has_sse2; +extern void (*update_cpuspeed)(void); + /* machdep.c */ void dumpconf(void); void cpu_reset(void); @@ -191,14 +193,12 @@ void rtcdrain(void *); /* est.c */ #if !defined(SMALL_KERNEL) && defined(I686_CPU) void est_init(const char *); -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(int *); int longrun_setperf(int); #endif diff --git a/sys/arch/i386/pci/elan520.c b/sys/arch/i386/pci/elan520.c index ea16605365b..a81e9f2a419 100644 --- a/sys/arch/i386/pci/elan520.c +++ b/sys/arch/i386/pci/elan520.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elan520.c,v 1.8 2004/06/05 15:06:22 grange Exp $ */ +/* $OpenBSD: elan520.c,v 1.9 2004/06/06 17:34:37 grange Exp $ */ /* $NetBSD: elan520.c,v 1.4 2002/10/02 05:47:15 thorpej Exp $ */ /*- @@ -70,7 +70,7 @@ struct elansc_softc { int elansc_match(struct device *, void *, void *); void elansc_attach(struct device *, struct device *, void *); -int elansc_cpuspeed(int *); +void elansc_update_cpuspeed(void); int elansc_setperf(int); void elansc_wdogctl(struct elansc_softc *, int, uint16_t); @@ -158,7 +158,6 @@ elansc_attach(struct device *parent, struct device *self, void *aux) wdog_register(sc, elansc_wdogctl_cb); elansc = sc; - cpu_cpuspeed = elansc_cpuspeed; cpu_setperf = elansc_setperf; /* Initialize GPIO pins array */ @@ -267,16 +266,15 @@ elansc_wdogctl_cb(void *self, int period) return (period); } -int -elansc_cpuspeed(int *freq) +void +elansc_update_cpuspeed(void) { 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); - *freq = elansc_mhz[cpuctl & CPUCTL_CPU_CLK_SPD_MASK]; - return (0); + pentium_mhz = elansc_mhz[cpuctl & CPUCTL_CPU_CLK_SPD_MASK]; } int @@ -300,6 +298,8 @@ elansc_setperf(int level) enable_intr(); write_eflags(eflags); + elansc_update_cpuspeed(); + return (0); } diff --git a/sys/arch/i386/pci/ichpcib.c b/sys/arch/i386/pci/ichpcib.c index 2ad5944ee0e..19845122659 100644 --- a/sys/arch/i386/pci/ichpcib.c +++ b/sys/arch/i386/pci/ichpcib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ichpcib.c,v 1.2 2004/05/07 04:35:59 grange Exp $ */ +/* $OpenBSD: ichpcib.c,v 1.3 2004/06/06 17:34:37 grange Exp $ */ /* * Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org> * @@ -211,6 +211,9 @@ ichss_setperf(int level) /* Restore bus mastering arbitration state */ bus_space_write_1(sc->sc_pm_iot, sc->sc_pm_ioh, ICH_PM_CNTL, cntl); + + if (update_cpuspeed != NULL) + update_cpuspeed(); } splx(s); |