Adding upstream version 6.02~pre8+dfsg.
[syslinux-debian/hramrach.git] / com32 / hdt / hdt-menu-processor.c
blobf28833b5487c67cc41f01b01da6a562d6a41e3e5
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
12 * conditions:
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 * -----------------------------------------------------------------------
29 #include "hdt-menu.h"
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);
40 menu->items_count++;
42 memset(buffer, 0, sizeof(buffer));
43 if (flush)
44 return;
46 if (flag)
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 if (hardware->acpi.madt.processor_local_apic_count > 0) {
58 snprintf(buffer, sizeof buffer,
59 " Main Processors (%d logical / %d phys. ) ",
60 hardware->acpi.madt.processor_local_apic_count,
61 hardware->physical_cpu_count);
62 menu->menu = add_menu(buffer, -1);
63 menu->items_count = 0;
64 set_menu_pos(SUBMENU_Y, SUBMENU_X);
65 } else {
66 menu->menu = add_menu(" Main Processor ", -1);
67 menu->items_count = 0;
68 set_menu_pos(SUBMENU_Y, SUBMENU_X);
71 snprintf(buffer, sizeof buffer, "Vendor : %s", hardware->cpu.vendor);
72 snprintf(statbuffer, sizeof statbuffer, "Vendor: %s", hardware->cpu.vendor);
73 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
74 menu->items_count++;
76 snprintf(buffer, sizeof buffer, "Model : %s", hardware->cpu.model);
77 snprintf(statbuffer, sizeof statbuffer, "Model: %s", hardware->cpu.model);
78 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
79 menu->items_count++;
81 snprintf(buffer, sizeof buffer, "CPU Cores : %d", hardware->cpu.num_cores);
82 snprintf(statbuffer, sizeof statbuffer, "Number of CPU cores: %d",
83 hardware->cpu.num_cores);
84 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
85 menu->items_count++;
87 if (hardware->dmi.processor.core_enabled != 0) {
88 snprintf(buffer, sizeof buffer, "CPU Enable: %d", hardware->dmi.processor.core_enabled);
89 snprintf(statbuffer, sizeof statbuffer, "Number of CPU Enabled : %d",
90 hardware->dmi.processor.core_enabled);
91 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
92 menu->items_count++;
95 if (hardware->dmi.processor.thread_count != 0) {
96 snprintf(buffer, sizeof buffer, "CPU Thread: %d", hardware->dmi.processor.thread_count);
97 snprintf(statbuffer, sizeof statbuffer, "Number of CPU Threads : %d",
98 hardware->dmi.processor.thread_count);
99 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
100 menu->items_count++;
103 snprintf(buffer, sizeof buffer, "L1 Cache : %dK + %dK (I+D)",
104 hardware->cpu.l1_instruction_cache_size,
105 hardware->cpu.l1_data_cache_size);
106 snprintf(statbuffer, sizeof statbuffer,
107 "L1 Cache Size: %dK + %dK (Instruction + Data)",
108 hardware->cpu.l1_instruction_cache_size,
109 hardware->cpu.l1_data_cache_size);
110 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
111 menu->items_count++;
113 snprintf(buffer, sizeof buffer, "L2 Cache : %dK",
114 hardware->cpu.l2_cache_size);
115 snprintf(statbuffer, sizeof statbuffer, "L2 Cache Size: %dK",
116 hardware->cpu.l2_cache_size);
117 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
118 menu->items_count++;
120 snprintf(buffer, sizeof buffer, "Family ID : %d", hardware->cpu.family);
121 snprintf(statbuffer, sizeof statbuffer, "Family ID: %d",
122 hardware->cpu.family);
123 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
124 menu->items_count++;
126 snprintf(buffer, sizeof buffer, "Model ID : %d", hardware->cpu.model_id);
127 snprintf(statbuffer, sizeof statbuffer, "Model ID: %d",
128 hardware->cpu.model_id);
129 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
130 menu->items_count++;
132 snprintf(buffer, sizeof buffer, "Stepping : %d", hardware->cpu.stepping);
133 snprintf(statbuffer, sizeof statbuffer, "Stepping: %d",
134 hardware->cpu.stepping);
135 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
136 menu->items_count++;
138 if (hardware->is_dmi_valid) {
139 snprintf(buffer, sizeof buffer, "FSB : %d",
140 hardware->dmi.processor.external_clock);
141 snprintf(statbuffer, sizeof statbuffer,
142 "Front Side Bus (MHz): %d",
143 hardware->dmi.processor.external_clock);
144 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
145 menu->items_count++;
147 snprintf(buffer, sizeof buffer, "Cur. Speed: %d",
148 hardware->dmi.processor.current_speed);
149 snprintf(statbuffer, sizeof statbuffer,
150 "Current Speed (MHz): %d",
151 hardware->dmi.processor.current_speed);
152 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
153 menu->items_count++;
155 snprintf(buffer, sizeof buffer, "Max Speed : %d",
156 hardware->dmi.processor.max_speed);
157 snprintf(statbuffer, sizeof statbuffer, "Max Speed (MHz): %d",
158 hardware->dmi.processor.max_speed);
159 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
160 menu->items_count++;
162 snprintf(buffer, sizeof buffer, "Upgrade : %s",
163 hardware->dmi.processor.upgrade);
164 snprintf(statbuffer, sizeof statbuffer, "Upgrade: %s",
165 hardware->dmi.processor.upgrade);
166 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
167 menu->items_count++;
169 snprintf(buffer, sizeof buffer, "Voltage : %d.%02d",
170 hardware->dmi.processor.voltage_mv / 1000,
171 hardware->dmi.processor.voltage_mv -
172 ((hardware->dmi.processor.voltage_mv / 1000) * 1000));
173 snprintf(statbuffer, sizeof statbuffer, "Voltage (V) : %d.%02d",
174 hardware->dmi.processor.voltage_mv / 1000,
175 hardware->dmi.processor.voltage_mv -
176 ((hardware->dmi.processor.voltage_mv / 1000) * 1000));
177 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
178 menu->items_count++;
181 if (hardware->cpu.flags.smp) {
182 snprintf(buffer, sizeof buffer, "SMP : Yes");
183 snprintf(statbuffer, sizeof statbuffer, "SMP: Yes");
184 } else {
185 snprintf(buffer, sizeof buffer, "SMP : No");
186 snprintf(statbuffer, sizeof statbuffer, "SMP: No");
188 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
189 menu->items_count++;
191 if (hardware->cpu.flags.lm) {
192 snprintf(buffer, sizeof buffer, "x86_64 : Yes");
193 snprintf(statbuffer, sizeof statbuffer,
194 "x86_64 compatible processor: Yes");
195 } else {
196 snprintf(buffer, sizeof buffer, "X86_64 : No");
197 snprintf(statbuffer, sizeof statbuffer,
198 "X86_64 compatible processor: No");
200 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
201 menu->items_count++;
203 if ((hardware->cpu.flags.vmx) || (hardware->cpu.flags.svm)) {
204 snprintf(buffer, sizeof buffer, "Hw Virt. : Yes");
205 snprintf(statbuffer, sizeof statbuffer,
206 "Hardware Virtualisation Capable: Yes");
207 } else {
208 snprintf(buffer, sizeof buffer, "Hw Virt. : No");
209 snprintf(statbuffer, sizeof statbuffer,
210 "Hardware Virtualisation Capabable : No");
212 add_item(buffer, statbuffer, OPT_INACTIVE, NULL, 0);
213 menu->items_count++;
215 memset(buffer1, 0, sizeof(buffer1));
216 show_flag(menu, buffer1, hardware->cpu.flags.fpu, "fpu ", false);
217 show_flag(menu, buffer1, hardware->cpu.flags.vme, "vme ", false);
218 show_flag(menu, buffer1, hardware->cpu.flags.de, "de ", false);
219 show_flag(menu, buffer1, hardware->cpu.flags.pse, "pse ", false);
220 show_flag(menu, buffer1, hardware->cpu.flags.tsc, "tsc ", false);
221 show_flag(menu, buffer1, hardware->cpu.flags.msr, "msr ", false);
222 show_flag(menu, buffer1, hardware->cpu.flags.pae, "pae ", false);
223 show_flag(menu, buffer1, hardware->cpu.flags.mce, "mce ", false);
224 show_flag(menu, buffer1, hardware->cpu.flags.cx8, "cx8 ", false);
225 show_flag(menu, buffer1, hardware->cpu.flags.apic, "apic ", false);
226 show_flag(menu, buffer1, hardware->cpu.flags.sep, "sep ", false);
227 show_flag(menu, buffer1, hardware->cpu.flags.mtrr, "mtrr ", false);
228 show_flag(menu, buffer1, hardware->cpu.flags.pge, "pge ", false);
229 show_flag(menu, buffer1, hardware->cpu.flags.mca, "mca ", false);
230 show_flag(menu, buffer1, hardware->cpu.flags.cmov, "cmov ", false);
231 show_flag(menu, buffer1, hardware->cpu.flags.pat, "pat ", false);
232 show_flag(menu, buffer1, hardware->cpu.flags.pse_36, "pse_36 ", false);
233 show_flag(menu, buffer1, hardware->cpu.flags.psn, "psn ", false);
234 show_flag(menu, buffer1, hardware->cpu.flags.clflsh, "clflsh ", false);
235 show_flag(menu, buffer1, hardware->cpu.flags.dts, "dts ", false);
236 show_flag(menu, buffer1, hardware->cpu.flags.acpi, "acpi ", false);
237 show_flag(menu, buffer1, hardware->cpu.flags.mmx, "mmx ", false);
238 show_flag(menu, buffer1, hardware->cpu.flags.sse, "sse ", false);
239 show_flag(menu, buffer1, hardware->cpu.flags.sse2, "sse2 ", false);
240 show_flag(menu, buffer1, hardware->cpu.flags.ss, "ss ", false);
241 show_flag(menu, buffer1, hardware->cpu.flags.htt, "ht ", false);
242 show_flag(menu, buffer1, hardware->cpu.flags.acc, "acc ", false);
243 show_flag(menu, buffer1, hardware->cpu.flags.syscall, "syscall ", false);
244 show_flag(menu, buffer1, hardware->cpu.flags.mp, "mp ", false);
245 show_flag(menu, buffer1, hardware->cpu.flags.nx, "nx ", false);
246 show_flag(menu, buffer1, hardware->cpu.flags.mmxext, "mmxext ", false);
247 show_flag(menu, buffer1, hardware->cpu.flags.lm, "lm ", false);
248 show_flag(menu, buffer1, hardware->cpu.flags.nowext, "3dnowext ", false);
249 show_flag(menu, buffer1, hardware->cpu.flags.now, "3dnow! ", false);
250 show_flag(menu, buffer1, hardware->cpu.flags.svm, "svm ", false);
251 show_flag(menu, buffer1, hardware->cpu.flags.vmx, "vmx ", false);
252 show_flag(menu, buffer1, hardware->cpu.flags.pbe, "pbe ", false);
253 show_flag(menu, buffer1, hardware->cpu.flags.fxsr_opt, "fxsr_opt ", false);
254 show_flag(menu, buffer1, hardware->cpu.flags.gbpages, "gbpages ", false);
255 show_flag(menu, buffer1, hardware->cpu.flags.rdtscp, "rdtscp ", false);
256 show_flag(menu, buffer1, hardware->cpu.flags.pni, "pni ", false);
257 show_flag(menu, buffer1, hardware->cpu.flags.pclmulqd, "pclmulqd ", false);
258 show_flag(menu, buffer1, hardware->cpu.flags.dtes64, "dtes64 ", false);
259 show_flag(menu, buffer1, hardware->cpu.flags.smx, "smx ", false);
260 show_flag(menu, buffer1, hardware->cpu.flags.est, "est ", false);
261 show_flag(menu, buffer1, hardware->cpu.flags.tm2, "tm2 ", false);
262 show_flag(menu, buffer1, hardware->cpu.flags.sse3, "sse3 ", false);
263 show_flag(menu, buffer1, hardware->cpu.flags.fma, "fma ", false);
264 show_flag(menu, buffer1, hardware->cpu.flags.cx16, "cx16 ", false);
265 show_flag(menu, buffer1, hardware->cpu.flags.xtpr, "xtpr ", false);
266 show_flag(menu, buffer1, hardware->cpu.flags.pdcm, "pdcm ", false);
267 show_flag(menu, buffer1, hardware->cpu.flags.dca, "dca ", false);
268 show_flag(menu, buffer1, hardware->cpu.flags.xmm4_1, "xmm4_1 ", false);
269 show_flag(menu, buffer1, hardware->cpu.flags.xmm4_2, "xmm4_2 ", false);
270 show_flag(menu, buffer1, hardware->cpu.flags.x2apic, "x2apic ", false);
271 show_flag(menu, buffer1, hardware->cpu.flags.movbe, "movbe ", false);
272 show_flag(menu, buffer1, hardware->cpu.flags.popcnt, "popcnt ", false);
273 show_flag(menu, buffer1, hardware->cpu.flags.aes, "aes ", false);
274 show_flag(menu, buffer1, hardware->cpu.flags.xsave, "xsave ", false);
275 show_flag(menu, buffer1, hardware->cpu.flags.osxsave, "osxsave ", false);
276 show_flag(menu, buffer1, hardware->cpu.flags.avx, "avx ", false);
277 show_flag(menu, buffer1, hardware->cpu.flags.hypervisor, "hypervisor ",
278 false);
279 show_flag(menu, buffer1, hardware->cpu.flags.ace2, "ace2 ", false);
280 show_flag(menu, buffer1, hardware->cpu.flags.ace2_en, "ace2_en ", false);
281 show_flag(menu, buffer1, hardware->cpu.flags.phe, "phe ", false);
282 show_flag(menu, buffer1, hardware->cpu.flags.phe_en, "phe_en ", false);
283 show_flag(menu, buffer1, hardware->cpu.flags.pmm, "pmm ", false);
284 show_flag(menu, buffer1, hardware->cpu.flags.pmm_en, "pmm_en ", false);
285 show_flag(menu, buffer1, hardware->cpu.flags.extapic, "extapic ", false);
286 show_flag(menu, buffer1, hardware->cpu.flags.cr8_legacy, "cr8_legacy ",
287 false);
288 show_flag(menu, buffer1, hardware->cpu.flags.abm, "abm ", false);
289 show_flag(menu, buffer1, hardware->cpu.flags.sse4a, "sse4a ", false);
290 show_flag(menu, buffer1, hardware->cpu.flags.misalignsse, "misalignsse ",
291 false);
292 show_flag(menu, buffer1, hardware->cpu.flags.nowprefetch, "3dnowprefetch ",
293 false);
294 show_flag(menu, buffer1, hardware->cpu.flags.osvw, "osvw ", false);
295 show_flag(menu, buffer1, hardware->cpu.flags.ibs, "ibs ", false);
296 show_flag(menu, buffer1, hardware->cpu.flags.sse5, "sse5 ", false);
297 show_flag(menu, buffer1, hardware->cpu.flags.skinit, "skinit ", false);
298 show_flag(menu, buffer1, hardware->cpu.flags.wdt, "wdt ", false);
299 show_flag(menu, buffer1, hardware->cpu.flags.ida, "ida ", false);
300 show_flag(menu, buffer1, hardware->cpu.flags.arat, "arat ", false);
301 show_flag(menu, buffer1, hardware->cpu.flags.tpr_shadow, "tpr_shadow ",
302 false);
303 show_flag(menu, buffer1, hardware->cpu.flags.vnmi, "vnmi ", false);
304 show_flag(menu, buffer1, hardware->cpu.flags.flexpriority, "flexpriority ",
305 false);
306 show_flag(menu, buffer1, hardware->cpu.flags.ept, "ept ", false);
307 show_flag(menu, buffer1, hardware->cpu.flags.vpid, "vpid ", false);
309 /* Let's flush the remaining flags */
310 show_flag(menu, buffer1, false, "", true);
312 printf("MENU: Processor menu done (%d items)\n", menu->items_count);