ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-v850 / thread_info.h
1 /*
2  * include/asm-v850/thread_info.h -- v850 low-level thread information
3  *
4  *  Copyright (C) 2002  NEC Corporation
5  *  Copyright (C) 2002  Miles Bader <miles@gnu.org>
6  *  Copyright (C) 2002  David Howells (dhowells@redhat.com)
7  *    - Incorporating suggestions made by Linus Torvalds and Dave Miller
8  *
9  * This file is subject to the terms and conditions of the GNU General
10  * Public License.  See the file COPYING in the main directory of this
11  * archive for more details.
12  *
13  * This file was derived from the PPC version, include/asm-ppc/thread_info.h
14  * which was adapted from the i386 version by Paul Mackerras
15  */
16
17 #ifndef __V850_THREAD_INFO_H__
18 #define __V850_THREAD_INFO_H__
19
20 #ifdef __KERNEL__
21
22 #ifndef __ASSEMBLY__
23
24 /*
25  * low level task data.
26  * If you change this, change the TI_* offsets below to match.
27  */
28 struct thread_info {
29         struct task_struct      *task;          /* main task structure */
30         struct exec_domain      *exec_domain;   /* execution domain */
31         unsigned long           flags;          /* low level flags */
32         int                     cpu;            /* cpu we're on */
33         int                     preempt_count;
34         struct restart_block    restart_block;
35 };
36
37 #define INIT_THREAD_INFO(tsk)                                                 \
38 {                                                                             \
39         .task =         &tsk,                                                 \
40         .exec_domain =  &default_exec_domain,                                 \
41         .flags =        0,                                                    \
42         .cpu =          0,                                                    \
43         .preempt_count = 1,                                                   \
44         .restart_block = {                                                    \
45                 .fn = do_no_restart_syscall,                                  \
46         },                                                                    \
47 }
48
49 #define init_thread_info        (init_thread_union.thread_info)
50 #define init_stack              (init_thread_union.stack)
51
52 /*
53  * macros/functions for gaining access to the thread information structure
54  */
55
56 /* thread information allocation */
57 #define alloc_thread_info(tsk) ((struct thread_info *) \
58                                 __get_free_pages(GFP_KERNEL, 1))
59 #define free_thread_info(ti)    free_pages((unsigned long) (ti), 1)
60 #define get_thread_info(ti)     get_task_struct((ti)->task)
61 #define put_thread_info(ti)     put_task_struct((ti)->task)
62
63 #endif /* __ASSEMBLY__ */
64
65
66 /*
67  * Offsets in thread_info structure, used in assembly code
68  */
69 #define TI_TASK         0
70 #define TI_EXECDOMAIN   4
71 #define TI_FLAGS        8
72 #define TI_CPU          12
73 #define TI_PREEMPT      16
74
75 #define PREEMPT_ACTIVE          0x4000000
76
77 /*
78  * thread information flag bit numbers
79  */
80 #define TIF_SYSCALL_TRACE       0       /* syscall trace active */
81 #define TIF_NOTIFY_RESUME       1       /* resumption notification requested */
82 #define TIF_SIGPENDING          2       /* signal pending */
83 #define TIF_NEED_RESCHED        3       /* rescheduling necessary */
84 #define TIF_POLLING_NRFLAG      4       /* true if poll_idle() is polling
85                                            TIF_NEED_RESCHED */
86
87 /* as above, but as bit values */
88 #define _TIF_SYSCALL_TRACE      (1<<TIF_SYSCALL_TRACE)
89 #define _TIF_NOTIFY_RESUME      (1<<TIF_NOTIFY_RESUME)
90 #define _TIF_SIGPENDING         (1<<TIF_SIGPENDING)
91 #define _TIF_NEED_RESCHED       (1<<TIF_NEED_RESCHED)
92 #define _TIF_POLLING_NRFLAG     (1<<TIF_POLLING_NRFLAG)
93
94
95 /* Size of kernel stack for each process.  */
96 #define THREAD_SIZE             0x2000
97
98 /* The alignment of kernel threads, with thread_info structures at their
99    base.  Thus, a pointer for a task's task structure can be derived from
100    its kernel stack pointer.  */
101 #define THREAD_ALIGNMENT        THREAD_SIZE
102 #define THREAD_MASK             (-THREAD_ALIGNMENT)
103
104
105 #ifdef __ASSEMBLY__
106
107 /* Put a pointer to the current thread_info structure into REG.  Note that
108    this definition requires THREAD_MASK to be representable as a signed
109    16-bit value.  */
110 #define GET_CURRENT_THREAD(reg)                                         \
111         /* Use `addi' and then `and' instead of just `andi', because    \
112            `addi' sign-extends the immediate value, whereas `andi'      \
113            zero-extends it.  */                                         \
114         addi    THREAD_MASK, r0, reg;                                   \
115         and     sp, reg
116
117 #else
118
119 /* Return a pointer to the current thread_info structure.  */
120 static inline struct thread_info *current_thread_info (void)
121 {
122         register unsigned long sp __asm__ ("sp");
123         return (struct thread_info *)(sp & THREAD_MASK);
124 }
125
126 #endif /* __ASSEMBLY__ */
127
128
129 #endif /* __KERNEL__ */
130
131 #endif /* __V850_THREAD_INFO_H__ */