ktemp(8) on Phenom II
Randi Harper
randi at freebsd.org
Wed Mar 11 20:00:53 PDT 2009
I'm not subscribed to current, so if you reply, make sure you include me in
the CC. :)
This adds support for all 4 cores of the Phenom II - although I'm not really
sure why you'd need it. Please test, as I have no idea if this is going to
break anything or if I did something obviously wrong. Works fine on my box,
but I am *so* not a developer. Also, I didn't try it on current. Apply the
patch referred to earlier in this thread before applying this one, or
clearly it's not going to work.
[root at deviant ~]# uname -a
FreeBSD deviant.freebsdgirl.com 7.1-RELEASE FreeBSD 7.1-RELEASE #0: Thu Jan
1 08:58:24 UTC 2009
root at driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
amd64
[root at deviant ~]# sysctl dev.cpu | grep temperature
dev.cpu.0.temperature: 40.0C
dev.cpu.1.temperature: 40.0C
dev.cpu.2.temperature: 40.0C
dev.cpu.3.temperature: 40.0C
-- randi
--- k8temp.c.orig 2009-03-12 10:25:41.000000000 -0700
+++ k8temp.c 2009-03-12 10:21:54.000000000 -0700
@@ -51,10 +51,16 @@
typedef enum {
SENSOR0_CORE0,
SENSOR0_CORE1,
+ SENSOR0_CORE2,
+ SENSOR0_CORE3,
SENSOR1_CORE0,
SENSOR1_CORE1,
+ SENSOR1_CORE2,
+ SENSOR1_CORE3,
CORE0,
- CORE1
+ CORE1,
+ CORE2,
+ CORE3
} k8sensor_t;
struct k8temp_softc {
@@ -62,7 +68,7 @@
int sc_temps[4];
int sc_ntemps;
struct sysctl_oid *sc_oid;
- struct sysctl_oid *sc_sysctl_cpu[2];
+ struct sysctl_oid *sc_sysctl_cpu[4];
struct intr_config_hook sc_ich;
int32_t (*sc_gettemp)(device_t, k8sensor_t);
};
@@ -227,6 +233,18 @@
OID_AUTO, "core1", CTLTYPE_INT | CTLFLAG_RD,
dev, SENSOR0_CORE1, k8temp_sysctl, "IK",
"Sensor 0 / Core 1 temperature");
+
+ SYSCTL_ADD_PROC(sysctlctx,
+ SYSCTL_CHILDREN(sysctlnode),
+ OID_AUTO, "core2", CTLTYPE_INT | CTLFLAG_RD,
+ dev, SENSOR0_CORE2, k8temp_sysctl, "IK",
+ "Sensor 0 / Core 2 temperature");
+
+ SYSCTL_ADD_PROC(sysctlctx,
+ SYSCTL_CHILDREN(sysctlnode),
+ OID_AUTO, "core3", CTLTYPE_INT | CTLFLAG_RD,
+ dev, SENSOR0_CORE3, k8temp_sysctl, "IK",
+ "Sensor 0 / Core 3 temperature");
sysctlnode = SYSCTL_ADD_NODE(sysctlctx,
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
"sensor1",
@@ -244,6 +262,18 @@
dev, SENSOR1_CORE1, k8temp_sysctl, "IK",
"Sensor 1 / Core 1 temperature");
+ SYSCTL_ADD_PROC(sysctlctx,
+ SYSCTL_CHILDREN(sysctlnode),
+ OID_AUTO, "core2", CTLTYPE_INT | CTLFLAG_RD,
+ dev, SENSOR1_CORE2, k8temp_sysctl, "IK",
+ "Sensor 1 / Core 2 temperature");
+
+ SYSCTL_ADD_PROC(sysctlctx,
+ SYSCTL_CHILDREN(sysctlnode),
+ OID_AUTO, "core3", CTLTYPE_INT | CTLFLAG_RD,
+ dev, SENSOR1_CORE3, k8temp_sysctl, "IK",
+ "Sensor 1 / Core 3 temperature");
+
return (0);
}
@@ -264,7 +294,7 @@
nexus = device_find_child(root_bus, "nexus", 0);
acpi = device_find_child(nexus, "acpi", 0);
- for (i = 0; i < 2; i++) {
+ for (i = 0; i < 4; i++) {
cpu = device_find_child(acpi, "cpu",
device_get_unit(dev) * 2 + i);
if (cpu) {
@@ -315,6 +345,16 @@
auxtemp[1] = sc->sc_gettemp(dev, SENSOR1_CORE1);
temp = imax(auxtemp[0], auxtemp[1]);
break;
+ case CORE2:
+ auxtemp[0] = sc->sc_gettemp(dev, SENSOR0_CORE2);
+ auxtemp[1] = sc->sc_gettemp(dev, SENSOR1_CORE2);
+ temp = imax(auxtemp[0], auxtemp[1]);
+ break;
+ case CORE3:
+ auxtemp[0] = sc->sc_gettemp(dev, SENSOR0_CORE3);
+ auxtemp[1] = sc->sc_gettemp(dev, SENSOR1_CORE3);
+ temp = imax(auxtemp[0], auxtemp[1]);
+ break;
default:
temp = sc->sc_gettemp(dev, arg2);
break;
More information about the freebsd-current
mailing list