From 421ecee5da527eef4104e83402290921ff6f7a86 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sat, 28 Feb 2004 18:12:22 +0000 Subject: sysctl hw.cpuspeed output --- sys/arch/amd64/amd64/identcpu.c | 18 ++++++++++++++++-- sys/arch/amd64/include/cpu.h | 3 ++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index f843aedf085..2f8fda8d2f8 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.3 2004/02/27 21:21:44 grange Exp $ */ +/* $OpenBSD: identcpu.c,v 1.4 2004/02/28 18:12:21 deraadt Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -36,13 +36,18 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include +#include #include +#include +#include +#include +#include #include #include /* sysctl wants this. */ char cpu_model[48]; +int cpuspeed; const struct { u_int32_t bit; @@ -88,6 +93,13 @@ const struct { { CPUID_3DNOW, "3DNOW" } }; +int +cpu_amd64speed(int *freq) +{ + *freq = cpuspeed; + return (0); +} + void identifycpu(struct cpu_info *ci) { @@ -135,6 +147,8 @@ identifycpu(struct cpu_info *ci) if (ci->ci_tsc_freq != 0) printf(", %lu.%02lu MHz", (ci->ci_tsc_freq + 4999) / 1000000, ((ci->ci_tsc_freq + 4999) / 10000) % 100); + cpuspeed = (ci->ci_tsc_freq + 4999) / 1000000; + cpu_cpuspeed = cpu_amd64speed; printf("\n%s: ", ci->ci_dev->dv_xname); diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index 219689caa93..953f2da6998 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.4 2004/02/25 00:16:41 deraadt Exp $ */ +/* $OpenBSD: cpu.h,v 1.5 2004/02/28 18:12:21 deraadt Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -277,6 +277,7 @@ void cc_microset(struct cpu_info *); /* identcpu.c */ void identifycpu(struct cpu_info *); +int cpu_amd64speed(int *); void cpu_probe_features(struct cpu_info *); /* machdep.c */ -- cgit v1.2.3