ia64/xen-unstable

view xen/include/asm-x86/x86_64/current.h @ 3911:2d1350c497e9

bitkeeper revision 1.1236.1.12 (421da2beCWorg82h5pKlUfgL04gvhA)

Fix x86/64 get_stack_bottom().
Signed-off-by: Keir Fraser <keir.fraser@cl.cam.ac.uk>
author kaf24@scramble.cl.cam.ac.uk
date Thu Feb 24 09:47:42 2005 +0000 (2005-02-24)
parents 0a4b76b6b5a0
children 9a7751095472
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
3 #ifndef _X86_64_CURRENT_H
4 #define _X86_64_CURRENT_H
6 struct domain;
8 #define STACK_RESERVED \
9 (sizeof(execution_context_t) + sizeof(struct domain *))
11 static inline struct exec_domain *get_current(void)
12 {
13 struct exec_domain *ed;
14 __asm__ ( "orq %%rsp,%0; andq $~7,%0; movq (%0),%0"
15 : "=r" (ed) : "0" (STACK_SIZE-8) );
16 return ed;
17 }
19 #define current get_current()
21 static inline void set_current(struct exec_domain *ed)
22 {
23 __asm__ ( "orq %%rsp,%0; andq $~7,%0; movq %1,(%0)"
24 : : "r" (STACK_SIZE-8), "r" (ed) );
25 }
27 static inline execution_context_t *get_execution_context(void)
28 {
29 execution_context_t *execution_context;
30 __asm__( "andq %%rsp,%0; addq %2,%0"
31 : "=r" (execution_context)
32 : "0" (~(STACK_SIZE-1)), "i" (STACK_SIZE-STACK_RESERVED) );
33 return execution_context;
34 }
36 /*
37 * Get the bottom-of-stack, as stored in the per-CPU TSS. This is actually
38 * 64 bytes before the real bottom of the stack to allow space for:
39 * domain pointer, DS, ES, FS, GS, FS_BASE, GS_BASE_OS, GS_BASE_APP
40 */
41 static inline unsigned long get_stack_bottom(void)
42 {
43 unsigned long p;
44 __asm__( "andq %%rsp,%0; addq %2,%0"
45 : "=r" (p)
46 : "0" (~(STACK_SIZE-1)), "i" (STACK_SIZE-64) );
47 return p;
48 }
50 #define reset_stack_and_jump(__fn) \
51 __asm__ __volatile__ ( \
52 "movq %0,%%rsp; jmp "STR(__fn) \
53 : : "r" (get_execution_context()) )
55 #define schedule_tail(_ed) ((_ed)->arch.schedule_tail)(_ed)
57 #endif /* !(_X86_64_CURRENT_H) */