tsc.h 1.2 KB
Newer Older
1
/*
T
Thomas Gleixner 已提交
2
 * x86 TSC related functions
3
 */
H
H. Peter Anvin 已提交
4 5
#ifndef _ASM_X86_TSC_H
#define _ASM_X86_TSC_H
6 7 8

#include <asm/processor.h>

T
Thomas Gleixner 已提交
9 10 11
#define NS_SCALE	10 /* 2^10, carefully chosen */
#define US_SCALE	32 /* 2^32, arbitralrily chosen */

12 13 14 15 16 17 18
/*
 * Standard way to access the cycle counter.
 */
typedef unsigned long long cycles_t;

extern unsigned int cpu_khz;
extern unsigned int tsc_khz;
19 20

extern void disable_TSC(void);
21 22 23 24 25 26 27 28 29 30

static inline cycles_t get_cycles(void)
{
	unsigned long long ret = 0;

#ifndef CONFIG_X86_TSC
	if (!cpu_has_tsc)
		return 0;
#endif
	rdtscll(ret);
I
Ingo Molnar 已提交
31

32 33 34 35
	return ret;
}

extern void tsc_init(void);
36
extern void mark_tsc_unstable(char *reason);
37
extern int unsynchronized_tsc(void);
38
extern int check_tsc_unstable(void);
39
extern int check_tsc_disabled(void);
40
extern unsigned long native_calibrate_tsc(void);
41

42 43
extern int tsc_clocksource_reliable;

44 45 46 47 48 49 50
/*
 * Boot-time check whether the TSCs are synchronized across
 * all CPUs/cores:
 */
extern void check_tsc_sync_source(int cpu);
extern void check_tsc_sync_target(void);

51
extern int notsc_setup(char *);
52 53
extern void tsc_save_sched_clock_state(void);
extern void tsc_restore_sched_clock_state(void);
54

55
/* MSR based TSC calibration for Intel Atom SoC platforms */
56
unsigned long try_msr_calibrate_tsc(void);
57

H
H. Peter Anvin 已提交
58
#endif /* _ASM_X86_TSC_H */