]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/sparc64/sparc64/identcpu.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / sparc64 / sparc64 / identcpu.c
1 /*-
2  * Initial implementation:
3  * Copyright (c) 2001 Robert Drehmel
4  * All rights reserved.
5  *
6  * As long as the above copyright statement and this notice remain
7  * unchanged, you can do what ever you want with this file.
8  */
9
10 #include <sys/cdefs.h>
11 __FBSDID("$FreeBSD$");
12
13 #include <sys/param.h>
14 #include <sys/systm.h>
15 #include <sys/kernel.h>
16 #include <sys/sysctl.h>
17
18 #include <machine/md_var.h>
19 #include <machine/ver.h>
20
21 char machine[] = MACHINE;
22 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
23     machine, 0, "Machine class");
24
25 static char cpu_model[128];
26 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
27     cpu_model, 0, "Machine model");
28
29 static SYSCTL_NODE(_hw, OID_AUTO, freq, CTLFLAG_RD, 0, "");
30
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");
35
36 void
37 cpu_identify(u_long vers, u_int freq, u_int id)
38 {
39         const char *manus;
40         const char *impls;
41
42         switch (VER_MANUF(vers)) {
43         case 0x04:
44                 manus = "HAL/Fujitsu";
45                 break;
46         case 0x13:
47         case 0x17:
48         case 0x22:
49         case 0x3e:
50                 manus = "Sun Microsystems";
51                 break;
52         default:
53                 manus = NULL;
54                 break;
55         }
56         switch (VER_IMPL(vers)) {
57         case CPU_IMPL_SPARC64:
58                 impls = "SPARC64";
59                 break;
60         case CPU_IMPL_SPARC64II:
61                 impls = "SPARC64-II";
62                 break;
63         case CPU_IMPL_SPARC64III:
64                 impls = "SPARC64-III";
65                 break;
66         case CPU_IMPL_SPARC64IV:
67                 impls = "SPARC64-IV";
68                 break;
69         case CPU_IMPL_SPARC64V:
70                 impls = "SPARC64-V";
71                 break;
72         case CPU_IMPL_SPARC64VI:
73                 impls = "SPARC64-VI";
74                 break;
75         case CPU_IMPL_SPARC64VII:
76                 impls = "SPARC64-VII";
77                 break;
78         case CPU_IMPL_SPARC64VIIIfx:
79                 impls = "SPARC64-VIIIfx";
80                 break;
81         case CPU_IMPL_ULTRASPARCI:
82                 impls = "UltraSparc-I";
83                 break;
84         case CPU_IMPL_ULTRASPARCII:
85                 impls = "UltraSparc-II";
86                 break;
87         case CPU_IMPL_ULTRASPARCIIi:
88                 impls = "UltraSparc-IIi";
89                 break;
90         case CPU_IMPL_ULTRASPARCIIe:
91                 impls = "UltraSparc-IIe";
92                 break;
93         case CPU_IMPL_ULTRASPARCIII:
94                 impls = "UltraSparc-III";
95                 break;
96         case CPU_IMPL_ULTRASPARCIIIp:
97                 impls = "UltraSparc-III+";
98                 break;
99         case CPU_IMPL_ULTRASPARCIIIi:
100                 impls = "UltraSparc-IIIi";
101                 break;
102         case CPU_IMPL_ULTRASPARCIV:
103                 impls = "UltraSparc-IV";
104                 break;
105         case CPU_IMPL_ULTRASPARCIVp:
106                 impls = "UltraSparc-IV+";
107                 break;
108         case CPU_IMPL_ULTRASPARCIIIip:
109                 impls = "UltraSparc-IIIi+";
110                 break;
111         default:
112                 impls = NULL;
113                 break;
114         }
115         if (manus == NULL || impls == NULL) {
116                 printf(
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);
121                 return;
122         }
123
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);
127         if (bootverbose) {
128                 printf("  mask=0x%lx maxtl=%ld maxwin=%ld\n", VER_MASK(vers),
129                     VER_MAXTL(vers), VER_MAXWIN(vers));
130         }
131
132         /*
133          * Calculate the average CPU frequency.
134          */
135         freq = (freq + 500000ul) / 1000000ul;
136         cpu_freq = (cpu_freq * cpu_count + freq) / (cpu_count + 1);
137         cpu_count++;
138 }