67 #define CPUID_C(leaf, _ecx_) \
70 __cpuidex(out, leaf, _ecx_); \
76 #elif defined(__i386__) && defined(__PIC__)
78 static inline void _Vc_cpuid(
int leaf,
unsigned int &eax,
unsigned int &ebx,
unsigned int &ecx,
unsigned int &edx)
81 asm(
"mov %%ebx, %[tmpb]\n\t"
83 "mov %%ebx, %[ebx]\n\t"
84 "mov %[tmpb], %%ebx\n\t"
85 : [tmpb]
"=m"(tmpb),
"=a"(eax), [ebx]
"=m"(ebx),
"+c"(ecx),
"=d"(edx)
91 _Vc_cpuid(leaf, eax, ebx, ecx, edx)
92 #define CPUID_C(leaf, _ecx_) \
94 _Vc_cpuid(leaf, eax, ebx, ecx, edx)
97 __asm__("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(leaf))
98 #define CPUID_C(leaf, _ecx_) \
99 __asm__("cpuid" : "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx) : "a"(leaf), "c"(_ecx_))
114 case 0xE:
return 128;
115 case 0xF:
return 0xff;
123 static bool done =
false;
127 uint eax, ebx, ecx, edx;
139 const uchar processorFamilyExt = (eax & 0x0ff00000) >> 20;
141 const uchar processorModelExt = (eax & 0x000f0000) >> 12;
145 const uchar processorFamilyExt = (eax & 0x0ff00000) >> 20;
147 const uchar processorModelExt = (eax & 0x000f0000) >> 12;
150 const uchar processorModelExt = (eax & 0x000f0000) >> 12;
180 s_L3Data = (edx >> 18) * 512 * 1024;
187 bool checkLeaf4 =
false;
193 if (0 == (0x80000000u & eax)) {
194 for (
int i = 0; i < 3; ++i) {
199 if (0 == (0x80000000u & ebx)) {
200 for (
int i = 0; i < 4; ++i) {
205 if (0 == (0x80000000u & ecx)) {
206 for (
int i = 0; i < 4; ++i) {
211 if (0 == (0x80000000u & edx)) {
212 for (
int i = 0; i < 4; ++i) {
217 }
while (--repeat > 0);
224 for (
int i = 0; eax & 0x1f; ++i) {
226 const int cacheLevel = (eax >> 5) & 7;
228 const int linesize = 1 + (ebx & 0xfff); ebx >>= 12;
229 const int partitions = 1 + (ebx & 0x3ff); ebx >>= 10;
230 const int ways = 1 + (ebx & 0x3ff);
231 const int sets = 1 + ecx;
232 const int size = ways * partitions * linesize * sets;
233 switch (eax & 0x1f) {
235 switch (cacheLevel) {
254 switch (cacheLevel) {
262 switch (cacheLevel) {
static uint s_processorFeaturesD
static uint s_logicalProcessors
Namespace for new ROOT classes and functions.
static ushort s_L3DataLineSize
static uint s_processorFeatures8C
#define CPUID_C(leaf, _ecx_)
static uchar s_cacheLineSize
static uint s_L1Instruction
static uint s_L1Associativity
static ushort s_L1InstructionLineSize
static uint s_L2Associativity
static void init()
Reads the CPU capabilities and stores them for faster subsequent access.
static void interpret(uchar byte, bool *checkLeaf4)
static unsigned int CpuIdAmdAssociativityTable(int bits)
static uint s_processorFeaturesC
static bool isAmd()
Return whether the CPU vendor is AMD.
static uint s_L3Associativity
static uchar s_processorModel
static uint s_processorFeatures8D
static ushort s_L2DataLineSize
static ushort cacheLineSize()
Return the cache line size in bits.
static ushort s_L1DataLineSize
static ProcessorType s_processorType
static uchar s_processorFamily
static uchar s_brandIndex