direct-io.hg

view xen/include/asm-x86/x86_64/current.h @ 3280:dda5ab69e74a

bitkeeper revision 1.1159.1.477 (41bf20d2wgoxIqhcE0nzBC8W-yFPhg)

sync w/ head.
author cl349@arcadians.cl.cam.ac.uk
date Tue Dec 14 17:20:18 2004 +0000 (2004-12-14)
parents ead91151a0e6 e606dfe099cc
children c65b544a8c4e
line source
1 #ifndef _X86_64_CURRENT_H
2 #define _X86_64_CURRENT_H
4 #if !defined(__ASSEMBLY__)
5 struct domain;
7 #include <asm/pda.h>
9 #define STACK_RESERVED \
10 (sizeof(execution_context_t))
12 static inline struct domain * get_current(void)
13 {
14 struct domain *current;
15 current = read_pda(pcurrent);
16 return current;
17 }
19 #define current get_current()
21 static inline void set_current(struct domain *p)
22 {
23 write_pda(pcurrent,p);
24 }
26 static inline execution_context_t *get_execution_context(void)
27 {
28 execution_context_t *execution_context;
29 __asm__( "andq %%rsp,%0; addq %2,%0"
30 : "=r" (execution_context)
31 : "0" (~(STACK_SIZE-1)), "i" (STACK_SIZE-STACK_RESERVED) );
32 return execution_context;
33 }
35 static inline unsigned long get_stack_top(void)
36 {
37 unsigned long p;
38 __asm__ ( "orq %%rsp,%0; andq $~7,%0"
39 : "=r" (p) : "0" (STACK_SIZE-8) );
40 return p;
41 }
43 #define reset_stack_and_jump(__fn) \
44 __asm__ __volatile__ ( \
45 "movq %0,%%rsp; jmp "STR(__fn) \
46 : : "r" (get_execution_context()) )
48 #define schedule_tail(_d) ((_d)->thread.schedule_tail)(_d)
50 #else
52 #ifndef ASM_OFFSET_H
53 #include <asm/offset.h>
54 #endif
56 #define GET_CURRENT(reg) movq %gs:(pda_pcurrent),reg
58 #endif
60 #endif /* !(_X86_64_CURRENT_H) */