OSAPI  0.29
Open System API
machine_cpu_type_amd.h
1 // *****************************************************************************************
2 //
3 // File description:
4 //
5 // Author: Joao Costa
6 // Purpose: Provide AMD CPU specific declarations/definitions
7 //
8 // *****************************************************************************************
9 
10 #ifndef OSAPI_MACHINE_CPU_TYPE_AMD_H_
11 #define OSAPI_MACHINE_CPU_TYPE_AMD_H_
12 
13 #if (OSAPI_CPU_ARCHITECTURE_TARGET == OSAPI_CPU_ARCHITECTURE_X86) || (OSAPI_CPU_ARCHITECTURE_TARGET == OSAPI_CPU_ARCHITECTURE_AMD64)
14 
15 
16 // *****************************************************************************************
17 //
18 // Section: Import headers
19 //
20 // *****************************************************************************************
21 
22 // System headers
23 #include <stdint.h>
24 
25 
26 
27 // *****************************************************************************************
28 //
29 // Section: Define structures for Standard CPUID functions
30 //
31 // *****************************************************************************************
32 
33 // *****************************************************************************************
34 // Standard CPUID function 1
35 // *****************************************************************************************
36 
38 {
39  uint32_t SSE3:1; // 1
40  uint32_t PCLMULQDQ:1; // 2
41  uint32_t DTES64:1; // 3
42  uint32_t MONITOR:1; // 4
43  uint32_t DS_CPL:1; // 5
44  uint32_t VMX:1; // 6
45  uint32_t SMX:1; // 7
46  uint32_t EIST:1; // 8
47  uint32_t TM2:1; // 9
48  uint32_t SSSE3:1; // 10
49  uint32_t CNXT_ID:1; // 11
50  uint32_t :1; // 12
51  uint32_t FMA:1; // 13
52  uint32_t CMPXCHG16B:1; // 14
53  uint32_t XTPR:1; // 15
54  uint32_t PDCM:1; // 16
55  uint32_t :1; // 17
56  uint32_t :1; // 18
57  uint32_t DCA:1; // 19
58  uint32_t SSE4_1:1; // 20
59  uint32_t SSE4_2:1; // 21
60  uint32_t x2APIC:1; // 22
61  uint32_t MOVBE:1; // 23
62  uint32_t :1; // 24
63  uint32_t POPCNT:1; // 25
64  uint32_t AES:1; // 26
65  uint32_t XSAVE:1; // 27
66  uint32_t OSXSAVE:1; // 28
67  uint32_t AVX:1; // 29
68  uint32_t F16C:1; // 30
69  uint32_t RDRAND:1; // 31
70  uint32_t HYPERVISOR:1; // 32
71 };
72 
73 
75 {
76  uint32_t FPU:1; // 1
77  uint32_t VME:1; // 2
78  uint32_t DE:1; // 3
79  uint32_t PSE:1; // 4
80  uint32_t TSC:1; // 5
81  uint32_t MSR:1; // 6
82  uint32_t PAE:1; // 7
83  uint32_t MCE:1; // 8
84  uint32_t CX8:1; // 9
85  uint32_t :1; // 10
86  uint32_t APIC:1; // 11
87  uint32_t SEP:1; // 12
88  uint32_t MTRR:1; // 13
89  uint32_t PGE:1; // 14
90  uint32_t MCA:1; // 15
91  uint32_t CMOV:1; // 16
92  uint32_t PAT:1; // 17
93  uint32_t PSE36:1; // 18
94  uint32_t PSN:1; // 19
95  uint32_t :1; // 20
96  uint32_t CLFSH:1; // 21
97  uint32_t DS:1; // 22
98  uint32_t ACPI:1; // 23
99  uint32_t MMX:1; // 24
100  uint32_t FXSR:1; // 25
101  uint32_t SSE:1; // 26
102  uint32_t SSE2:1; // 27
103  uint32_t SS:1; // 28
104  uint32_t HTT:1; // 29
105  uint32_t :1; // 30
106  uint32_t TM:1; // 31
107  uint32_t PBE:1; // 32
108 };
109 
110 // Structure that matches the register structure
112 {
113  uint32_t eax;
114  uint32_t ebx;
115  struct amd_cpu_features_s1_c_S ecx;
116  struct amd_cpu_features_s1_d_S edx;
117 };
118 
119 
120 // *****************************************************************************************
121 // Standard CPUID function 6
122 // *****************************************************************************************
123 
125 {
126  uint32_t DIGTEMP:1; // 1
127  uint32_t TRBOBST:1; // 2
128  uint32_t ARAT:1; // 3
129 };
130 
131 
133 {
134  uint32_t MPERF_APERF_MSR:1; // 1
135 };
136 
137 // Structure that matches the register structure
139 {
140  struct amd_cpu_features_s6_a_S eax;
141  uint32_t ebx;
142  struct amd_cpu_features_s6_c_S ecx;
143  uint32_t edx;
144 };
145 
146 
147 
148 // *****************************************************************************************
149 // Standard CPUID function 7
150 // *****************************************************************************************
151 
153 {
154  uint32_t FSGSBASE:1; // 1
155  uint32_t :1; // 2
156  uint32_t SGX:1; // 3
157  uint32_t BMI1:1; // 4
158  uint32_t HLE:1; // 5
159  uint32_t AVX2:1; // 6
160  uint32_t :1; // 7
161  uint32_t SMEP:1; // 8
162  uint32_t BMI2:1; // 9
163  uint32_t ERMS:1; // 10
164  uint32_t INVPCID:1; // 11
165  uint32_t RTM:1; // 12
166  uint32_t PQM:1; // 13
167  uint32_t :1; // 14
168  uint32_t MPX:1; // 15
169  uint32_t PQE:1; // 16
170  uint32_t AVX512_F:1; // 17
171  uint32_t AVX512_DQ:1; // 18
172  uint32_t RDSEED:1; // 19
173  uint32_t ADX:1; // 20
174  uint32_t SMAP:1; // 21
175  uint32_t AVX512_IFMA:1; // 22
176  uint32_t PCOMMIT:1; // 23
177  uint32_t CLFLUSHOPT:1; // 24
178  uint32_t CLWB:1; // 25
179  uint32_t INTEL_PT:1; // 26
180  uint32_t AVX512_PF:1; // 27
181  uint32_t AVX512_ER:1; // 28
182  uint32_t AVX512_CD:1; // 29
183  uint32_t SHA:1; // 30
184  uint32_t AVX512_BW:1; // 31
185  uint32_t AVX512_VL:1; // 32
186 
187 };
188 
189 
191 {
192  uint32_t PREFETCHWT1:1; // 1
193  uint32_t AVX512_VBMI:1; // 2
194  uint32_t UMIP:1; // 3
195  uint32_t PKU:1; // 4
196  uint32_t OSPKE:1; // 5
197  uint32_t WAITPKG:1; // 6
198  uint32_t AVX512_VBMI2:1; // 7
199  uint32_t SHSTK:1; // 8
200  uint32_t GFNI:1; // 9
201  uint32_t VAES:1; // 10
202  uint32_t VPCLMULQDQ:1; // 11
203  uint32_t AVX512_VNNI:1; // 12
204  uint32_t AVX512_BITALG:1; // 13
205  uint32_t :1; // 14
206  uint32_t AVX512_VPOPCNTDQ:1; // 15
207  uint32_t :1; // 16
208  uint32_t :1; // 17
209  uint32_t :5; // 18-22 (The value of userspace MPX Address-Width Adjust used by the BNDLDX and BNDSTX Intel MPX instructions in 64-bit mode)
210  uint32_t RDPID:1; // 23
211  uint32_t :2; // 24-25 (reserved)
212  uint32_t CLDEMOTE:1; // 26
213  uint32_t :1; // 27
214  uint32_t MOVDIRI:1; // 28
215  uint32_t MOVDIR64B:1; // 29
216  uint32_t ENQCMD:1; // 30
217  uint32_t SGX_LC:1; // 31
218  uint32_t :1; // 32
219 };
220 
221 
223 {
224  uint32_t :1; // 1
225  uint32_t :1; // 2
226  uint32_t AVX512_4VNNIW:1; // 3
227  uint32_t AVX512_4FMAPS:1; // 4
228  uint32_t FSRM:1; // 5
229  uint32_t :3; // 6-8
230  uint32_t AVX512_VP2I:1; // 9
231  uint32_t :1; // 10
232  uint32_t MD_CLEAR:1; // 11
233  uint32_t :2; // 12-13
234  uint32_t TSX_FORCE_ABORT:1; // 14
235  uint32_t SERIALIZE:1; // 15
236  uint32_t HYBRID:1; // 16
237  uint32_t TSXLDTRK:1; // 17
238  uint32_t :1; // 18
239  uint32_t PCONFIG:1; // 19
240  uint32_t :1; // 20
241  uint32_t IBT:1; // 21
242  uint32_t :5; // 22-26
243  uint32_t SPEC_CTRL:1; // 27
244  uint32_t STIBP:1; // 28
245  uint32_t :1; // 29
246  uint32_t IA32_AC:1; // 30
247  uint32_t IA32_CC:1; // 31
248  uint32_t SSBD:1; // 32
249 
250 };
251 
252 // Structure that matches the register structure for request 7, option 0 (sub-leaf)
254 {
255  uint32_t eax;
256  struct amd_cpu_features_s7_b_S ebx;
257  struct amd_cpu_features_s7_c_S ecx;
258  struct amd_cpu_features_s7_d_S edx;
259 };
260 
261 
263 {
264  uint32_t :5; // 1-5
265  uint32_t AVX512_BF16:1; // 6
266  uint32_t :26; // 7-32
267 
268 };
269 
270 
271 // Structure that matches the register structure for request 7, option 1 (sub-leaf)
273 {
274  struct amd_cpu_features_s7_1_a_S exx;
275  uint32_t ebx;
276  uint32_t ecx;
277  uint32_t edx;
278 };
279 
280 
281 
282 // *****************************************************************************************
283 // Standard CPUID function D
284 // *****************************************************************************************
285 /*
286 struct common_features_sd_a_S
287 {
288  uint32_t DIGTEMP:1; // 1
289  uint32_t TRBOBST:1; // 2
290  uint32_t ARAT:1; // 3
291 };
292 
293 
294 struct common_features_sd_c_S
295 {
296  uint32_t MPERF_APERF_MSR:1; // 1
297 };
298 
299 
300 // Structure that matches the register structure
301 struct common_features_sd_S
302 {
303  struct common_features_sd_a_S eax;
304  uint32_t ebx;
305  struct common_features_sd_c_S ecx;
306  uint32_t edx;
307 };
308 */
309 
310 // *****************************************************************************************
311 // Standard CPUID function F
312 // *****************************************************************************************
313 /*
314 struct common_features_sf_a_S
315 {
316  uint32_t DIGTEMP:1; // 1
317  uint32_t TRBOBST:1; // 2
318  uint32_t ARAT:1; // 3
319 };
320 
321 
322 struct common_features_sf_c_S
323 {
324  uint32_t MPERF_APERF_MSR:1; // 1
325 };
326 
327 
328 // Structure that matches the register structure
329 struct common_features_sf_S
330 {
331  struct common_features_sf_a_S eax;
332  uint32_t ebx;
333  struct common_features_sf_c_S ecx;
334  uint32_t edx;
335 };
336 */
337 
338 // *****************************************************************************************
339 //
340 // Section: Define structures for Extended CPUID functions
341 //
342 // *****************************************************************************************
343 
344 
345 // *****************************************************************************************
346 // Extended CPUID function 1
347 // *****************************************************************************************
348 
350 {
351  uint32_t LAHF_SAHF:1; // 1
352  uint32_t CMP:1; // 2
353  uint32_t SVM:1; // 3
354  uint32_t EXTAPIC:1; // 4
355  uint32_t CR8:1; // 5
356  uint32_t ABM:1; // 6
357  uint32_t SSE4A:1; // 7
358  uint32_t MISALIGN:1; // 8
359  uint32_t S3D_PREF:1; // 9
360  uint32_t OSVW:1; // 10
361  uint32_t IBS:1; // 11
362  uint32_t XOP:1; // 12
363  uint32_t SKINIT:1; // 13
364  uint32_t WDT:1; // 14
365  uint32_t :1; // 15
366  uint32_t LWP:1; // 16
367  uint32_t FMA4:1; // 17
368  uint32_t TCE:1; // 18
369  uint32_t :1; // 19
370  uint32_t NID:1; // 20
371  uint32_t :1; // 21
372  uint32_t TBM:1; // 22
373  uint32_t TOPO:1; // 23
374  uint32_t PCORE:1; // 24
375  uint32_t PNB:1; // 25
376  uint32_t :1; // 26
377  uint32_t BPEXT:1; // 27
378  uint32_t PTSC:1; // 28
379  uint32_t PL2:1; // 29
380  uint32_t :3; // 30-32
381 
382 };
383 
384 
386 {
387  uint32_t :19; // 1-19 // Already available in standard function 1
388  uint32_t MP:1; // 20
389  uint32_t NX:1; // 21
390  uint32_t :1; // 22
391  uint32_t MMXEXT:1; // 23
392  uint32_t :2; // 24-25
393  uint32_t FXSR_OPT:1; // 26
394  uint32_t PDP1GB:1; // 27
395  uint32_t RDTSCP:1; // 28
396  uint32_t :1; // 29
397  uint32_t LM:1; // 30
398  uint32_t E3DNOW:1; // 31
399  uint32_t S3DNOW:1; // 32
400 };
401 
402 
403 // Structure that matches the register structure
405 {
406  uint32_t eax;
407  uint32_t ebx;
408  struct amd_cpu_features_e1_c_S ecx;
409  struct amd_cpu_features_e1_d_S edx;
410 };
411 
412 
413 // *****************************************************************************************
414 // Extended CPUID function 7
415 // *****************************************************************************************
416 /*
417 struct common_features_e7_c_S
418 {
419  uint32_t :8; // 1-8
420  uint32_t INVTSC:1; // 9
421 };
422 
423 // Structure that matches the register structure
424 struct common_features_e7_S
425 {
426  uint32_t eax;
427  uint32_t ebx;
428  struct common_features_e7_c_S ecx;
429  uint32_t edx;
430 };
431 
432 */
433 
434 // *****************************************************************************************
435 // Extended CPUID function 7
436 // *****************************************************************************************
437 
439 {
440  uint32_t :8; // 1-8
441  uint32_t INVTSC:1; // 9
442 };
443 
444 // Structure that matches the register structure
446 {
447  uint32_t eax;
448  struct amd_cpu_features_e7_b_S ebx;
449  uint32_t ecx;
450  uint32_t edx;
451 };
452 
453 // *****************************************************************************************
454 // Extended CPUID function 8
455 // *****************************************************************************************
456 
458 {
459  uint32_t :8; // 1-8
460  uint32_t INVTSC:1; // 9
461 };
462 
463 // Structure that matches the register structure
465 {
466  uint32_t eax;
467  uint32_t ebx;
468  struct amd_cpu_features_e8_c_S ecx;
469  uint32_t edx;
470 };
471 
472 
473 // *****************************************************************************************
474 // Extended CPUID function A
475 // *****************************************************************************************
476 
478 {
479  uint32_t :8; // 1-8
480  uint32_t INVTSC:1; // 9
481 };
482 
483 // Structure that matches the register structure
485 {
486  uint32_t eax;
487  uint32_t ebx;
488  struct amd_cpu_features_eA_c_S ecx;
489  uint32_t edx;
490 };
491 
492 
493 #endif // AMD64
494 
495 #endif /* OSAPI_MACHINE_CPU_TYPE_AMD_H_ */
amd_cpu_features_s7_d_S
Definition: machine_cpu_type_amd.h:222
amd_cpu_features_eA_c_S
Definition: machine_cpu_type_amd.h:477
amd_cpu_features_s1_S
Definition: machine_cpu_type_amd.h:111
amd_cpu_features_s7_1_a_S
Definition: machine_cpu_type_amd.h:262
amd_cpu_features_s6_S
Definition: machine_cpu_type_amd.h:138
amd_cpu_features_s7_c_S
Definition: machine_cpu_type_amd.h:190
amd_cpu_features_s7_S
Definition: machine_cpu_type_amd.h:253
amd_cpu_features_e1_S
Definition: machine_cpu_type_amd.h:404
amd_cpu_features_e1_d_S
Definition: machine_cpu_type_amd.h:385
amd_cpu_features_s1_d_S
Definition: machine_cpu_type_amd.h:74
amd_cpu_features_s6_a_S
Definition: machine_cpu_type_amd.h:124
amd_cpu_features_e7_S
Definition: machine_cpu_type_amd.h:445
amd_cpu_features_eA_S
Definition: machine_cpu_type_amd.h:484
amd_cpu_features_s7_1_S
Definition: machine_cpu_type_amd.h:272
amd_cpu_features_e1_c_S
Definition: machine_cpu_type_amd.h:349
amd_cpu_features_s1_c_S
Definition: machine_cpu_type_amd.h:37
amd_cpu_features_e7_b_S
Definition: machine_cpu_type_amd.h:438
amd_cpu_features_s7_b_S
Definition: machine_cpu_type_amd.h:152
amd_cpu_features_s6_c_S
Definition: machine_cpu_type_amd.h:132
amd_cpu_features_e8_S
Definition: machine_cpu_type_amd.h:464
amd_cpu_features_e8_c_S
Definition: machine_cpu_type_amd.h:457