1
2
3
4
5
6
7
8
9
10
11#ifndef _ASM_PROCESSOR_H
12#define _ASM_PROCESSOR_H
13
14#include <linux/cpumask.h>
15#include <linux/threads.h>
16
17#include <asm/cachectl.h>
18#include <asm/cpu.h>
19#include <asm/cpu-info.h>
20#include <asm/mipsregs.h>
21#include <asm/prefetch.h>
22#include <asm/system.h>
23
24
25
26
27#define current_text_addr() ({ __label__ _l; _l: &&_l;})
28
29
30
31
32extern void (*cpu_wait)(void);
33
34extern unsigned int vced_count, vcei_count;
35
36#ifdef CONFIG_32BIT
37
38
39
40
41#define TASK_SIZE 0x7fff8000UL
42#define STACK_TOP TASK_SIZE
43
44
45
46
47
48#define TASK_UNMAPPED_BASE ((TASK_SIZE / 3) & ~(PAGE_SIZE))
49#endif
50
51#ifdef CONFIG_64BIT
52
53
54
55
56
57
58
59#define TASK_SIZE32 0x7fff8000UL
60#define TASK_SIZE 0x10000000000UL
61#define STACK_TOP \
62 (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE)
63
64
65
66
67
68#define TASK_UNMAPPED_BASE \
69 (test_thread_flag(TIF_32BIT_ADDR) ? \
70 PAGE_ALIGN(TASK_SIZE32 / 3) : PAGE_ALIGN(TASK_SIZE / 3))
71#define TASK_SIZE_OF(tsk) \
72 (test_tsk_thread_flag(tsk, TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE)
73#endif
74
75#ifdef __KERNEL__
76#define STACK_TOP_MAX TASK_SIZE
77#endif
78
79#define NUM_FPU_REGS 32
80
81typedef __u64 fpureg_t;
82
83
84
85
86
87
88
89
90struct mips_fpu_struct {
91 fpureg_t fpr[NUM_FPU_REGS];
92 unsigned int fcr31;
93};
94
95#define NUM_DSP_REGS 6
96
97typedef __u32 dspreg_t;
98
99struct mips_dsp_state {
100 dspreg_t dspr[NUM_DSP_REGS];
101 unsigned int dspcontrol;
102};
103
104#define INIT_CPUMASK { \
105 {0,} \
106}
107
108struct mips3264_watch_reg_state {
109
110
111
112 unsigned long watchlo[NUM_WATCH_REGS];
113
114 u16 watchhi[NUM_WATCH_REGS];
115};
116
117union mips_watch_reg_state {
118 struct mips3264_watch_reg_state mips3264;
119};
120
121typedef struct {
122 unsigned long seg;
123} mm_segment_t;
124
125#define ARCH_MIN_TASKALIGN 8
126
127struct mips_abi;
128
129
130
131
132struct thread_struct {
133
134 unsigned long reg16;
135 unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
136 unsigned long reg29, reg30, reg31;
137
138
139 unsigned long cp0_status;
140
141
142 struct mips_fpu_struct fpu;
143#ifdef CONFIG_MIPS_MT_FPAFF
144
145 unsigned long emulated_fp;
146
147 cpumask_t user_cpus_allowed;
148#endif
149
150
151 struct mips_dsp_state dsp;
152
153
154 union mips_watch_reg_state watch;
155
156
157 unsigned long cp0_badvaddr;
158 unsigned long cp0_baduaddr;
159 unsigned long error_code;
160 unsigned long trap_no;
161 unsigned long irix_trampoline;
162 unsigned long irix_oldctx;
163 struct mips_abi *abi;
164};
165
166#ifdef CONFIG_MIPS_MT_FPAFF
167#define FPAFF_INIT \
168 .emulated_fp = 0, \
169 .user_cpus_allowed = INIT_CPUMASK,
170#else
171#define FPAFF_INIT
172#endif
173
174#define INIT_THREAD { \
175
176
177 \
178 .reg16 = 0, \
179 .reg17 = 0, \
180 .reg18 = 0, \
181 .reg19 = 0, \
182 .reg20 = 0, \
183 .reg21 = 0, \
184 .reg22 = 0, \
185 .reg23 = 0, \
186 .reg29 = 0, \
187 .reg30 = 0, \
188 .reg31 = 0, \
189
190
191 \
192 .cp0_status = 0, \
193
194
195 \
196 .fpu = { \
197 .fpr = {0,}, \
198 .fcr31 = 0, \
199 }, \
200
201
202 \
203 FPAFF_INIT \
204
205
206 \
207 .dsp = { \
208 .dspr = {0, }, \
209 .dspcontrol = 0, \
210 }, \
211
212
213 \
214 .watch = {{{0,},},}, \
215
216
217 \
218 .cp0_badvaddr = 0, \
219 .cp0_baduaddr = 0, \
220 .error_code = 0, \
221 .trap_no = 0, \
222 .irix_trampoline = 0, \
223 .irix_oldctx = 0, \
224}
225
226struct task_struct;
227
228
229#define release_thread(thread) do { } while(0)
230
231
232#define prepare_to_copy(tsk) do { } while (0)
233
234extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
235
236extern unsigned long thread_saved_pc(struct task_struct *tsk);
237
238
239
240
241extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
242
243unsigned long get_wchan(struct task_struct *p);
244
245#define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + THREAD_SIZE - 32)
246#define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk) - 1)
247#define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc)
248#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
249#define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status)
250
251#define cpu_relax() barrier()
252
253
254
255
256
257
258
259
260
261
262
263
264
265#define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
266
267#ifdef CONFIG_CPU_HAS_PREFETCH
268
269#define ARCH_HAS_PREFETCH
270
271static inline void prefetch(const void *addr)
272{
273 __asm__ __volatile__(
274 " .set mips4 \n"
275 " pref %0, (%1) \n"
276 " .set mips0 \n"
277 :
278 : "i" (Pref_Load), "r" (addr));
279}
280
281#endif
282
283#endif
284