diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/cpu/x86/tsc.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/include/cpu/x86/tsc.h b/src/include/cpu/x86/tsc.h index c57362755a..6ce7f5fc7d 100644 --- a/src/include/cpu/x86/tsc.h +++ b/src/include/cpu/x86/tsc.h @@ -1,6 +1,14 @@ #ifndef CPU_X86_TSC_H #define CPU_X86_TSC_H +#if CONFIG_TSC_SYNC_MFENCE +#define TSC_SYNC "mfence\n" +#elif CONFIG_TSC_SYNC_LFENCE +#define TSC_SYNC "lfence\n" +#else +#define TSC_SYNC +#endif + struct tsc_struct { unsigned lo; unsigned hi; @@ -10,10 +18,11 @@ typedef struct tsc_struct tsc_t; static inline tsc_t rdtsc(void) { tsc_t res; - __asm__ __volatile__ ( + asm volatile ( + TSC_SYNC "rdtsc" : "=a" (res.lo), "=d"(res.hi) /* outputs */ - ); + ); return res; } @@ -22,7 +31,11 @@ static inline tsc_t rdtsc(void) static inline unsigned long long rdtscll(void) { unsigned long long val; - asm volatile ("rdtsc" : "=A" (val)); + asm volatile ( + TSC_SYNC + "rdtsc" + : "=A" (val) + ); return val; } #endif |