X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=kitten%2Finclude%2Farch-x86_64%2Ftsc.h;fp=kitten%2Finclude%2Farch-x86_64%2Ftsc.h;h=4d5a53d12b2b57355ca0549fe28226a5a0a5e079;hb=66a1a4c7a9edcd7d8bc207aca093d694a6e6b5b2;hp=0000000000000000000000000000000000000000;hpb=f7cf9c19ecb0a589dd45ae0d2c91814bd3c2acc2;p=palacios-OLD.git diff --git a/kitten/include/arch-x86_64/tsc.h b/kitten/include/arch-x86_64/tsc.h new file mode 100644 index 0000000..4d5a53d --- /dev/null +++ b/kitten/include/arch-x86_64/tsc.h @@ -0,0 +1,41 @@ +/* + * linux/include/asm-i386/tsc.h + * + * i386 TSC related functions + */ +#ifndef _ARCH_x86_64_TSC_H +#define _ARCH_x86_64_TSC_H + +#include +#include + +typedef uint64_t cycles_t; + +/** + * Returns the current value of the CPU's cycle counter. + * + * NOTE: This is not serializing. It doesn't necessarily wait for previous + * instructions to complete before reading the cycle counter. Also, + * subsequent instructions could potentially begin execution before + * the cycle counter is read. + */ +static __always_inline cycles_t +get_cycles(void) +{ + cycles_t ret = 0; + rdtscll(ret); + return ret; +} + +/** + * This is a synchronizing version of get_cycles(). It ensures that all + * previous instructions have completed before reading the cycle counter. + */ +static __always_inline cycles_t +get_cycles_sync(void) +{ + sync_core(); + return get_cycles(); +} + +#endif