1 /* $Id: ttable.h,v 1.18 2002/02/09 19:49:32 davem Exp $ */
2 #ifndef _SPARC64_TTABLE_H
3 #define _SPARC64_TTABLE_H
5 #include <linux/config.h>
9 #include <asm/thread_info.h>
12 #define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop;
14 /* We need a "cleaned" instruction... */
15 #define CLEAN_WINDOW \
16 rdpr %cleanwin, %l0; add %l0, 1, %l0; \
17 wrpr %l0, 0x0, %cleanwin; \
18 clr %o0; clr %o1; clr %o2; clr %o3; \
19 clr %o4; clr %o5; clr %o6; clr %o7; \
20 clr %l0; clr %l1; clr %l2; clr %l3; \
21 clr %l4; clr %l5; clr %l6; clr %l7; \
23 nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
25 #define TRAP(routine) \
26 sethi %hi(109f), %g7; \
28 109: or %g7, %lo(109b), %g7; \
30 add %sp, PTREGS_OFF, %o0; \
35 #define TRAP_7INSNS(routine) \
36 sethi %hi(109f), %g7; \
38 109: or %g7, %lo(109b), %g7; \
40 add %sp, PTREGS_OFF, %o0; \
44 #define TRAP_SAVEFPU(routine) \
45 sethi %hi(109f), %g7; \
46 ba,pt %xcc, do_fptrap; \
47 109: or %g7, %lo(109b), %g7; \
49 add %sp, PTREGS_OFF, %o0; \
54 #define TRAP_NOSAVE(routine) \
55 ba,pt %xcc, routine; \
57 nop; nop; nop; nop; nop; nop;
59 #define TRAP_NOSAVE_7INSNS(routine) \
60 ba,pt %xcc, routine; \
62 nop; nop; nop; nop; nop;
64 #define TRAPTL1(routine) \
65 sethi %hi(109f), %g7; \
66 ba,pt %xcc, etraptl1; \
67 109: or %g7, %lo(109b), %g7; \
69 add %sp, PTREGS_OFF, %o0; \
74 #define TRAP_ARG(routine, arg) \
75 sethi %hi(109f), %g7; \
77 109: or %g7, %lo(109b), %g7; \
78 add %sp, PTREGS_OFF, %o0; \
84 #define TRAPTL1_ARG(routine, arg) \
85 sethi %hi(109f), %g7; \
86 ba,pt %xcc, etraptl1; \
87 109: or %g7, %lo(109b), %g7; \
88 add %sp, PTREGS_OFF, %o0; \
94 #define SYSCALL_TRAP(routine, systbl) \
95 sethi %hi(109f), %g7; \
96 ba,pt %xcc, scetrap; \
97 109: or %g7, %lo(109b), %g7; \
98 sethi %hi(systbl), %l7; \
99 ba,pt %xcc, routine; \
100 or %l7, %lo(systbl), %l7; \
103 #define INDIRECT_SOLARIS_SYSCALL(num) \
104 sethi %hi(109f), %g7; \
106 109: or %g7, %lo(109b), %g7; \
107 ba,pt %xcc, tl0_solaris + 0xc; \
111 #define TRAP_UTRAP(handler,lvl) \
112 ldx [%g6 + TI_UTRAPS], %g1; \
113 sethi %hi(109f), %g7; \
115 or %g7, %lo(109f), %g7; \
117 109: ldx [%g1 + handler*8], %g1; \
118 ba,pt %xcc, utrap_ill; \
121 #ifdef CONFIG_SUNOS_EMUL
122 #define SUNOS_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sunos_sys_table)
124 #define SUNOS_SYSCALL_TRAP TRAP(sunos_syscall)
127 #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
129 #define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110)
131 #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
132 #define GETCC_TRAP TRAP(getcc)
133 #define SETCC_TRAP TRAP(setcc)
134 #ifdef CONFIG_SOLARIS_EMUL
135 #define SOLARIS_SYSCALL_TRAP TRAP(solaris_sparc_syscall)
137 #define SOLARIS_SYSCALL_TRAP TRAP(solaris_syscall)
139 /* FIXME: Write these actually */
140 #define NETBSD_SYSCALL_TRAP TRAP(netbsd_syscall)
141 #define BREAKPOINT_TRAP TRAP(breakpoint_trap)
143 #define TRAP_IRQ(routine, level) \
145 wrpr %g0, 15, %pil; \
146 b,pt %xcc, etrap_irq; \
150 add %sp, PTREGS_OFF, %o1; \
151 ba,a,pt %xcc, rtrap_irq;
153 #define TICK_SMP_IRQ \
155 wrpr %g0, 15, %pil; \
156 sethi %hi(109f), %g7; \
157 b,pt %xcc, etrap_irq; \
158 109: or %g7, %lo(109b), %g7; \
159 call smp_percpu_timer_interrupt; \
160 add %sp, PTREGS_OFF, %o0; \
161 ba,a,pt %xcc, rtrap_irq;
163 #define TRAP_IVEC TRAP_NOSAVE(do_ivec)
165 #define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
167 #define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
169 #define FLUSH_WINDOW_TRAP \
173 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1; \
175 stx %l1, [%sp + PTREGS_OFF + PT_V9_TPC]; \
176 ba,pt %xcc, rtrap_clr_l6; \
177 stx %l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
179 #ifdef CONFIG_KPROBES
180 #define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl)
182 #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
185 /* Before touching these macros, you owe it to yourself to go and
186 * see how arch/sparc64/kernel/winfixup.S works... -DaveM
188 * For the user cases we used to use the %asi register, but
189 * it turns out that the "wr xxx, %asi" costs ~5 cycles, so
190 * now we use immediate ASI loads and stores instead. Kudos
191 * to Greg Onufer for pointing out this performance anomaly.
193 * Further note that we cannot use the g2, g4, g5, and g7 alternate
194 * globals in the spill routines, check out the save instruction in
195 * arch/sparc64/kernel/etrap.S to see what I mean about g2, and
196 * g4/g5 are the globals which are preserved by etrap processing
197 * for the caller of it. The g7 register is the return pc for
198 * etrap. Finally, g6 is the current thread register so we cannot
199 * us it in the spill handlers either. Most of these rules do not
200 * apply to fill processing, only g6 is not usable.
203 /* Normal kernel spill */
204 #define SPILL_0_NORMAL \
205 stx %l0, [%sp + STACK_BIAS + 0x00]; \
206 stx %l1, [%sp + STACK_BIAS + 0x08]; \
207 stx %l2, [%sp + STACK_BIAS + 0x10]; \
208 stx %l3, [%sp + STACK_BIAS + 0x18]; \
209 stx %l4, [%sp + STACK_BIAS + 0x20]; \
210 stx %l5, [%sp + STACK_BIAS + 0x28]; \
211 stx %l6, [%sp + STACK_BIAS + 0x30]; \
212 stx %l7, [%sp + STACK_BIAS + 0x38]; \
213 stx %i0, [%sp + STACK_BIAS + 0x40]; \
214 stx %i1, [%sp + STACK_BIAS + 0x48]; \
215 stx %i2, [%sp + STACK_BIAS + 0x50]; \
216 stx %i3, [%sp + STACK_BIAS + 0x58]; \
217 stx %i4, [%sp + STACK_BIAS + 0x60]; \
218 stx %i5, [%sp + STACK_BIAS + 0x68]; \
219 stx %i6, [%sp + STACK_BIAS + 0x70]; \
220 stx %i7, [%sp + STACK_BIAS + 0x78]; \
221 saved; retry; nop; nop; nop; nop; nop; nop; \
222 nop; nop; nop; nop; nop; nop; nop; nop;
224 /* Normal 64bit spill */
225 #define SPILL_1_GENERIC(ASI) \
226 add %sp, STACK_BIAS + 0x00, %g1; \
227 stxa %l0, [%g1 + %g0] ASI; \
229 stxa %l1, [%g1 + %g3] ASI; \
230 add %g1, 0x10, %g1; \
231 stxa %l2, [%g1 + %g0] ASI; \
232 stxa %l3, [%g1 + %g3] ASI; \
233 add %g1, 0x10, %g1; \
234 stxa %l4, [%g1 + %g0] ASI; \
235 stxa %l5, [%g1 + %g3] ASI; \
236 add %g1, 0x10, %g1; \
237 stxa %l6, [%g1 + %g0] ASI; \
238 stxa %l7, [%g1 + %g3] ASI; \
239 add %g1, 0x10, %g1; \
240 stxa %i0, [%g1 + %g0] ASI; \
241 stxa %i1, [%g1 + %g3] ASI; \
242 add %g1, 0x10, %g1; \
243 stxa %i2, [%g1 + %g0] ASI; \
244 stxa %i3, [%g1 + %g3] ASI; \
245 add %g1, 0x10, %g1; \
246 stxa %i4, [%g1 + %g0] ASI; \
247 stxa %i5, [%g1 + %g3] ASI; \
248 add %g1, 0x10, %g1; \
249 stxa %i6, [%g1 + %g0] ASI; \
250 stxa %i7, [%g1 + %g3] ASI; \
253 b,a,pt %xcc, spill_fixup_dax; \
254 b,a,pt %xcc, spill_fixup_mna; \
255 b,a,pt %xcc, spill_fixup;
257 /* Normal 32bit spill */
258 #define SPILL_2_GENERIC(ASI) \
260 stwa %l0, [%sp + %g0] ASI; \
262 stwa %l1, [%sp + %g3] ASI; \
263 add %sp, 0x08, %g1; \
264 stwa %l2, [%g1 + %g0] ASI; \
265 stwa %l3, [%g1 + %g3] ASI; \
266 add %g1, 0x08, %g1; \
267 stwa %l4, [%g1 + %g0] ASI; \
268 stwa %l5, [%g1 + %g3] ASI; \
269 add %g1, 0x08, %g1; \
270 stwa %l6, [%g1 + %g0] ASI; \
271 stwa %l7, [%g1 + %g3] ASI; \
272 add %g1, 0x08, %g1; \
273 stwa %i0, [%g1 + %g0] ASI; \
274 stwa %i1, [%g1 + %g3] ASI; \
275 add %g1, 0x08, %g1; \
276 stwa %i2, [%g1 + %g0] ASI; \
277 stwa %i3, [%g1 + %g3] ASI; \
278 add %g1, 0x08, %g1; \
279 stwa %i4, [%g1 + %g0] ASI; \
280 stwa %i5, [%g1 + %g3] ASI; \
281 add %g1, 0x08, %g1; \
282 stwa %i6, [%g1 + %g0] ASI; \
283 stwa %i7, [%g1 + %g3] ASI; \
286 b,a,pt %xcc, spill_fixup_dax; \
287 b,a,pt %xcc, spill_fixup_mna; \
288 b,a,pt %xcc, spill_fixup;
290 #define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
291 #define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
292 #define SPILL_3_NORMAL SPILL_0_NORMAL
293 #define SPILL_4_NORMAL SPILL_0_NORMAL
294 #define SPILL_5_NORMAL SPILL_0_NORMAL
295 #define SPILL_6_NORMAL SPILL_0_NORMAL
296 #define SPILL_7_NORMAL SPILL_0_NORMAL
298 #define SPILL_0_OTHER SPILL_0_NORMAL
299 #define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
300 #define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
301 #define SPILL_3_OTHER SPILL_3_NORMAL
302 #define SPILL_4_OTHER SPILL_4_NORMAL
303 #define SPILL_5_OTHER SPILL_5_NORMAL
304 #define SPILL_6_OTHER SPILL_6_NORMAL
305 #define SPILL_7_OTHER SPILL_7_NORMAL
307 /* Normal kernel fill */
308 #define FILL_0_NORMAL \
309 ldx [%sp + STACK_BIAS + 0x00], %l0; \
310 ldx [%sp + STACK_BIAS + 0x08], %l1; \
311 ldx [%sp + STACK_BIAS + 0x10], %l2; \
312 ldx [%sp + STACK_BIAS + 0x18], %l3; \
313 ldx [%sp + STACK_BIAS + 0x20], %l4; \
314 ldx [%sp + STACK_BIAS + 0x28], %l5; \
315 ldx [%sp + STACK_BIAS + 0x30], %l6; \
316 ldx [%sp + STACK_BIAS + 0x38], %l7; \
317 ldx [%sp + STACK_BIAS + 0x40], %i0; \
318 ldx [%sp + STACK_BIAS + 0x48], %i1; \
319 ldx [%sp + STACK_BIAS + 0x50], %i2; \
320 ldx [%sp + STACK_BIAS + 0x58], %i3; \
321 ldx [%sp + STACK_BIAS + 0x60], %i4; \
322 ldx [%sp + STACK_BIAS + 0x68], %i5; \
323 ldx [%sp + STACK_BIAS + 0x70], %i6; \
324 ldx [%sp + STACK_BIAS + 0x78], %i7; \
325 restored; retry; nop; nop; nop; nop; nop; nop; \
326 nop; nop; nop; nop; nop; nop; nop; nop;
328 /* Normal 64bit fill */
329 #define FILL_1_GENERIC(ASI) \
330 add %sp, STACK_BIAS + 0x00, %g1; \
331 ldxa [%g1 + %g0] ASI, %l0; \
334 ldxa [%g1 + %g2] ASI, %l1; \
336 ldxa [%g1 + %g3] ASI, %l2; \
337 ldxa [%g1 + %g5] ASI, %l3; \
338 add %g1, 0x20, %g1; \
339 ldxa [%g1 + %g0] ASI, %l4; \
340 ldxa [%g1 + %g2] ASI, %l5; \
341 ldxa [%g1 + %g3] ASI, %l6; \
342 ldxa [%g1 + %g5] ASI, %l7; \
343 add %g1, 0x20, %g1; \
344 ldxa [%g1 + %g0] ASI, %i0; \
345 ldxa [%g1 + %g2] ASI, %i1; \
346 ldxa [%g1 + %g3] ASI, %i2; \
347 ldxa [%g1 + %g5] ASI, %i3; \
348 add %g1, 0x20, %g1; \
349 ldxa [%g1 + %g0] ASI, %i4; \
350 ldxa [%g1 + %g2] ASI, %i5; \
351 ldxa [%g1 + %g3] ASI, %i6; \
352 ldxa [%g1 + %g5] ASI, %i7; \
354 retry; nop; nop; nop; nop; \
355 b,a,pt %xcc, fill_fixup_dax; \
356 b,a,pt %xcc, fill_fixup_mna; \
357 b,a,pt %xcc, fill_fixup;
359 /* Normal 32bit fill */
360 #define FILL_2_GENERIC(ASI) \
362 lduwa [%sp + %g0] ASI, %l0; \
365 lduwa [%sp + %g2] ASI, %l1; \
367 lduwa [%sp + %g3] ASI, %l2; \
368 lduwa [%sp + %g5] ASI, %l3; \
369 add %sp, 0x10, %g1; \
370 lduwa [%g1 + %g0] ASI, %l4; \
371 lduwa [%g1 + %g2] ASI, %l5; \
372 lduwa [%g1 + %g3] ASI, %l6; \
373 lduwa [%g1 + %g5] ASI, %l7; \
374 add %g1, 0x10, %g1; \
375 lduwa [%g1 + %g0] ASI, %i0; \
376 lduwa [%g1 + %g2] ASI, %i1; \
377 lduwa [%g1 + %g3] ASI, %i2; \
378 lduwa [%g1 + %g5] ASI, %i3; \
379 add %g1, 0x10, %g1; \
380 lduwa [%g1 + %g0] ASI, %i4; \
381 lduwa [%g1 + %g2] ASI, %i5; \
382 lduwa [%g1 + %g3] ASI, %i6; \
383 lduwa [%g1 + %g5] ASI, %i7; \
385 retry; nop; nop; nop; nop; \
386 b,a,pt %xcc, fill_fixup_dax; \
387 b,a,pt %xcc, fill_fixup_mna; \
388 b,a,pt %xcc, fill_fixup;
390 #define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
391 #define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
392 #define FILL_3_NORMAL FILL_0_NORMAL
393 #define FILL_4_NORMAL FILL_0_NORMAL
394 #define FILL_5_NORMAL FILL_0_NORMAL
395 #define FILL_6_NORMAL FILL_0_NORMAL
396 #define FILL_7_NORMAL FILL_0_NORMAL
398 #define FILL_0_OTHER FILL_0_NORMAL
399 #define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
400 #define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
401 #define FILL_3_OTHER FILL_3_NORMAL
402 #define FILL_4_OTHER FILL_4_NORMAL
403 #define FILL_5_OTHER FILL_5_NORMAL
404 #define FILL_6_OTHER FILL_6_NORMAL
405 #define FILL_7_OTHER FILL_7_NORMAL
407 #endif /* !(_SPARC64_TTABLE_H) */