Module Name: src
Committed By: jruoho
Date: Wed Jun 15 03:22:40 UTC 2011
Modified Files:
src/distrib/sets/lists/modules: md.amd64 md.i386
src/sys/arch/x86/pci: amdtemp.c
src/sys/modules: Makefile
Added Files:
src/sys/modules/amdtemp: Makefile amdtemp.ioconf
Log Message:
Modularize amdtemp(4).
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/distrib/sets/lists/modules/md.amd64
cvs rdiff -u -r1.24 -r1.25 src/distrib/sets/lists/modules/md.i386
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/x86/pci/amdtemp.c
cvs rdiff -u -r1.70 -r1.71 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/amdtemp/Makefile \
src/sys/modules/amdtemp/amdtemp.ioconf
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/modules/md.amd64
diff -u src/distrib/sets/lists/modules/md.amd64:1.20 src/distrib/sets/lists/modules/md.amd64:1.21
--- src/distrib/sets/lists/modules/md.amd64:1.20 Thu Apr 14 15:45:27 2011
+++ src/distrib/sets/lists/modules/md.amd64 Wed Jun 15 03:22:39 2011
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.20 2011/04/14 15:45:27 yamt Exp $
+# $NetBSD: md.amd64,v 1.21 2011/06/15 03:22:39 jruoho Exp $
./@MODULEDIR@/acpiacad base-kernel-modules kmod
./@MODULEDIR@/acpiacad/acpiacad.kmod base-kernel-modules kmod
./@MODULEDIR@/acpibat base-kernel-modules kmod
@@ -25,6 +25,8 @@
./@MODULEDIR@/acpiwmi/acpiwmi.kmod base-kernel-modules kmod
./@MODULEDIR@/aibs base-kernel-modules kmod
./@MODULEDIR@/aibs/aibs.kmod base-kernel-modules kmod
+./@MODULEDIR@/amdtemp base-kernel-modules kmod
+./@MODULEDIR@/amdtemp/amdtemp.kmod base-kernel-modules kmod
./@MODULEDIR@/aps base-kernel-modules kmod
./@MODULEDIR@/aps/aps.kmod base-kernel-modules kmod
./@MODULEDIR@/asus base-kernel-modules kmod
Index: src/distrib/sets/lists/modules/md.i386
diff -u src/distrib/sets/lists/modules/md.i386:1.24 src/distrib/sets/lists/modules/md.i386:1.25
--- src/distrib/sets/lists/modules/md.i386:1.24 Thu Apr 14 15:45:28 2011
+++ src/distrib/sets/lists/modules/md.i386 Wed Jun 15 03:22:39 2011
@@ -1,4 +1,4 @@
-# $NetBSD: md.i386,v 1.24 2011/04/14 15:45:28 yamt Exp $
+# $NetBSD: md.i386,v 1.25 2011/06/15 03:22:39 jruoho Exp $
./@MODULEDIR@/acpiacad base-kernel-modules kmod
./@MODULEDIR@/acpiacad/acpiacad.kmod base-kernel-modules kmod
./@MODULEDIR@/acpibat base-kernel-modules kmod
@@ -25,6 +25,8 @@
./@MODULEDIR@/acpiwmi/acpiwmi.kmod base-kernel-modules kmod
./@MODULEDIR@/aibs base-kernel-modules kmod
./@MODULEDIR@/aibs/aibs.kmod base-kernel-modules kmod
+./@MODULEDIR@/amdtemp base-kernel-modules kmod
+./@MODULEDIR@/amdtemp/amdtemp.kmod base-kernel-modules kmod
./@MODULEDIR@/aps base-kernel-modules kmod
./@MODULEDIR@/aps/aps.kmod base-kernel-modules kmod
./@MODULEDIR@/asus base-kernel-modules kmod
Index: src/sys/arch/x86/pci/amdtemp.c
diff -u src/sys/arch/x86/pci/amdtemp.c:1.9 src/sys/arch/x86/pci/amdtemp.c:1.10
--- src/sys/arch/x86/pci/amdtemp.c:1.9 Fri Oct 16 12:05:19 2009
+++ src/sys/arch/x86/pci/amdtemp.c Wed Jun 15 03:22:39 2011
@@ -1,7 +1,7 @@
-/* $NetBSD: amdtemp.c,v 1.9 2009/10/16 12:05:19 cegger Exp $ */
+/* $NetBSD: amdtemp.c,v 1.10 2011/06/15 03:22:39 jruoho Exp $ */
/* $OpenBSD: kate.c,v 1.2 2008/03/27 04:52:03 cnst Exp $ */
-/*
+/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
@@ -48,22 +48,24 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.9 2009/10/16 12:05:19 cegger Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdtemp.c,v 1.10 2011/06/15 03:22:39 jruoho Exp $ ");
#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/cpu.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kmem.h>
-#include <dev/sysmon/sysmonvar.h>
+#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/cpu.h>
#include <machine/specialreg.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
+#include <dev/sysmon/sysmonvar.h>
+
/*
* AMD K8:
* http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/32559.pdf
@@ -114,7 +116,7 @@
#define F10_TEMP_CURTEMP (1 << 21)
/*
- * Revision Guide for AMD NPT Family 0Fh Processors,
+ * Revision Guide for AMD NPT Family 0Fh Processors,
* Publication # 33610, Revision 3.30, February 2008
*/
#define K8_SOCKET_F 1 /* Server */
@@ -156,6 +158,7 @@
struct sysmon_envsys *sc_sme;
envsys_data_t *sc_sensor;
+ size_t sc_sensor_len;
char sc_rev;
int8_t sc_numsensors;
@@ -164,8 +167,9 @@
};
-static int amdtemp_match(device_t, cfdata_t, void *);
+static int amdtemp_match(device_t, cfdata_t, void *);
static void amdtemp_attach(device_t, device_t, void *);
+static int amdtemp_detach(device_t, int);
static void amdtemp_k8_init(struct amdtemp_softc *, pcireg_t);
static void amdtemp_k8_setup_sensors(struct amdtemp_softc *, int);
@@ -175,8 +179,8 @@
static void amdtemp_family10_setup_sensors(struct amdtemp_softc *, int);
static void amdtemp_family10_refresh(struct sysmon_envsys *, envsys_data_t *);
-CFATTACH_DECL_NEW(amdtemp, sizeof(struct amdtemp_softc),
- amdtemp_match, amdtemp_attach, NULL, NULL);
+CFATTACH_DECL_NEW(amdtemp, sizeof(struct amdtemp_softc),
+ amdtemp_match, amdtemp_attach, amdtemp_detach, NULL);
static int
amdtemp_match(device_t parent, cfdata_t match, void *aux)
@@ -232,7 +236,6 @@
struct amdtemp_softc *sc = device_private(self);
struct pci_attach_args *pa = aux;
pcireg_t cpu_signature;
- size_t len;
int error;
uint8_t i;
@@ -275,9 +278,9 @@
aprint_debug_dev(self, "Workaround enabled\n");
sc->sc_sme = sysmon_envsys_create();
- len = sizeof(envsys_data_t) * sc->sc_numsensors;
- sc->sc_sensor = kmem_zalloc(len, KM_NOSLEEP);
- if (!sc->sc_sensor)
+ sc->sc_sensor_len = sizeof(envsys_data_t) * sc->sc_numsensors;
+ sc->sc_sensor = kmem_zalloc(sc->sc_sensor_len, KM_NOSLEEP);
+ if (sc->sc_sensor == NULL)
goto bad2;
switch (sc->sc_family) {
@@ -328,9 +331,26 @@
return;
bad:
- kmem_free(sc->sc_sensor, len);
+ kmem_free(sc->sc_sensor, sc->sc_sensor_len);
+ sc->sc_sensor = NULL;
+
bad2:
sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
+}
+
+static int
+amdtemp_detach(device_t self, int flags)
+{
+ struct amdtemp_softc *sc = device_private(self);
+
+ if (sc->sc_sme != NULL)
+ sysmon_envsys_unregister(sc->sc_sme);
+
+ if (sc->sc_sensor != NULL)
+ kmem_free(sc->sc_sensor, sc->sc_sensor_len);
+
+ return 0;
}
static void
@@ -492,3 +512,32 @@
/* envsys(4) wants uK... convert from Celsius. */
edata->value_cur = (value * 125000) + 273150000;
}
+
+MODULE(MODULE_CLASS_DRIVER, amdtemp, NULL);
+
+#ifdef _MODULE
+#include "ioconf.c"
+#endif
+
+static int
+amdtemp_modcmd(modcmd_t cmd, void *aux)
+{
+ int error = 0;
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+#ifdef _MODULE
+ error = config_init_component(cfdriver_ioconf_amdtemp,
+ cfattach_ioconf_amdtemp, cfdata_ioconf_amdtemp);
+#endif
+ return error;
+ case MODULE_CMD_FINI:
+#ifdef _MODULE
+ error = config_fini_component(cfdriver_ioconf_amdtemp,
+ cfattach_ioconf_amdtemp, cfdata_ioconf_amdtemp);
+#endif
+ return error;
+ default:
+ return ENOTTY;
+ }
+}
Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.70 src/sys/modules/Makefile:1.71
--- src/sys/modules/Makefile:1.70 Thu Apr 14 15:45:27 2011
+++ src/sys/modules/Makefile Wed Jun 15 03:22:40 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.70 2011/04/14 15:45:27 yamt Exp $
+# $NetBSD: Makefile,v 1.71 2011/06/15 03:22:40 jruoho Exp $
.include <bsd.own.mk>
@@ -89,6 +89,7 @@
.if ${MACHINE_ARCH} == "i386" || \
${MACHINE_ARCH} == "x86_64"
+SUBDIR+= amdtemp
SUBDIR+= coretemp
SUBDIR+= est
SUBDIR+= odcm
Added files:
Index: src/sys/modules/amdtemp/Makefile
diff -u /dev/null src/sys/modules/amdtemp/Makefile:1.1
--- /dev/null Wed Jun 15 03:22:40 2011
+++ src/sys/modules/amdtemp/Makefile Wed Jun 15 03:22:40 2011
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2011/06/15 03:22:40 jruoho Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/arch/x86/pci
+
+KMOD= amdtemp
+IOCONF= amdtemp.ioconf
+SRCS= amdtemp.c
+
+WARNS= 4
+
+.include <bsd.kmodule.mk>
Index: src/sys/modules/amdtemp/amdtemp.ioconf
diff -u /dev/null src/sys/modules/amdtemp/amdtemp.ioconf:1.1
--- /dev/null Wed Jun 15 03:22:40 2011
+++ src/sys/modules/amdtemp/amdtemp.ioconf Wed Jun 15 03:22:40 2011
@@ -0,0 +1,11 @@
+# $NetBSD: amdtemp.ioconf,v 1.1 2011/06/15 03:22:40 jruoho Exp $
+
+ioconf amdtemp
+
+include "conf/files"
+include "dev/pci/files.pci"
+include "arch/x86/pci/files.pci"
+
+pseudo-root pci*
+
+amdtemp* at pci? dev ? function ?