]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Application/Cpuid/Cpuid.c
BaseTools: Update sign tool to make MonotonicCount *after* Payload
[mirror_edk2.git] / UefiCpuPkg / Application / Cpuid / Cpuid.c
CommitLineData
25705752
MK
1/** @file\r
2 UEFI Application to display CPUID leaf information.\r
3\r
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <Uefi.h>\r
16#include <Library/BaseLib.h>\r
17#include <Library/UefiLib.h>\r
18#include <Register/Cpuid.h>\r
19\r
20///\r
21/// Macro used to display the value of a bit field in a register returned by CPUID.\r
22///\r
23#define PRINT_BIT_FIELD(Variable, FieldName) \\r
d2ba6f41 24 Print (L"%5a%42a: %x\n", #Variable, #FieldName, Variable.Bits.FieldName);\r
25705752
MK
25\r
26///\r
27/// Macro used to display the value of a register returned by CPUID.\r
28///\r
29#define PRINT_VALUE(Variable, Description) \\r
30 Print (L"%5a%42a: %x\n", #Variable, #Description, Variable);\r
31\r
32///\r
33/// Structure for cache description lookup table\r
34///\r
35typedef struct {\r
36 UINT8 CacheDescriptor;\r
37 CHAR8 *Type;\r
38 CHAR8 *Description;\r
39} CPUID_CACHE_INFO_DESCRIPTION;\r
40\r
41///\r
42/// Cache description lookup table\r
43///\r
44CPUID_CACHE_INFO_DESCRIPTION mCpuidCacheInfoDescription[] = {\r
45 { 0x00 , "General" , "Null descriptor, this byte contains no information" },\r
46 { 0x01 , "TLB" , "Instruction TLB: 4 KByte pages, 4-way set associative, 32 entries" },\r
47 { 0x02 , "TLB" , "Instruction TLB: 4 MByte pages, fully associative, 2 entries" },\r
48 { 0x03 , "TLB" , "Data TLB: 4 KByte pages, 4-way set associative, 64 entries" },\r
49 { 0x04 , "TLB" , "Data TLB: 4 MByte pages, 4-way set associative, 8 entries" },\r
50 { 0x05 , "TLB" , "Data TLB1: 4 MByte pages, 4-way set associative, 32 entries" },\r
51 { 0x06 , "Cache" , "1st-level instruction cache: 8 KBytes, 4-way set associative, 32 byte line size" },\r
52 { 0x08 , "Cache" , "1st-level instruction cache: 16 KBytes, 4-way set associative, 32 byte line size" },\r
53 { 0x09 , "Cache" , "1st-level instruction cache: 32KBytes, 4-way set associative, 64 byte line size" },\r
54 { 0x0A , "Cache" , "1st-level data cache: 8 KBytes, 2-way set associative, 32 byte line size" },\r
55 { 0x0B , "TLB" , "Instruction TLB: 4 MByte pages, 4-way set associative, 4 entries" },\r
56 { 0x0C , "Cache" , "1st-level data cache: 16 KBytes, 4-way set associative, 32 byte line size" },\r
57 { 0x0D , "Cache" , "1st-level data cache: 16 KBytes, 4-way set associative, 64 byte line size" },\r
58 { 0x0E , "Cache" , "1st-level data cache: 24 KBytes, 6-way set associative, 64 byte line size" },\r
59 { 0x1D , "Cache" , "2nd-level cache: 128 KBytes, 2-way set associative, 64 byte line size" },\r
60 { 0x21 , "Cache" , "2nd-level cache: 256 KBytes, 8-way set associative, 64 byte line size" },\r
61 { 0x22 , "Cache" , "3rd-level cache: 512 KBytes, 4-way set associative, 64 byte line size, 2 lines per sector" },\r
62 { 0x23 , "Cache" , "3rd-level cache: 1 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" },\r
63 { 0x24 , "Cache" , "2nd-level cache: 1 MBytes, 16-way set associative, 64 byte line size" },\r
64 { 0x25 , "Cache" , "3rd-level cache: 2 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" },\r
65 { 0x29 , "Cache" , "3rd-level cache: 4 MBytes, 8-way set associative, 64 byte line size, 2 lines per sector" },\r
66 { 0x2C , "Cache" , "1st-level data cache: 32 KBytes, 8-way set associative, 64 byte line size" },\r
67 { 0x30 , "Cache" , "1st-level instruction cache: 32 KBytes, 8-way set associative, 64 byte line size" },\r
68 { 0x40 , "Cache" , "No 2nd-level cache or, if processor contains a valid 2nd-level cache, no 3rd-level cache" },\r
69 { 0x41 , "Cache" , "2nd-level cache: 128 KBytes, 4-way set associative, 32 byte line size" },\r
70 { 0x42 , "Cache" , "2nd-level cache: 256 KBytes, 4-way set associative, 32 byte line size" },\r
71 { 0x43 , "Cache" , "2nd-level cache: 512 KBytes, 4-way set associative, 32 byte line size" },\r
72 { 0x44 , "Cache" , "2nd-level cache: 1 MByte, 4-way set associative, 32 byte line size" },\r
73 { 0x45 , "Cache" , "2nd-level cache: 2 MByte, 4-way set associative, 32 byte line size" },\r
74 { 0x46 , "Cache" , "3rd-level cache: 4 MByte, 4-way set associative, 64 byte line size" },\r
75 { 0x47 , "Cache" , "3rd-level cache: 8 MByte, 8-way set associative, 64 byte line size" },\r
76 { 0x48 , "Cache" , "2nd-level cache: 3MByte, 12-way set associative, 64 byte line size" },\r
77 { 0x49 , "Cache" , "3rd-level cache: 4MB, 16-way set associative, 64-byte line size (Intel Xeon processor MP, Family 0FH, Model 06H). 2nd-level cache: 4 MByte, 16-way set associative, 64 byte line size" },\r
78 { 0x4A , "Cache" , "3rd-level cache: 6MByte, 12-way set associative, 64 byte line size" },\r
79 { 0x4B , "Cache" , "3rd-level cache: 8MByte, 16-way set associative, 64 byte line size" },\r
80 { 0x4C , "Cache" , "3rd-level cache: 12MByte, 12-way set associative, 64 byte line size" },\r
81 { 0x4D , "Cache" , "3rd-level cache: 16MByte, 16-way set associative, 64 byte line size" },\r
82 { 0x4E , "Cache" , "2nd-level cache: 6MByte, 24-way set associative, 64 byte line size" },\r
83 { 0x4F , "TLB" , "Instruction TLB: 4 KByte pages, 32 entries" },\r
84 { 0x50 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 64 entries" },\r
85 { 0x51 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 128 entries" },\r
86 { 0x52 , "TLB" , "Instruction TLB: 4 KByte and 2-MByte or 4-MByte pages, 256 entries" },\r
87 { 0x55 , "TLB" , "Instruction TLB: 2-MByte or 4-MByte pages, fully associative, 7 entries" },\r
88 { 0x56 , "TLB" , "Data TLB0: 4 MByte pages, 4-way set associative, 16 entries" },\r
89 { 0x57 , "TLB" , "Data TLB0: 4 KByte pages, 4-way associative, 16 entries" },\r
90 { 0x59 , "TLB" , "Data TLB0: 4 KByte pages, fully associative, 16 entries" },\r
91 { 0x5A , "TLB" , "Data TLB0: 2-MByte or 4 MByte pages, 4-way set associative, 32 entries" },\r
92 { 0x5B , "TLB" , "Data TLB: 4 KByte and 4 MByte pages, 64 entries" },\r
93 { 0x5C , "TLB" , "Data TLB: 4 KByte and 4 MByte pages,128 entries" },\r
94 { 0x5D , "TLB" , "Data TLB: 4 KByte and 4 MByte pages,256 entries" },\r
95 { 0x60 , "Cache" , "1st-level data cache: 16 KByte, 8-way set associative, 64 byte line size" },\r
96 { 0x61 , "TLB" , "Instruction TLB: 4 KByte pages, fully associative, 48 entries" },\r
97 { 0x63 , "TLB" , "Data TLB: 1 GByte pages, 4-way set associative, 4 entries" },\r
98 { 0x66 , "Cache" , "1st-level data cache: 8 KByte, 4-way set associative, 64 byte line size" },\r
99 { 0x67 , "Cache" , "1st-level data cache: 16 KByte, 4-way set associative, 64 byte line size" },\r
100 { 0x68 , "Cache" , "1st-level data cache: 32 KByte, 4-way set associative, 64 byte line size" },\r
101 { 0x6A , "Cache" , "uTLB: 4 KByte pages, 8-way set associative, 64 entries" },\r
102 { 0x6B , "Cache" , "DTLB: 4 KByte pages, 8-way set associative, 256 entries" },\r
103 { 0x6C , "Cache" , "DTLB: 2M/4M pages, 8-way set associative, 128 entries" },\r
104 { 0x6D , "Cache" , "DTLB: 1 GByte pages, fully associative, 16 entries" },\r
105 { 0x70 , "Cache" , "Trace cache: 12 K-uop, 8-way set associative" },\r
106 { 0x71 , "Cache" , "Trace cache: 16 K-uop, 8-way set associative" },\r
107 { 0x72 , "Cache" , "Trace cache: 32 K-uop, 8-way set associative" },\r
108 { 0x76 , "TLB" , "Instruction TLB: 2M/4M pages, fully associative, 8 entries" },\r
109 { 0x78 , "Cache" , "2nd-level cache: 1 MByte, 4-way set associative, 64byte line size" },\r
110 { 0x79 , "Cache" , "2nd-level cache: 128 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" },\r
111 { 0x7A , "Cache" , "2nd-level cache: 256 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" },\r
112 { 0x7B , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 64 byte line size, 2 lines per sector" },\r
113 { 0x7C , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size, 2 lines per sector" },\r
114 { 0x7D , "Cache" , "2nd-level cache: 2 MByte, 8-way set associative, 64byte line size" },\r
115 { 0x7F , "Cache" , "2nd-level cache: 512 KByte, 2-way set associative, 64-byte line size" },\r
116 { 0x80 , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 64-byte line size" },\r
117 { 0x82 , "Cache" , "2nd-level cache: 256 KByte, 8-way set associative, 32 byte line size" },\r
118 { 0x83 , "Cache" , "2nd-level cache: 512 KByte, 8-way set associative, 32 byte line size" },\r
119 { 0x84 , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 32 byte line size" },\r
120 { 0x85 , "Cache" , "2nd-level cache: 2 MByte, 8-way set associative, 32 byte line size" },\r
121 { 0x86 , "Cache" , "2nd-level cache: 512 KByte, 4-way set associative, 64 byte line size" },\r
122 { 0x87 , "Cache" , "2nd-level cache: 1 MByte, 8-way set associative, 64 byte line size" },\r
123 { 0xA0 , "DTLB" , "DTLB: 4k pages, fully associative, 32 entries" },\r
124 { 0xB0 , "TLB" , "Instruction TLB: 4 KByte pages, 4-way set associative, 128 entries" },\r
125 { 0xB1 , "TLB" , "Instruction TLB: 2M pages, 4-way, 8 entries or 4M pages, 4-way, 4 entries" },\r
126 { 0xB2 , "TLB" , "Instruction TLB: 4KByte pages, 4-way set associative, 64 entries" },\r
127 { 0xB3 , "TLB" , "Data TLB: 4 KByte pages, 4-way set associative, 128 entries" },\r
128 { 0xB4 , "TLB" , "Data TLB1: 4 KByte pages, 4-way associative, 256 entries" },\r
129 { 0xB5 , "TLB" , "Instruction TLB: 4KByte pages, 8-way set associative, 64 entries" },\r
130 { 0xB6 , "TLB" , "Instruction TLB: 4KByte pages, 8-way set associative, 128 entries" },\r
131 { 0xBA , "TLB" , "Data TLB1: 4 KByte pages, 4-way associative, 64 entries" },\r
132 { 0xC0 , "TLB" , "Data TLB: 4 KByte and 4 MByte pages, 4-way associative, 8 entries" },\r
133 { 0xC1 , "STLB" , "Shared 2nd-Level TLB: 4 KByte/2MByte pages, 8-way associative, 1024 entries" },\r
134 { 0xC2 , "DTLB" , "DTLB: 4 KByte/2 MByte pages, 4-way associative, 16 entries" },\r
135 { 0xC3 , "STLB" , "Shared 2nd-Level TLB: 4 KByte /2 MByte pages, 6-way associative, 1536 entries. Also 1GBbyte pages, 4-way, 16 entries." },\r
136 { 0xCA , "STLB" , "Shared 2nd-Level TLB: 4 KByte pages, 4-way associative, 512 entries" },\r
137 { 0xD0 , "Cache" , "3rd-level cache: 512 KByte, 4-way set associative, 64 byte line size" },\r
138 { 0xD1 , "Cache" , "3rd-level cache: 1 MByte, 4-way set associative, 64 byte line size" },\r
139 { 0xD2 , "Cache" , "3rd-level cache: 2 MByte, 4-way set associative, 64 byte line size" },\r
140 { 0xD6 , "Cache" , "3rd-level cache: 1 MByte, 8-way set associative, 64 byte line size" },\r
141 { 0xD7 , "Cache" , "3rd-level cache: 2 MByte, 8-way set associative, 64 byte line size" },\r
142 { 0xD8 , "Cache" , "3rd-level cache: 4 MByte, 8-way set associative, 64 byte line size" },\r
143 { 0xDC , "Cache" , "3rd-level cache: 1.5 MByte, 12-way set associative, 64 byte line size" },\r
144 { 0xDD , "Cache" , "3rd-level cache: 3 MByte, 12-way set associative, 64 byte line size" },\r
145 { 0xDE , "Cache" , "3rd-level cache: 6 MByte, 12-way set associative, 64 byte line size" },\r
146 { 0xE2 , "Cache" , "3rd-level cache: 2 MByte, 16-way set associative, 64 byte line size" },\r
147 { 0xE3 , "Cache" , "3rd-level cache: 4 MByte, 16-way set associative, 64 byte line size" },\r
148 { 0xE4 , "Cache" , "3rd-level cache: 8 MByte, 16-way set associative, 64 byte line size" },\r
149 { 0xEA , "Cache" , "3rd-level cache: 12MByte, 24-way set associative, 64 byte line size" },\r
150 { 0xEB , "Cache" , "3rd-level cache: 18MByte, 24-way set associative, 64 byte line size" },\r
151 { 0xEC , "Cache" , "3rd-level cache: 24MByte, 24-way set associative, 64 byte line size" },\r
152 { 0xF0 , "Prefetch" , "64-Byte prefetching" },\r
153 { 0xF1 , "Prefetch" , "128-Byte prefetching" },\r
154 { 0xFF , "General" , "CPUID leaf 2 does not report cache descriptor information, use CPUID leaf 4 to query cache parameters" }\r
155};\r
156\r
157///\r
158/// The maximum supported CPUID leaf index starting from leaf 0x00000000.\r
159///\r
160UINT32 gMaximumBasicFunction = CPUID_SIGNATURE;\r
161\r
162///\r
163/// The maximum supported CPUID leaf index starting from leaf 0x80000000.\r
164///\r
165UINT32 gMaximumExtendedFunction = CPUID_EXTENDED_FUNCTION;\r
166\r
167/**\r
168 Display CPUID_SIGNATURE leaf.\r
169\r
170**/\r
171VOID\r
172CpuidSignature (\r
173 VOID\r
174 )\r
175{\r
176 UINT32 Eax;\r
177 UINT32 Ebx;\r
178 UINT32 Ecx;\r
179 UINT32 Edx;\r
180 CHAR8 Signature[13];\r
181\r
25705752
MK
182 AsmCpuid (CPUID_SIGNATURE, &Eax, &Ebx, &Ecx, &Edx);\r
183\r
184 Print (L"CPUID_SIGNATURE (Leaf %08x)\n", CPUID_SIGNATURE);\r
185 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, Edx);\r
186 PRINT_VALUE (Eax, MaximumLeaf);\r
187 *(UINT32 *)(Signature + 0) = Ebx;\r
188 *(UINT32 *)(Signature + 4) = Edx;\r
189 *(UINT32 *)(Signature + 8) = Ecx;\r
190 Signature [12] = 0;\r
191 Print (L" Signature = %a\n", Signature);\r
192\r
193 gMaximumBasicFunction = Eax;\r
194}\r
195\r
196/**\r
197 Display CPUID_VERSION_INFO leaf.\r
198\r
199**/\r
200VOID\r
201CpuidVersionInfo (\r
202 VOID\r
203 )\r
204{\r
205 CPUID_VERSION_INFO_EAX Eax;\r
206 CPUID_VERSION_INFO_EBX Ebx;\r
207 CPUID_VERSION_INFO_ECX Ecx;\r
208 CPUID_VERSION_INFO_EDX Edx;\r
5a676df9
JF
209 UINT32 DisplayFamily;\r
210 UINT32 DisplayModel;\r
25705752 211\r
321ef72c
JF
212 if (CPUID_VERSION_INFO > gMaximumBasicFunction) {\r
213 return;\r
214 }\r
215\r
25705752
MK
216 AsmCpuid (CPUID_VERSION_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32);\r
217\r
218 Print (L"CPUID_VERSION_INFO (Leaf %08x)\n", CPUID_VERSION_INFO);\r
219 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
220\r
221 DisplayFamily = Eax.Bits.FamilyId;\r
222 if (Eax.Bits.FamilyId == 0x0F) {\r
223 DisplayFamily |= (Eax.Bits.ExtendedFamilyId << 4);\r
224 }\r
225\r
226 DisplayModel = Eax.Bits.Model;\r
227 if (Eax.Bits.FamilyId == 0x06 || Eax.Bits.FamilyId == 0x0f) {\r
228 DisplayModel |= (Eax.Bits.ExtendedModelId << 4);\r
229 }\r
230\r
231 Print (L" Family = %x Model = %x Stepping = %x\n", DisplayFamily, DisplayModel, Eax.Bits.SteppingId);\r
232\r
233 PRINT_BIT_FIELD (Eax, SteppingId);\r
234 PRINT_BIT_FIELD (Eax, Model);\r
235 PRINT_BIT_FIELD (Eax, FamilyId);\r
236 PRINT_BIT_FIELD (Eax, ProcessorType);\r
237 PRINT_BIT_FIELD (Eax, ExtendedModelId);\r
238 PRINT_BIT_FIELD (Eax, ExtendedFamilyId);\r
239 PRINT_BIT_FIELD (Ebx, BrandIndex);\r
240 PRINT_BIT_FIELD (Ebx, CacheLineSize);\r
241 PRINT_BIT_FIELD (Ebx, MaximumAddressableIdsForLogicalProcessors);\r
242 PRINT_BIT_FIELD (Ebx, InitialLocalApicId);\r
243 PRINT_BIT_FIELD (Ecx, SSE3);\r
244 PRINT_BIT_FIELD (Ecx, PCLMULQDQ);\r
245 PRINT_BIT_FIELD (Ecx, DTES64);\r
246 PRINT_BIT_FIELD (Ecx, MONITOR);\r
247 PRINT_BIT_FIELD (Ecx, DS_CPL);\r
248 PRINT_BIT_FIELD (Ecx, VMX);\r
249 PRINT_BIT_FIELD (Ecx, SMX);\r
250 PRINT_BIT_FIELD (Ecx, TM2);\r
251 PRINT_BIT_FIELD (Ecx, SSSE3);\r
252 PRINT_BIT_FIELD (Ecx, CNXT_ID);\r
253 PRINT_BIT_FIELD (Ecx, SDBG);\r
254 PRINT_BIT_FIELD (Ecx, FMA);\r
255 PRINT_BIT_FIELD (Ecx, CMPXCHG16B);\r
256 PRINT_BIT_FIELD (Ecx, xTPR_Update_Control);\r
257 PRINT_BIT_FIELD (Ecx, PDCM);\r
258 PRINT_BIT_FIELD (Ecx, PCID);\r
259 PRINT_BIT_FIELD (Ecx, DCA);\r
260 PRINT_BIT_FIELD (Ecx, SSE4_1);\r
261 PRINT_BIT_FIELD (Ecx, SSE4_2);\r
262 PRINT_BIT_FIELD (Ecx, x2APIC);\r
263 PRINT_BIT_FIELD (Ecx, MOVBE);\r
264 PRINT_BIT_FIELD (Ecx, POPCNT);\r
265 PRINT_BIT_FIELD (Ecx, TSC_Deadline);\r
266 PRINT_BIT_FIELD (Ecx, AESNI);\r
267 PRINT_BIT_FIELD (Ecx, XSAVE);\r
268 PRINT_BIT_FIELD (Ecx, OSXSAVE);\r
269 PRINT_BIT_FIELD (Ecx, AVX);\r
270 PRINT_BIT_FIELD (Ecx, F16C);\r
271 PRINT_BIT_FIELD (Ecx, RDRAND);\r
272 PRINT_BIT_FIELD (Edx, FPU);\r
273 PRINT_BIT_FIELD (Edx, VME);\r
274 PRINT_BIT_FIELD (Edx, DE);\r
275 PRINT_BIT_FIELD (Edx, PSE);\r
276 PRINT_BIT_FIELD (Edx, TSC);\r
277 PRINT_BIT_FIELD (Edx, MSR);\r
278 PRINT_BIT_FIELD (Edx, PAE);\r
279 PRINT_BIT_FIELD (Edx, MCE);\r
280 PRINT_BIT_FIELD (Edx, CX8);\r
281 PRINT_BIT_FIELD (Edx, APIC);\r
282 PRINT_BIT_FIELD (Edx, SEP);\r
283 PRINT_BIT_FIELD (Edx, MTRR);\r
284 PRINT_BIT_FIELD (Edx, PGE);\r
285 PRINT_BIT_FIELD (Edx, MCA);\r
286 PRINT_BIT_FIELD (Edx, CMOV);\r
287 PRINT_BIT_FIELD (Edx, PAT);\r
288 PRINT_BIT_FIELD (Edx, PSE_36);\r
289 PRINT_BIT_FIELD (Edx, PSN);\r
290 PRINT_BIT_FIELD (Edx, CLFSH);\r
291 PRINT_BIT_FIELD (Edx, DS);\r
292 PRINT_BIT_FIELD (Edx, ACPI);\r
293 PRINT_BIT_FIELD (Edx, MMX);\r
294 PRINT_BIT_FIELD (Edx, FXSR);\r
295 PRINT_BIT_FIELD (Edx, SSE);\r
296 PRINT_BIT_FIELD (Edx, SSE2);\r
297 PRINT_BIT_FIELD (Edx, SS);\r
298 PRINT_BIT_FIELD (Edx, HTT);\r
299 PRINT_BIT_FIELD (Edx, TM);\r
300 PRINT_BIT_FIELD (Edx, PBE);\r
301}\r
302\r
303/**\r
304 Lookup a cache description string from the mCpuidCacheInfoDescription table.\r
305\r
306 @param[in] CacheDescriptor Cache descriptor value from CPUID_CACHE_INFO.\r
307\r
308**/\r
309CPUID_CACHE_INFO_DESCRIPTION *\r
310LookupCacheDescription (\r
311 UINT8 CacheDescriptor\r
312 )\r
313{\r
314 UINTN NumDescriptors;\r
315 UINTN Descriptor;\r
316\r
317 if (CacheDescriptor == 0x00) {\r
318 return NULL;\r
319 }\r
320 NumDescriptors = sizeof (mCpuidCacheInfoDescription)/sizeof (mCpuidCacheInfoDescription[0]);\r
321 for (Descriptor = 0; Descriptor < NumDescriptors; Descriptor++) {\r
322 if (CacheDescriptor == mCpuidCacheInfoDescription[Descriptor].CacheDescriptor) {\r
323 return &mCpuidCacheInfoDescription[Descriptor];\r
324 }\r
325 }\r
326 return NULL;\r
327}\r
328\r
329/**\r
330 Display CPUID_CACHE_INFO leaf for each supported cache descriptor.\r
331\r
332**/\r
333VOID\r
334CpuidCacheInfo (\r
335 VOID\r
336 )\r
337{\r
338 CPUID_CACHE_INFO_CACHE_TLB Eax;\r
339 CPUID_CACHE_INFO_CACHE_TLB Ebx;\r
340 CPUID_CACHE_INFO_CACHE_TLB Ecx;\r
341 CPUID_CACHE_INFO_CACHE_TLB Edx;\r
342 UINTN Index;\r
343 CPUID_CACHE_INFO_DESCRIPTION *CacheDescription;\r
344\r
345 if (CPUID_CACHE_INFO > gMaximumBasicFunction) {\r
346 return;\r
347 }\r
348\r
349 AsmCpuid (CPUID_CACHE_INFO, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32);\r
350\r
351 Print (L"CPUID_CACHE_INFO (Leaf %08x)\n", CPUID_CACHE_INFO);\r
352 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
353 if (Eax.Bits.NotValid == 0) {\r
354 //\r
355 // Process Eax.CacheDescriptor[1..3]. Ignore Eax.CacheDescriptor[0]\r
356 //\r
357 for (Index = 1; Index < 4; Index++) {\r
358 CacheDescription = LookupCacheDescription (Eax.CacheDescriptor[Index]);\r
359 if (CacheDescription != NULL) {\r
360 Print (L" %-8a %a\n",\r
361 CacheDescription->Type,\r
362 CacheDescription->Description\r
363 );\r
364 }\r
365 }\r
366 }\r
367 if (Ebx.Bits.NotValid == 0) {\r
368 //\r
369 // Process Ebx.CacheDescriptor[0..3]\r
370 //\r
371 for (Index = 0; Index < 4; Index++) {\r
372 CacheDescription = LookupCacheDescription (Ebx.CacheDescriptor[Index]);\r
373 if (CacheDescription != NULL) {\r
374 Print (L" %-8a %a\n",\r
375 CacheDescription->Type,\r
376 CacheDescription->Description\r
377 );\r
378 }\r
379 }\r
380 }\r
381 if (Ecx.Bits.NotValid == 0) {\r
382 //\r
383 // Process Ecx.CacheDescriptor[0..3]\r
384 //\r
385 for (Index = 0; Index < 4; Index++) {\r
386 CacheDescription = LookupCacheDescription (Ecx.CacheDescriptor[Index]);\r
387 if (CacheDescription != NULL) {\r
388 Print (L" %-8a %a\n",\r
389 CacheDescription->Type,\r
390 CacheDescription->Description\r
391 );\r
392 }\r
393 }\r
394 }\r
395 if (Edx.Bits.NotValid == 0) {\r
396 //\r
397 // Process Edx.CacheDescriptor[0..3]\r
398 //\r
399 for (Index = 0; Index < 4; Index++) {\r
400 CacheDescription = LookupCacheDescription (Edx.CacheDescriptor[Index]);\r
401 if (CacheDescription != NULL) {\r
402 Print (L" %-8a %a\n",\r
403 CacheDescription->Type,\r
404 CacheDescription->Description\r
405 );\r
406 }\r
407 }\r
408 }\r
409}\r
410\r
411/**\r
412 Display CPUID_SERIAL_NUMBER leaf if it is supported.\r
413\r
414**/\r
415VOID\r
416CpuidSerialNumber (\r
417 VOID\r
418 )\r
419{\r
420 CPUID_VERSION_INFO_EDX VersionInfoEdx;\r
421 UINT32 Ecx;\r
422 UINT32 Edx;\r
423\r
424 Print (L"CPUID_SERIAL_NUMBER (Leaf %08x)\n", CPUID_SERIAL_NUMBER);\r
425\r
426 if (CPUID_SERIAL_NUMBER > gMaximumBasicFunction) {\r
427 return;\r
428 }\r
429\r
430 AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, NULL, &VersionInfoEdx.Uint32);\r
431 if (VersionInfoEdx.Bits.PSN == 0) {\r
432 Print (L" Not Supported\n");\r
433 return;\r
434 }\r
435\r
436 AsmCpuid (CPUID_SERIAL_NUMBER, NULL, NULL, &Ecx, &Edx);\r
437 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, Ecx, Edx);\r
438 Print (L" Processor Serial Number = %08x%08x%08x\n", 0, Edx, Ecx);\r
439}\r
440\r
441/**\r
442 Display CPUID_CACHE_PARAMS for all supported sub-leafs.\r
443\r
444**/\r
445VOID\r
446CpuidCacheParams (\r
447 VOID\r
448 )\r
449{\r
450 UINT32 CacheLevel;\r
451 CPUID_CACHE_PARAMS_EAX Eax;\r
452 CPUID_CACHE_PARAMS_EBX Ebx;\r
453 UINT32 Ecx;\r
454 CPUID_CACHE_PARAMS_EDX Edx;\r
455\r
456 if (CPUID_CACHE_PARAMS > gMaximumBasicFunction) {\r
457 return;\r
458 }\r
459\r
460 CacheLevel = 0;\r
461 do {\r
462 AsmCpuidEx (\r
463 CPUID_CACHE_PARAMS, CacheLevel,\r
464 &Eax.Uint32, &Ebx.Uint32, &Ecx, &Edx.Uint32\r
465 );\r
466 if (Eax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL) {\r
467 Print (L"CPUID_CACHE_PARAMS (Leaf %08x, Sub-Leaf %08x)\n", CPUID_CACHE_PARAMS, CacheLevel);\r
468 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx, Edx.Uint32);\r
469 PRINT_BIT_FIELD (Eax, CacheType);\r
470 PRINT_BIT_FIELD (Eax, CacheLevel);\r
471 PRINT_BIT_FIELD (Eax, SelfInitializingCache);\r
472 PRINT_BIT_FIELD (Eax, FullyAssociativeCache);\r
473 PRINT_BIT_FIELD (Eax, MaximumAddressableIdsForLogicalProcessors);\r
474 PRINT_BIT_FIELD (Eax, MaximumAddressableIdsForProcessorCores);\r
475 PRINT_BIT_FIELD (Ebx, LineSize);\r
476 PRINT_BIT_FIELD (Ebx, LinePartitions);\r
477 PRINT_BIT_FIELD (Ebx, Ways);\r
478 PRINT_VALUE (Ecx, NumberOfSets);\r
479 PRINT_BIT_FIELD (Edx, Invalidate);\r
480 PRINT_BIT_FIELD (Edx, CacheInclusiveness);\r
481 PRINT_BIT_FIELD (Edx, ComplexCacheIndexing);\r
482 }\r
483 CacheLevel++;\r
484 } while (Eax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL);\r
485}\r
486\r
487/**\r
488 Display CPUID_MONITOR_MWAIT leaf.\r
489\r
490**/\r
491VOID\r
492CpuidMonitorMwait (\r
493 VOID\r
494 )\r
495{\r
496 CPUID_MONITOR_MWAIT_EAX Eax;\r
497 CPUID_MONITOR_MWAIT_EBX Ebx;\r
498 CPUID_MONITOR_MWAIT_ECX Ecx;\r
499 CPUID_MONITOR_MWAIT_EDX Edx;\r
500\r
501 if (CPUID_MONITOR_MWAIT > gMaximumBasicFunction) {\r
502 return;\r
503 }\r
504\r
505 AsmCpuid (CPUID_MONITOR_MWAIT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32);\r
506\r
507 Print (L"CPUID_MONITOR_MWAIT (Leaf %08x)\n", CPUID_MONITOR_MWAIT);\r
508 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
509\r
510 PRINT_BIT_FIELD (Eax, SmallestMonitorLineSize);\r
511 PRINT_BIT_FIELD (Ebx, LargestMonitorLineSize);\r
512 PRINT_BIT_FIELD (Ecx, ExtensionsSupported);\r
513 PRINT_BIT_FIELD (Ecx, InterruptAsBreak);\r
514 PRINT_BIT_FIELD (Edx, C0States);\r
515 PRINT_BIT_FIELD (Edx, C1States);\r
516 PRINT_BIT_FIELD (Edx, C2States);\r
517 PRINT_BIT_FIELD (Edx, C3States);\r
518 PRINT_BIT_FIELD (Edx, C4States);\r
519 PRINT_BIT_FIELD (Edx, C5States);\r
520 PRINT_BIT_FIELD (Edx, C6States);\r
521 PRINT_BIT_FIELD (Edx, C7States);\r
522}\r
523\r
524/**\r
525 Display CPUID_THERMAL_POWER_MANAGEMENT leaf.\r
526\r
527**/\r
528VOID\r
529CpuidThermalPowerManagement (\r
530 VOID\r
531 )\r
532{\r
533 CPUID_THERMAL_POWER_MANAGEMENT_EAX Eax;\r
534 CPUID_THERMAL_POWER_MANAGEMENT_EBX Ebx;\r
535 CPUID_THERMAL_POWER_MANAGEMENT_ECX Ecx;\r
536\r
537 if (CPUID_THERMAL_POWER_MANAGEMENT > gMaximumBasicFunction) {\r
538 return;\r
539 }\r
540\r
541 AsmCpuid (CPUID_THERMAL_POWER_MANAGEMENT, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL);\r
542\r
543 Print (L"CPUID_THERMAL_POWER_MANAGEMENT (Leaf %08x)\n", CPUID_THERMAL_POWER_MANAGEMENT);\r
544 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, 0);\r
545\r
546 PRINT_BIT_FIELD (Eax, DigitalTemperatureSensor);\r
547 PRINT_BIT_FIELD (Eax, TurboBoostTechnology);\r
548 PRINT_BIT_FIELD (Eax, ARAT);\r
549 PRINT_BIT_FIELD (Eax, PLN);\r
550 PRINT_BIT_FIELD (Eax, ECMD);\r
551 PRINT_BIT_FIELD (Eax, PTM);\r
552 PRINT_BIT_FIELD (Eax, HWP);\r
553 PRINT_BIT_FIELD (Eax, HWP_Notification);\r
554 PRINT_BIT_FIELD (Eax, HWP_Activity_Window);\r
555 PRINT_BIT_FIELD (Eax, HWP_Energy_Performance_Preference);\r
556 PRINT_BIT_FIELD (Eax, HWP_Package_Level_Request);\r
557 PRINT_BIT_FIELD (Eax, HDC);\r
558 PRINT_BIT_FIELD (Ebx, InterruptThresholds);\r
559 PRINT_BIT_FIELD (Ecx, HardwareCoordinationFeedback);\r
560 PRINT_BIT_FIELD (Ecx, PerformanceEnergyBias);\r
561}\r
562\r
563/**\r
564 Display CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS for all supported sub-leafs.\r
565\r
566**/\r
567VOID\r
568CpuidStructuredExtendedFeatureFlags (\r
569 VOID\r
570 )\r
571{\r
572 UINT32 Eax;\r
573 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX Ebx;\r
574 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_ECX Ecx;\r
575 UINT32 SubLeaf;\r
576\r
577 if (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS > gMaximumBasicFunction) {\r
578 return;\r
579 }\r
580\r
581 AsmCpuidEx (\r
582 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,\r
583 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO,\r
584 &Eax, NULL, NULL, NULL\r
585 );\r
586 for (SubLeaf = 0; SubLeaf <= Eax; SubLeaf++) {\r
587 AsmCpuidEx (\r
588 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,\r
589 SubLeaf,\r
590 NULL, &Ebx.Uint32, &Ecx.Uint32, NULL\r
591 );\r
592 if (Ebx.Uint32 != 0 || Ecx.Uint32 != 0) {\r
593 Print (L"CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS (Leaf %08x, Sub-Leaf %08x)\n", CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, SubLeaf);\r
594 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx.Uint32, 0);\r
595 PRINT_BIT_FIELD (Ebx, FSGSBASE);\r
596 PRINT_BIT_FIELD (Ebx, IA32_TSC_ADJUST);\r
f5a2d6f0 597 PRINT_BIT_FIELD (Ebx, SGX);\r
25705752
MK
598 PRINT_BIT_FIELD (Ebx, BMI1);\r
599 PRINT_BIT_FIELD (Ebx, HLE);\r
600 PRINT_BIT_FIELD (Ebx, AVX2);\r
601 PRINT_BIT_FIELD (Ebx, FDP_EXCPTN_ONLY);\r
602 PRINT_BIT_FIELD (Ebx, SMEP);\r
603 PRINT_BIT_FIELD (Ebx, BMI2);\r
604 PRINT_BIT_FIELD (Ebx, EnhancedRepMovsbStosb);\r
605 PRINT_BIT_FIELD (Ebx, INVPCID);\r
606 PRINT_BIT_FIELD (Ebx, RTM);\r
607 PRINT_BIT_FIELD (Ebx, PQM);\r
608 PRINT_BIT_FIELD (Ebx, DeprecateFpuCsDs);\r
609 PRINT_BIT_FIELD (Ebx, MPX);\r
610 PRINT_BIT_FIELD (Ebx, PQE);\r
611 PRINT_BIT_FIELD (Ebx, RDSEED);\r
612 PRINT_BIT_FIELD (Ebx, ADX);\r
613 PRINT_BIT_FIELD (Ebx, SMAP);\r
614 PRINT_BIT_FIELD (Ebx, CLFLUSHOPT);\r
615 PRINT_BIT_FIELD (Ebx, IntelProcessorTrace);\r
616 PRINT_BIT_FIELD (Ecx, PREFETCHWT1);\r
617 PRINT_BIT_FIELD (Ecx, PKU);\r
618 PRINT_BIT_FIELD (Ecx, OSPKE);\r
619 }\r
620 SubLeaf++;\r
621 } while (SubLeaf <= Eax);\r
622}\r
623\r
624/**\r
625 Display CPUID_DIRECT_CACHE_ACCESS_INFO leaf.\r
626\r
627**/\r
628VOID\r
629CpuidDirectCacheAccessInfo (\r
630 VOID\r
631 )\r
632{\r
633 UINT32 Eax;\r
634\r
635 if (CPUID_DIRECT_CACHE_ACCESS_INFO > gMaximumBasicFunction) {\r
636 return;\r
637 }\r
638\r
639 AsmCpuid (CPUID_DIRECT_CACHE_ACCESS_INFO, &Eax, NULL, NULL, NULL);\r
640 Print (L"CPUID_DIRECT_CACHE_ACCESS_INFO (Leaf %08x)\n", CPUID_DIRECT_CACHE_ACCESS_INFO);\r
641 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, 0, 0);\r
642}\r
643\r
644/**\r
645 Display CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING leaf.\r
646\r
647**/\r
648VOID\r
649CpuidArchitecturalPerformanceMonitoring (\r
650 VOID\r
651 )\r
652{\r
653 CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EAX Eax;\r
654 CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EBX Ebx;\r
655 CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING_EDX Edx;\r
656\r
657 if (CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING > gMaximumBasicFunction) {\r
658 return;\r
659 }\r
660\r
661 AsmCpuid (CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING, &Eax.Uint32, &Ebx.Uint32, NULL, &Edx.Uint32);\r
662 Print (L"CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING (Leaf %08x)\n", CPUID_ARCHITECTURAL_PERFORMANCE_MONITORING);\r
663 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, 0, Edx.Uint32);\r
664 PRINT_BIT_FIELD (Eax, ArchPerfMonVerID);\r
665 PRINT_BIT_FIELD (Eax, PerformanceMonitorCounters);\r
666 PRINT_BIT_FIELD (Eax, PerformanceMonitorCounterWidth);\r
667 PRINT_BIT_FIELD (Eax, EbxBitVectorLength);\r
668 PRINT_BIT_FIELD (Ebx, UnhaltedCoreCycles);\r
669 PRINT_BIT_FIELD (Ebx, InstructionsRetired);\r
670 PRINT_BIT_FIELD (Ebx, UnhaltedReferenceCycles);\r
671 PRINT_BIT_FIELD (Ebx, LastLevelCacheReferences);\r
672 PRINT_BIT_FIELD (Ebx, LastLevelCacheMisses);\r
673 PRINT_BIT_FIELD (Ebx, BranchInstructionsRetired);\r
674 PRINT_BIT_FIELD (Ebx, AllBranchMispredictRetired);\r
675 PRINT_BIT_FIELD (Edx, FixedFunctionPerformanceCounters);\r
676 PRINT_BIT_FIELD (Edx, FixedFunctionPerformanceCounterWidth);\r
677}\r
678\r
679/**\r
680 Display CPUID_EXTENDED_TOPOLOGY leafs for all supported levels.\r
681\r
682**/\r
683VOID\r
684CpuidExtendedTopology (\r
685 VOID\r
686 )\r
687{\r
688 CPUID_EXTENDED_TOPOLOGY_EAX Eax;\r
689 CPUID_EXTENDED_TOPOLOGY_EBX Ebx;\r
690 CPUID_EXTENDED_TOPOLOGY_ECX Ecx;\r
691 UINT32 Edx;\r
692 UINT32 LevelNumber;\r
693\r
694 if (CPUID_EXTENDED_TOPOLOGY > gMaximumBasicFunction) {\r
695 return;\r
696 }\r
697\r
698 LevelNumber = 0;\r
699 do {\r
700 AsmCpuidEx (\r
701 CPUID_EXTENDED_TOPOLOGY, LevelNumber,\r
702 &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx\r
703 );\r
704 if (Eax.Bits.ApicIdShift != 0) {\r
705 Print (L"CPUID_EXTENDED_TOPOLOGY (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_TOPOLOGY, LevelNumber);\r
706 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx);\r
707 PRINT_BIT_FIELD (Eax, ApicIdShift);\r
708 PRINT_BIT_FIELD (Ebx, LogicalProcessors);\r
709 PRINT_BIT_FIELD (Ecx, LevelNumber);\r
710 PRINT_BIT_FIELD (Ecx, LevelType);\r
711 PRINT_VALUE (Edx, x2APIC_ID);\r
712 }\r
713 LevelNumber++;\r
714 } while (Eax.Bits.ApicIdShift != 0);\r
715}\r
716\r
717/**\r
718 Display CPUID_EXTENDED_STATE sub-leaf.\r
719\r
720**/\r
721VOID\r
722CpuidExtendedStateSubLeaf (\r
723 VOID\r
724 )\r
725{\r
726 CPUID_EXTENDED_STATE_SUB_LEAF_EAX Eax;\r
727 UINT32 Ebx;\r
728 CPUID_EXTENDED_STATE_SUB_LEAF_ECX Ecx;\r
729 UINT32 Edx;\r
730\r
731 AsmCpuidEx (\r
732 CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF,\r
733 &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx\r
734 );\r
735 Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_SUB_LEAF);\r
736 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx.Uint32, Edx);\r
737 PRINT_BIT_FIELD (Eax, XSAVEOPT);\r
738 PRINT_BIT_FIELD (Eax, XSAVEC);\r
739 PRINT_BIT_FIELD (Eax, XGETBV);\r
740 PRINT_BIT_FIELD (Eax, XSAVES);\r
741 PRINT_VALUE (Ebx, EnabledSaveStateSize_XCR0_IA32_XSS);\r
742 PRINT_BIT_FIELD (Ecx, XCR0);\r
743 PRINT_BIT_FIELD (Ecx, PT);\r
744 PRINT_BIT_FIELD (Ecx, XCR0_1);\r
745 PRINT_VALUE (Edx, IA32_XSS_Supported_32_63);\r
746}\r
747\r
748/**\r
749 Display CPUID_EXTENDED_STATE size and offset information sub-leaf.\r
750\r
751**/\r
752VOID\r
753CpuidExtendedStateSizeOffset (\r
754 VOID\r
755 )\r
756{\r
757 UINT32 Eax;\r
758 UINT32 Ebx;\r
759 CPUID_EXTENDED_STATE_SIZE_OFFSET_ECX Ecx;\r
760 UINT32 Edx;\r
761 UINT32 SubLeaf;\r
762\r
763 for (SubLeaf = CPUID_EXTENDED_STATE_SIZE_OFFSET; SubLeaf < 32; SubLeaf++) {\r
764 AsmCpuidEx (\r
765 CPUID_EXTENDED_STATE, SubLeaf,\r
766 &Eax, &Ebx, &Ecx.Uint32, &Edx\r
767 );\r
768 if (Edx != 0) {\r
769 Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, SubLeaf);\r
770 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx.Uint32, Edx);\r
771 PRINT_VALUE (Eax, FeatureSaveStateSize);\r
772 PRINT_VALUE (Ebx, FeatureSaveStateOffset);\r
773 PRINT_BIT_FIELD (Ecx, XSS);\r
774 PRINT_BIT_FIELD (Ecx, Compacted);\r
775 }\r
776 }\r
777}\r
778\r
779/**\r
780 Display CPUID_EXTENDED_STATE main leaf and sub-leafs.\r
781\r
782**/\r
783VOID\r
784CpuidExtendedStateMainLeaf (\r
785 VOID\r
786 )\r
787{\r
788 CPUID_EXTENDED_STATE_MAIN_LEAF_EAX Eax;\r
789 UINT32 Ebx;\r
790 UINT32 Ecx;\r
791 UINT32 Edx;\r
792\r
793 if (CPUID_EXTENDED_STATE > gMaximumBasicFunction) {\r
794 return;\r
795 }\r
796\r
797 AsmCpuidEx (\r
798 CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_MAIN_LEAF,\r
799 &Eax.Uint32, &Ebx, &Ecx, &Edx\r
800 );\r
801 Print (L"CPUID_EXTENDED_STATE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_EXTENDED_STATE, CPUID_EXTENDED_STATE_MAIN_LEAF);\r
802 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx, Edx);\r
803 PRINT_BIT_FIELD (Eax, x87);\r
804 PRINT_BIT_FIELD (Eax, SSE);\r
805 PRINT_BIT_FIELD (Eax, AVX);\r
806 PRINT_BIT_FIELD (Eax, MPX);\r
807 PRINT_BIT_FIELD (Eax, AVX_512);\r
808 PRINT_BIT_FIELD (Eax, IA32_XSS);\r
809 PRINT_BIT_FIELD (Eax, PKRU);\r
810 PRINT_VALUE (Ebx, EnabledSaveStateSize);\r
811 PRINT_VALUE (Ecx, SupportedSaveStateSize);\r
812 PRINT_VALUE (Edx, XCR0_Supported_32_63);\r
813\r
814 CpuidExtendedStateSubLeaf ();\r
815 CpuidExtendedStateSizeOffset ();\r
816}\r
817\r
818/**\r
819 Display CPUID_PLATFORM_QOS_MONITORING enumeration sub-leaf.\r
820\r
821**/\r
822VOID\r
823CpuidPlatformQosMonitoringEnumerationSubLeaf (\r
824 VOID\r
825 )\r
826{\r
827 UINT32 Ebx;\r
828 CPUID_PLATFORM_QOS_MONITORING_ENUMERATION_SUB_LEAF_EDX Edx;\r
829\r
830 if (CPUID_PLATFORM_QOS_MONITORING > gMaximumBasicFunction) {\r
831 return;\r
832 }\r
833\r
834 AsmCpuidEx (\r
835 CPUID_PLATFORM_QOS_MONITORING, CPUID_PLATFORM_QOS_MONITORING_ENUMERATION_SUB_LEAF,\r
836 NULL, &Ebx, NULL, &Edx.Uint32\r
837 );\r
838 Print (L"CPUID_PLATFORM_QOS_MONITORING (Leaf %08x, Sub-Leaf %08x)\n", CPUID_PLATFORM_QOS_MONITORING, CPUID_PLATFORM_QOS_MONITORING_ENUMERATION_SUB_LEAF);\r
839 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx, 0, Edx.Uint32);\r
840 PRINT_VALUE (Ebx, Maximum_RMID_Range);\r
841 PRINT_BIT_FIELD (Edx, L3CacheQosEnforcement);\r
842}\r
843\r
844/**\r
845 Display CPUID_PLATFORM_QOS_MONITORING capability sub-leaf.\r
846\r
847**/\r
848VOID\r
849CpuidPlatformQosMonitoringCapabilitySubLeaf (\r
850 VOID\r
851 )\r
852{\r
853 UINT32 Ebx;\r
854 UINT32 Ecx;\r
855 CPUID_PLATFORM_QOS_MONITORING_CAPABILITY_SUB_LEAF_EDX Edx;\r
856\r
857 if (CPUID_PLATFORM_QOS_MONITORING > gMaximumBasicFunction) {\r
858 return;\r
859 }\r
860\r
861 AsmCpuidEx (\r
862 CPUID_PLATFORM_QOS_MONITORING, CPUID_PLATFORM_QOS_MONITORING_CAPABILITY_SUB_LEAF,\r
863 NULL, &Ebx, &Ecx, &Edx.Uint32\r
864 );\r
865 Print (L"CPUID_PLATFORM_QOS_MONITORING (Leaf %08x, Sub-Leaf %08x)\n", CPUID_PLATFORM_QOS_MONITORING, CPUID_PLATFORM_QOS_MONITORING_CAPABILITY_SUB_LEAF);\r
866 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx, Ecx, Edx.Uint32);\r
867 PRINT_VALUE (Ebx, OccupancyConversionFactor);\r
868 PRINT_VALUE (Ecx, Maximum_RMID_Range);\r
869 PRINT_BIT_FIELD (Edx, L3CacheOccupancyMonitoring);\r
870}\r
871\r
872/**\r
873 Display CPUID_PLATFORM_QOS_ENFORCEMENT sub-leaf.\r
874\r
875**/\r
876VOID\r
877CpuidPlatformQosEnforcementResidSubLeaf (\r
878 VOID\r
879 )\r
880{\r
881 CPUID_PLATFORM_QOS_ENFORCEMENT_RESID_SUB_LEAF_EAX Eax;\r
882 UINT32 Ebx;\r
883 CPUID_PLATFORM_QOS_ENFORCEMENT_RESID_SUB_LEAF_ECX Ecx;\r
884 CPUID_PLATFORM_QOS_ENFORCEMENT_RESID_SUB_LEAF_EDX Edx;\r
885\r
886 AsmCpuidEx (\r
887 CPUID_PLATFORM_QOS_ENFORCEMENT, CPUID_PLATFORM_QOS_ENFORCEMENT_RESID_SUB_LEAF,\r
888 &Eax.Uint32, &Ebx, &Ecx.Uint32, &Edx.Uint32\r
889 );\r
890 Print (L"CPUID_PLATFORM_QOS_ENFORCEMENT (Leaf %08x, Sub-Leaf %08x)\n", CPUID_PLATFORM_QOS_ENFORCEMENT, CPUID_PLATFORM_QOS_ENFORCEMENT_RESID_SUB_LEAF);\r
891 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, Ecx.Uint32, Edx.Uint32);\r
892 PRINT_BIT_FIELD (Eax, CapacityLength);\r
893 PRINT_VALUE (Ebx, AllocationUnitBitMap);\r
894 PRINT_BIT_FIELD (Ecx, CosUpdatesInfrequent);\r
895 PRINT_BIT_FIELD (Ecx, CodeDataPrioritization);\r
896 PRINT_BIT_FIELD (Edx, HighestCosNumber);\r
897}\r
898\r
899/**\r
900 Display CPUID_PLATFORM_QOS_ENFORCEMENT main leaf and sub-leaf.\r
901\r
902**/\r
903VOID\r
904CpuidPlatformQosEnforcementMainLeaf (\r
905 VOID\r
906 )\r
907{\r
908 CPUID_PLATFORM_QOS_ENFORCEMENT_MAIN_LEAF_EBX Ebx;\r
909\r
910 if (CPUID_PLATFORM_QOS_ENFORCEMENT > gMaximumBasicFunction) {\r
911 return;\r
912 }\r
913\r
914 AsmCpuidEx (\r
915 CPUID_PLATFORM_QOS_ENFORCEMENT, CPUID_PLATFORM_QOS_ENFORCEMENT_MAIN_LEAF,\r
916 NULL, &Ebx.Uint32, NULL, NULL\r
917 );\r
918 Print (L"CPUID_PLATFORM_QOS_ENFORCEMENT (Leaf %08x, Sub-Leaf %08x)\n", CPUID_PLATFORM_QOS_ENFORCEMENT, CPUID_PLATFORM_QOS_ENFORCEMENT_MAIN_LEAF);\r
919 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, Ebx.Uint32, 0, 0);\r
920 PRINT_BIT_FIELD (Ebx, L3CacheQosEnforcement);\r
921\r
922 CpuidPlatformQosEnforcementResidSubLeaf ();\r
923}\r
924\r
f5a2d6f0
JF
925/**\r
926 Display Sub-Leaf 0 Enumeration of Intel SGX Capabilities.\r
927\r
928**/\r
929VOID\r
930CpuidEnumerationOfIntelSgxCapabilities0SubLeaf (\r
931 VOID\r
932 )\r
933{\r
934 CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EAX Eax;\r
935 UINT32 Ebx;\r
936 CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF_EDX Edx;\r
937\r
938 AsmCpuidEx (\r
939 CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF,\r
940 &Eax.Uint32, &Ebx, NULL, &Edx.Uint32\r
941 );\r
942 Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_0_SUB_LEAF);\r
943 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx, 0, Edx.Uint32);\r
944 PRINT_BIT_FIELD (Eax, SGX1);\r
945 PRINT_BIT_FIELD (Eax, SGX2);\r
946 PRINT_BIT_FIELD (Edx, MaxEnclaveSize_Not64);\r
947 PRINT_BIT_FIELD (Edx, MaxEnclaveSize_64);\r
948}\r
949\r
950/**\r
951 Display Sub-Leaf 1 Enumeration of Intel SGX Capabilities.\r
952\r
953**/\r
954VOID\r
955CpuidEnumerationOfIntelSgxCapabilities1SubLeaf (\r
956 VOID\r
957 )\r
958{\r
959 UINT32 Eax;\r
960 UINT32 Ebx;\r
961 UINT32 Ecx;\r
962 UINT32 Edx;\r
963\r
964 AsmCpuidEx (\r
965 CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF,\r
966 &Eax, &Ebx, &Ecx, &Edx\r
967 );\r
968 Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, CPUID_INTEL_SGX_CAPABILITIES_1_SUB_LEAF);\r
969 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, Ecx, Edx);\r
970}\r
971\r
972/**\r
973 Display Sub-Leaf Index 2 or Higher Enumeration of Intel SGX Resources.\r
974\r
975**/\r
976VOID\r
977CpuidEnumerationOfIntelSgxResourcesSubLeaf (\r
978 VOID\r
979 )\r
980{\r
981 CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EAX Eax;\r
982 CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EBX Ebx;\r
983 CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_ECX Ecx;\r
984 CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF_EDX Edx;\r
985 UINT32 SubLeaf;\r
986 \r
987 SubLeaf = CPUID_INTEL_SGX_CAPABILITIES_RESOURCES_SUB_LEAF;\r
988 do {\r
989 AsmCpuidEx (\r
990 CPUID_INTEL_SGX, SubLeaf,\r
991 &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32\r
992 );\r
993 if (Eax.Bits.SubLeafType == 0x1) {\r
994 Print (L"CPUID_INTEL_SGX (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_SGX, SubLeaf);\r
995 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
996 PRINT_BIT_FIELD (Eax, SubLeafType);\r
997 PRINT_BIT_FIELD (Eax, LowAddressOfEpcSection);\r
998 PRINT_BIT_FIELD (Ebx, HighAddressOfEpcSection);\r
999 PRINT_BIT_FIELD (Ecx, EpcSection);\r
1000 PRINT_BIT_FIELD (Ecx, LowSizeOfEpcSection);\r
1001 PRINT_BIT_FIELD (Edx, HighSizeOfEpcSection);\r
1002 }\r
1003 SubLeaf++;\r
1004 } while (Eax.Bits.SubLeafType == 0x1);\r
1005}\r
1006\r
1007/**\r
1008 Display Intel SGX Resource Enumeration.\r
1009\r
1010**/\r
1011VOID\r
1012CpuidEnumerationOfIntelSgx (\r
1013 VOID\r
1014 )\r
1015{\r
1016 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EBX Ebx;\r
1017\r
1018 if (CPUID_INTEL_SGX > gMaximumBasicFunction) {\r
1019 return;\r
1020 }\r
1021\r
1022 AsmCpuidEx (\r
1023 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS,\r
1024 CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_SUB_LEAF_INFO,\r
1025 NULL, &Ebx.Uint32, NULL, NULL\r
1026 );\r
1027 if (Ebx.Bits.SGX != 1) {\r
1028 //\r
1029 // Only if CPUID.(EAX=07H, ECX=0H):EBX.SGX = 1, the processor has support\r
1030 // for Intel SGX.\r
1031 //\r
1032 return;\r
1033 }\r
1034 \r
1035 CpuidEnumerationOfIntelSgxCapabilities0SubLeaf ();\r
1036 CpuidEnumerationOfIntelSgxCapabilities1SubLeaf ();\r
1037 CpuidEnumerationOfIntelSgxResourcesSubLeaf ();\r
1038}\r
1039\r
25705752
MK
1040/**\r
1041 Display CPUID_INTEL_PROCESSOR_TRACE sub-leafs.\r
1042\r
1043 @param[in] MaximumSubLeaf Maximum sub-leaf index for CPUID_INTEL_PROCESSOR_TRACE.\r
1044\r
1045**/\r
1046VOID\r
1047CpuidIntelProcessorTraceSubLeaf (\r
1048 UINT32 MaximumSubLeaf\r
1049 )\r
1050{\r
1051 UINT32 SubLeaf;\r
1052 CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EAX Eax;\r
1053 CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF_EBX Ebx;\r
1054\r
1055 for (SubLeaf = CPUID_INTEL_PROCESSOR_TRACE_SUB_LEAF; SubLeaf <= MaximumSubLeaf; SubLeaf++) {\r
1056 AsmCpuidEx (\r
1057 CPUID_INTEL_PROCESSOR_TRACE, SubLeaf,\r
1058 &Eax.Uint32, &Ebx.Uint32, NULL, NULL\r
1059 );\r
1060 Print (L"CPUID_INTEL_PROCESSOR_TRACE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_PROCESSOR_TRACE, SubLeaf);\r
1061 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, 0, 0);\r
1062 PRINT_BIT_FIELD (Eax, ConfigurableAddressRanges);\r
1063 PRINT_BIT_FIELD (Eax, MtcPeriodEncodings);\r
1064 PRINT_BIT_FIELD (Ebx, CycleThresholdEncodings);\r
1065 PRINT_BIT_FIELD (Ebx, PsbFrequencyEncodings);\r
1066 }\r
1067}\r
1068\r
1069/**\r
1070 Display CPUID_INTEL_PROCESSOR_TRACE main leaf and sub-leafs.\r
1071\r
1072**/\r
1073VOID\r
1074CpuidIntelProcessorTraceMainLeaf (\r
1075 VOID\r
1076 )\r
1077{\r
1078 UINT32 Eax;\r
1079 CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_EBX Ebx;\r
1080 CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF_ECX Ecx;\r
1081\r
1082 if (CPUID_INTEL_PROCESSOR_TRACE > gMaximumBasicFunction) {\r
1083 return;\r
1084 }\r
1085\r
1086 AsmCpuidEx (\r
1087 CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF,\r
1088 &Eax, &Ebx.Uint32, &Ecx.Uint32, NULL\r
1089 );\r
1090 Print (L"CPUID_INTEL_PROCESSOR_TRACE (Leaf %08x, Sub-Leaf %08x)\n", CPUID_INTEL_PROCESSOR_TRACE, CPUID_INTEL_PROCESSOR_TRACE_MAIN_LEAF);\r
1091 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx.Uint32, 0);\r
1092 PRINT_VALUE (Eax, MaximumSubLeaf);\r
1093 PRINT_BIT_FIELD (Ebx, Cr3Filter);\r
1094 PRINT_BIT_FIELD (Ebx, ConfigurablePsb);\r
1095 PRINT_BIT_FIELD (Ebx, IpTraceStopFiltering);\r
1096 PRINT_BIT_FIELD (Ebx, Mtc);\r
1097 PRINT_BIT_FIELD (Ecx, RTIT);\r
1098 PRINT_BIT_FIELD (Ecx, ToPA);\r
1099 PRINT_BIT_FIELD (Ecx, SingleRangeOutput);\r
1100 PRINT_BIT_FIELD (Ecx, TraceTransportSubsystem);\r
1101 PRINT_BIT_FIELD (Ecx, LIP);\r
1102\r
1103 CpuidIntelProcessorTraceSubLeaf (Eax);\r
1104}\r
1105\r
1106/**\r
1107 Display CPUID_TIME_STAMP_COUNTER leaf.\r
1108\r
1109**/\r
1110VOID\r
1111CpuidTimeStampCounter (\r
1112 VOID\r
1113 )\r
1114{\r
1115 UINT32 Eax;\r
1116 UINT32 Ebx;\r
1117\r
1118 if (CPUID_TIME_STAMP_COUNTER > gMaximumBasicFunction) {\r
1119 return;\r
1120 }\r
1121\r
1122 AsmCpuid (CPUID_TIME_STAMP_COUNTER, &Eax, &Ebx, NULL, NULL);\r
1123 Print (L"CPUID_TIME_STAMP_COUNTER (Leaf %08x)\n", CPUID_TIME_STAMP_COUNTER);\r
1124 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx, 0, 0);\r
1125}\r
1126\r
1127/**\r
1128 Display CPUID_PROCESSOR_FREQUENCY leaf.\r
1129\r
1130**/\r
1131VOID\r
1132CpuidProcessorFrequency (\r
1133 VOID\r
1134 )\r
1135{\r
1136 CPUID_PROCESSOR_FREQUENCY_EAX Eax;\r
1137 CPUID_PROCESSOR_FREQUENCY_EBX Ebx;\r
1138 CPUID_PROCESSOR_FREQUENCY_ECX Ecx;\r
1139\r
1140 if (CPUID_PROCESSOR_FREQUENCY > gMaximumBasicFunction) {\r
1141 return;\r
1142 }\r
1143\r
1144 AsmCpuid (CPUID_PROCESSOR_FREQUENCY, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, NULL);\r
1145 Print (L"CPUID_PROCESSOR_FREQUENCY (Leaf %08x)\n", CPUID_PROCESSOR_FREQUENCY);\r
1146 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, 0);\r
1147 PRINT_BIT_FIELD (Eax, ProcessorBaseFrequency);\r
1148 PRINT_BIT_FIELD (Ebx, MaximumFrequency);\r
1149 PRINT_BIT_FIELD (Ecx, BusFrequency);\r
1150}\r
1151\r
1152/**\r
1153 Display CPUID_SOC_VENDOR sub-leafs that contain the SoC Vendor Brand String.\r
1154 Also display these sub-leafs as a single SoC Vendor Brand String.\r
1155\r
1156**/\r
1157VOID\r
1158CpuidSocVendorBrandString (\r
1159 VOID\r
1160 )\r
1161{\r
1162 CPUID_SOC_VENDOR_BRAND_STRING_DATA Eax;\r
1163 CPUID_SOC_VENDOR_BRAND_STRING_DATA Ebx;\r
1164 CPUID_SOC_VENDOR_BRAND_STRING_DATA Ecx;\r
1165 CPUID_SOC_VENDOR_BRAND_STRING_DATA Edx;\r
1166 //\r
1167 // Array to store brand string from 3 brand string leafs with\r
1168 // 4 32-bit brand string values per leaf and an extra value to\r
1169 // null terminate the string.\r
1170 //\r
1171 UINT32 BrandString[3 * 4 + 1];\r
1172\r
1173 AsmCpuidEx (\r
1174 CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING1,\r
1175 &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32\r
1176 );\r
1177 Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING1);\r
1178 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
1179 BrandString[0] = Eax.Uint32;\r
1180 BrandString[1] = Ebx.Uint32;\r
1181 BrandString[2] = Ecx.Uint32;\r
1182 BrandString[3] = Edx.Uint32;\r
1183\r
1184 AsmCpuidEx (\r
1185 CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING2,\r
1186 &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32\r
1187 );\r
1188 Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING2);\r
1189 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
1190 BrandString[4] = Eax.Uint32;\r
1191 BrandString[5] = Ebx.Uint32;\r
1192 BrandString[6] = Ecx.Uint32;\r
1193 BrandString[7] = Edx.Uint32;\r
1194\r
1195 AsmCpuidEx (\r
1196 CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING3,\r
1197 &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32\r
1198 );\r
1199 Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_BRAND_STRING3);\r
1200 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
1201 BrandString[8] = Eax.Uint32;\r
1202 BrandString[9] = Ebx.Uint32;\r
1203 BrandString[10] = Ecx.Uint32;\r
1204 BrandString[11] = Edx.Uint32;\r
1205\r
1206 BrandString[12] = 0;\r
1207\r
1208 Print (L"Vendor Brand String = %a\n", (CHAR8 *)BrandString);\r
1209}\r
1210\r
1211/**\r
1212 Display CPUID_SOC_VENDOR main leaf and sub-leafs.\r
1213\r
1214**/\r
1215VOID\r
1216CpuidSocVendor (\r
1217 VOID\r
1218 )\r
1219{\r
1220 UINT32 Eax;\r
1221 CPUID_SOC_VENDOR_MAIN_LEAF_EBX Ebx;\r
1222 UINT32 Ecx;\r
1223 UINT32 Edx;\r
1224\r
1225 if (CPUID_SOC_VENDOR > gMaximumBasicFunction) {\r
1226 return;\r
1227 }\r
1228\r
1229 AsmCpuidEx (\r
1230 CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_MAIN_LEAF,\r
1231 &Eax, &Ebx.Uint32, &Ecx, &Edx\r
1232 );\r
1233 Print (L"CPUID_SOC_VENDOR (Leaf %08x, Sub-Leaf %08x)\n", CPUID_SOC_VENDOR, CPUID_SOC_VENDOR_MAIN_LEAF);\r
1234 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, Ebx.Uint32, Ecx, Edx);\r
1235 if (Eax < 3) {\r
1236 Print (L" Not Supported\n");\r
1237 return;\r
1238 }\r
1239 PRINT_VALUE (Eax, MaxSOCID_Index);\r
1240 PRINT_BIT_FIELD (Ebx, SocVendorId);\r
1241 PRINT_BIT_FIELD (Ebx, IsVendorScheme);\r
1242 PRINT_VALUE (Ecx, ProjectID);\r
1243 PRINT_VALUE (Edx, SteppingID);\r
1244 CpuidSocVendorBrandString ();\r
1245}\r
1246\r
1247/**\r
1248 Display CPUID_EXTENDED_FUNCTION leaf.\r
1249\r
1250**/\r
1251VOID\r
1252CpuidExtendedFunction (\r
1253 VOID\r
1254 )\r
1255{\r
1256 UINT32 Eax;\r
1257\r
1258 AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL);\r
1259 Print (L"CPUID_EXTENDED_FUNCTION (Leaf %08x)\n", CPUID_EXTENDED_FUNCTION);\r
1260 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, 0, 0);\r
1261 PRINT_VALUE (Eax, MaximumExtendedFunction);\r
1262\r
1263 gMaximumExtendedFunction = Eax;\r
1264}\r
1265\r
1266/**\r
1267 Display CPUID_EXTENDED_CPU_SIG leaf.\r
1268\r
1269**/\r
1270VOID\r
1271CpuidExtendedCpuSig (\r
1272 VOID\r
1273 )\r
1274{\r
1275 UINT32 Eax;\r
1276 CPUID_EXTENDED_CPU_SIG_ECX Ecx;\r
1277 CPUID_EXTENDED_CPU_SIG_EDX Edx;\r
1278\r
1279 if (CPUID_EXTENDED_CPU_SIG > gMaximumExtendedFunction) {\r
1280 return;\r
1281 }\r
1282\r
1283 AsmCpuid (CPUID_EXTENDED_CPU_SIG, &Eax, NULL, &Ecx.Uint32, &Edx.Uint32);\r
1284 Print (L"CPUID_EXTENDED_CPU_SIG (Leaf %08x)\n", CPUID_EXTENDED_CPU_SIG);\r
1285 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax, 0, Ecx.Uint32, Edx.Uint32);\r
1286 PRINT_BIT_FIELD (Ecx, LAHF_SAHF);\r
1287 PRINT_BIT_FIELD (Ecx, LZCNT);\r
1288 PRINT_BIT_FIELD (Ecx, PREFETCHW);\r
1289 PRINT_BIT_FIELD (Edx, SYSCALL_SYSRET);\r
1290 PRINT_BIT_FIELD (Edx, NX);\r
1291 PRINT_BIT_FIELD (Edx, Page1GB);\r
1292 PRINT_BIT_FIELD (Edx, RDTSCP);\r
1293 PRINT_BIT_FIELD (Edx, LM);\r
1294}\r
1295\r
1296/**\r
1297 Display CPUID_BRAND_STRING1, CPUID_BRAND_STRING2 and CPUID_BRAND_STRING3\r
1298 leafs. Also display these three leafs as a single brand string.\r
1299\r
1300**/\r
1301VOID\r
1302CpuidProcessorBrandString (\r
1303 VOID\r
1304 )\r
1305{\r
1306 CPUID_BRAND_STRING_DATA Eax;\r
1307 CPUID_BRAND_STRING_DATA Ebx;\r
1308 CPUID_BRAND_STRING_DATA Ecx;\r
1309 CPUID_BRAND_STRING_DATA Edx;\r
1310 //\r
1311 // Array to store brand string from 3 brand string leafs with\r
1312 // 4 32-bit brand string values per leaf and an extra value to\r
1313 // null terminate the string.\r
1314 //\r
1315 UINT32 BrandString[3 * 4 + 1];\r
1316\r
1317 if (CPUID_BRAND_STRING1 <= gMaximumExtendedFunction) {\r
1318 AsmCpuid (CPUID_BRAND_STRING1, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32);\r
1319 Print (L"CPUID_BRAND_STRING1 (Leaf %08x)\n", CPUID_BRAND_STRING1);\r
1320 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
1321 BrandString[0] = Eax.Uint32;\r
1322 BrandString[1] = Ebx.Uint32;\r
1323 BrandString[2] = Ecx.Uint32;\r
1324 BrandString[3] = Edx.Uint32;\r
1325 }\r
1326\r
1327 if (CPUID_BRAND_STRING2 <= gMaximumExtendedFunction) {\r
1328 AsmCpuid (CPUID_BRAND_STRING2, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32);\r
1329 Print (L"CPUID_BRAND_STRING2 (Leaf %08x)\n", CPUID_BRAND_STRING2);\r
1330 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
1331 BrandString[4] = Eax.Uint32;\r
1332 BrandString[5] = Ebx.Uint32;\r
1333 BrandString[6] = Ecx.Uint32;\r
1334 BrandString[7] = Edx.Uint32;\r
1335 }\r
1336\r
1337 if (CPUID_BRAND_STRING3 <= gMaximumExtendedFunction) {\r
1338 AsmCpuid (CPUID_BRAND_STRING3, &Eax.Uint32, &Ebx.Uint32, &Ecx.Uint32, &Edx.Uint32);\r
1339 Print (L"CPUID_BRAND_STRING3 (Leaf %08x)\n", CPUID_BRAND_STRING3);\r
1340 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, Ebx.Uint32, Ecx.Uint32, Edx.Uint32);\r
1341 BrandString[8] = Eax.Uint32;\r
1342 BrandString[9] = Ebx.Uint32;\r
1343 BrandString[10] = Ecx.Uint32;\r
1344 BrandString[11] = Edx.Uint32;\r
1345 }\r
1346\r
1347 BrandString[12] = 0;\r
1348\r
1349 Print (L"Brand String = %a\n", (CHAR8 *)BrandString);\r
1350}\r
1351\r
1352/**\r
1353 Display CPUID_EXTENDED_CACHE_INFO leaf.\r
1354\r
1355**/\r
1356VOID\r
1357CpuidExtendedCacheInfo (\r
1358 VOID\r
1359 )\r
1360{\r
1361 CPUID_EXTENDED_CACHE_INFO_ECX Ecx;\r
1362\r
1363 if (CPUID_EXTENDED_CACHE_INFO > gMaximumExtendedFunction) {\r
1364 return;\r
1365 }\r
1366\r
1367 AsmCpuid (CPUID_EXTENDED_CACHE_INFO, NULL, NULL, &Ecx.Uint32, NULL);\r
1368 Print (L"CPUID_EXTENDED_CACHE_INFO (Leaf %08x)\n", CPUID_EXTENDED_CACHE_INFO);\r
1369 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, Ecx.Uint32, 0);\r
1370 PRINT_BIT_FIELD (Ecx, CacheLineSize);\r
1371 PRINT_BIT_FIELD (Ecx, L2Associativity);\r
1372 PRINT_BIT_FIELD (Ecx, CacheSize);\r
1373}\r
1374\r
1375/**\r
1376 Display CPUID_EXTENDED_TIME_STAMP_COUNTER leaf.\r
1377\r
1378**/\r
1379VOID\r
1380CpuidExtendedTimeStampCounter (\r
1381 VOID\r
1382 )\r
1383{\r
1384 CPUID_EXTENDED_TIME_STAMP_COUNTER_EDX Edx;\r
1385\r
1386 if (CPUID_EXTENDED_TIME_STAMP_COUNTER > gMaximumExtendedFunction) {\r
1387 return;\r
1388 }\r
1389\r
1390 AsmCpuid (CPUID_EXTENDED_TIME_STAMP_COUNTER, NULL, NULL, NULL, &Edx.Uint32);\r
1391 Print (L"CPUID_EXTENDED_TIME_STAMP_COUNTER (Leaf %08x)\n", CPUID_EXTENDED_TIME_STAMP_COUNTER);\r
1392 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", 0, 0, 0, Edx.Uint32);\r
1393 PRINT_BIT_FIELD (Edx, InvariantTsc);\r
1394}\r
1395\r
1396/**\r
1397 Display CPUID_VIR_PHY_ADDRESS_SIZE leaf.\r
1398\r
1399**/\r
1400VOID\r
1401CpuidVirPhyAddressSize (\r
1402 VOID\r
1403 )\r
1404{\r
1405 CPUID_VIR_PHY_ADDRESS_SIZE_EAX Eax;\r
1406\r
1407 if (CPUID_VIR_PHY_ADDRESS_SIZE > gMaximumExtendedFunction) {\r
1408 return;\r
1409 }\r
1410\r
1411 AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Eax.Uint32, NULL, NULL, NULL);\r
1412 Print (L"CPUID_VIR_PHY_ADDRESS_SIZE (Leaf %08x)\n", CPUID_VIR_PHY_ADDRESS_SIZE);\r
1413 Print (L" EAX:%08x EBX:%08x ECX:%08x EDX:%08x\n", Eax.Uint32, 0, 0, 0);\r
1414 PRINT_BIT_FIELD (Eax, PhysicalAddressBits);\r
1415 PRINT_BIT_FIELD (Eax, LinearAddressBits);\r
1416}\r
1417\r
1418/**\r
1419 The user Entry Point for Application. The user code starts with this function\r
1420 as the real entry point for the application.\r
1421\r
1422 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
1423 @param[in] SystemTable A pointer to the EFI System Table.\r
1424\r
1425 @retval EFI_SUCCESS The entry point is executed successfully.\r
1426 @retval other Some error occurs when executing this entry point.\r
1427\r
1428**/\r
1429EFI_STATUS\r
1430EFIAPI\r
1431UefiMain (\r
1432 IN EFI_HANDLE ImageHandle,\r
1433 IN EFI_SYSTEM_TABLE *SystemTable\r
1434 )\r
1435{\r
1436 Print (L"UEFI CPUID Version 0.5\n");\r
1437\r
1438 CpuidSignature ();\r
1439 CpuidVersionInfo ();\r
1440 CpuidCacheInfo ();\r
1441 CpuidSerialNumber ();\r
1442 CpuidCacheParams();\r
1443 CpuidMonitorMwait ();\r
1444 CpuidThermalPowerManagement ();\r
1445 CpuidStructuredExtendedFeatureFlags ();\r
1446 CpuidDirectCacheAccessInfo();\r
1447 CpuidArchitecturalPerformanceMonitoring ();\r
1448 CpuidExtendedTopology ();\r
1449 CpuidExtendedStateMainLeaf ();\r
1450 CpuidPlatformQosMonitoringEnumerationSubLeaf ();\r
1451 CpuidPlatformQosMonitoringCapabilitySubLeaf ();\r
1452 CpuidPlatformQosEnforcementMainLeaf ();\r
f5a2d6f0 1453 CpuidEnumerationOfIntelSgx ();\r
25705752
MK
1454 CpuidIntelProcessorTraceMainLeaf ();\r
1455 CpuidTimeStampCounter ();\r
1456 CpuidProcessorFrequency ();\r
1457 CpuidSocVendor ();\r
1458 CpuidExtendedFunction ();\r
1459 CpuidExtendedCpuSig ();\r
1460 CpuidProcessorBrandString ();\r
1461 CpuidExtendedCacheInfo ();\r
1462 CpuidExtendedTimeStampCounter ();\r
1463 CpuidVirPhyAddressSize ();\r
1464\r
1465 return EFI_SUCCESS;\r
1466}\r