Module Name: src Committed By: sborrill Date: Mon Oct 5 11:37:14 UTC 2009
Modified Files: src/sys/arch/i386/conf [netbsd-5]: ALL GENERIC src/sys/arch/x86/conf [netbsd-5]: files.x86 src/sys/arch/x86/include [netbsd-5]: cpuvar.h src/sys/arch/x86/x86 [netbsd-5]: identcpu.c Added Files: src/sys/arch/x86/x86 [netbsd-5]: viac7temp.c Log Message: Pull up the following revisions(s) (requested by jmcneill in ticket #1061): sys/arch/x86/conf/files.x86: revision 1.53 sys/arch/x86/include/cpuvar.h: revision 1.31 sys/arch/x86/x86/identcpu.c: revision 1.17 sys/arch/x86/x86/viac7temp.c: revision 1.1 sys/arch/i386/conf/ALL: revision 1.218 sys/arch/i386/conf/GENERIC: revision 1.949 Add support for VIA C7 temperature sensors (options VIA_C7TEMP) and enable in i386 GENERIC kernel. To generate a diff of this commit: cvs rdiff -u -r1.183.4.4 -r1.183.4.5 src/sys/arch/i386/conf/ALL cvs rdiff -u -r1.915.2.7 -r1.915.2.8 src/sys/arch/i386/conf/GENERIC cvs rdiff -u -r1.44.4.1 -r1.44.4.2 src/sys/arch/x86/conf/files.x86 cvs rdiff -u -r1.27.8.1 -r1.27.8.2 src/sys/arch/x86/include/cpuvar.h cvs rdiff -u -r1.10.4.3 -r1.10.4.4 src/sys/arch/x86/x86/identcpu.c cvs rdiff -u -r0 -r1.1.2.2 src/sys/arch/x86/x86/viac7temp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/i386/conf/ALL diff -u src/sys/arch/i386/conf/ALL:1.183.4.4 src/sys/arch/i386/conf/ALL:1.183.4.5 --- src/sys/arch/i386/conf/ALL:1.183.4.4 Sat Sep 26 19:52:09 2009 +++ src/sys/arch/i386/conf/ALL Mon Oct 5 11:37:13 2009 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.183.4.4 2009/09/26 19:52:09 snj Exp $ +# $NetBSD: ALL,v 1.183.4.5 2009/10/05 11:37:13 sborrill Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.183.4.4 $" +#ident "ALL-$Revision: 1.183.4.5 $" maxusers 32 # estimated number of users @@ -629,6 +629,9 @@ # Intel Core's on-die Thermal sensor options INTEL_CORETEMP +# VIA C7 Temperature sensor +options VIA_C7TEMP + # Intel ICH SMBus controller ichsmb* at pci? dev ? function ? iic* at ichsmb? Index: src/sys/arch/i386/conf/GENERIC diff -u src/sys/arch/i386/conf/GENERIC:1.915.2.7 src/sys/arch/i386/conf/GENERIC:1.915.2.8 --- src/sys/arch/i386/conf/GENERIC:1.915.2.7 Sat Sep 26 19:52:09 2009 +++ src/sys/arch/i386/conf/GENERIC Mon Oct 5 11:37:13 2009 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.915.2.7 2009/09/26 19:52:09 snj Exp $ +# $NetBSD: GENERIC,v 1.915.2.8 2009/10/05 11:37:13 sborrill Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.915.2.7 $" +#ident "GENERIC-$Revision: 1.915.2.8 $" maxusers 64 # estimated number of users @@ -622,6 +622,9 @@ # Intel Core's on-die Thermal sensor options INTEL_CORETEMP +# VIA C7 Temperature sensor +options VIA_C7TEMP + # Intel ICH SMBus controller ichsmb* at pci? dev ? function ? iic* at ichsmb? Index: src/sys/arch/x86/conf/files.x86 diff -u src/sys/arch/x86/conf/files.x86:1.44.4.1 src/sys/arch/x86/conf/files.x86:1.44.4.2 --- src/sys/arch/x86/conf/files.x86:1.44.4.1 Tue Jun 16 02:19:44 2009 +++ src/sys/arch/x86/conf/files.x86 Mon Oct 5 11:37:14 2009 @@ -1,4 +1,4 @@ -# $NetBSD: files.x86,v 1.44.4.1 2009/06/16 02:19:44 snj Exp $ +# $NetBSD: files.x86,v 1.44.4.2 2009/10/05 11:37:14 sborrill Exp $ # options for MP configuration through the MP spec defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI @@ -23,6 +23,9 @@ # AMD Powernow/Cool`n'Quiet Technology defflag opt_powernow_k8.h POWERNOW_K8 +# VIA C7 Temperature sensor +defflag opt_via_c7temp.h VIA_C7TEMP: sysmon_envsys + # VIA PadLock support defflag opt_viapadlock.h VIA_PADLOCK: opencrypto file arch/x86/x86/via_padlock.c via_padlock @@ -93,6 +96,9 @@ # Intel On-Die Temperature sensor file arch/x86/x86/coretemp.c intel_coretemp +# VIA C7 Temperature sensor +file arch/x86/x86/viac7temp.c via_c7temp + # IPMI device device ipmi: sysmon_envsys, sysmon_wdog attach ipmi at ipmibus Index: src/sys/arch/x86/include/cpuvar.h diff -u src/sys/arch/x86/include/cpuvar.h:1.27.8.1 src/sys/arch/x86/include/cpuvar.h:1.27.8.2 --- src/sys/arch/x86/include/cpuvar.h:1.27.8.1 Mon Oct 5 10:34:07 2009 +++ src/sys/arch/x86/include/cpuvar.h Mon Oct 5 11:37:14 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: cpuvar.h,v 1.27.8.1 2009/10/05 10:34:07 sborrill Exp $ */ +/* $NetBSD: cpuvar.h,v 1.27.8.2 2009/10/05 11:37:14 sborrill Exp $ */ /*- * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -91,6 +91,7 @@ #include "opt_enhanced_speedstep.h" #include "opt_intel_coretemp.h" #include "opt_intel_odcm.h" +#include "opt_via_c7temp.h" #endif #ifdef MULTIPROCESSOR @@ -116,6 +117,10 @@ void x86_cpu_idle_xen(void); #endif +#ifdef VIA_C7TEMP +void viac7temp_register(struct cpu_info *); +#endif + #ifdef INTEL_CORETEMP void coretemp_register(struct cpu_info *); #endif Index: src/sys/arch/x86/x86/identcpu.c diff -u src/sys/arch/x86/x86/identcpu.c:1.10.4.3 src/sys/arch/x86/x86/identcpu.c:1.10.4.4 --- src/sys/arch/x86/x86/identcpu.c:1.10.4.3 Tue Jun 16 02:19:44 2009 +++ src/sys/arch/x86/x86/identcpu.c Mon Oct 5 11:37:14 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: identcpu.c,v 1.10.4.3 2009/06/16 02:19:44 snj Exp $ */ +/* $NetBSD: identcpu.c,v 1.10.4.4 2009/10/05 11:37:14 sborrill Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,11 +30,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.10.4.3 2009/06/16 02:19:44 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.10.4.4 2009/10/05 11:37:14 sborrill Exp $"); #include "opt_enhanced_speedstep.h" #include "opt_intel_odcm.h" #include "opt_intel_coretemp.h" +#include "opt_via_c7temp.h" #include "opt_powernow_k8.h" #include "opt_xen.h" #ifdef i386 /* XXX */ @@ -714,6 +715,18 @@ coretemp_register(ci); #endif +#ifdef VIA_C7TEMP + if (cpu_vendor == CPUVENDOR_IDT && + CPUID2FAMILY(ci->ci_signature) == 6 && + CPUID2MODEL(ci->ci_signature) >= 0x9) { + uint32_t descs[4]; + + x86_cpuid(0xc0000000, descs); + if (descs[0] >= 0xc0000002) /* has temp sensor */ + viac7temp_register(ci); + } +#endif + #if defined(POWERNOW_K7) || defined(POWERNOW_K8) if (cpu_vendor == CPUVENDOR_AMD && powernow_probe(ci)) { switch (CPUID2FAMILY(ci->ci_signature)) { Added files: Index: src/sys/arch/x86/x86/viac7temp.c diff -u /dev/null src/sys/arch/x86/x86/viac7temp.c:1.1.2.2 --- /dev/null Mon Oct 5 11:37:14 2009 +++ src/sys/arch/x86/x86/viac7temp.c Mon Oct 5 11:37:14 2009 @@ -0,0 +1,115 @@ +/* $NetBSD: viac7temp.c,v 1.1.2.2 2009/10/05 11:37:14 sborrill Exp $ */ + +/*- + * Copyright (c) 2009 Jared D. McNeill <jmcne...@invisible.ca> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> +__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.1.2.2 2009/10/05 11:37:14 sborrill Exp $"); + +#include <sys/param.h> +#include <sys/kmem.h> +#include <sys/xcall.h> +#include <sys/cpu.h> +#include <sys/device.h> + +#include <dev/sysmon/sysmonvar.h> + +#include <machine/cpuvar.h> +#include <machine/specialreg.h> +#include <machine/cpufunc.h> + +struct viac7temp_softc { + struct cpu_info *sc_ci; + struct sysmon_envsys *sc_sme; + envsys_data_t sc_sensor; +}; + +static void viac7temp_refresh(struct sysmon_envsys *, envsys_data_t *); +static void viac7temp_refresh_xcall(void *, void *); + +void +viac7temp_register(struct cpu_info *ci) +{ + struct viac7temp_softc *sc; + + sc = kmem_zalloc(sizeof(struct viac7temp_softc), KM_SLEEP); + + sc->sc_sensor.units = ENVSYS_STEMP; + sc->sc_sensor.flags = 0; + sc->sc_sensor.monitor = true; + strlcpy(sc->sc_sensor.desc, "temperature", + sizeof(sc->sc_sensor.desc)); + + sc->sc_sme = sysmon_envsys_create(); + if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) { + sysmon_envsys_destroy(sc->sc_sme); + goto bad; + } + + /* + * Hook into the system monitor. + */ + sc->sc_sme->sme_name = device_xname(ci->ci_dev); + sc->sc_sme->sme_cookie = sc; + sc->sc_sme->sme_refresh = viac7temp_refresh; + + if (sysmon_envsys_register(sc->sc_sme)) { + aprint_error_dev(ci->ci_dev, + "unable to register with sysmon\n"); + sysmon_envsys_destroy(sc->sc_sme); + goto bad; + } + + return; + +bad: + kmem_free(sc, sizeof(struct viac7temp_softc)); +} + +static void +viac7temp_refresh(struct sysmon_envsys *sme, envsys_data_t *edata) +{ + struct viac7temp_softc *sc = sme->sme_cookie; + uint64_t where; + + where = xc_unicast(0, viac7temp_refresh_xcall, sc, edata, sc->sc_ci); + xc_wait(where); +} + +static void +viac7temp_refresh_xcall(void *arg0, void *arg1) +{ + /* struct viac7temp_softc *sc = (struct viac7temp_softc *)arg0; */ + envsys_data_t *edata = (envsys_data_t *)arg1; + uint32_t descs[4]; + + x86_cpuid(0xc0000002, descs); + + edata->value_cur = descs[0] >> 8; + edata->value_cur *= 1000000; + edata->value_cur += 273150000; + edata->state = ENVSYS_SVALID; +}