1 #ifndef FIO_ARCH_X86_COMMON
2 #define FIO_ARCH_X86_COMMON
6 static inline void do_cpuid(unsigned int *eax, unsigned int *ebx,
7 unsigned int *ecx, unsigned int *edx)
10 : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
11 : "0" (*eax), "2" (*ecx)
15 static inline void cpuid(unsigned int op,
16 unsigned int *eax, unsigned int *ebx,
17 unsigned int *ecx, unsigned int *edx)
21 do_cpuid(eax, ebx, ecx, edx);
24 #define ARCH_HAVE_INIT
26 extern int tsc_reliable;
28 static inline int arch_init_intel(unsigned int level)
30 unsigned int eax, ebx, ecx = 0, edx;
36 do_cpuid(&eax, &ebx, &ecx, &edx);
37 if (!(edx & (1U << 4)))
41 * Check for constant rate and synced (across cores) TSC
44 do_cpuid(&eax, &ebx, &ecx, &edx);
45 return edx & (1U << 8);
48 static inline int arch_init_amd(unsigned int level)
50 unsigned int eax, ebx, ecx, edx;
52 cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
56 cpuid(0x80000007, &eax, &ebx, &ecx, &edx);
63 static inline int arch_init(char *envp[])
68 cpuid(0, &level, (unsigned int *) &str[0],
69 (unsigned int *) &str[8],
70 (unsigned int *) &str[4]);
72 if (!strcmp(str, "GenuineIntel"))
73 tsc_reliable = arch_init_intel(level);
74 else if (!strcmp(str, "AuthenticAMD"))
75 tsc_reliable = arch_init_amd(level);