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 / current.h
diff --git a/kitten/include/arch-x86_64/current.h b/kitten/include/arch-x86_64/current.h
new file mode 100644 (file)
index 0000000..9967cf6
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef _X86_64_CURRENT_H
+#define _X86_64_CURRENT_H
+
+#if !defined(__ASSEMBLY__) 
+struct task_struct;
+
+#include <arch/pda.h>
+
+/**
+ * In normal operation, the current task pointer is read directly from
+ * the PDA.
+ *
+ * If the PDA has not been setup or is not available for some reason,
+ * the slower get_current_via_RSP() must be used instead.  This is
+ * sometimes necessary during the bootstrap process.
+ */
+static inline struct task_struct *
+get_current(void) 
+{ 
+       struct task_struct *t = read_pda(pcurrent); 
+       return t;
+} 
+#define current get_current()
+
+/**
+ * Derives the current task pointer from the current value of the
+ * stack pointer (RSP register).
+ *
+ * WARNING: Do not call this from interrupt context.  It won't work.
+ *          It is only safe to call this from task context.
+ */
+static inline struct task_struct *
+get_current_via_RSP(void)
+{
+       struct task_struct *tsk;
+       __asm__("andq %%rsp,%0; " : "=r" (tsk) : "0" (~(TASK_SIZE - 1)));
+       return tsk;
+}
+
+#else
+
+#ifndef ASM_OFFSET_H
+#include <arch/asm-offsets.h> 
+#endif
+
+#define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg
+
+#endif
+
+#endif /* !(_X86_64_CURRENT_H) */