aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-i386/current.h
blob: 5a12a1201f56894abb9d3a449d5c2d529b33e606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _I386_CURRENT_H
#define _I386_CURRENT_H

struct task_struct;

static inline struct task_struct * get_current(void)
{
    struct task_struct *current;
    __asm__ ( "orl %%esp,%0; movl (%0),%0" 
              : "=r" (current) : "0" (4092UL) );
    return current;
}
 
#define current get_current()

static inline void set_current(struct task_struct *p)
{
    __asm__ ( "orl %%esp,%0; movl %1,(%0)" 
              : : "r" (4092UL), "r" (p) );    
}

static inline execution_context_t *get_execution_context(void)
{
    execution_context_t *execution_context;
    __asm__ ( "andl %%esp,%0; addl $4096-72,%0"
              : "=r" (execution_context) : "0" (~4095UL) );
    return execution_context;
}

static inline unsigned long get_stack_top(void)
{
    unsigned long p;
    __asm__ ( "orl %%esp,%0" 
              : "=r" (p) : "0" (4092UL) );
    return p;
}

#define schedule_tail(_p)                                         \
    __asm__ __volatile__ (                                        \
        "andl %%esp,%0; addl $4096-72,%0; movl %0,%%esp; jmp *%1" \
        : : "r" (~4095UL), "r" (unlikely(is_idle_task((_p))) ?    \
                                continue_cpu_idle_loop :          \
                                continue_nonidle_task) )


#endif /* !(_I386_CURRENT_H) */