blob: 5531993f7d9f279963432793c296b01e956d092a [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
Myles Watson1d6d45e2009-11-06 17:02:51 +000020#if !defined( __ROMCC__ ) && !defined (__PRE_RAM__)
Eric Biedermanc84c1902004-10-14 20:13:01 +000021static inline unsigned long long rdtscll(void)
22{
23 unsigned long long val;
24 asm volatile ("rdtsc" : "=A" (val));
25 return val;
26}
Eric Biedermanc84c1902004-10-14 20:13:01 +000027#endif
28
Eric Biedermanc84c1902004-10-14 20:13:01 +000029#endif /* CPU_X86_TSC_H */