blob: c57362755a5b2afecc1d0d682ddee52302b497e0 [file] [log] [blame]
Eric Biedermanc84c1902004-10-14 20:13:01 +00001#ifndef CPU_X86_TSC_H
2#define CPU_X86_TSC_H
3
4struct tsc_struct {
5 unsigned lo;
6 unsigned hi;
7};
8typedef struct tsc_struct tsc_t;
9
Stefan Reinauer348a1ba2010-03-17 01:51:11 +000010static inline tsc_t rdtsc(void)
Eric Biedermanc84c1902004-10-14 20:13:01 +000011{
12 tsc_t res;
13 __asm__ __volatile__ (
14 "rdtsc"
15 : "=a" (res.lo), "=d"(res.hi) /* outputs */
16 );
17 return res;
18}
19
Stefan Reinauer35b6bbb2010-03-28 21:26:54 +000020#if !defined(__ROMCC__)
21/* Too many registers for ROMCC */
Eric Biedermanc84c1902004-10-14 20:13:01 +000022static inline unsigned long long rdtscll(void)
23{
24 unsigned long long val;
25 asm volatile ("rdtsc" : "=A" (val));
26 return val;
27}
Eric Biedermanc84c1902004-10-14 20:13:01 +000028#endif
29
Eric Biedermanc84c1902004-10-14 20:13:01 +000030#endif /* CPU_X86_TSC_H */