Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios-OLD.git] / kitten / include / arch-x86_64 / tsc.h
diff --git a/kitten/include/arch-x86_64/tsc.h b/kitten/include/arch-x86_64/tsc.h
new file mode 100644 (file)
index 0000000..4d5a53d
--- /dev/null
@@ -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 <lwk/types.h>
+#include <arch/processor.h>
+
+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