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
23
24
25
26#define current_text_addr() ({ __label__ _l; _l: &&_l;})
27
28
29
30
31extern void (*cpu_wait)(void);
32
33extern unsigned int vced_count, vcei_count;
34
35
36
37
38#define HAVE_ARCH_PICK_MMAP_LAYOUT 1
39
40
41
42
43
44#define SPECIAL_PAGES_SIZE PAGE_SIZE
45
46#ifdef CONFIG_32BIT
47
48
49
50
51#define TASK_SIZE 0x7fff8000UL
52
53#ifdef __KERNEL__
54#define STACK_TOP_MAX TASK_SIZE
55#endif
56
57#define TASK_IS_32BIT_ADDR 1
58
59#endif
60
61#ifdef CONFIG_64BIT
62
63
64
65
66
67
68
69#define TASK_SIZE32 0x7fff8000UL
70#define TASK_SIZE64 0x10000000000UL
71#define TASK_SIZE (test_thread_flag(TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64)
72
73#ifdef __KERNEL__
74#define STACK_TOP_MAX TASK_SIZE64
75#endif
76
77
78#define TASK_SIZE_OF(tsk) \
79 (test_tsk_thread_flag(tsk, TIF_32BIT_ADDR) ? TASK_SIZE32 : TASK_SIZE64)
80
81#define TASK_IS_32BIT_ADDR test_thread_flag(TIF_32BIT_ADDR)
82
83#endif
84
85#define STACK_TOP ((TASK_SIZE & PAGE_MASK) - SPECIAL_PAGES_SIZE)
86
87
88
89
90
91#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE / 3)
92
93
94#define NUM_FPU_REGS 32
95
96typedef __u64 fpureg_t;
97
98
99
100
101
102
103
104
105struct mips_fpu_struct {
106 fpureg_t fpr[NUM_FPU_REGS];
107 unsigned int fcr31;
108};
109
110#define NUM_DSP_REGS 6
111
112typedef __u32 dspreg_t;
113
114struct mips_dsp_state {
115 dspreg_t dspr[NUM_DSP_REGS];
116 unsigned int dspcontrol;
117};
118
119#define INIT_CPUMASK { \
120 {0,} \
121}
122
123struct mips3264_watch_reg_state {
124
125
126
127 unsigned long watchlo[NUM_WATCH_REGS];
128
129 u16 watchhi[NUM_WATCH_REGS];
130};
131
132union mips_watch_reg_state {
133 struct mips3264_watch_reg_state mips3264;
134};
135
136#ifdef CONFIG_CPU_CAVIUM_OCTEON
137
138struct octeon_cop2_state {
139
140 unsigned long cop2_crc_iv;
141
142 unsigned long cop2_crc_length;
143
144 unsigned long cop2_crc_poly;
145
146 unsigned long cop2_llm_dat[2];
147
148 unsigned long cop2_3des_iv;
149
150 unsigned long cop2_3des_key[3];
151
152 unsigned long cop2_3des_result;
153
154 unsigned long cop2_aes_inp0;
155
156 unsigned long cop2_aes_iv[2];
157
158
159 unsigned long cop2_aes_key[4];
160
161 unsigned long cop2_aes_keylen;
162
163 unsigned long cop2_aes_result[2];
164
165
166
167
168
169 unsigned long cop2_hsh_datw[15];
170
171
172
173 unsigned long cop2_hsh_ivw[8];
174
175 unsigned long cop2_gfm_mult[2];
176
177 unsigned long cop2_gfm_poly;
178
179 unsigned long cop2_gfm_result[2];
180};
181#define INIT_OCTEON_COP2 {0,}
182
183struct octeon_cvmseg_state {
184 unsigned long cvmseg[CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE]
185 [cpu_dcache_line_size() / sizeof(unsigned long)];
186};
187
188#endif
189
190typedef struct {
191 unsigned long seg;
192} mm_segment_t;
193
194#define ARCH_MIN_TASKALIGN 8
195
196struct mips_abi;
197
198
199
200
201struct thread_struct {
202
203 unsigned long reg16;
204 unsigned long reg17, reg18, reg19, reg20, reg21, reg22, reg23;
205 unsigned long reg29, reg30, reg31;
206
207
208 unsigned long cp0_status;
209
210
211 struct mips_fpu_struct fpu;
212#ifdef CONFIG_MIPS_MT_FPAFF
213
214 unsigned long emulated_fp;
215
216 cpumask_t user_cpus_allowed;
217#endif
218
219
220 struct mips_dsp_state dsp;
221
222
223 union mips_watch_reg_state watch;
224
225
226 unsigned long cp0_badvaddr;
227 unsigned long cp0_baduaddr;
228 unsigned long error_code;
229 unsigned long irix_trampoline;
230 unsigned long irix_oldctx;
231#ifdef CONFIG_CPU_CAVIUM_OCTEON
232 struct octeon_cop2_state cp2 __attribute__ ((__aligned__(128)));
233 struct octeon_cvmseg_state cvmseg __attribute__ ((__aligned__(128)));
234#endif
235 struct mips_abi *abi;
236};
237
238#ifdef CONFIG_MIPS_MT_FPAFF
239#define FPAFF_INIT \
240 .emulated_fp = 0, \
241 .user_cpus_allowed = INIT_CPUMASK,
242#else
243#define FPAFF_INIT
244#endif
245
246#ifdef CONFIG_CPU_CAVIUM_OCTEON
247#define OCTEON_INIT \
248 .cp2 = INIT_OCTEON_COP2,
249#else
250#define OCTEON_INIT
251#endif
252
253#define INIT_THREAD { \
254
255
256 \
257 .reg16 = 0, \
258 .reg17 = 0, \
259 .reg18 = 0, \
260 .reg19 = 0, \
261 .reg20 = 0, \
262 .reg21 = 0, \
263 .reg22 = 0, \
264 .reg23 = 0, \
265 .reg29 = 0, \
266 .reg30 = 0, \
267 .reg31 = 0, \
268
269
270 \
271 .cp0_status = 0, \
272
273
274 \
275 .fpu = { \
276 .fpr = {0,}, \
277 .fcr31 = 0, \
278 }, \
279
280
281 \
282 FPAFF_INIT \
283
284
285 \
286 .dsp = { \
287 .dspr = {0, }, \
288 .dspcontrol = 0, \
289 }, \
290
291
292 \
293 .watch = {{{0,},},}, \
294
295
296 \
297 .cp0_badvaddr = 0, \
298 .cp0_baduaddr = 0, \
299 .error_code = 0, \
300 .irix_trampoline = 0, \
301 .irix_oldctx = 0, \
302
303
304 \
305 OCTEON_INIT \
306}
307
308struct task_struct;
309
310
311#define release_thread(thread) do { } while(0)
312
313extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
314
315extern unsigned long thread_saved_pc(struct task_struct *tsk);
316
317
318
319
320extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
321
322unsigned long get_wchan(struct task_struct *p);
323
324#define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + \
325 THREAD_SIZE - 32 - sizeof(struct pt_regs))
326#define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk))
327#define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc)
328#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
329#define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status)
330
331#define cpu_relax() barrier()
332
333
334
335
336
337
338
339
340
341
342
343
344
345#define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
346
347#ifdef CONFIG_CPU_HAS_PREFETCH
348
349#define ARCH_HAS_PREFETCH
350#define prefetch(x) __builtin_prefetch((x), 0, 1)
351
352#define ARCH_HAS_PREFETCHW
353#define prefetchw(x) __builtin_prefetch((x), 1, 1)
354
355
356
357
358
359#define __ARCH_WANT_UNLOCKED_CTXSW
360
361#endif
362
363#endif
364