This source file includes following definitions.
- procfs_getcpuinfstr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/mount.h>
43 #include <sys/vnode.h>
44 #include <miscfs/procfs/procfs.h>
45 #include <machine/cpu.h>
46 #include <machine/cpufunc.h>
47 #include <machine/specialreg.h>
48
49 extern int i386_fpu_present, i386_fpu_exception, i386_fpu_fdivbug;
50
51 static const char * const i386_features[] = {
52 "fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce",
53 "cx8", "apic", NULL, "sep", "mtrr", "pge", "mca", "cmov",
54 "pat", "pse36", "pn", "clflush", NULL, "dts", "acpi", "mmx",
55 "fxsr", "sse", "sse2", "ss", "ht", "tm", "ia64", "pbe"
56 };
57
58
59
60
61
62
63
64
65 int
66 procfs_getcpuinfstr(char *buf, int *len)
67 {
68 int left, l, i;
69 char featurebuf[256], *p;
70
71 p = featurebuf;
72 left = sizeof featurebuf;
73 for (i = 0; i < 32; i++) {
74 if ((cpu_feature & (1 << i)) && i386_features[i]) {
75 l = snprintf(p, left, "%s ", i386_features[i]);
76 if (l == -1)
77 l = 0;
78 else if (l >= left)
79 l = left - 1;
80 left -= l;
81 p += l;
82 if (left <= 0)
83 break;
84 }
85 }
86
87 p = buf;
88 left = *len;
89 l = snprintf(p, left,
90 "processor\t: %d\n"
91 "vendor_id\t: %s\n"
92 "cpu family\t: %d\n"
93 "model\t\t: %d\n"
94 "model name\t: %s\n"
95 "stepping\t: ",
96 0,
97 cpu_vendor,
98 cpuid_level >= 0 ? ((cpu_id >> 8) & 15) : cpu_class + 3,
99 cpuid_level >= 0 ? ((cpu_id >> 4) & 15) : 0,
100 cpu_model
101 );
102 if (l == -1)
103 l = 0;
104 else if (l >= left)
105 l = left - 1;
106
107 left -= l;
108 p += l;
109 if (left <= 0)
110 return 0;
111
112 if (cpuid_level >= 0)
113 l = snprintf(p, left, "%d\n", cpu_id & 15);
114 else
115 l = snprintf(p, left, "unknown\n");
116
117 if (l == -1)
118 l = 0;
119 else if (l >= left)
120 l = left - 1;
121 left -= l;
122 p += l;
123 if (left <= 0)
124 return 0;
125
126 #if defined(I586_CPU) || defined(I686_CPU)
127 if (cpuspeed != 0)
128 l = snprintf(p, left, "cpu MHz\t\t: %d\n",
129 cpuspeed);
130 else
131 #endif
132 l = snprintf(p, left, "cpu MHz\t\t: unknown\n");
133
134 if (l == -1)
135 l = 0;
136 else if (l >= left)
137 l = left - 1;
138 left -= l;
139 p += l;
140 if (left <= 0)
141 return 0;
142
143 l = snprintf(p, left,
144 "fdiv_bug\t: %s\n"
145 "fpu\t\t: %s\n"
146 "fpu_exception:\t: %s\n"
147 "cpuid level\t: %d\n"
148 "wp\t\t: %s\n"
149 "flags\t\t: %s\n",
150 i386_fpu_fdivbug ? "yes" : "no",
151 i386_fpu_present ? "yes" : "no",
152 i386_fpu_exception ? "yes" : "no",
153 cpuid_level,
154 (rcr0() & CR0_WP) ? "yes" : "no",
155 featurebuf);
156 if (l == -1)
157 l = 0;
158 else if (l >= left)
159 l = left - 1;
160
161 *len = (p + l) - buf;
162
163 return 0;
164 }