summaryrefslogtreecommitdiff
path: root/src/include/cpu/x86/tsc.h
blob: 96afaa6e7d02a7450343efb658956d38a7215b2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef CPU_X86_TSC_H
#define CPU_X86_TSC_H

struct tsc_struct {
	unsigned lo;
	unsigned hi;
};
typedef struct tsc_struct tsc_t;

static tsc_t rdtsc(void)
{
	tsc_t res;
	__asm__ __volatile__ (
		"rdtsc"
		: "=a" (res.lo), "=d"(res.hi) /* outputs */
		);
	return res;
}

#ifndef __ROMCC__
static inline unsigned long long rdtscll(void)
{
	unsigned long long val;
	asm volatile ("rdtsc" : "=A" (val));
	return val;
}
#endif


#endif /* CPU_X86_TSC_H */