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 * -----------------------------------------------------------------------
35 #include "hdt-common.h"
37 void main_show_cpu(int argc __unused
, char **argv __unused
,
38 struct s_hardware
*hardware
)
44 more_printf(" Manufacturer : %s \n", hardware
->cpu
.vendor
);
45 more_printf(" Product : %s \n", hardware
->cpu
.model
);
46 more_printf(" CPU Cores : %d \n", hardware
->cpu
.num_cores
);
47 more_printf(" L2 Cache : %dK\n", hardware
->cpu
.l2_cache_size
);
49 memset(features
, 0, sizeof(features
));
50 snprintf(features
, sizeof(features
), " Features : %d Mhz : ",
51 hardware
->dmi
.processor
.current_speed
);
52 if (hardware
->cpu
.flags
.lm
)
53 strcat(features
, "x86_64 64bit ");
55 strcat(features
, "x86 32bit ");
56 if (hardware
->cpu
.flags
.smp
)
57 strcat(features
, "SMP ");
58 if (hardware
->cpu
.flags
.vmx
|| hardware
->cpu
.flags
.svm
)
59 strcat(features
, "HwVIRT ");
61 more_printf("%s\n", features
);
64 static void show_flag(char *buffer
, bool flag
, char *flag_name
, bool flush
)
66 char output_buffer
[81];
67 if ((((strlen(buffer
) + strlen(flag_name
)) > 66) && flag
) || flush
) {
68 snprintf(output_buffer
, sizeof output_buffer
, "Flags : %s\n",
70 more_printf("%s", output_buffer
);
71 memset(buffer
, 0, sizeof(buffer
));
76 strcat(buffer
, flag_name
);
79 static void show_cpu(int argc __unused
, char **argv __unused
,
80 struct s_hardware
*hardware
)
85 more_printf("Vendor : %s\n", hardware
->cpu
.vendor
);
86 more_printf("Model : %s\n", hardware
->cpu
.model
);
87 more_printf("CPU Cores : %d\n", hardware
->cpu
.num_cores
);
88 more_printf("L1 Cache : %dK + %dK (I + D) \n",
89 hardware
->cpu
.l1_instruction_cache_size
,
90 hardware
->cpu
.l1_data_cache_size
);
91 more_printf("L2 Cache : %dK\n", hardware
->cpu
.l2_cache_size
);
92 more_printf("Family ID : %d\n", hardware
->cpu
.family
);
93 more_printf("Model ID : %d\n", hardware
->cpu
.model_id
);
94 more_printf("Stepping : %d\n", hardware
->cpu
.stepping
);
95 if (hardware
->is_dmi_valid
) {
96 more_printf("FSB : %d MHz\n",
97 hardware
->dmi
.processor
.external_clock
);
98 more_printf("Cur. Speed: %d MHz\n",
99 hardware
->dmi
.processor
.current_speed
);
100 more_printf("Max Speed : %d MHz\n", hardware
->dmi
.processor
.max_speed
);
101 more_printf("Upgrade : %s\n", hardware
->dmi
.processor
.upgrade
);
102 more_printf("Voltage : %d.%02d\n",
103 hardware
->dmi
.processor
.voltage_mv
/ 1000,
104 hardware
->dmi
.processor
.voltage_mv
-
105 ((hardware
->dmi
.processor
.voltage_mv
/ 1000) * 1000));
107 if (hardware
->cpu
.flags
.smp
) {
108 more_printf("SMP : yes\n");
110 more_printf("SMP : no\n");
112 if (hardware
->cpu
.flags
.lm
) {
113 more_printf("x86_64 : yes\n");
115 more_printf("x86_64 : no\n");
118 if (hardware
->cpu
.flags
.vmx
|| hardware
->cpu
.flags
.svm
) {
119 more_printf("HwVirt : yes\n");
121 more_printf("HwVirt : no\n");
124 memset(buffer
, 0, sizeof(buffer
));
125 show_flag(buffer
, hardware
->cpu
.flags
.fpu
, "fpu ", false);
126 show_flag(buffer
, hardware
->cpu
.flags
.vme
, "vme ", false);
127 show_flag(buffer
, hardware
->cpu
.flags
.de
, "de ", false);
128 show_flag(buffer
, hardware
->cpu
.flags
.pse
, "pse ", false);
129 show_flag(buffer
, hardware
->cpu
.flags
.tsc
, "tsc ", false);
130 show_flag(buffer
, hardware
->cpu
.flags
.msr
, "msr ", false);
131 show_flag(buffer
, hardware
->cpu
.flags
.pae
, "pae ", false);
132 show_flag(buffer
, hardware
->cpu
.flags
.mce
, "mce ", false);
133 show_flag(buffer
, hardware
->cpu
.flags
.cx8
, "cx8 ", false);
134 show_flag(buffer
, hardware
->cpu
.flags
.apic
, "apic ", false);
135 show_flag(buffer
, hardware
->cpu
.flags
.sep
, "sep ", false);
136 show_flag(buffer
, hardware
->cpu
.flags
.mtrr
, "mtrr ", false);
137 show_flag(buffer
, hardware
->cpu
.flags
.pge
, "pge ", false);
138 show_flag(buffer
, hardware
->cpu
.flags
.mca
, "mca ", false);
139 show_flag(buffer
, hardware
->cpu
.flags
.cmov
, "cmov ", false);
140 show_flag(buffer
, hardware
->cpu
.flags
.pat
, "pat ", false);
141 show_flag(buffer
, hardware
->cpu
.flags
.pse_36
, "pse_36 ", false);
142 show_flag(buffer
, hardware
->cpu
.flags
.psn
, "psn ", false);
143 show_flag(buffer
, hardware
->cpu
.flags
.clflsh
, "clflsh ", false);
144 show_flag(buffer
, hardware
->cpu
.flags
.dts
, "dts ", false);
145 show_flag(buffer
, hardware
->cpu
.flags
.acpi
, "acpi ", false);
146 show_flag(buffer
, hardware
->cpu
.flags
.mmx
, "mmx ", false);
147 show_flag(buffer
, hardware
->cpu
.flags
.sse
, "sse ", false);
148 show_flag(buffer
, hardware
->cpu
.flags
.sse2
, "sse2 ", false);
149 show_flag(buffer
, hardware
->cpu
.flags
.ss
, "ss ", false);
150 show_flag(buffer
, hardware
->cpu
.flags
.htt
, "ht ", false);
151 show_flag(buffer
, hardware
->cpu
.flags
.acc
, "acc ", false);
152 show_flag(buffer
, hardware
->cpu
.flags
.syscall
, "syscall ", false);
153 show_flag(buffer
, hardware
->cpu
.flags
.mp
, "mp ", false);
154 show_flag(buffer
, hardware
->cpu
.flags
.nx
, "nx ", false);
155 show_flag(buffer
, hardware
->cpu
.flags
.mmxext
, "mmxext ", false);
156 show_flag(buffer
, hardware
->cpu
.flags
.lm
, "lm ", false);
157 show_flag(buffer
, hardware
->cpu
.flags
.nowext
, "3dnowext ", false);
158 show_flag(buffer
, hardware
->cpu
.flags
.now
, "3dnow! ", false);
159 show_flag(buffer
, hardware
->cpu
.flags
.svm
, "svm ", false);
160 show_flag(buffer
, hardware
->cpu
.flags
.vmx
, "vmx ", false);
161 show_flag(buffer
, hardware
->cpu
.flags
.pbe
, "pbe ", false);
162 show_flag(buffer
, hardware
->cpu
.flags
.fxsr_opt
, "fxsr_opt ", false);
163 show_flag(buffer
, hardware
->cpu
.flags
.gbpages
, "gbpages ", false);
164 show_flag(buffer
, hardware
->cpu
.flags
.rdtscp
, "rdtscp ", false);
165 show_flag(buffer
, hardware
->cpu
.flags
.pni
, "pni ", false);
166 show_flag(buffer
, hardware
->cpu
.flags
.pclmulqd
, "pclmulqd ", false);
167 show_flag(buffer
, hardware
->cpu
.flags
.dtes64
, "dtes64 ", false);
168 show_flag(buffer
, hardware
->cpu
.flags
.smx
, "smx ", false);
169 show_flag(buffer
, hardware
->cpu
.flags
.est
, "est ", false);
170 show_flag(buffer
, hardware
->cpu
.flags
.tm2
, "tm2 ", false);
171 show_flag(buffer
, hardware
->cpu
.flags
.sse3
, "sse3 ", false);
172 show_flag(buffer
, hardware
->cpu
.flags
.fma
, "fma ", false);
173 show_flag(buffer
, hardware
->cpu
.flags
.cx16
, "cx16 ", false);
174 show_flag(buffer
, hardware
->cpu
.flags
.xtpr
, "xtpr ", false);
175 show_flag(buffer
, hardware
->cpu
.flags
.pdcm
, "pdcm ", false);
176 show_flag(buffer
, hardware
->cpu
.flags
.dca
, "dca ", false);
177 show_flag(buffer
, hardware
->cpu
.flags
.xmm4_1
, "xmm4_1 ", false);
178 show_flag(buffer
, hardware
->cpu
.flags
.xmm4_2
, "xmm4_2 ", false);
179 show_flag(buffer
, hardware
->cpu
.flags
.x2apic
, "x2apic ", false);
180 show_flag(buffer
, hardware
->cpu
.flags
.movbe
, "movbe ", false);
181 show_flag(buffer
, hardware
->cpu
.flags
.popcnt
, "popcnt ", false);
182 show_flag(buffer
, hardware
->cpu
.flags
.aes
, "aes ", false);
183 show_flag(buffer
, hardware
->cpu
.flags
.xsave
, "xsave ", false);
184 show_flag(buffer
, hardware
->cpu
.flags
.osxsave
, "osxsave ", false);
185 show_flag(buffer
, hardware
->cpu
.flags
.avx
, "avx ", false);
186 show_flag(buffer
, hardware
->cpu
.flags
.hypervisor
, "hypervisor ", false);
187 show_flag(buffer
, hardware
->cpu
.flags
.ace2
, "ace2 ", false);
188 show_flag(buffer
, hardware
->cpu
.flags
.ace2_en
, "ace2_en ", false);
189 show_flag(buffer
, hardware
->cpu
.flags
.phe
, "phe ", false);
190 show_flag(buffer
, hardware
->cpu
.flags
.phe_en
, "phe_en ", false);
191 show_flag(buffer
, hardware
->cpu
.flags
.pmm
, "pmm ", false);
192 show_flag(buffer
, hardware
->cpu
.flags
.pmm_en
, "pmm_en ", false);
193 show_flag(buffer
, hardware
->cpu
.flags
.extapic
, "extapic ", false);
194 show_flag(buffer
, hardware
->cpu
.flags
.cr8_legacy
, "cr8_legacy ", false);
195 show_flag(buffer
, hardware
->cpu
.flags
.abm
, "abm ", false);
196 show_flag(buffer
, hardware
->cpu
.flags
.sse4a
, "sse4a ", false);
197 show_flag(buffer
, hardware
->cpu
.flags
.misalignsse
, "misalignsse ", false);
198 show_flag(buffer
, hardware
->cpu
.flags
.nowprefetch
, "3dnowprefetch ", false);
199 show_flag(buffer
, hardware
->cpu
.flags
.osvw
, "osvw ", false);
200 show_flag(buffer
, hardware
->cpu
.flags
.ibs
, "ibs ", false);
201 show_flag(buffer
, hardware
->cpu
.flags
.sse5
, "sse5 ", false);
202 show_flag(buffer
, hardware
->cpu
.flags
.skinit
, "skinit ", false);
203 show_flag(buffer
, hardware
->cpu
.flags
.wdt
, "wdt ", false);
204 show_flag(buffer
, hardware
->cpu
.flags
.ida
, "ida ", false);
205 show_flag(buffer
, hardware
->cpu
.flags
.arat
, "arat ", false);
206 show_flag(buffer
, hardware
->cpu
.flags
.tpr_shadow
, "tpr_shadow ", false);
207 show_flag(buffer
, hardware
->cpu
.flags
.vnmi
, "vnmi ", false);
208 show_flag(buffer
, hardware
->cpu
.flags
.flexpriority
, "flexpriority ", false);
209 show_flag(buffer
, hardware
->cpu
.flags
.ept
, "ept ", false);
210 show_flag(buffer
, hardware
->cpu
.flags
.vpid
, "vpid ", false);
212 /* Let's flush the remaining flags */
213 show_flag(buffer
, false, "", true);
216 struct cli_module_descr cpu_show_modules
= {
218 .default_callback
= show_cpu
,
221 struct cli_mode_descr cpu_mode
= {
224 .default_modules
= NULL
,
225 .show_modules
= &cpu_show_modules
,