2 * Initial implementation:
3 * Copyright (c) 2001 Robert Drehmel
6 * As long as the above copyright statement and this notice remain
7 * unchanged, you can do what ever you want with this file.
10 #include <sys/cdefs.h>
11 __FBSDID("$FreeBSD$");
13 #include <sys/param.h>
14 #include <sys/systm.h>
15 #include <sys/kernel.h>
16 #include <sys/sysctl.h>
18 #include <machine/md_var.h>
19 #include <machine/ver.h>
21 char machine[] = MACHINE;
22 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
23 machine, 0, "Machine class");
25 static char cpu_model[128];
26 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
27 cpu_model, 0, "Machine model");
29 static SYSCTL_NODE(_hw, OID_AUTO, freq, CTLFLAG_RD, 0, "");
31 static u_int cpu_count;
32 static u_int cpu_freq;
33 SYSCTL_UINT(_hw_freq, OID_AUTO, cpu, CTLFLAG_RD, &cpu_freq, 0,
34 "CPU clock frequency");
37 cpu_identify(u_long vers, u_int freq, u_int id)
42 switch (VER_MANUF(vers)) {
44 manus = "HAL/Fujitsu";
50 manus = "Sun Microsystems";
56 switch (VER_IMPL(vers)) {
57 case CPU_IMPL_SPARC64:
60 case CPU_IMPL_SPARC64II:
63 case CPU_IMPL_SPARC64III:
64 impls = "SPARC64-III";
66 case CPU_IMPL_SPARC64IV:
69 case CPU_IMPL_SPARC64V:
72 case CPU_IMPL_SPARC64VI:
75 case CPU_IMPL_SPARC64VII:
76 impls = "SPARC64-VII";
78 case CPU_IMPL_SPARC64VIIIfx:
79 impls = "SPARC64-VIIIfx";
81 case CPU_IMPL_ULTRASPARCI:
82 impls = "UltraSparc-I";
84 case CPU_IMPL_ULTRASPARCII:
85 impls = "UltraSparc-II";
87 case CPU_IMPL_ULTRASPARCIIi:
88 impls = "UltraSparc-IIi";
90 case CPU_IMPL_ULTRASPARCIIe:
91 impls = "UltraSparc-IIe";
93 case CPU_IMPL_ULTRASPARCIII:
94 impls = "UltraSparc-III";
96 case CPU_IMPL_ULTRASPARCIIIp:
97 impls = "UltraSparc-III+";
99 case CPU_IMPL_ULTRASPARCIIIi:
100 impls = "UltraSparc-IIIi";
102 case CPU_IMPL_ULTRASPARCIV:
103 impls = "UltraSparc-IV";
105 case CPU_IMPL_ULTRASPARCIVp:
106 impls = "UltraSparc-IV+";
108 case CPU_IMPL_ULTRASPARCIIIip:
109 impls = "UltraSparc-IIIi+";
115 if (manus == NULL || impls == NULL) {
117 "CPU: unknown; please e-mail the following value together\n"
118 " with the exact name of your processor to "
119 "<freebsd-sparc64@FreeBSD.org>.\n"
120 " version register: <0x%lx>\n", vers);
124 snprintf(cpu_model, sizeof(cpu_model), "%s %s", manus, impls);
125 printf("cpu%d: %s %s Processor (%d.%02d MHz CPU)\n", id, manus, impls,
126 (freq + 4999) / 1000000, ((freq + 4999) / 10000) % 100);
128 printf(" mask=0x%lx maxtl=%ld maxwin=%ld\n", VER_MASK(vers),
129 VER_MAXTL(vers), VER_MAXWIN(vers));
133 * Calculate the average CPU frequency.
135 freq = (freq + 500000ul) / 1000000ul;
136 cpu_freq = (cpu_freq * cpu_count + freq) / (cpu_count + 1);