1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Erwan Velu - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * -----------------------------------------------------------------------
31 static void show_flag(struct s_my_menu
*menu
, char *buffer
, bool flag
,
32 char *flag_name
, bool flush
)
34 char output_buffer
[SUBMENULEN
+ 1];
35 char statbuffer
[SUBMENULEN
+ 1];
36 if ((((strlen(buffer
) + strlen(flag_name
)) > 35) && flag
) || flush
) {
37 snprintf(output_buffer
, sizeof output_buffer
, "Flags : %s", buffer
);
38 snprintf(statbuffer
, sizeof statbuffer
, "Flags: %s", buffer
);
39 add_item(output_buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
42 memset(buffer
, 0, sizeof(buffer
));
47 strcat(buffer
, flag_name
);
50 /* Compute Processor menu */
51 void compute_processor(struct s_my_menu
*menu
, struct s_hardware
*hardware
)
53 char buffer
[SUBMENULEN
+ 1];
54 char buffer1
[SUBMENULEN
+ 1];
55 char statbuffer
[STATLEN
+ 1];
57 menu
->menu
= add_menu(" Main Processor ", -1);
58 menu
->items_count
= 0;
59 set_menu_pos(SUBMENU_Y
, SUBMENU_X
);
61 snprintf(buffer
, sizeof buffer
, "Vendor : %s", hardware
->cpu
.vendor
);
62 snprintf(statbuffer
, sizeof statbuffer
, "Vendor: %s", hardware
->cpu
.vendor
);
63 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
66 snprintf(buffer
, sizeof buffer
, "Model : %s", hardware
->cpu
.model
);
67 snprintf(statbuffer
, sizeof statbuffer
, "Model: %s", hardware
->cpu
.model
);
68 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
71 snprintf(buffer
, sizeof buffer
, "CPU Cores : %d", hardware
->cpu
.num_cores
);
72 snprintf(statbuffer
, sizeof statbuffer
, "Number of CPU cores: %d",
73 hardware
->cpu
.num_cores
);
74 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
77 snprintf(buffer
, sizeof buffer
, "L1 Cache : %dK + %dK (I+D)",
78 hardware
->cpu
.l1_instruction_cache_size
,
79 hardware
->cpu
.l1_data_cache_size
);
80 snprintf(statbuffer
, sizeof statbuffer
,
81 "L1 Cache Size: %dK + %dK (Instruction + Data)",
82 hardware
->cpu
.l1_instruction_cache_size
,
83 hardware
->cpu
.l1_data_cache_size
);
84 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
87 snprintf(buffer
, sizeof buffer
, "L2 Cache : %dK",
88 hardware
->cpu
.l2_cache_size
);
89 snprintf(statbuffer
, sizeof statbuffer
, "L2 Cache Size: %dK",
90 hardware
->cpu
.l2_cache_size
);
91 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
94 snprintf(buffer
, sizeof buffer
, "Family ID : %d", hardware
->cpu
.family
);
95 snprintf(statbuffer
, sizeof statbuffer
, "Family ID: %d",
96 hardware
->cpu
.family
);
97 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
100 snprintf(buffer
, sizeof buffer
, "Model ID : %d", hardware
->cpu
.model_id
);
101 snprintf(statbuffer
, sizeof statbuffer
, "Model ID: %d",
102 hardware
->cpu
.model_id
);
103 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
106 snprintf(buffer
, sizeof buffer
, "Stepping : %d", hardware
->cpu
.stepping
);
107 snprintf(statbuffer
, sizeof statbuffer
, "Stepping: %d",
108 hardware
->cpu
.stepping
);
109 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
112 if (hardware
->is_dmi_valid
) {
113 snprintf(buffer
, sizeof buffer
, "FSB : %d",
114 hardware
->dmi
.processor
.external_clock
);
115 snprintf(statbuffer
, sizeof statbuffer
,
116 "Front Side Bus (MHz): %d",
117 hardware
->dmi
.processor
.external_clock
);
118 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
121 snprintf(buffer
, sizeof buffer
, "Cur. Speed: %d",
122 hardware
->dmi
.processor
.current_speed
);
123 snprintf(statbuffer
, sizeof statbuffer
,
124 "Current Speed (MHz): %d",
125 hardware
->dmi
.processor
.current_speed
);
126 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
129 snprintf(buffer
, sizeof buffer
, "Max Speed : %d",
130 hardware
->dmi
.processor
.max_speed
);
131 snprintf(statbuffer
, sizeof statbuffer
, "Max Speed (MHz): %d",
132 hardware
->dmi
.processor
.max_speed
);
133 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
136 snprintf(buffer
, sizeof buffer
, "Upgrade : %s",
137 hardware
->dmi
.processor
.upgrade
);
138 snprintf(statbuffer
, sizeof statbuffer
, "Upgrade: %s",
139 hardware
->dmi
.processor
.upgrade
);
140 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
143 snprintf(buffer
, sizeof buffer
, "Voltage : %d.%02d",
144 hardware
->dmi
.processor
.voltage_mv
/ 1000,
145 hardware
->dmi
.processor
.voltage_mv
-
146 ((hardware
->dmi
.processor
.voltage_mv
/ 1000) * 1000));
147 snprintf(statbuffer
, sizeof statbuffer
, "Voltage (V) : %d.%02d",
148 hardware
->dmi
.processor
.voltage_mv
/ 1000,
149 hardware
->dmi
.processor
.voltage_mv
-
150 ((hardware
->dmi
.processor
.voltage_mv
/ 1000) * 1000));
151 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
155 if (hardware
->cpu
.flags
.smp
) {
156 snprintf(buffer
, sizeof buffer
, "SMP : Yes");
157 snprintf(statbuffer
, sizeof statbuffer
, "SMP: Yes");
159 snprintf(buffer
, sizeof buffer
, "SMP : No");
160 snprintf(statbuffer
, sizeof statbuffer
, "SMP: No");
162 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
165 if (hardware
->cpu
.flags
.lm
) {
166 snprintf(buffer
, sizeof buffer
, "x86_64 : Yes");
167 snprintf(statbuffer
, sizeof statbuffer
,
168 "x86_64 compatible processor: Yes");
170 snprintf(buffer
, sizeof buffer
, "X86_64 : No");
171 snprintf(statbuffer
, sizeof statbuffer
,
172 "X86_64 compatible processor: No");
174 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
177 if ((hardware
->cpu
.flags
.vmx
) || (hardware
->cpu
.flags
.svm
)) {
178 snprintf(buffer
, sizeof buffer
, "Hw Virt. : Yes");
179 snprintf(statbuffer
, sizeof statbuffer
,
180 "Hardware Virtualisation Capable: Yes");
182 snprintf(buffer
, sizeof buffer
, "Hw Virt. : No");
183 snprintf(statbuffer
, sizeof statbuffer
,
184 "Hardware Virtualisation Capabable : No");
186 add_item(buffer
, statbuffer
, OPT_INACTIVE
, NULL
, 0);
189 memset(buffer1
, 0, sizeof(buffer1
));
190 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.fpu
, "fpu ", false);
191 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.vme
, "vme ", false);
192 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.de
, "de ", false);
193 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pse
, "pse ", false);
194 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.tsc
, "tsc ", false);
195 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.msr
, "msr ", false);
196 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pae
, "pae ", false);
197 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.mce
, "mce ", false);
198 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.cx8
, "cx8 ", false);
199 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.apic
, "apic ", false);
200 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.sep
, "sep ", false);
201 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.mtrr
, "mtrr ", false);
202 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pge
, "pge ", false);
203 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.mca
, "mca ", false);
204 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.cmov
, "cmov ", false);
205 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pat
, "pat ", false);
206 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pse_36
, "pse_36 ", false);
207 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.psn
, "psn ", false);
208 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.clflsh
, "clflsh ", false);
209 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.dts
, "dts ", false);
210 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.acpi
, "acpi ", false);
211 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.mmx
, "mmx ", false);
212 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.sse
, "sse ", false);
213 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.sse2
, "sse2 ", false);
214 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.ss
, "ss ", false);
215 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.htt
, "ht ", false);
216 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.acc
, "acc ", false);
217 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.syscall
, "syscall ", false);
218 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.mp
, "mp ", false);
219 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.nx
, "nx ", false);
220 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.mmxext
, "mmxext ", false);
221 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.lm
, "lm ", false);
222 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.nowext
, "3dnowext ", false);
223 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.now
, "3dnow! ", false);
224 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.svm
, "svm ", false);
225 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.vmx
, "vmx ", false);
226 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pbe
, "pbe ", false);
227 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.fxsr_opt
, "fxsr_opt ", false);
228 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.gbpages
, "gbpages ", false);
229 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.rdtscp
, "rdtscp ", false);
230 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pni
, "pni ", false);
231 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pclmulqd
, "pclmulqd ", false);
232 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.dtes64
, "dtes64 ", false);
233 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.smx
, "smx ", false);
234 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.est
, "est ", false);
235 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.tm2
, "tm2 ", false);
236 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.sse3
, "sse3 ", false);
237 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.fma
, "fma ", false);
238 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.cx16
, "cx16 ", false);
239 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.xtpr
, "xtpr ", false);
240 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pdcm
, "pdcm ", false);
241 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.dca
, "dca ", false);
242 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.xmm4_1
, "xmm4_1 ", false);
243 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.xmm4_2
, "xmm4_2 ", false);
244 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.x2apic
, "x2apic ", false);
245 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.movbe
, "movbe ", false);
246 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.popcnt
, "popcnt ", false);
247 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.aes
, "aes ", false);
248 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.xsave
, "xsave ", false);
249 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.osxsave
, "osxsave ", false);
250 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.avx
, "avx ", false);
251 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.hypervisor
, "hypervisor ",
253 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.ace2
, "ace2 ", false);
254 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.ace2_en
, "ace2_en ", false);
255 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.phe
, "phe ", false);
256 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.phe_en
, "phe_en ", false);
257 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pmm
, "pmm ", false);
258 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.pmm_en
, "pmm_en ", false);
259 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.extapic
, "extapic ", false);
260 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.cr8_legacy
, "cr8_legacy ",
262 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.abm
, "abm ", false);
263 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.sse4a
, "sse4a ", false);
264 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.misalignsse
, "misalignsse ",
266 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.nowprefetch
, "3dnowprefetch ",
268 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.osvw
, "osvw ", false);
269 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.ibs
, "ibs ", false);
270 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.sse5
, "sse5 ", false);
271 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.skinit
, "skinit ", false);
272 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.wdt
, "wdt ", false);
273 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.ida
, "ida ", false);
274 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.arat
, "arat ", false);
275 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.tpr_shadow
, "tpr_shadow ",
277 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.vnmi
, "vnmi ", false);
278 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.flexpriority
, "flexpriority ",
280 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.ept
, "ept ", false);
281 show_flag(menu
, buffer1
, hardware
->cpu
.flags
.vpid
, "vpid ", false);
283 /* Let's flush the remaining flags */
284 show_flag(menu
, buffer1
, false, "", true);
286 printf("MENU: Processor menu done (%d items)\n", menu
->items_count
);