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.git] / kitten / include / arch-x86_64 / current.h
1 #ifndef _X86_64_CURRENT_H
2 #define _X86_64_CURRENT_H
3
4 #if !defined(__ASSEMBLY__) 
5 struct task_struct;
6
7 #include <arch/pda.h>
8
9 /**
10  * In normal operation, the current task pointer is read directly from
11  * the PDA.
12  *
13  * If the PDA has not been setup or is not available for some reason,
14  * the slower get_current_via_RSP() must be used instead.  This is
15  * sometimes necessary during the bootstrap process.
16  */
17 static inline struct task_struct *
18 get_current(void) 
19
20         struct task_struct *t = read_pda(pcurrent); 
21         return t;
22
23 #define current get_current()
24
25 /**
26  * Derives the current task pointer from the current value of the
27  * stack pointer (RSP register).
28  *
29  * WARNING: Do not call this from interrupt context.  It won't work.
30  *          It is only safe to call this from task context.
31  */
32 static inline struct task_struct *
33 get_current_via_RSP(void)
34 {
35         struct task_struct *tsk;
36         __asm__("andq %%rsp,%0; " : "=r" (tsk) : "0" (~(TASK_SIZE - 1)));
37         return tsk;
38 }
39
40 #else
41
42 #ifndef ASM_OFFSET_H
43 #include <arch/asm-offsets.h> 
44 #endif
45
46 #define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg
47
48 #endif
49
50 #endif /* !(_X86_64_CURRENT_H) */