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