#pragma once #include "ehs/Types.h" #include "Architecture.h" #include "OS.h" #include "ehs/Str.h" #include "ehs/Array.h" namespace ehs { enum class Architecture : UInt_8 { X64, X86, ARM64, ARM, UNKNOWN }; enum class Endianness : UInt_8 { LE, BE }; struct TSC { UInt_32 coreId = 0; UInt_32 highCount = 0; UInt_32 lowCount = 0; }; class EHS_LIB_IO CPU { private: #ifdef EHS_OS_LINUX static UInt_64 TSC_Freq; #endif public: static const bool hasFPU; static const bool hasVME; static const bool hasDE; static const bool hasPSE; static const bool hasTSC; static const bool hasMSR; static const bool hasPAE; static const bool hasMCE; static const bool hasCX8; static const bool hasAPIC; static const bool hasSEP; static const bool hasMTRR; static const bool hasPGE; static const bool hasMCA; static const bool hasCMOV; static const bool hasPSE_36; static const bool hasPSN; static const bool hasCLFSH; static const bool hasDS; static const bool hasACPI; static const bool hasMMX; static const bool hasFXSR; static const bool hasSSE; static const bool hasSSE2; static const bool hasSS; static const bool hasHTT; static const bool hasTM; static const bool hasIA64; static const bool hasPBE; static const bool hasSSE3; static const bool hasPCLMULQDQ; static const bool hasDTES64; static const bool hasMONITOR; static const bool hasVMX; static const bool hasSMX; static const bool hasEST; static const bool hasTM2; static const bool hasSSSE3; static const bool hasCNXT_ID; static const bool hasSDBG; static const bool hasFMA; static const bool hasCX16; static const bool hasXTPR; static const bool hasPDCM; static const bool hasPCID; static const bool hasDCA; static const bool hasSSE4_1; static const bool hasSSE4_2; static const bool hasX2APIC; static const bool hasMOVBE; static const bool hasPOPCNT; static const bool hasTSC_DEADLINE; static const bool hasAES; static const bool hasXSAVE; static const bool hasOSXSAVE; static const bool hasAVX; static const bool hasF16C; static const bool hasRDRND; static const bool hasHYPERVISOR; static const bool hasAVX2; static const bool hasAVX512F; static const bool hasRDSEED; static const bool hasADX; static Architecture GetArchitecture(); static UInt_8 PointerSize(); static Endianness GetEndianness(); static void RDTSCP(TSC* tsc); static UInt_64 GetTSC_Freq(); static UInt_64 GetTSC(); /// Retrieves the CPU manufacturer id as a non null-terminated ASCII string. /// @param[out] input A twelve byte character array representing the manufacturer id. static void GetManufacturer(Char_8* input); static UInt_32 GetInfoBits(); static UInt_8 GetSteppingId(); static UInt_8 GetModelId(); static UInt_8 GetFamilyId(); static UInt_8 GetProcessorTypeId(); static UInt_8 GetExtModelId(); static UInt_8 GetExtFamilyId(); /// Retrieves the CPU brand as a null-terminated ASCII string. /// @param[out] input A 48 byte character array representing the brand. static void GetBrand(Char_8* input); static UInt_8 GetCacheLineSize(); static UInt_32 GetFeatureBits_1(); static UInt_32 GetFeatureBits_2(); static UInt_32 GetExtFeatureBits_1(); static UInt_32 GetExtFeatureBits_2(); static UInt_32 GetExtFeatureBits_3(); private: static bool RetrieveFPU(); static bool RetrieveVME(); static bool RetrieveDE(); static bool RetrievePSE(); static bool RetrieveTSC(); static bool RetrieveMSR(); static bool RetrievePAE(); static bool RetrieveMCE(); static bool RetrieveCX8(); static bool RetrieveAPIC(); static bool RetrieveSEP(); static bool RetrieveMTRR(); static bool RetrievePGE(); static bool RetrieveMCA(); static bool RetrieveCMOV(); static bool RetrievePAT(); static bool RetrievePSE_36(); static bool RetrievePSN(); static bool RetrieveCLFSH(); static bool RetrieveDS(); static bool RetrieveACPI(); static bool RetrieveMMX(); static bool RetrieveFXSR(); static bool RetrieveSSE(); static bool RetrieveSSE2(); static bool RetrieveSS(); static bool RetrieveHTT(); static bool RetrieveTM(); static bool RetrieveIA64(); static bool RetrievePBE(); static bool RetrieveSSE3(); static bool RetrievePCLMULQDQ(); static bool RetrieveDTES64(); static bool RetrieveMONITOR(); static bool RetrieveDS_CPL(); static bool RetrieveVMX(); static bool RetrieveSMX(); static bool RetrieveEST(); static bool RetrieveTM2(); static bool RetrieveSSSE3(); static bool RetrieveCNXT_ID(); static bool RetrieveSDBG(); static bool RetrieveFMA(); static bool RetrieveCX16(); static bool RetrieveXTPR(); static bool RetrievePDCM(); static bool RetrievePCID(); static bool RetrieveDCA(); static bool RetrieveSSE4_1(); static bool RetrieveSSE4_2(); static bool RetrieveX2APIC(); static bool RetrieveMOVBE(); static bool RetrievePOPCNT(); static bool RetrieveTSC_DEADLINE(); static bool RetrieveAES(); static bool RetrieveXSAVE(); static bool RetrieveOSXSAVE(); static bool RetrieveAVX(); static bool RetrieveF16C(); static bool RetrieveRDRND(); static bool RetrieveHYPERVISOR(); static bool RetrieveAVX2(); static bool RetrieveAVX512F(); static bool RetrieveRDSEED(); static bool RetrieveADX(); //static Str_8 ToStr(); static UInt_64 RetrieveTSC_Freq(); static UInt_64 CalculateTSC_Freq(); }; }