1 #ifndef FIO_ARCH_X86_COMMON
2 #define FIO_ARCH_X86_COMMON
6 static inline void cpuid(unsigned int op,
7 unsigned int *eax, unsigned int *ebx,
8 unsigned int *ecx, unsigned int *edx)
12 do_cpuid(eax, ebx, ecx, edx);
15 #define ARCH_HAVE_INIT
17 extern int tsc_reliable;
19 static inline int arch_init_intel(unsigned int level)
21 unsigned int eax, ebx, ecx = 0, edx;
27 do_cpuid(&eax, &ebx, &ecx, &edx);
28 if (!(edx & (1U << 4)))
32 * Check for constant rate and synced (across cores) TSC
35 do_cpuid(&eax, &ebx, &ecx, &edx);
36 return edx & (1U << 8);
39 static inline int arch_init_amd(unsigned int level)
41 unsigned int eax, ebx, ecx, edx;
43 cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
47 cpuid(0x80000007, &eax, &ebx, &ecx, &edx);
54 static inline int arch_init(char *envp[])
59 cpuid(0, &level, (unsigned int *) &str[0],
60 (unsigned int *) &str[8],
61 (unsigned int *) &str[4]);
63 if (!strcmp(str, "GenuineIntel"))
64 tsc_reliable = arch_init_intel(level);
65 else if (!strcmp(str, "AuthenticAMD"))
66 tsc_reliable = arch_init_amd(level);