tsc.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * x86 TSC related functions
  3. */
  4. #ifndef _ASM_X86_TSC_H
  5. #define _ASM_X86_TSC_H
  6. #include <asm/processor.h>
  7. #define NS_SCALE 10 /* 2^10, carefully chosen */
  8. #define US_SCALE 32 /* 2^32, arbitralrily chosen */
  9. /*
  10. * Standard way to access the cycle counter.
  11. */
  12. typedef unsigned long long cycles_t;
  13. extern unsigned int cpu_khz;
  14. extern unsigned int tsc_khz;
  15. extern void disable_TSC(void);
  16. static inline cycles_t get_cycles(void)
  17. {
  18. #ifndef CONFIG_X86_TSC
  19. if (!cpu_has_tsc)
  20. return 0;
  21. #endif
  22. return rdtsc();
  23. }
  24. extern void tsc_init(void);
  25. extern void mark_tsc_unstable(char *reason);
  26. extern int unsynchronized_tsc(void);
  27. extern int check_tsc_unstable(void);
  28. extern int check_tsc_disabled(void);
  29. extern unsigned long native_calibrate_tsc(void);
  30. extern int tsc_clocksource_reliable;
  31. /*
  32. * Boot-time check whether the TSCs are synchronized across
  33. * all CPUs/cores:
  34. */
  35. extern void check_tsc_sync_source(int cpu);
  36. extern void check_tsc_sync_target(void);
  37. extern int notsc_setup(char *);
  38. extern void tsc_save_sched_clock_state(void);
  39. extern void tsc_restore_sched_clock_state(void);
  40. /* MSR based TSC calibration for Intel Atom SoC platforms */
  41. unsigned long try_msr_calibrate_tsc(void);
  42. #endif /* _ASM_X86_TSC_H */