Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Modularize coretemp(4). Ok jmcneill@.



details:   https://anonhg.NetBSD.org/src/rev/59840c1f0db0
branches:  trunk
changeset: 762397:59840c1f0db0
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sun Feb 20 13:42:45 2011 +0000

description:
Modularize coretemp(4). Ok jmcneill@.

diffstat:

 sys/arch/amd64/conf/GENERIC   |   10 +-
 sys/arch/i386/conf/ALL        |   10 +-
 sys/arch/i386/conf/GENERIC    |   10 +-
 sys/arch/x86/conf/files.x86   |   12 +-
 sys/arch/x86/include/cpu.h    |    3 +-
 sys/arch/x86/include/cpuvar.h |    7 +-
 sys/arch/x86/x86/coretemp.c   |  280 ++++++++++++++++++++++++++---------------
 sys/arch/x86/x86/cpu.c        |   14 +-
 sys/arch/x86/x86/identcpu.c   |   10 +-
 9 files changed, 215 insertions(+), 141 deletions(-)

diffs (truncated from 647 to 300 lines):

diff -r dd56b22ff988 -r 59840c1f0db0 sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Sun Feb 20 13:27:46 2011 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Sun Feb 20 13:42:45 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.309 2011/02/19 00:13:55 jmcneill Exp $
+# $NetBSD: GENERIC,v 1.310 2011/02/20 13:42:45 jruoho Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.309 $"
+#ident                 "GENERIC-$Revision: 1.310 $"
 
 maxusers       64              # estimated number of users
 
@@ -86,6 +86,9 @@
 # AMD PowerNow! and Cool`n'Quiet technology
 options        POWERNOW_K8
 
+# Intel Core's on-die Thermal sensor
+coretemp*      at cpu?
+
 # Intel(R) On Demand Clock Modulation (aka ODCM)
 # options       INTEL_ONDEMAND_CLOCKMOD
 
@@ -465,9 +468,6 @@
 piixpm* at pci? dev ? function ?       # PIIX4 compatible PM controller
 iic*   at piixpm?                      # SMBus on PIIX4
 
-# Intel Core's on-die Thermal sensor
-options        INTEL_CORETEMP
-
 # Intel ICH SMBus controller
 ichsmb*        at pci? dev ? function ?
 iic*   at ichsmb?
diff -r dd56b22ff988 -r 59840c1f0db0 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL    Sun Feb 20 13:27:46 2011 +0000
+++ b/sys/arch/i386/conf/ALL    Sun Feb 20 13:42:45 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.289 2011/02/19 13:52:27 jmcneill Exp $
+# $NetBSD: ALL,v 1.290 2011/02/20 13:42:45 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.289 $"
+#ident                 "ALL-$Revision: 1.290 $"
 
 maxusers       64              # estimated number of users
 
@@ -42,6 +42,9 @@
 # VIA PadLock
 padlock0       at cpu0
 
+# Intel Core's on-die Thermal sensor
+coretemp*      at cpu?
+
 # Intel(R) On Demand Clock Modulation (aka ODCM)
 options        INTEL_ONDEMAND_CLOCKMOD
 
@@ -685,9 +688,6 @@
 alipm* at pci? dev ? function ?
 iic*   at alipm?
 
-# Intel Core's on-die Thermal sensor
-options        INTEL_CORETEMP
-
 # VIA C7 Temperature sensor
 options        VIA_C7TEMP
 
diff -r dd56b22ff988 -r 59840c1f0db0 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Sun Feb 20 13:27:46 2011 +0000
+++ b/sys/arch/i386/conf/GENERIC        Sun Feb 20 13:42:45 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1018 2011/02/19 13:52:27 jmcneill Exp $
+# $NetBSD: GENERIC,v 1.1019 2011/02/20 13:42:45 jruoho Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.1018 $"
+#ident                 "GENERIC-$Revision: 1.1019 $"
 
 maxusers       64              # estimated number of users
 
@@ -47,6 +47,9 @@
 # AMD PowerNow! and Cool`n'Quiet technology
 options        POWERNOW_K8
 
+# Intel Core's on-die Thermal sensor
+coretemp*      at cpu?
+
 # VIA PadLock
 #padlock0      at cpu0
 
@@ -643,9 +646,6 @@
 alipm* at pci? dev ? function ?
 iic*   at alipm?
 
-# Intel Core's on-die Thermal sensor
-options        INTEL_CORETEMP
-
 # VIA C7 Temperature sensor
 options        VIA_C7TEMP
 
diff -r dd56b22ff988 -r 59840c1f0db0 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86       Sun Feb 20 13:27:46 2011 +0000
+++ b/sys/arch/x86/conf/files.x86       Sun Feb 20 13:42:45 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.x86,v 1.58 2011/02/19 13:52:28 jmcneill Exp $
+#      $NetBSD: files.x86,v 1.59 2011/02/20 13:42:45 jruoho Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -17,9 +17,6 @@
 defflag                        ENHANCED_SPEEDSTEP
 defflag        opt_est.h               EST_FREQ_USERWRITE
 
-# Intel On Die Temperature sensor
-defflag        opt_intel_coretemp.h    INTEL_CORETEMP: sysmon_envsys
-
 # Pentium 4+ Thermal Monitor ODCM (aka On Demand Clock Modulation)
 defflag opt_intel_odcm.h       INTEL_ONDEMAND_CLOCKMOD
 
@@ -44,6 +41,10 @@
 attach cpu at cpubus
 file   arch/x86/x86/cpu.c              cpu
 
+device coretemp: sysmon_envsys
+attach coretemp at cpufeaturebus
+file   arch/x86/x86/coretemp.c         coretemp
+
 device padlock: opencrypto
 attach padlock at cpufeaturebus
 file   arch/x86/x86/via_padlock.c      padlock
@@ -107,9 +108,6 @@
 file   arch/x86/x86/est.c              enhanced_speedstep
 file   arch/x86/x86/intel_busclock.c   enhanced_speedstep
 
-# 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
 
diff -r dd56b22ff988 -r 59840c1f0db0 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Sun Feb 20 13:27:46 2011 +0000
+++ b/sys/arch/x86/include/cpu.h        Sun Feb 20 13:42:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.28 2011/02/20 12:47:21 jmcneill Exp $        */
+/*     $NetBSD: cpu.h,v 1.29 2011/02/20 13:42:45 jruoho Exp $  */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -180,6 +180,7 @@
        struct evcnt ci_ipi_events[X86_NIPI];
 
        device_t        ci_padlock;     /* VIA PadLock private storage */
+       device_t        ci_tempsensor;  /* Intel coretemp(4) or equivalent */
 
        struct i386tss  ci_tss;         /* Per-cpu TSS; shared among LWPs */
        char            ci_iomap[IOMAPSIZE]; /* I/O Bitmap */
diff -r dd56b22ff988 -r 59840c1f0db0 sys/arch/x86/include/cpuvar.h
--- a/sys/arch/x86/include/cpuvar.h     Sun Feb 20 13:27:46 2011 +0000
+++ b/sys/arch/x86/include/cpuvar.h     Sun Feb 20 13:42:45 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuvar.h,v 1.39 2011/02/19 13:52:28 jmcneill Exp $ */
+/*     $NetBSD: cpuvar.h,v 1.40 2011/02/20 13:42:45 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -96,7 +96,6 @@
 #include "opt_multiprocessor.h"
 #include "opt_enhanced_speedstep.h"
 #ifndef XEN
-#include "opt_intel_coretemp.h"
 #include "opt_intel_odcm.h"
 #include "opt_via_c7temp.h"
 #endif
@@ -129,10 +128,6 @@
 void viac7temp_register(struct cpu_info *);
 #endif
 
-#ifdef INTEL_CORETEMP
-void coretemp_register(struct cpu_info *);
-#endif
-
 #ifdef INTEL_ONDEMAND_CLOCKMOD
 void clockmod_init(void);
 #endif
diff -r dd56b22ff988 -r 59840c1f0db0 sys/arch/x86/x86/coretemp.c
--- a/sys/arch/x86/x86/coretemp.c       Sun Feb 20 13:27:46 2011 +0000
+++ b/sys/arch/x86/x86/coretemp.c       Sun Feb 20 13:42:45 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: coretemp.c,v 1.16 2010/08/25 05:07:43 jruoho Exp $ */
+/* $NetBSD: coretemp.c,v 1.17 2011/02/20 13:42:46 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -36,81 +36,170 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.16 2010/08/25 05:07:43 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coretemp.c,v 1.17 2011/02/20 13:42:46 jruoho Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
-#include <sys/kmem.h>
+#include <sys/cpu.h>
+#include <sys/module.h>
 #include <sys/xcall.h>
-#include <sys/cpu.h>
 
 #include <dev/sysmon/sysmonvar.h>
 
 #include <machine/cpuvar.h>
+#include <machine/cpufunc.h>
+#include <machine/cputypes.h>
 #include <machine/specialreg.h>
-#include <machine/cpufunc.h>
 
-struct coretemp_softc {
-       struct cpu_info         *sc_ci;
-       struct sysmon_envsys    *sc_sme;
-       envsys_data_t           sc_sensor;
-       char                    sc_dvname[32];
-       int                     sc_tjmax;
-};
-
+static int     coretemp_match(device_t, cfdata_t, void *);
+static void    coretemp_attach(device_t, device_t, void *);
+static int     coretemp_detach(device_t, int);
+static int     coretemp_quirks(struct cpu_info *);
+static void    coretemp_ext_config(device_t);
 static void    coretemp_refresh(struct sysmon_envsys *, envsys_data_t *);
 static void    coretemp_refresh_xcall(void *, void *);
 
-void
-coretemp_register(struct cpu_info *ci)
+struct coretemp_softc {
+       device_t                 sc_dev;
+       struct cpu_info         *sc_ci;
+       struct sysmon_envsys    *sc_sme;
+       envsys_data_t            sc_sensor;
+       int                      sc_tjmax;
+};
+
+CFATTACH_DECL_NEW(coretemp, sizeof(struct coretemp_softc),
+    coretemp_match, coretemp_attach, coretemp_detach, NULL);
+
+static int
+coretemp_match(device_t parent, cfdata_t cf, void *aux)
 {
-       struct coretemp_softc *sc;
+       struct cpufeature_attach_args *cfaa = aux;
+       struct cpu_info *ci = cfaa->ci;
        uint32_t regs[4];
-       uint64_t msr;
-       int cpumodel, cpuextmodel, cpumask;
+
+       if (strcmp(cfaa->name, "coretemp") != 0)
+               return 0;
+
+       if (cpu_vendor != CPUVENDOR_INTEL || cpuid_level < 0x06)
+               return 0;
 
        /*
-        * Don't attach on anything but the first SMT ID.
-        */
-       if (ci->ci_smt_id != 0)
-               return;
-
-       /*
-        * CPUID 0x06 returns 1 if the processor has on-die thermal
-        * sensors. EBX[0:3] contains the number of sensors.
+        * CPUID 0x06 returns 1 if the processor
+        * has on-die thermal sensors. EBX[0:3]
+        * contains the number of sensors.
         */
        x86_cpuid(0x06, regs);
+
        if ((regs[0] & CPUID_DSPM_DTS) == 0)
-               return;
+               return 0;
+
+       return coretemp_quirks(ci);
+}
+
+static void
+coretemp_attach(device_t parent, device_t self, void *aux)



Home | Main Index | Thread Index | Old Index