1
2
3
4
5
6
7
8
9
10
11
12#ifndef _ASM_THREAD_INFO_H
13#define _ASM_THREAD_INFO_H
14
15#ifdef __KERNEL__
16
17#include <asm/page.h>
18
19#define PREEMPT_ACTIVE 0x10000000
20
21#ifdef CONFIG_4KSTACKS
22#define THREAD_SIZE (4096)
23#else
24#define THREAD_SIZE (8192)
25#endif
26
27#define STACK_WARN (THREAD_SIZE / 8)
28
29
30
31
32
33
34
35
36#ifndef __ASSEMBLY__
37typedef struct {
38 unsigned long seg;
39} mm_segment_t;
40
41struct thread_info {
42 struct task_struct *task;
43 struct exec_domain *exec_domain;
44 struct pt_regs *frame;
45 unsigned long flags;
46 __u32 cpu;
47 __s32 preempt_count;
48
49 mm_segment_t addr_limit;
50
51
52
53 struct restart_block restart_block;
54
55 __u8 supervisor_stack[0];
56};
57
58#define thread_info_to_uregs(ti) \
59 ((struct pt_regs *) \
60 ((unsigned long)ti + THREAD_SIZE - sizeof(struct pt_regs)))
61
62#else
63
64#ifndef __ASM_OFFSETS_H__
65#include <asm/asm-offsets.h>
66#endif
67
68#endif
69
70
71
72
73#ifndef __ASSEMBLY__
74
75#define INIT_THREAD_INFO(tsk) \
76{ \
77 .task = &tsk, \
78 .exec_domain = &default_exec_domain, \
79 .flags = 0, \
80 .cpu = 0, \
81 .preempt_count = INIT_PREEMPT_COUNT, \
82 .addr_limit = KERNEL_DS, \
83 .restart_block = { \
84 .fn = do_no_restart_syscall, \
85 }, \
86}
87
88#define init_thread_info (init_thread_union.thread_info)
89#define init_stack (init_thread_union.stack)
90#define init_uregs \
91 ((struct pt_regs *) \
92 ((unsigned long) init_stack + THREAD_SIZE - sizeof(struct pt_regs)))
93
94extern struct thread_info *__current_ti;
95
96
97static inline __attribute__((const))
98struct thread_info *current_thread_info(void)
99{
100 struct thread_info *ti;
101 asm("mov sp,%0\n"
102 "and %1,%0\n"
103 : "=d" (ti)
104 : "i" (~(THREAD_SIZE - 1))
105 : "cc");
106 return ti;
107}
108
109static inline __attribute__((const))
110struct pt_regs *current_frame(void)
111{
112 return current_thread_info()->frame;
113}
114
115
116static inline unsigned long current_stack_pointer(void)
117{
118 unsigned long sp;
119 asm("mov sp,%0; ":"=r" (sp));
120 return sp;
121}
122
123#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
124
125
126#ifdef CONFIG_DEBUG_STACK_USAGE
127#define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL)
128#else
129#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
130#endif
131
132#define free_thread_info(ti) kfree((ti))
133#define get_thread_info(ti) get_task_struct((ti)->task)
134#define put_thread_info(ti) put_task_struct((ti)->task)
135
136#else
137
138#ifndef __VMLINUX_LDS__
139
140.macro GET_THREAD_INFO reg
141 mov sp,\reg
142 and -THREAD_SIZE,\reg
143.endm
144#endif
145#endif
146
147
148
149
150
151
152
153
154#define TIF_SYSCALL_TRACE 0
155#define TIF_NOTIFY_RESUME 1
156#define TIF_SIGPENDING 2
157#define TIF_NEED_RESCHED 3
158#define TIF_SINGLESTEP 4
159#define TIF_RESTORE_SIGMASK 5
160#define TIF_POLLING_NRFLAG 16
161#define TIF_MEMDIE 17
162#define TIF_FREEZE 18
163
164#define _TIF_SYSCALL_TRACE +(1 << TIF_SYSCALL_TRACE)
165#define _TIF_NOTIFY_RESUME +(1 << TIF_NOTIFY_RESUME)
166#define _TIF_SIGPENDING +(1 << TIF_SIGPENDING)
167#define _TIF_NEED_RESCHED +(1 << TIF_NEED_RESCHED)
168#define _TIF_SINGLESTEP +(1 << TIF_SINGLESTEP)
169#define _TIF_RESTORE_SIGMASK +(1 << TIF_RESTORE_SIGMASK)
170#define _TIF_POLLING_NRFLAG +(1 << TIF_POLLING_NRFLAG)
171#define _TIF_FREEZE +(1 << TIF_FREEZE)
172
173#define _TIF_WORK_MASK 0x0000FFFE
174#define _TIF_ALLWORK_MASK 0x0000FFFF
175
176#endif
177
178#endif
179