bits from it.
ok krw@ kettenis@
-/* $OpenBSD: identcpu.c,v 1.61 2015/03/14 03:38:46 jsg Exp $ */
+/* $OpenBSD: identcpu.c,v 1.62 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*
{ SEFF0EBX_RDSEED, "RDSEED" },
{ SEFF0EBX_ADX, "ADX" },
{ SEFF0EBX_SMAP, "SMAP" },
+}, cpu_tpm_eaxfeatures[] = {
+ { TPM_SENSOR, "SENSOR" },
+ { TPM_ARAT, "ARAT" },
}, cpu_cpuid_perf_eax[] = {
{ CPUIDEAX_VERID, "PERF" },
}, cpu_cpuid_apmi_edx[] = {
printf(",%s", cpu_seff0_ebxfeatures[i].str);
}
+ if (!strcmp(cpu_vendor, "GenuineIntel") && cpuid_level >= 0x06 ) {
+ CPUID(0x06, ci->ci_feature_tpmflags, dummy, dummy, dummy);
+ for (i = 0; i < nitems(cpu_tpm_eaxfeatures); i++)
+ if (ci->ci_feature_tpmflags &
+ cpu_tpm_eaxfeatures[i].bit)
+ printf(",%s", cpu_tpm_eaxfeatures[i].str);
+ }
+
printf("\n");
x86_print_cacheinfo(ci);
ci->ci_cflushsz = ((cflushsz >> 8) & 0xff) * 8;
}
- if (CPU_IS_PRIMARY(ci) && !strcmp(cpu_vendor, "GenuineIntel") &&
- cpuid_level >= 0x06 ) {
- CPUID(0x06, val, dummy, dummy, dummy);
- if (val & 0x1) {
- strlcpy(ci->ci_sensordev.xname, ci->ci_dev->dv_xname,
- sizeof(ci->ci_sensordev.xname));
- ci->ci_sensor.type = SENSOR_TEMP;
- sensor_task_register(ci, intelcore_update_sensor, 5);
- sensor_attach(&ci->ci_sensordev, &ci->ci_sensor);
- sensordev_install(&ci->ci_sensordev);
- }
+ if (CPU_IS_PRIMARY(ci) && (ci->ci_feature_tpmflags & TPM_SENSOR)) {
+ strlcpy(ci->ci_sensordev.xname, ci->ci_dev->dv_xname,
+ sizeof(ci->ci_sensordev.xname));
+ ci->ci_sensor.type = SENSOR_TEMP;
+ sensor_task_register(ci, intelcore_update_sensor, 5);
+ sensor_attach(&ci->ci_sensordev, &ci->ci_sensor);
+ sensordev_install(&ci->ci_sensordev);
}
#endif
-/* $OpenBSD: cpu.h,v 1.92 2015/05/18 19:59:27 guenther Exp $ */
+/* $OpenBSD: cpu.h,v 1.93 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */
/*-
u_int32_t ci_feature_flags;
u_int32_t ci_feature_eflags;
u_int32_t ci_feature_sefflags;
+ u_int32_t ci_feature_tpmflags;
u_int32_t ci_signature;
u_int32_t ci_family;
u_int32_t ci_model;
-/* $OpenBSD: specialreg.h,v 1.35 2015/04/19 19:45:21 sf Exp $ */
+/* $OpenBSD: specialreg.h,v 1.36 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: specialreg.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */
/* $NetBSD: x86/specialreg.h,v 1.2 2003/04/25 21:54:30 fvdl Exp $ */
#define SEFF0EBX_ADX 0x00080000 /* ADCX/ADOX instructions */
#define SEFF0EBX_SMAP 0x00100000 /* Supervisor mode access prevent */
+/*
+ * Thermal and Power Management (CPUID function 0x6) EAX bits
+ */
+#define TPM_SENSOR 0x00000001 /* Digital temp sensor */
+#define TPM_ARAT 0x00000004 /* APIC Timer Always Running */
+
/*
* "Architectural Performance Monitoring" bits (CPUID function 0x0a):
* EAX bits, EBX bits, EDX bits.
-/* $OpenBSD: machdep.c,v 1.569 2015/04/18 22:16:21 kettenis Exp $ */
+/* $OpenBSD: machdep.c,v 1.570 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
{ SEFF0EBX_SMAP, "SMAP" },
};
+const struct cpu_cpuid_feature cpu_tpm_eaxfeatures[] = {
+ { TPM_SENSOR, "SENSOR" },
+ { TPM_ARAT, "ARAT" },
+};
+
const struct cpu_cpuid_feature i386_cpuid_eaxperf[] = {
{ CPUIDEAX_VERID, "PERF" },
};
void
intel686_cpusensors_setup(struct cpu_info *ci)
{
- u_int regs[4];
-
- if (!CPU_IS_PRIMARY(ci) || cpuid_level < 0x06)
- return;
-
- /* CPUID.06H.EAX[0] = 1 tells us if we have on-die sensor */
- cpuid(0x06, regs);
- if ((regs[0] & 0x01) != 1)
+ if (!CPU_IS_PRIMARY(ci) || (ci->ci_feature_tpmflags & TPM_SENSOR) == 0)
return;
/* Setup the sensors structures */
(numbits == 0 ? "" : ","),
cpu_seff0_ebxfeatures[i].feature_name);
}
+
+ if (!strcmp(cpu_vendor, "GenuineIntel") &&
+ cpuid_level >= 0x06 ) {
+ u_int dummy;
+
+ CPUID(0x06, ci->ci_feature_tpmflags, dummy,
+ dummy, dummy);
+ max = nitems(cpu_tpm_eaxfeatures);
+ for (i = 0; i < max; i++)
+ if (ci->ci_feature_tpmflags &
+ cpu_tpm_eaxfeatures[i].feature_bit)
+ printf(",%s", cpu_tpm_eaxfeatures[i].feature_name);
+ }
+
printf("\n");
}
}
-/* $OpenBSD: cpu.h,v 1.139 2015/04/18 22:16:21 kettenis Exp $ */
+/* $OpenBSD: cpu.h,v 1.140 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */
/*-
u_int32_t ci_model; /* extended cpuid model */
u_int32_t ci_feature_flags; /* X86 CPUID feature bits */
u_int32_t ci_feature_sefflags; /* more CPUID feature bits */
+ u_int32_t ci_feature_tpmflags; /* thermal & power bits */
u_int32_t cpu_class; /* CPU class */
u_int32_t ci_cflushsz; /* clflush cache-line size */
-/* $OpenBSD: specialreg.h,v 1.50 2015/03/25 20:59:30 kettenis Exp $ */
+/* $OpenBSD: specialreg.h,v 1.51 2015/05/28 20:10:58 guenther Exp $ */
/* $NetBSD: specialreg.h,v 1.7 1994/10/27 04:16:26 cgd Exp $ */
/*-
#define SEFF0EBX_ADX 0x00080000 /* ADCX/ADOX instructions */
#define SEFF0EBX_SMAP 0x00100000 /* Supervisor mode access prevent */
+/*
+ * Thermal and Power Management (CPUID function 0x6) EAX bits
+ */
+#define TPM_SENSOR 0x00000001 /* Digital temp sensor */
+#define TPM_ARAT 0x00000004 /* APIC Timer Always Running */
+
/*
* "Architectural Performance Monitoring" bits (CPUID function 0x0a):
* EAX bits