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