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