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