1#ifndef __ASM_SH_THREAD_INFO_H
2#define __ASM_SH_THREAD_INFO_H
3
4
5
6
7
8
9
10
11
12#ifdef __KERNEL__
13
14#include <asm/page.h>
15
16
17
18
19#define FAULT_CODE_WRITE (1 << 0)
20#define FAULT_CODE_INITIAL (1 << 1)
21#define FAULT_CODE_ITLB (1 << 2)
22#define FAULT_CODE_PROT (1 << 3)
23#define FAULT_CODE_USER (1 << 4)
24
25#ifndef __ASSEMBLY__
26#include <asm/processor.h>
27
28struct thread_info {
29 struct task_struct *task;
30 unsigned long flags;
31 __u32 status;
32 __u32 cpu;
33 int preempt_count;
34 mm_segment_t addr_limit;
35 unsigned long previous_sp;
36
37 __u8 supervisor_stack[0];
38};
39
40#endif
41
42#if defined(CONFIG_4KSTACKS)
43#define THREAD_SHIFT 12
44#else
45#define THREAD_SHIFT 13
46#endif
47
48#define THREAD_SIZE (1 << THREAD_SHIFT)
49#define STACK_WARN (THREAD_SIZE >> 3)
50
51
52
53
54#ifndef __ASSEMBLY__
55#define INIT_THREAD_INFO(tsk) \
56{ \
57 .task = &tsk, \
58 .flags = 0, \
59 .status = 0, \
60 .cpu = 0, \
61 .preempt_count = INIT_PREEMPT_COUNT, \
62 .addr_limit = KERNEL_DS, \
63}
64
65#define init_thread_info (init_thread_union.thread_info)
66#define init_stack (init_thread_union.stack)
67
68
69register unsigned long current_stack_pointer asm("r15") __used;
70
71
72static inline struct thread_info *current_thread_info(void)
73{
74 struct thread_info *ti;
75#if defined(CONFIG_SUPERH64)
76 __asm__ __volatile__ ("getcon cr17, %0" : "=r" (ti));
77#elif defined(CONFIG_CPU_HAS_SR_RB)
78 __asm__ __volatile__ ("stc r7_bank, %0" : "=r" (ti));
79#else
80 unsigned long __dummy;
81
82 __asm__ __volatile__ (
83 "mov r15, %0\n\t"
84 "and %1, %0\n\t"
85 : "=&r" (ti), "=r" (__dummy)
86 : "1" (~(THREAD_SIZE - 1))
87 : "memory");
88#endif
89
90 return ti;
91}
92
93#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
94
95extern void arch_task_cache_init(void);
96extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
97extern void arch_release_task_struct(struct task_struct *tsk);
98extern void init_thread_xstate(void);
99
100#endif
101
102
103
104
105
106
107
108
109
110
111#define TIF_SYSCALL_TRACE 0
112#define TIF_SIGPENDING 1
113#define TIF_NEED_RESCHED 2
114#define TIF_SINGLESTEP 4
115#define TIF_SYSCALL_AUDIT 5
116#define TIF_SECCOMP 6
117#define TIF_NOTIFY_RESUME 7
118#define TIF_SYSCALL_TRACEPOINT 8
119#define TIF_POLLING_NRFLAG 17
120#define TIF_MEMDIE 18
121
122#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
123#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
124#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
125#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
126#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
127#define _TIF_SECCOMP (1 << TIF_SECCOMP)
128#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
129#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
130#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
131
132
133#define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
134 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \
135 _TIF_SYSCALL_TRACEPOINT)
136
137
138#define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \
139 _TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \
140 _TIF_SINGLESTEP | _TIF_NOTIFY_RESUME | \
141 _TIF_SYSCALL_TRACEPOINT)
142
143
144#define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \
145 _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP))
146
147
148
149
150
151
152
153
154#define TS_USEDFPU 0x0002
155
156#ifndef __ASSEMBLY__
157
158#define TI_FLAG_FAULT_CODE_SHIFT 24
159
160
161
162
163static inline void set_thread_fault_code(unsigned int val)
164{
165 struct thread_info *ti = current_thread_info();
166 ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT)))
167 | (val << TI_FLAG_FAULT_CODE_SHIFT);
168}
169
170static inline unsigned int get_thread_fault_code(void)
171{
172 struct thread_info *ti = current_thread_info();
173 return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
174}
175
176#endif
177
178#endif
179
180#endif
181