diff options
author | marcel <marcel@FreeBSD.org> | 2009-12-23 06:52:12 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2009-12-23 06:52:12 +0000 |
commit | 23c3bda2df0c608f826b3c7bb89df2c2975f9214 (patch) | |
tree | 5674061ad293ecf646944e620d10b54b28df54fd /sys/sparc64 | |
parent | 6c6778bb48b1c2300ef6ed51d5ef47cbeaa34830 (diff) | |
download | FreeBSD-src-23c3bda2df0c608f826b3c7bb89df2c2975f9214.zip FreeBSD-src-23c3bda2df0c608f826b3c7bb89df2c2975f9214.tar.gz |
Calculate the average CPU clock frequency and export that through
the hw.freq.cpu sysctl variable. This can be used by ports that
need to know "the" CPU frequency.
Diffstat (limited to 'sys/sparc64')
-rw-r--r-- | sys/sparc64/sparc64/identcpu.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/sparc64/sparc64/identcpu.c b/sys/sparc64/sparc64/identcpu.c index 020dc924..cdb09e6 100644 --- a/sys/sparc64/sparc64/identcpu.c +++ b/sys/sparc64/sparc64/identcpu.c @@ -27,6 +27,13 @@ static char cpu_model[128]; SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD, cpu_model, 0, "Machine model"); +SYSCTL_NODE(_hw, OID_AUTO, freq, CTLFLAG_RD, 0, ""); + +static u_int cpu_count; +static u_int cpu_freq; +SYSCTL_UINT(_hw_freq, OID_AUTO, cpu, CTLFLAG_RD, &cpu_freq, 0, + "CPU clock frequency"); + int cpu_impl; void @@ -104,4 +111,11 @@ cpu_identify(u_long vers, u_int freq, u_int id) printf(" mask=0x%lx maxtl=%ld maxwin=%ld\n", VER_MASK(vers), VER_MAXTL(vers), VER_MAXWIN(vers)); } + + /* + * Calculate the average CPU frequency. + */ + freq = (freq + 500000ul) / 1000000ul; + cpu_freq = (cpu_freq * cpu_count + freq) / (cpu_count + 1); + cpu_count++; } |