VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / include / asm-ppc64 / thread_info.h
1 /* thread_info.h: PPC low-level thread information
2  * adapted from the i386 version by Paul Mackerras
3  *
4  * Copyright (C) 2002  David Howells (dhowells@redhat.com)
5  * - Incorporating suggestions made by Linus Torvalds and Dave Miller
6  */
7
8 #ifndef _ASM_THREAD_INFO_H
9 #define _ASM_THREAD_INFO_H
10
11 #ifdef __KERNEL__
12
13 #ifndef __ASSEMBLY__
14 #include <linux/config.h>
15 #include <asm/processor.h>
16 #include <asm/page.h>
17 #include <linux/stringify.h>
18
19 /*
20  * low level task data.
21  */
22 struct thread_info {
23         struct task_struct *task;               /* main task structure */
24         struct exec_domain *exec_domain;        /* execution domain */
25         unsigned long   flags;                  /* low level flags */
26         int             cpu;                    /* cpu we're on */
27         int             preempt_count;
28         struct restart_block restart_block;
29         /* set by force_successful_syscall_return */
30         unsigned char   syscall_noerror;
31 };
32
33 /*
34  * macros/functions for gaining access to the thread information structure
35  *
36  * preempt_count needs to be 1 initially, until the scheduler is functional.
37  */
38 #define INIT_THREAD_INFO(tsk)                   \
39 {                                               \
40         .task =         &tsk,                   \
41         .exec_domain =  &default_exec_domain,   \
42         .flags =        0,                      \
43         .cpu =          0,                      \
44         .preempt_count = 1,                     \
45         .restart_block = {                      \
46                 .fn = do_no_restart_syscall,    \
47         },                                      \
48 }
49
50 #define init_thread_info        (init_thread_union.thread_info)
51 #define init_stack              (init_thread_union.stack)
52
53 /* thread information allocation */
54
55 #define THREAD_ORDER            2
56 #define THREAD_SIZE             (PAGE_SIZE << THREAD_ORDER)
57 #define THREAD_SHIFT            (PAGE_SHIFT + THREAD_ORDER)
58 #ifdef CONFIG_DEBUG_STACK_USAGE
59 #define alloc_thread_info(tsk)                                  \
60         ({                                                      \
61                 struct thread_info *ret;                        \
62                                                                 \
63                 ret = kmalloc(THREAD_SIZE, GFP_KERNEL);         \
64                 if (ret)                                        \
65                         memset(ret, 0, THREAD_SIZE);            \
66                 ret;                                            \
67         })
68 #else
69 #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
70 #endif
71 #define free_thread_info(ti)    kfree(ti)
72 #define get_thread_info(ti)     get_task_struct((ti)->task)
73 #define put_thread_info(ti)     put_task_struct((ti)->task)
74
75 /* how to get the thread information struct from C */
76 static inline struct thread_info *current_thread_info(void)
77 {
78         struct thread_info *ti;
79         __asm__("clrrdi %0,1,%1" : "=r"(ti) : "i" (THREAD_SHIFT));
80         return ti;
81 }
82
83 #endif /* __ASSEMBLY__ */
84
85 #define PREEMPT_ACTIVE          0x4000000
86
87 /*
88  * thread information flag bit numbers
89  */
90 #define TIF_SYSCALL_TRACE       0       /* syscall trace active */
91 #define TIF_NOTIFY_RESUME       1       /* resumption notification requested */
92 #define TIF_SIGPENDING          2       /* signal pending */
93 #define TIF_NEED_RESCHED        3       /* rescheduling necessary */
94 #define TIF_POLLING_NRFLAG      4       /* true if poll_idle() is polling
95                                            TIF_NEED_RESCHED */
96 #define TIF_32BIT               5       /* 32 bit binary */
97 #define TIF_RUN_LIGHT           6       /* iSeries run light */
98 #define TIF_ABI_PENDING         7       /* 32/64 bit switch needed */
99 #define TIF_SYSCALL_AUDIT       8       /* syscall auditing active */
100
101 /* as above, but as bit values */
102 #define _TIF_SYSCALL_TRACE      (1<<TIF_SYSCALL_TRACE)
103 #define _TIF_NOTIFY_RESUME      (1<<TIF_NOTIFY_RESUME)
104 #define _TIF_SIGPENDING         (1<<TIF_SIGPENDING)
105 #define _TIF_NEED_RESCHED       (1<<TIF_NEED_RESCHED)
106 #define _TIF_POLLING_NRFLAG     (1<<TIF_POLLING_NRFLAG)
107 #define _TIF_32BIT              (1<<TIF_32BIT)
108 #define _TIF_RUN_LIGHT          (1<<TIF_RUN_LIGHT)
109 #define _TIF_ABI_PENDING        (1<<TIF_ABI_PENDING)
110 #define _TIF_SYSCALL_AUDIT      (1<<TIF_SYSCALL_AUDIT)
111 #define _TIF_SYSCALL_T_OR_A     (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)
112
113 #define _TIF_USER_WORK_MASK     (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
114                                  _TIF_NEED_RESCHED)
115
116 #endif /* __KERNEL__ */
117
118 #endif /* _ASM_THREAD_INFO_H */