1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _ASM_TILE_PROCESSOR_H
16#define _ASM_TILE_PROCESSOR_H
17
18#ifndef __ASSEMBLY__
19
20
21
22
23
24#include <linux/types.h>
25#include <asm/ptrace.h>
26#include <asm/percpu.h>
27
28#include <arch/chip.h>
29#include <arch/spr_def.h>
30
31struct task_struct;
32struct thread_struct;
33
34typedef struct {
35 unsigned long seg;
36} mm_segment_t;
37
38
39
40
41
42void *current_text_addr(void);
43
44#if CHIP_HAS_TILE_DMA()
45
46struct tile_dma_state {
47 int enabled;
48 unsigned long src;
49 unsigned long dest;
50 unsigned long strides;
51 unsigned long chunk_size;
52 unsigned long src_chunk;
53 unsigned long dest_chunk;
54 unsigned long byte;
55 unsigned long status;
56};
57
58
59
60
61
62#define DMA_STATUS_MASK \
63 (SPR_DMA_STATUS__RUNNING_MASK | SPR_DMA_STATUS__DONE_MASK)
64#endif
65
66
67
68
69
70struct async_tlb {
71 short fault_num;
72 char is_fault;
73 char is_write;
74 unsigned long address;
75};
76
77#ifdef CONFIG_HARDWALL
78struct hardwall_info;
79struct hardwall_task {
80
81 struct hardwall_info *info;
82
83 struct list_head list;
84};
85#ifdef __tilepro__
86#define HARDWALL_TYPES 1
87#else
88#define HARDWALL_TYPES 3
89#endif
90#endif
91
92struct thread_struct {
93
94 unsigned long ksp;
95
96 unsigned long pc;
97
98 unsigned long usp0;
99
100 pid_t creator_pid;
101#if CHIP_HAS_TILE_DMA()
102
103 struct tile_dma_state tile_dma_state;
104#endif
105
106 unsigned long ex_context[2];
107
108 unsigned long system_save[4];
109
110 unsigned long long interrupt_mask;
111
112 unsigned long intctrl_0;
113#if CHIP_HAS_PROC_STATUS_SPR()
114
115 unsigned long proc_status;
116#endif
117#if !CHIP_HAS_FIXED_INTVEC_BASE()
118
119 unsigned long interrupt_vector_base;
120#endif
121#if CHIP_HAS_TILE_RTF_HWM()
122
123 unsigned long tile_rtf_hwm;
124#endif
125#if CHIP_HAS_DSTREAM_PF()
126
127 unsigned long dstream_pf;
128#endif
129#ifdef CONFIG_HARDWALL
130
131 struct hardwall_task hardwall[HARDWALL_TYPES];
132#endif
133#if CHIP_HAS_TILE_DMA()
134
135 struct async_tlb dma_async_tlb;
136#endif
137#if CHIP_HAS_SN_PROC()
138
139 int sn_proc_running;
140
141 struct async_tlb sn_async_tlb;
142#endif
143};
144
145#endif
146
147
148
149
150
151#define STACK_TOP_DELTA 8
152
153
154
155
156
157
158#ifdef __tilegx__
159#define KSTK_PTREGS_GAP 48
160#else
161#define KSTK_PTREGS_GAP 56
162#endif
163
164#ifndef __ASSEMBLY__
165
166#ifdef __tilegx__
167#define TASK_SIZE_MAX (MEM_LOW_END + 1)
168#else
169#define TASK_SIZE_MAX PAGE_OFFSET
170#endif
171
172
173#ifdef CONFIG_COMPAT
174#define COMPAT_TASK_SIZE (1UL << 31)
175#define TASK_SIZE ((current_thread_info()->status & TS_COMPAT) ?\
176 COMPAT_TASK_SIZE : TASK_SIZE_MAX)
177#else
178#define TASK_SIZE TASK_SIZE_MAX
179#endif
180
181
182#define VDSO_BASE (TASK_SIZE - PAGE_SIZE)
183
184#define STACK_TOP VDSO_BASE
185
186
187#define STACK_TOP_MAX TASK_SIZE_MAX
188
189
190
191
192
193#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
194
195#define HAVE_ARCH_PICK_MMAP_LAYOUT
196
197#define INIT_THREAD { \
198 .ksp = (unsigned long)init_stack + THREAD_SIZE - STACK_TOP_DELTA, \
199 .interrupt_mask = -1ULL \
200}
201
202
203DECLARE_PER_CPU(unsigned long, boot_sp);
204
205
206DECLARE_PER_CPU(unsigned long, boot_pc);
207
208
209static inline void start_thread(struct pt_regs *regs,
210 unsigned long pc, unsigned long usp)
211{
212 regs->pc = pc;
213 regs->sp = usp;
214}
215
216
217static inline void release_thread(struct task_struct *dead_task)
218{
219
220}
221
222extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
223
224extern int do_work_pending(struct pt_regs *regs, u32 flags);
225
226
227
228
229
230
231#define thread_saved_pc(t) ((t)->thread.pc)
232
233unsigned long get_wchan(struct task_struct *p);
234
235
236#define task_ksp0(task) ((unsigned long)(task)->stack + THREAD_SIZE)
237
238
239#define KSTK_TOP(task) (task_ksp0(task) - STACK_TOP_DELTA)
240#define task_pt_regs(task) \
241 ((struct pt_regs *)(task_ksp0(task) - KSTK_PTREGS_GAP) - 1)
242#define task_sp(task) (task_pt_regs(task)->sp)
243#define task_pc(task) (task_pt_regs(task)->pc)
244
245#define KSTK_EIP(task) task_pc(task)
246#define KSTK_ESP(task) task_sp(task)
247
248
249#ifdef __tilegx__
250# define REGFMT "0x%016lx"
251#else
252# define REGFMT "0x%08lx"
253#endif
254
255
256
257
258
259
260static inline void cpu_relax(void)
261{
262 __insn_mfspr(SPR_PASS);
263 barrier();
264}
265
266
267struct seq_operations;
268extern const struct seq_operations cpuinfo_op;
269
270
271extern char chip_model[64];
272
273
274extern int node_controller[];
275
276#if CHIP_HAS_CBOX_HOME_MAP()
277
278extern int hash_default;
279
280
281extern int kstack_hash;
282
283
284#define uheap_hash hash_default
285
286#else
287#define hash_default 0
288#define kstack_hash 0
289#define uheap_hash 0
290#endif
291
292
293extern int kdata_huge;
294
295
296#define ARCH_HAS_PREFETCH
297#define prefetch(x) __builtin_prefetch(x)
298#define PREFETCH_STRIDE CHIP_L2_LINE_SIZE()
299
300
301#ifdef __tilegx__
302#define prefetch_L1(x) __insn_prefetch_l1_fault((void *)(x))
303#else
304#define prefetch_L1(x) __insn_prefetch_L1((void *)(x))
305#endif
306
307#else
308
309
310#define CPU_RELAX mfspr zero, SPR_PASS
311
312#endif
313
314
315#if SPR_EX_CONTEXT_1_1__PL_SHIFT != 0
316# error Fix assembly assumptions about PL
317#endif
318
319
320#if SPR_EX_CONTEXT_1_1__PL_SHIFT != SPR_EX_CONTEXT_0_1__PL_SHIFT || \
321 SPR_EX_CONTEXT_1_1__PL_RMASK != SPR_EX_CONTEXT_0_1__PL_RMASK || \
322 SPR_EX_CONTEXT_1_1__ICS_SHIFT != SPR_EX_CONTEXT_0_1__ICS_SHIFT || \
323 SPR_EX_CONTEXT_1_1__ICS_RMASK != SPR_EX_CONTEXT_0_1__ICS_RMASK
324# error Fix assumptions that EX1 macros work for both PL0 and PL1
325#endif
326
327
328#define EX1_PL(ex1) \
329 (((ex1) >> SPR_EX_CONTEXT_1_1__PL_SHIFT) & SPR_EX_CONTEXT_1_1__PL_RMASK)
330#define EX1_ICS(ex1) \
331 (((ex1) >> SPR_EX_CONTEXT_1_1__ICS_SHIFT) & SPR_EX_CONTEXT_1_1__ICS_RMASK)
332#define PL_ICS_EX1(pl, ics) \
333 (((pl) << SPR_EX_CONTEXT_1_1__PL_SHIFT) | \
334 ((ics) << SPR_EX_CONTEXT_1_1__ICS_SHIFT))
335
336
337
338
339
340#define USER_PL 0
341#if CONFIG_KERNEL_PL == 2
342#define GUEST_PL 1
343#endif
344#define KERNEL_PL CONFIG_KERNEL_PL
345
346
347#define CPU_LOG_MASK_VALUE 12
348#define CPU_MASK_VALUE ((1 << CPU_LOG_MASK_VALUE) - 1)
349#if CONFIG_NR_CPUS > CPU_MASK_VALUE
350# error Too many cpus!
351#endif
352#define raw_smp_processor_id() \
353 ((int)__insn_mfspr(SPR_SYSTEM_SAVE_K_0) & CPU_MASK_VALUE)
354#define get_current_ksp0() \
355 (__insn_mfspr(SPR_SYSTEM_SAVE_K_0) & ~CPU_MASK_VALUE)
356#define next_current_ksp0(task) ({ \
357 unsigned long __ksp0 = task_ksp0(task); \
358 int __cpu = raw_smp_processor_id(); \
359 BUG_ON(__ksp0 & CPU_MASK_VALUE); \
360 __ksp0 | __cpu; \
361})
362
363#endif
364