[PATCH] i386: Add X86_FEATURE_RDTSCP
[deliverable/linux.git] / include / asm-i386 / tsc.h
CommitLineData
2272b0e0
AS
1/*
2 * linux/include/asm-i386/tsc.h
3 *
4 * i386 TSC related functions
5 */
6#ifndef _ASM_i386_TSC_H
7#define _ASM_i386_TSC_H
8
9#include <asm/processor.h>
10
11/*
12 * Standard way to access the cycle counter.
13 */
14typedef unsigned long long cycles_t;
15
16extern unsigned int cpu_khz;
17extern unsigned int tsc_khz;
18
19static inline cycles_t get_cycles(void)
20{
21 unsigned long long ret = 0;
22
23#ifndef CONFIG_X86_TSC
24 if (!cpu_has_tsc)
25 return 0;
26#endif
27
28#if defined(CONFIG_X86_GENERIC) || defined(CONFIG_X86_TSC)
29 rdtscll(ret);
30#endif
31 return ret;
32}
33
34/* Like get_cycles, but make sure the CPU is synchronized. */
35static __always_inline cycles_t get_cycles_sync(void)
36{
37 unsigned long long ret;
2272b0e0
AS
38 unsigned eax;
39
40 /*
41 * Don't do an additional sync on CPUs where we know
42 * RDTSC is already synchronous:
43 */
44 alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC,
45 "=a" (eax), "0" (1) : "ebx","ecx","edx","memory");
2272b0e0
AS
46 rdtscll(ret);
47
48 return ret;
49}
50
51extern void tsc_init(void);
5a90cf20 52extern void mark_tsc_unstable(char *reason);
2272b0e0
AS
53extern int unsynchronized_tsc(void);
54extern void init_tsc_clocksource(void);
55
56/*
57 * Boot-time check whether the TSCs are synchronized across
58 * all CPUs/cores:
59 */
60extern void check_tsc_sync_source(int cpu);
61extern void check_tsc_sync_target(void);
62
63#endif
This page took 0.041198 seconds and 5 git commands to generate.