Module Name: src Committed By: jruoho Date: Thu Feb 24 13:58:39 UTC 2011
Modified Files: src/sys/arch/i386/conf: ALL GENERIC src/sys/arch/x86/conf: files.x86 src/sys/arch/x86/x86: cpu.c identcpu.c viac7temp.c Log Message: Move VIA_C7TEMP to the cpufeaturebus. To generate a diff of this commit: cvs rdiff -u -r1.295 -r1.296 src/sys/arch/i386/conf/ALL cvs rdiff -u -r1.1022 -r1.1023 src/sys/arch/i386/conf/GENERIC cvs rdiff -u -r1.61 -r1.62 src/sys/arch/x86/conf/files.x86 cvs rdiff -u -r1.84 -r1.85 src/sys/arch/x86/x86/cpu.c cvs rdiff -u -r1.26 -r1.27 src/sys/arch/x86/x86/identcpu.c cvs rdiff -u -r1.3 -r1.4 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.295 src/sys/arch/i386/conf/ALL:1.296 --- src/sys/arch/i386/conf/ALL:1.295 Thu Feb 24 10:56:01 2011 +++ src/sys/arch/i386/conf/ALL Thu Feb 24 13:58:39 2011 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.295 2011/02/24 10:56:01 jruoho Exp $ +# $NetBSD: ALL,v 1.296 2011/02/24 13:58:39 jruoho 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.295 $" +#ident "ALL-$Revision: 1.296 $" maxusers 64 # estimated number of users @@ -34,6 +34,7 @@ est0 at cpu0 # Intel Enhanced SpeedStep (non-ACPI) padlock0 at cpu0 # VIA PadLock powernow0 at cpu0 # AMD PowerNow! and Cool'n'Quiet (non-ACPI) +viac7temp* at cpu? # VIA C7 temperature sensor # Intel(R) On Demand Clock Modulation (aka ODCM) options INTEL_ONDEMAND_CLOCKMOD @@ -682,9 +683,6 @@ alipm* at pci? dev ? function ? iic* at alipm? -# 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.1022 src/sys/arch/i386/conf/GENERIC:1.1023 --- src/sys/arch/i386/conf/GENERIC:1.1022 Thu Feb 24 10:56:01 2011 +++ src/sys/arch/i386/conf/GENERIC Thu Feb 24 13:58:39 2011 @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.1022 2011/02/24 10:56:01 jruoho Exp $ +# $NetBSD: GENERIC,v 1.1023 2011/02/24 13:58:39 jruoho Exp $ # # GENERIC machine description file # @@ -22,7 +22,7 @@ options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "GENERIC-$Revision: 1.1022 $" +#ident "GENERIC-$Revision: 1.1023 $" maxusers 64 # estimated number of users @@ -42,6 +42,7 @@ est0 at cpu0 # Intel Enhanced SpeedStep (non-ACPI) #padlock0 at cpu0 # VIA PadLock powernow0 at cpu0 # AMD PowerNow! and Cool'n'Quiet (non-ACPI) +viac7temp* at cpu? # VIA C7 temperature sensor # Intel(R) On Demand Clock Modulation (aka ODCM) #options INTEL_ONDEMAND_CLOCKMOD @@ -636,9 +637,6 @@ alipm* at pci? dev ? function ? iic* at alipm? -# 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.61 src/sys/arch/x86/conf/files.x86:1.62 --- src/sys/arch/x86/conf/files.x86:1.61 Thu Feb 24 10:56:02 2011 +++ src/sys/arch/x86/conf/files.x86 Thu Feb 24 13:58:39 2011 @@ -1,4 +1,4 @@ -# $NetBSD: files.x86,v 1.61 2011/02/24 10:56:02 jruoho Exp $ +# $NetBSD: files.x86,v 1.62 2011/02/24 13:58:39 jruoho Exp $ # options for MP configuration through the MP spec defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI @@ -16,9 +16,6 @@ # Pentium 4+ Thermal Monitor ODCM (aka On Demand Clock Modulation) defflag opt_intel_odcm.h INTEL_ONDEMAND_CLOCKMOD -# VIA C7 Temperature sensor -defflag opt_via_c7temp.h VIA_C7TEMP: sysmon_envsys - # To be able to test for NetBSD/xen in shared files defflag opt_xen.h DO_NOT_DEFINE @@ -51,6 +48,10 @@ attach powernow at cpufeaturebus file arch/x86/x86/powernow.c powernow +device viac7temp: sysmon_envsys +attach viac7temp at cpufeaturebus +file arch/x86/x86/viac7temp.c viac7temp + file arch/x86/x86/apic.c ioapic | lapic file arch/x86/x86/bus_dma.c file arch/x86/x86/bus_space.c @@ -102,9 +103,6 @@ # Intel On Demand Clock Modulation file arch/x86/x86/iclockmod.c intel_ondemand_clockmod -# 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/x86/cpu.c diff -u src/sys/arch/x86/x86/cpu.c:1.84 src/sys/arch/x86/x86/cpu.c:1.85 --- src/sys/arch/x86/x86/cpu.c:1.84 Thu Feb 24 10:56:02 2011 +++ src/sys/arch/x86/x86/cpu.c Thu Feb 24 13:58:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.c,v 1.84 2011/02/24 10:56:02 jruoho Exp $ */ +/* $NetBSD: cpu.c,v 1.85 2011/02/24 13:58:39 jruoho Exp $ */ /*- * Copyright (c) 2000, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.84 2011/02/24 10:56:02 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.85 2011/02/24 13:58:39 jruoho Exp $"); #include "opt_ddb.h" #include "opt_mpbios.h" /* for MPDEBUG */ @@ -487,6 +487,12 @@ ci->ci_tempsensor = config_found_ia(self, "cpufeaturebus", &cfaa, NULL); } + + if (ci->ci_tempsensor == NULL) { + cfaa.name = "viac7temp"; + ci->ci_tempsensor = config_found_ia(self, + "cpufeaturebus", &cfaa, NULL); + } } return 0; Index: src/sys/arch/x86/x86/identcpu.c diff -u src/sys/arch/x86/x86/identcpu.c:1.26 src/sys/arch/x86/x86/identcpu.c:1.27 --- src/sys/arch/x86/x86/identcpu.c:1.26 Thu Feb 24 10:56:02 2011 +++ src/sys/arch/x86/x86/identcpu.c Thu Feb 24 13:58:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: identcpu.c,v 1.26 2011/02/24 10:56:02 jruoho Exp $ */ +/* $NetBSD: identcpu.c,v 1.27 2011/02/24 13:58:39 jruoho Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,10 +30,9 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.26 2011/02/24 10:56:02 jruoho Exp $"); +__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.27 2011/02/24 13:58:39 jruoho Exp $"); #include "opt_intel_odcm.h" -#include "opt_via_c7temp.h" #include "opt_xen.h" #include <sys/param.h> @@ -796,18 +795,6 @@ i386_use_fxsave = 0; #endif /* i386 */ -#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 - #ifdef INTEL_ONDEMAND_CLOCKMOD if (cpuid_level >= 1) { clockmod_init(); Index: src/sys/arch/x86/x86/viac7temp.c diff -u src/sys/arch/x86/x86/viac7temp.c:1.3 src/sys/arch/x86/x86/viac7temp.c:1.4 --- src/sys/arch/x86/x86/viac7temp.c:1.3 Sun Feb 13 17:47:56 2011 +++ src/sys/arch/x86/x86/viac7temp.c Thu Feb 24 13:58:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: viac7temp.c,v 1.3 2011/02/13 17:47:56 jmcneill Exp $ */ +/* $NetBSD: viac7temp.c,v 1.4 2011/02/24 13:58:39 jruoho Exp $ */ /*- * Copyright (c) 2009 Jared D. McNeill <jmcne...@invisible.ca> @@ -27,83 +27,131 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.3 2011/02/13 17:47:56 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: viac7temp.c,v 1.4 2011/02/24 13:58:39 jruoho Exp $"); #include <sys/param.h> +#include <sys/device.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> +#include <machine/cputypes.h> +#include <machine/specialreg.h> struct viac7temp_softc { + device_t sc_dev; struct cpu_info *sc_ci; struct sysmon_envsys *sc_sme; - envsys_data_t sc_sensor; + envsys_data_t sc_sensor; }; +static int viac7temp_match(device_t, cfdata_t, void *); +static void viac7temp_attach(device_t, device_t, void *); +static int viac7temp_detach(device_t, int); static void viac7temp_refresh(struct sysmon_envsys *, envsys_data_t *); static void viac7temp_refresh_xcall(void *, void *); -void -viac7temp_register(struct cpu_info *ci) +CFATTACH_DECL_NEW(viac7temp, sizeof(struct viac7temp_softc), + viac7temp_match, viac7temp_attach, viac7temp_detach, NULL); + +static int +viac7temp_match(device_t parent, cfdata_t cf, void *aux) { - struct viac7temp_softc *sc; + struct cpufeature_attach_args *cfaa = aux; + struct cpu_info *ci = cfaa->ci; + uint32_t family, model; + uint32_t descs[4]; + + if (strcmp(cfaa->name, "viac7temp") != 0) + return 0; + + if (cpu_vendor != CPUVENDOR_IDT) + return 0; + + model = CPUID2MODEL(ci->ci_signature); + family = CPUID2FAMILY(ci->ci_signature); + + if (family != 0x06 || model < 0x09) + return 0; + + x86_cpuid(0xc0000000, descs); + + if (descs[0] >= 0xc0000002) + return 1; + + return 0; +} - sc = kmem_zalloc(sizeof(struct viac7temp_softc), KM_SLEEP); +static void +viac7temp_attach(device_t parent, device_t self, void *aux) +{ + struct viac7temp_softc *sc = device_private(self); + struct cpufeature_attach_args *cfaa = aux; + struct cpu_info *ci = cfaa->ci; sc->sc_ci = ci; + sc->sc_dev = self; + sc->sc_sensor.units = ENVSYS_STEMP; sc->sc_sensor.flags = ENVSYS_FMONLIMITS; - strlcpy(sc->sc_sensor.desc, "temperature", + + (void)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); + + if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor) != 0) + goto fail; + sc->sc_sme->sme_cookie = sc; + sc->sc_sme->sme_name = device_xname(self); 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; - } + if (sysmon_envsys_register(sc->sc_sme) != 0) + goto fail; + + aprint_naive("\n"); + aprint_normal(": VIA C7 temperature sensor\n"); + + (void)pmf_device_register(self, NULL, NULL); return; -bad: - kmem_free(sc, sizeof(struct viac7temp_softc)); +fail: + sysmon_envsys_destroy(sc->sc_sme); + sc->sc_sme = NULL; +} + +static int +viac7temp_detach(device_t self, int flags) +{ + struct viac7temp_softc *sc = device_private(self); + + if (sc->sc_sme != NULL) + sysmon_envsys_unregister(sc->sc_sme); + + pmf_device_deregister(self); + + return 0; } static void viac7temp_refresh(struct sysmon_envsys *sme, envsys_data_t *edata) { struct viac7temp_softc *sc = sme->sme_cookie; - uint64_t where; + uint64_t xc; - where = xc_unicast(0, viac7temp_refresh_xcall, sc, edata, sc->sc_ci); - xc_wait(where); + xc = xc_unicast(0, viac7temp_refresh_xcall, sc, edata, sc->sc_ci); + xc_wait(xc); } 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; + envsys_data_t *edata = arg1; uint32_t descs[4]; x86_cpuid(0xc0000002, descs);