ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-arm26 / thread_info.h
1 /*
2  *  linux/include/asm-arm26/thread_info.h
3  *
4  *  Copyright (C) 2002 Russell King.
5  *  Copyright (C) 2003 Ian Molton.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11 #ifndef __ASM_ARM_THREAD_INFO_H
12 #define __ASM_ARM_THREAD_INFO_H
13
14 #ifdef __KERNEL__
15
16 #ifndef __ASSEMBLY__
17
18 struct task_struct;
19 struct exec_domain;
20
21 #include <asm/fpstate.h>
22 #include <asm/ptrace.h>
23 #include <asm/types.h>
24
25 typedef unsigned long mm_segment_t;
26
27 struct cpu_context_save {
28         __u32   r4;
29         __u32   r5;
30         __u32   r6;
31         __u32   r7;
32         __u32   r8;
33         __u32   r9;
34         __u32   sl;
35         __u32   fp;
36         __u32   sp;
37         __u32   pc;
38 };
39
40 /*
41  * low level task data that entry.S needs immediate access to.
42  * We assume cpu_context follows immedately after cpu_domain.
43  */
44 struct thread_info {
45         unsigned long           flags;          /* low level flags */
46         __s32                   preempt_count;  /* 0 => preemptable, <0 => bug */
47         mm_segment_t            addr_limit;     /* address limit */
48         struct task_struct      *task;          /* main task structure */
49         struct exec_domain      *exec_domain;   /* execution domain */
50         __u32                   cpu;            /* cpu */
51         struct cpu_context_save cpu_context;    /* cpu context */
52         struct restart_block    restart_block;
53         union fp_state          fpstate;
54 };
55
56 #define INIT_THREAD_INFO(tsk)                   \
57 {                                               \
58         .task           &tsk,                   \
59         .exec_domain    &default_exec_domain,   \
60         .flags          0,                      \
61         .preempt_count  0,                      \
62         .addr_limit     KERNEL_DS,              \
63         .restart_block  = {                             \
64                 .fn     = do_no_restart_syscall,        \
65         },                                              \
66 }
67
68 #define init_thread_info        (init_thread_union.thread_info)
69 #define init_stack              (init_thread_union.stack)
70
71 /*
72  * how to get the thread information struct from C
73  */
74 static inline struct thread_info *current_thread_info(void) __attribute_const__;
75
76 static inline struct thread_info *current_thread_info(void)
77 {
78         register unsigned long sp asm ("sp");
79         return (struct thread_info *)(sp & ~0x1fff);
80 }
81
82 /* FIXME - PAGE_SIZE < 32K */
83 #define THREAD_SIZE             (8192)
84 #define __get_user_regs(x) (((struct pt_regs *)((unsigned long)(x) + THREAD_SIZE - 8)) - 1)
85
86 extern struct thread_info *alloc_thread_info(struct task_struct *task);
87 extern void free_thread_info(struct thread_info *);
88
89 #define get_thread_info(ti)     get_task_struct((ti)->task)
90 #define put_thread_info(ti)     put_task_struct((ti)->task)
91
92 #define thread_saved_pc(tsk)    \
93         ((unsigned long)(pc_pointer((tsk)->thread_info->cpu_context.pc)))
94 #define thread_saved_fp(tsk)    \
95         ((unsigned long)((tsk)->thread_info->cpu_context.fp))
96
97 #else /* !__ASSEMBLY__ */
98
99 #define TI_FLAGS        0
100 #define TI_PREEMPT      4
101 #define TI_ADDR_LIMIT   8
102 #define TI_TASK         12
103 #define TI_EXEC_DOMAIN  16
104 #define TI_CPU          20
105 #define TI_CPU_SAVE     24
106 #define TI_RESTART_BLOCK 28
107 #define TI_FPSTATE      68
108
109 #endif
110
111 #define PREEMPT_ACTIVE  0x04000000
112
113 /*
114  * thread information flags:
115  *  TIF_SYSCALL_TRACE   - syscall trace active
116  *  TIF_NOTIFY_RESUME   - resumption notification requested
117  *  TIF_SIGPENDING      - signal pending
118  *  TIF_NEED_RESCHED    - rescheduling necessary
119  *  TIF_USEDFPU         - FPU was used by this task this quantum (SMP)
120  *  TIF_POLLING_NRFLAG  - true if poll_idle() is polling TIF_NEED_RESCHED
121  */
122 #define TIF_NOTIFY_RESUME       0
123 #define TIF_SIGPENDING          1
124 #define TIF_NEED_RESCHED        2
125 #define TIF_SYSCALL_TRACE       8
126 #define TIF_USED_FPU            16
127 #define TIF_POLLING_NRFLAG      17
128
129 #define _TIF_NOTIFY_RESUME      (1 << TIF_NOTIFY_RESUME)
130 #define _TIF_SIGPENDING         (1 << TIF_SIGPENDING)
131 #define _TIF_NEED_RESCHED       (1 << TIF_NEED_RESCHED)
132 #define _TIF_SYSCALL_TRACE      (1 << TIF_SYSCALL_TRACE)
133 #define _TIF_USED_FPU           (1 << TIF_USED_FPU)
134 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
135
136 /*
137  * Change these and you break ASM code in entry-common.S
138  */
139 #define _TIF_WORK_MASK          0x000000ff
140
141 #endif /* __KERNEL__ */
142 #endif /* __ASM_ARM_THREAD_INFO_H */