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#ifdef CONFIG_CPU_CAVIUM_OCTEON
230 struct octeon_cop2_state cp2 __attribute__ ((__aligned__(128)));
231 struct octeon_cvmseg_state cvmseg __attribute__ ((__aligned__(128)));
232#endif
233 struct mips_abi *abi;
234};
235
236#ifdef CONFIG_MIPS_MT_FPAFF
237#define FPAFF_INIT \
238 .emulated_fp = 0, \
239 .user_cpus_allowed = INIT_CPUMASK,
240#else
241#define FPAFF_INIT
242#endif
243
244#ifdef CONFIG_CPU_CAVIUM_OCTEON
245#define OCTEON_INIT \
246 .cp2 = INIT_OCTEON_COP2,
247#else
248#define OCTEON_INIT
249#endif
250
251#define INIT_THREAD { \
252
253
254 \
255 .reg16 = 0, \
256 .reg17 = 0, \
257 .reg18 = 0, \
258 .reg19 = 0, \
259 .reg20 = 0, \
260 .reg21 = 0, \
261 .reg22 = 0, \
262 .reg23 = 0, \
263 .reg29 = 0, \
264 .reg30 = 0, \
265 .reg31 = 0, \
266
267
268 \
269 .cp0_status = 0, \
270
271
272 \
273 .fpu = { \
274 .fpr = {0,}, \
275 .fcr31 = 0, \
276 }, \
277
278
279 \
280 FPAFF_INIT \
281
282
283 \
284 .dsp = { \
285 .dspr = {0, }, \
286 .dspcontrol = 0, \
287 }, \
288
289
290 \
291 .watch = {{{0,},},}, \
292
293
294 \
295 .cp0_badvaddr = 0, \
296 .cp0_baduaddr = 0, \
297 .error_code = 0, \
298
299
300 \
301 OCTEON_INIT \
302}
303
304struct task_struct;
305
306
307#define release_thread(thread) do { } while(0)
308
309extern unsigned long thread_saved_pc(struct task_struct *tsk);
310
311
312
313
314extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp);
315
316unsigned long get_wchan(struct task_struct *p);
317
318#define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + \
319 THREAD_SIZE - 32 - sizeof(struct pt_regs))
320#define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk))
321#define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc)
322#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
323#define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status)
324
325#define cpu_relax() barrier()
326
327
328
329
330
331
332
333
334
335
336
337
338
339#define return_address() ({__asm__ __volatile__("":::"$31");__builtin_return_address(0);})
340
341#ifdef CONFIG_CPU_HAS_PREFETCH
342
343#define ARCH_HAS_PREFETCH
344#define prefetch(x) __builtin_prefetch((x), 0, 1)
345
346#define ARCH_HAS_PREFETCHW
347#define prefetchw(x) __builtin_prefetch((x), 1, 1)
348
349
350
351
352
353#define __ARCH_WANT_UNLOCKED_CTXSW
354
355#endif
356
357#endif
358