EHS
CPU.h
Go to the documentation of this file.
1#pragma once
2
3#include "ehs/Types.h"
4#include "Architecture.h"
5#include "OS.h"
6#include "ehs/Str.h"
7#include "ehs/Array.h"
8
9namespace ehs
10{
11 enum class Architecture : UInt_8
12 {
13 X64,
14 X86,
15 ARM64,
16 ARM,
18 };
19
20 enum class Endianness : UInt_8
21 {
22 LE,
23 BE
24 };
25
26 struct TSC
27 {
31 };
32
33 class EHS_LIB_IO CPU
34 {
35 private:
36 #ifdef EHS_OS_LINUX
37 static UInt_64 TSC_Freq;
38 #endif
39
40 public:
41 static const bool hasFPU;
42 static const bool hasVME;
43 static const bool hasDE;
44 static const bool hasPSE;
45 static const bool hasTSC;
46 static const bool hasMSR;
47 static const bool hasPAE;
48 static const bool hasMCE;
49 static const bool hasCX8;
50 static const bool hasAPIC;
51 static const bool hasSEP;
52 static const bool hasMTRR;
53 static const bool hasPGE;
54 static const bool hasMCA;
55 static const bool hasCMOV;
56 static const bool hasPSE_36;
57 static const bool hasPSN;
58 static const bool hasCLFSH;
59 static const bool hasDS;
60 static const bool hasACPI;
61 static const bool hasMMX;
62 static const bool hasFXSR;
63 static const bool hasSSE;
64 static const bool hasSSE2;
65 static const bool hasSS;
66 static const bool hasHTT;
67 static const bool hasTM;
68 static const bool hasIA64;
69 static const bool hasPBE;
70 static const bool hasSSE3;
71 static const bool hasPCLMULQDQ;
72 static const bool hasDTES64;
73 static const bool hasMONITOR;
74 static const bool hasVMX;
75 static const bool hasSMX;
76 static const bool hasEST;
77 static const bool hasTM2;
78 static const bool hasSSSE3;
79 static const bool hasCNXT_ID;
80 static const bool hasSDBG;
81 static const bool hasFMA;
82 static const bool hasCX16;
83 static const bool hasXTPR;
84 static const bool hasPDCM;
85 static const bool hasPCID;
86 static const bool hasDCA;
87 static const bool hasSSE4_1;
88 static const bool hasSSE4_2;
89 static const bool hasX2APIC;
90 static const bool hasMOVBE;
91 static const bool hasPOPCNT;
92 static const bool hasTSC_DEADLINE;
93 static const bool hasAES;
94 static const bool hasXSAVE;
95 static const bool hasOSXSAVE;
96 static const bool hasAVX;
97 static const bool hasF16C;
98 static const bool hasRDRND;
99 static const bool hasHYPERVISOR;
100 static const bool hasAVX2;
101 static const bool hasAVX512F;
102 static const bool hasRDSEED;
103 static const bool hasADX;
104
105 static Architecture GetArchitecture();
106
107 static UInt_8 PointerSize();
108
109 static Endianness GetEndianness();
110
111 static void RDTSCP(TSC* tsc);
112
113 static UInt_64 GetTSC_Freq();
114
115 static UInt_64 GetTSC();
116
119 static void GetManufacturer(Char_8* input);
120
121 static UInt_32 GetInfoBits();
122
123 static UInt_8 GetSteppingId();
124
125 static UInt_8 GetModelId();
126
127 static UInt_8 GetFamilyId();
128
129 static UInt_8 GetProcessorTypeId();
130
131 static UInt_8 GetExtModelId();
132
133 static UInt_8 GetExtFamilyId();
134
137 static void GetBrand(Char_8* input);
138
139 static UInt_8 GetCacheLineSize();
140
141 static UInt_32 GetFeatureBits_1();
142
143 static UInt_32 GetFeatureBits_2();
144
145 static UInt_32 GetExtFeatureBits_1();
146
147 static UInt_32 GetExtFeatureBits_2();
148
149 static UInt_32 GetExtFeatureBits_3();
150
151 private:
152 static bool RetrieveFPU();
153
154 static bool RetrieveVME();
155
156 static bool RetrieveDE();
157
158 static bool RetrievePSE();
159
160 static bool RetrieveTSC();
161
162 static bool RetrieveMSR();
163
164 static bool RetrievePAE();
165
166 static bool RetrieveMCE();
167
168 static bool RetrieveCX8();
169
170 static bool RetrieveAPIC();
171
172 static bool RetrieveSEP();
173
174 static bool RetrieveMTRR();
175
176 static bool RetrievePGE();
177
178 static bool RetrieveMCA();
179
180 static bool RetrieveCMOV();
181
182 static bool RetrievePAT();
183
184 static bool RetrievePSE_36();
185
186 static bool RetrievePSN();
187
188 static bool RetrieveCLFSH();
189
190 static bool RetrieveDS();
191
192 static bool RetrieveACPI();
193
194 static bool RetrieveMMX();
195
196 static bool RetrieveFXSR();
197
198 static bool RetrieveSSE();
199
200 static bool RetrieveSSE2();
201
202 static bool RetrieveSS();
203
204 static bool RetrieveHTT();
205
206 static bool RetrieveTM();
207
208 static bool RetrieveIA64();
209
210 static bool RetrievePBE();
211
212 static bool RetrieveSSE3();
213
214 static bool RetrievePCLMULQDQ();
215
216 static bool RetrieveDTES64();
217
218 static bool RetrieveMONITOR();
219
220 static bool RetrieveDS_CPL();
221
222 static bool RetrieveVMX();
223
224 static bool RetrieveSMX();
225
226 static bool RetrieveEST();
227
228 static bool RetrieveTM2();
229
230 static bool RetrieveSSSE3();
231
232 static bool RetrieveCNXT_ID();
233
234 static bool RetrieveSDBG();
235
236 static bool RetrieveFMA();
237
238 static bool RetrieveCX16();
239
240 static bool RetrieveXTPR();
241
242 static bool RetrievePDCM();
243
244 static bool RetrievePCID();
245
246 static bool RetrieveDCA();
247
248 static bool RetrieveSSE4_1();
249
250 static bool RetrieveSSE4_2();
251
252 static bool RetrieveX2APIC();
253
254 static bool RetrieveMOVBE();
255
256 static bool RetrievePOPCNT();
257
258 static bool RetrieveTSC_DEADLINE();
259
260 static bool RetrieveAES();
261
262 static bool RetrieveXSAVE();
263
264 static bool RetrieveOSXSAVE();
265
266 static bool RetrieveAVX();
267
268 static bool RetrieveF16C();
269
270 static bool RetrieveRDRND();
271
272 static bool RetrieveHYPERVISOR();
273
274 static bool RetrieveAVX2();
275
276 static bool RetrieveAVX512F();
277
278 static bool RetrieveRDSEED();
279
280 static bool RetrieveADX();
281
282 //static Str_8 ToStr();
283
284 static UInt_64 RetrieveTSC_Freq();
285
286 static UInt_64 CalculateTSC_Freq();
287 };
288}
Definition: CPU.h:34
static const bool hasHYPERVISOR
Definition: CPU.h:99
static const bool hasFXSR
Definition: CPU.h:62
static const bool hasSDBG
Definition: CPU.h:80
static const bool hasACPI
Definition: CPU.h:60
static const bool hasMONITOR
Definition: CPU.h:73
static const bool hasAVX
Definition: CPU.h:96
static const bool hasTM2
Definition: CPU.h:77
static const bool hasVMX
Definition: CPU.h:74
static const bool hasSS
Definition: CPU.h:65
static const bool hasF16C
Definition: CPU.h:97
static const bool hasOSXSAVE
Definition: CPU.h:95
static const bool hasSEP
Definition: CPU.h:51
static const bool hasCX16
Definition: CPU.h:82
static const bool hasPSE_36
Definition: CPU.h:56
static const bool hasMOVBE
Definition: CPU.h:90
static const bool hasXSAVE
Definition: CPU.h:94
static const bool hasSSE3
Definition: CPU.h:70
static const bool hasHTT
Definition: CPU.h:66
static const bool hasDTES64
Definition: CPU.h:72
static const bool hasCX8
Definition: CPU.h:49
static const bool hasAVX512F
Definition: CPU.h:101
static const bool hasDCA
Definition: CPU.h:86
static const bool hasADX
Definition: CPU.h:103
static const bool hasEST
Definition: CPU.h:76
static const bool hasSSE
Definition: CPU.h:63
static const bool hasDE
Definition: CPU.h:43
static const bool hasAES
Definition: CPU.h:93
static const bool hasXTPR
Definition: CPU.h:83
static const bool hasTSC_DEADLINE
Definition: CPU.h:92
static const bool hasMTRR
Definition: CPU.h:52
static const bool hasMCE
Definition: CPU.h:48
static const bool hasTM
Definition: CPU.h:67
static const bool hasMSR
Definition: CPU.h:46
static const bool hasPSE
Definition: CPU.h:44
static const bool hasFPU
Definition: CPU.h:41
static const bool hasSMX
Definition: CPU.h:75
static const bool hasIA64
Definition: CPU.h:68
static const bool hasPAE
Definition: CPU.h:47
static const bool hasX2APIC
Definition: CPU.h:89
static const bool hasMCA
Definition: CPU.h:54
static const bool hasVME
Definition: CPU.h:42
static const bool hasSSE4_1
Definition: CPU.h:87
static const bool hasPGE
Definition: CPU.h:53
static const bool hasSSE2
Definition: CPU.h:64
static const bool hasPSN
Definition: CPU.h:57
static const bool hasSSSE3
Definition: CPU.h:78
static const bool hasSSE4_2
Definition: CPU.h:88
static const bool hasPDCM
Definition: CPU.h:84
static const bool hasAPIC
Definition: CPU.h:50
static const bool hasAVX2
Definition: CPU.h:100
static const bool hasPCLMULQDQ
Definition: CPU.h:71
static const bool hasFMA
Definition: CPU.h:81
static const bool hasPBE
Definition: CPU.h:69
static const bool hasMMX
Definition: CPU.h:61
static const bool hasRDSEED
Definition: CPU.h:102
static const bool hasRDRND
Definition: CPU.h:98
static const bool hasDS
Definition: CPU.h:59
static const bool hasPOPCNT
Definition: CPU.h:91
static const bool hasCNXT_ID
Definition: CPU.h:79
static const bool hasCMOV
Definition: CPU.h:55
static const bool hasTSC
Definition: CPU.h:45
static const bool hasCLFSH
Definition: CPU.h:58
static const bool hasPCID
Definition: CPU.h:85
Definition: Anchor.h:6
Endianness
Definition: CPU.h:21
Architecture
Definition: CPU.h:12
unsigned int UInt_32
Definition: Types.h:49
char Char_8
Definition: Types.h:40
unsigned char UInt_8
Definition: Types.h:43
Definition: CPU.h:27
UInt_32 lowCount
Definition: CPU.h:30
UInt_32 coreId
Definition: CPU.h:28
UInt_32 highCount
Definition: CPU.h:29