- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathcpuid.h
231 lines (216 loc) · 7.52 KB
/
cpuid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/*********************************************************************/
/* Copyright 2009, 2010 The University of Texas at Austin. */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or */
/* without modification, are permitted provided that the following */
/* conditions are met: */
/* */
/* 1. Redistributions of source code must retain the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer. */
/* */
/* 2. Redistributions in binary form must reproduce the above */
/* copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials */
/* provided with the distribution. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of The University of Texas at Austin. */
/*********************************************************************/
#ifndefCPUID_H
#defineCPUID_H
#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
#defineINTEL_AMD
#endif
#defineVENDOR_INTEL 1
#defineVENDOR_UMC 2
#defineVENDOR_AMD 3
#defineVENDOR_CYRIX 4
#defineVENDOR_NEXGEN 5
#defineVENDOR_CENTAUR 6
#defineVENDOR_RISE 7
#defineVENDOR_SIS 8
#defineVENDOR_TRANSMETA 9
#defineVENDOR_NSC 10
#defineVENDOR_HYGON 11
#defineVENDOR_ZHAOXIN 12
#defineVENDOR_UNKNOWN 99
#defineBITMASK(a, b, c) ((((a) >> (b)) & (c)))
#defineFAMILY_80486 4
#defineFAMILY_P5 5
#defineFAMILY_P6 6
#defineFAMILY_PM 7
#defineFAMILY_IA64 8
#ifdefINTEL_AMD
#defineGET_EXFAMILY 1
#defineGET_EXMODEL 2
#defineGET_TYPE 3
#defineGET_FAMILY 4
#defineGET_MODEL 5
#defineGET_APICID 6
#defineGET_LCOUNT 7
#defineGET_CHUNKS 8
#defineGET_STEPPING 9
#defineGET_BLANDID 10
#defineGET_FEATURE 11
#defineGET_NUMSHARE 12
#defineGET_NUMCORES 13
#endif
#ifdef__ia64__
#defineGET_ARCHREV 1
#defineGET_FAMILY 2
#defineGET_MODEL 3
#defineGET_REVISION 4
#defineGET_NUMBER 5
#endif
#defineCORE_UNKNOWN 0
#defineCORE_80486 1
#defineCORE_P5 2
#defineCORE_P6 3
#defineCORE_KATMAI 4
#defineCORE_COPPERMINE 5
#defineCORE_NORTHWOOD 6
#defineCORE_PRESCOTT 7
#defineCORE_BANIAS 8
#defineCORE_ATHLON 9
#defineCORE_OPTERON 10
#defineCORE_BARCELONA 11
#defineCORE_VIAC3 12
#defineCORE_YONAH 13
#defineCORE_CORE2 14
#defineCORE_PENRYN 15
#defineCORE_DUNNINGTON 16
#defineCORE_NEHALEM 17
#defineCORE_ATOM 18
#defineCORE_NANO 19
#defineCORE_SANDYBRIDGE 20
#defineCORE_BOBCAT 21
#defineCORE_BULLDOZER 22
#defineCORE_PILEDRIVER 23
#defineCORE_HASWELL 24
#defineCORE_STEAMROLLER 25
#defineCORE_EXCAVATOR 26
#defineCORE_ZEN 27
#defineCORE_SKYLAKEX 28
#defineCORE_DHYANA 29
#defineCORE_COOPERLAKE 30
#defineCORE_SAPPHIRERAPIDS 31
#defineHAVE_SSE (1 << 0)
#defineHAVE_SSE2 (1 << 1)
#defineHAVE_SSE3 (1 << 2)
#defineHAVE_SSSE3 (1 << 3)
#defineHAVE_SSE4_1 (1 << 4)
#defineHAVE_SSE4_2 (1 << 5)
#defineHAVE_SSE4A (1 << 6)
#defineHAVE_SSE5 (1 << 7)
#defineHAVE_MMX (1 << 8)
#defineHAVE_3DNOW (1 << 9)
#defineHAVE_3DNOWEX (1 << 10)
#defineHAVE_CMOV (1 << 11)
#defineHAVE_PSE (1 << 12)
#defineHAVE_CFLUSH (1 << 13)
#defineHAVE_HIT (1 << 14)
#defineHAVE_MISALIGNSSE (1 << 15)
#defineHAVE_128BITFPU (1 << 16)
#defineHAVE_FASTMOVU (1 << 17)
#defineHAVE_AVX (1 << 18)
#defineHAVE_FMA4 (1 << 19)
#defineHAVE_FMA3 (1 << 20)
#defineHAVE_AVX512VL (1 << 21)
#defineHAVE_AVX2 (1 << 22)
#defineHAVE_AVX512BF16 (1 << 23)
#defineHAVE_AMXBF16 (1 << 24)
#defineCACHE_INFO_L1_I 1
#defineCACHE_INFO_L1_D 2
#defineCACHE_INFO_L2 3
#defineCACHE_INFO_L3 4
#defineCACHE_INFO_L1_ITB 5
#defineCACHE_INFO_L1_DTB 6
#defineCACHE_INFO_L1_LITB 7
#defineCACHE_INFO_L1_LDTB 8
#defineCACHE_INFO_L2_ITB 9
#defineCACHE_INFO_L2_DTB 10
#defineCACHE_INFO_L2_LITB 11
#defineCACHE_INFO_L2_LDTB 12
typedefstruct {
intsize;
intassociative;
intlinesize;
intshared;
} cache_info_t;
#defineCPUTYPE_UNKNOWN 0
#defineCPUTYPE_INTEL_UNKNOWN 1
#defineCPUTYPE_UMC_UNKNOWN 2
#defineCPUTYPE_AMD_UNKNOWN 3
#defineCPUTYPE_CYRIX_UNKNOWN 4
#defineCPUTYPE_NEXGEN_UNKNOWN 5
#defineCPUTYPE_CENTAUR_UNKNOWN 6
#defineCPUTYPE_RISE_UNKNOWN 7
#defineCPUTYPE_SIS_UNKNOWN 8
#defineCPUTYPE_TRANSMETA_UNKNOWN 9
#defineCPUTYPE_NSC_UNKNOWN 10
#defineCPUTYPE_80386 11
#defineCPUTYPE_80486 12
#defineCPUTYPE_PENTIUM 13
#defineCPUTYPE_PENTIUM2 14
#defineCPUTYPE_PENTIUM3 15
#defineCPUTYPE_PENTIUMM 16
#defineCPUTYPE_PENTIUM4 17
#defineCPUTYPE_CORE2 18
#defineCPUTYPE_PENRYN 19
#defineCPUTYPE_DUNNINGTON 20
#defineCPUTYPE_NEHALEM 21
#defineCPUTYPE_ATOM 22
#defineCPUTYPE_ITANIUM 23
#defineCPUTYPE_ITANIUM2 24
#defineCPUTYPE_AMD5X86 25
#defineCPUTYPE_AMDK6 26
#defineCPUTYPE_ATHLON 27
#defineCPUTYPE_DURON 28
#defineCPUTYPE_OPTERON 29
#defineCPUTYPE_BARCELONA 30
#defineCPUTYPE_SHANGHAI 31
#defineCPUTYPE_ISTANBUL 32
#defineCPUTYPE_CYRIX5X86 33
#defineCPUTYPE_CYRIXM1 34
#defineCPUTYPE_CYRIXM2 35
#defineCPUTYPE_NEXGENNX586 36
#defineCPUTYPE_CENTAURC6 37
#defineCPUTYPE_RISEMP6 38
#defineCPUTYPE_SYS55X 39
#defineCPUTYPE_CRUSOETM3X 40
#defineCPUTYPE_NSGEODE 41
#defineCPUTYPE_VIAC3 42
#defineCPUTYPE_NANO 43
#defineCPUTYPE_SANDYBRIDGE 44
#defineCPUTYPE_BOBCAT 45
#defineCPUTYPE_BULLDOZER 46
#defineCPUTYPE_PILEDRIVER 47
#defineCPUTYPE_HASWELL 48
#defineCPUTYPE_STEAMROLLER 49
#defineCPUTYPE_EXCAVATOR 50
#defineCPUTYPE_ZEN 51
#defineCPUTYPE_SKYLAKEX 52
#defineCPUTYPE_DHYANA 53
#defineCPUTYPE_COOPERLAKE 54
#defineCPUTYPE_SAPPHIRERAPIDS 55
#defineCPUTYPE_HYGON_UNKNOWN 99
#endif