Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# deMachineWindowsCPU.hpp

Go to the documentation of this file.

    00001 ///////////////////////////////////////////////////////////////////////////////
    00002 /// @file deMachineWindowsCPU.cpp
    00003 ///
    00004 /// @brief CPU Detector
    00005 ///
    00006 /// @author Lightning
    00007 ///
    00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
    00009 /// contents of this file is subject to the Destiny3D Member License which
    00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
    00011 ///
    00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
    00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
    00014 /// for any particular purpose.
    00015 ///
    00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
    00017 ///
    00018 /// <hr>
    00019 ///                                 Change History
    00020 /// <hr>
    00021 ///
    00022 /// @date Nov 2001
    00023 /// @author Lightning
    00024 /// @remarks Creation
    00025 ///
    00026 ///////////////////////////////////////////////////////////////////////////////
    00027
    00028 #ifndef DEMACHINEWINDOWSCPU_HPP
    00029 #define DEMACHINEWINDOWSCPU_HPP
    00030
    00031
    00032
    00033 //=================================================================================
    00034 // Includes
    00035 //=================================================================================
    00036
    00037 #include "deMachineWindows.hpp"
    00038
    00039
    00040
    00041 //=================================================================================
    00042 // Defines
    00043 //=================================================================================
    00044
    00045 //Intel Feature Flags
    00046 #define CPU_INTEL_FPU     0x00000001 // Bit 0 - Floating-Point unit on chip
    00047 #define CPU_INTEL_VME     0x00000002 // Bit 1 - Virtual Mode Extention
    00048 #define CPU_INTEL_DE      0x00000004 // Bit 2 - Debugging Extention
    00049 #define CPU_INTEL_PSE     0x00000008 // Bit 3 - Page Size Extention
    00050 #define CPU_INTEL_TSC     0x00000010 // Bit 4 - Time Stamp Counter
    00051 #define CPU_INTEL_MSR     0x00000020 // Bit 5 - Model Specific Registers
    00052 #define CPU_INTEL_PAE     0x00000040 // Bit 6 - Physical Address Extention
    00053 #define CPU_INTEL_MCE     0x00000080 // Bit 7 - Machine Check Exception
    00054 #define CPU_INTEL_CX8     0x00000100 // Bit 8 - CMPXCHG8 Instruction
    00055 #define CPU_INTEL_APIC    0x00000200 // Bit 9 - Software-accessible local APIC on Chip
    00056 #define CPU_INTEL_BIT_10  0x00000400 // Bit 10 - Reserved
    00057 #define CPU_INTEL_SEP     0x00000800 // Bit 11 - Fast System Call
    00058 #define CPU_INTEL_MTRR    0x00001000 // Bit 12 - Memory Type Range Registers
    00059 #define CPU_INTEL_PGE     0x00002000 // Bit 13 - Page Global Enable
    00060 #define CPU_INTEL_MCA     0x00004000 // Bit 14 - Machine Check Architecture
    00061 #define CPU_INTEL_CMOV    0x00008000 // Bit 15 - Conditional Move Instruction
    00062 #define CPU_INTEL_PAT     0x00010000 // Bit 16 - Page Attribute Table
    00063 #define CPU_INTEL_PSE36   0x00020000 // Bit 17 - 36-bit Page Size Extention
    00064 #define CPU_INTEL_PN      0x00040000 // Bit 18 - Processor Number
    00065 #define CPU_INTEL_CLFSH   0x00080000 // Bit 19 - CLFlush command support
    00066 #define CPU_INTEL_BIT_20  0x00100000 // Bit 20 - Reserved
    00067 #define CPU_INTEL_DS      0x00200000 // Bit 21 - Debug Store
    00068 #define CPU_INTEL_ACPI    0x00400000 // Bit 22 - ACPI Preprocessor Performance Modulation Registers
    00069 #define CPU_INTEL_MMX     0x00800000 // Bit 23 - MMX technology
    00070 #define CPU_INTEL_FXSR    0x01000000 // Bit 24 - Fast Floating Point Save and Restore
    00071 #define CPU_INTEL_SSE     0x02000000 // Bit 25 - Streaming SIMD Extension
    00072 #define CPU_INTEL_SSE2    0x04000000 // Bit 26 - SSE2
    00073 #define CPU_INTEL_SS      0x08000000 // Bit 27 - Self Snoop
    00074 #define CPU_INTEL_BIT_28  0x10000000 // Bit 28 - Reserved
    00075 #define CPU_INTEL_TM      0x20000000 // Bit 29 - Thermal Monitor
    00076 #define CPU_INTEL_BIT_30  0x40000000 // Bit 30 - Reserved
    00077 #define CPU_INTEL_BIT_31  0x80000000 // Bit 31 - Reserved
    00078
    00079
    00080 //AMD Feature Flags
    00081 #define CPU_AMD_FPU       0x00000001 // Bit 0 - Floating-Point unit on chip
    00082 #define CPU_AMD_VME       0x00000002 // Bit 1 - Virtual Mode Extention
    00083 #define CPU_AMD_DE        0x00000004 // Bit 2 - Debugging Extention
    00084 #define CPU_AMD_PSE       0x00000008 // Bit 3 - Page Size Extention
    00085 #define CPU_AMD_TSC       0x00000010 // Bit 4 - Time Stamp Counter
    00086 #define CPU_AMD_MSR       0x00000020 // Bit 5 - Model Specific Registers
    00087 #define CPU_AMD_PAE       0x00000040 // Bit 6 - Page Address Extension
    00088 #define CPU_AMD_MCE       0x00000080 // Bit 7 - Machine Check Exception
    00089 #define CPU_AMD_CX8       0x00000100 // Bit 8 - CMPXCHG8 Instruction
    00090 #define CPU_AMD_APIC      0x00000200 // Bit 9 - On-chip APIC
    00091 #define CPU_AMD_BIT_10    0x00000400 // Bit 10 - Reserved
    00092 #define CPU_AMD_SEP       0x00000800 // Bit 11 - Fast System Call
    00093 #define CPU_AMD_MTRR      0x00001000 // Bit 12 - Memory Type Range Registers
    00094 #define CPU_AMD_PGE       0x00002000 // Bit 13 - Page Global Enable
    00095 #define CPU_AMD_MCA       0x00004000 // Bit 14 - Machine Check Architecture
    00096 #define CPU_AMD_CMOV      0x00008000 // Bit 15 - Integer Conditional Move Instruction
    00097 #define CPU_AMD_PAT       0x00010000 // Bit 16 - Page Attribute Table
    00098 #define CPU_AMD_PSE36     0x00020000 // Bit 17 - 36-bit Page Size Extension
    00099 #define CPU_AMD_BIT_18    0x00040000 // Bit 18 - Reserved
    00100 #define CPU_AMD_BIT_19    0x00080000 // Bit 19 - Reserved
    00101 #define CPU_AMD_BIT_20    0x00100000 // Bit 20 - Reserved
    00102 #define CPU_AMD_BIT_21    0x00200000 // Bit 21 - Reserved
    00103 #define CPU_AMD_BIT_22    0x00400000 // Bit 22 - Reserved
    00104 #define CPU_AMD_MMX       0x00800000 // Bit 23 - MMX technology
    00105 #define CPU_AMD_FXSR      0x01000000 // Bit 24 - Fast floating point save and restore
    00106 #define CPU_AMD_SSE       0x02000000 // Bit 25 - Streaming SIMD Extention
    00107 #define CPU_AMD_BIT_26    0x04000000 // Bit 26 - Reserved
    00108 #define CPU_AMD_BIT_27    0x08000000 // Bit 27 - Reserved
    00109 #define CPU_AMD_BIT_28    0x10000000 // Bit 28 - Reserved
    00110 #define CPU_AMD_BIT_29    0x20000000 // Bit 29 - Reserved
    00111 #define CPU_AMD_BIT_30    0x40000000 // Bit 30 - Reserved
    00112 #define CPU_AMD_BIT_31    0x80000000 // Bit 31 - Reserved
    00113
    00114 //AMD Extended Feature Flags
    00115 #define CPU_AMD_EXT_FPU       0x00000001 // Bit 0 - Floating-Point unit on chip
    00116 #define CPU_AMD_EXT_VME       0x00000002 // Bit 1 - Virtual Mode Extention
    00117 #define CPU_AMD_EXT_DE        0x00000004 // Bit 2 - Debugging Extention
    00118 #define CPU_AMD_EXT_PSE       0x00000008 // Bit 3 - Page Size Extention
    00119 #define CPU_AMD_EXT_TSC       0x00000010 // Bit 4 - Time Stamp Counter
    00120 #define CPU_AMD_EXT_MSR       0x00000020 // Bit 5 - Model Specific Registers
    00121 #define CPU_AMD_EXT_PAE       0x00000040 // Bit 6 - Page Address Extension
    00122 #define CPU_AMD_EXT_MCE       0x00000080 // Bit 7 - Machine Check Exception
    00123 #define CPU_AMD_EXT_CX8       0x00000100 // Bit 8 - CMPXCHG8 Instruction
    00124 #define CPU_AMD_EXT_APIC      0x00000200 // Bit 9 - On-chip APIC
    00125 #define CPU_AMD_EXT_BIT_10    0x00000400 // Bit 10 - Reserved
    00126 #define CPU_AMD_EXT_SEP       0x00000800 // Bit 11 - Fast System Call
    00127 #define CPU_AMD_EXT_MTRR      0x00001000 // Bit 12 - Memory Type Range Registers
    00128 #define CPU_AMD_EXT_PGE       0x00002000 // Bit 13 - Page Global Enable
    00129 #define CPU_AMD_EXT_MCA       0x00004000 // Bit 14 - Machine Check Architecture
    00130 #define CPU_AMD_EXT_CMOV      0x00008000 // Bit 15 - Integer Conditional Move Instruction
    00131 #define CPU_AMD_EXT_PAT       0x00010000 // Bit 16 - Page Attribute Table
    00132 #define CPU_AMD_EXT_PSE36     0x00020000 // Bit 17 - 36-bit Page Size Extension
    00133 #define CPU_AMD_EXT_BIT_18    0x00040000 // Bit 18 - Reserved
    00134 #define CPU_AMD_EXT_MPCAPABLE 0x00080000 // Bit 19 - Multiprocessing Capable
    00135 #define CPU_AMD_EXT_BIT_20    0x00100000 // Bit 20 - Reserved
    00136 #define CPU_AMD_EXT_BIT_21    0x00200000 // Bit 21 - Reserved
    00137 #define CPU_AMD_EXT_AMIE      0x00400000 // Bit 22 - AMD Multimedia Instructions Extensions
    00138 #define CPU_AMD_EXT_MMX       0x00800000 // Bit 23 - MMX technology
    00139 #define CPU_AMD_EXT_FXSR      0x01000000 // Bit 24 - Fast floating point save and restore
    00140 #define CPU_AMD_EXT_BIT_25    0x02000000 // Bit 25 - Reserved
    00141 #define CPU_AMD_EXT_BIT_26    0x04000000 // Bit 26 - Reserved
    00142 #define CPU_AMD_EXT_BIT_27    0x08000000 // Bit 27 - Reserved
    00143 #define CPU_AMD_EXT_BIT_28    0x10000000 // Bit 28 - Reserved
    00144 #define CPU_AMD_EXT_BIT_29    0x20000000 // Bit 29 - Reserved
    00145 #define CPU_AMD_EXT_3DNOWEXT  0x40000000 // Bit 30 - AMD 3DNOW! Extensions
    00146 #define CPU_AMD_EXT_3DNOW     0x80000000 // Bit 31 - AMD 3DNOW! Technology
    00147
    00148
    00149 //Intel processor types
    00150 #define INTEL_486SL                 "486(TM) SL processor"
    00151 #define INTEL_DX2WB                 "Write-Back Enhanced DX2(TM) processor"
    00152 #define INTEL_DX4                   "DX4(TM) processor"
    00153 #define INTEL_DX4OVERDRIVE          "DX4(TM) OverDrive(R) processor"
    00154 #define INTEL_PENTIUM               "Pentium(R) processor"
    00155 #define INTEL_PENTIUMMMX            "Pentium(R) processor with MMX"
    00156 #define INTEL_PENTIUMOVERDRIVE      "Pentium(R) OverDrive(R) processor"
    00157 #define INTEL_PENTIUMOVERDRIVEMMX   "Pentium(R) OverDrive(R) processor with MMX"
    00158 #define INTEL_PPRO                  "Pentium(R) Pro processor"
    00159 #define INTEL_PII                   "Pentium(R) II processor"
    00160 #define INTEL_PIIOVERDRIVE          "Pentium(R) II OverDrive(R) processor"
    00161 #define INTEL_PIIXEON               "Pentium(R) II Xeon(TM) processor"
    00162 #define INTEL_CELERON               "Celeron(TM) processor"
    00163 #define INTEL_PIII                  "Pentium(R) III processor"
    00164 #define INTEL_PIIIXEON              "Pentium(R) III Xeon(TM) processor"
    00165 #define PROCESSOR_UNKNOWN           "Unknown processor"
    00166
    00167
    00168
    00169 //=================================================================================
    00170 // deMachineWindowsCPU Class
    00171 //
    00172 // CPU Detector - Windows Version
    00173 //=================================================================================
    00174
    00175 class deMachineWindowsCPU
    00176 {
    00177 public:
    00178    deMachineWindowsCPU();
    00179
    00180    deBoolean GetCreationResult(void) { return CreationResult; }
    00181    deBoolean GetCPUInfo(deCPUInfo *Info);
    00182
    00183 private:
    00184    void StartTimer(long *Time, __int64 *Clock);
    00185    void GetVendorAndCPUInfo(void);
    00186    void GetIntelCPUInfo(long LargestExtendedFunction);
    00187    void GetEmbeddedCPUName(void);
    00188    char *GetIntelCPUName(void);
    00189    long GetIntelCPUCache(void);
    00190    void GetIntelCPUCacheValues(void);
    00191    void GetAMDCPUInfo(long LargestExtendedFunction);
    00192    void GetAMDCPUCacheValues(long LargestExtendedFunction);
    00193    void StopTimer(long *Time, __int64 *Clock);
    00194
    00195    deBoolean CreationResult;
    00196    deCPUInfo CPUInfo;
    00197 };
    00198
    00199
    00200
    00201 #endif  // End: DEMACHINEWINDOWSCPU_HPP