]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/asm-sparc64/ttable.h
[SPARC64]: Kill out-of-date commentary in asm-sparc64/tsb.h
[linux-2.6-omap-h63xx.git] / include / asm-sparc64 / ttable.h
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
4
5 #include <linux/config.h>
6 #include <asm/utrap.h>
7
8 #ifdef __ASSEMBLY__
9 #include <asm/thread_info.h>
10 #endif
11
12 #define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop;
13
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;    \
22         retry;                                                          \
23         nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
24
25 #define TRAP(routine)                                   \
26         sethi   %hi(109f), %g7;                         \
27         ba,pt   %xcc, etrap;                            \
28 109:     or     %g7, %lo(109b), %g7;                    \
29         call    routine;                                \
30          add    %sp, PTREGS_OFF, %o0;                   \
31         ba,pt   %xcc, rtrap;                            \
32          clr    %l6;                                    \
33         nop;
34
35 #define TRAP_7INSNS(routine)                            \
36         sethi   %hi(109f), %g7;                         \
37         ba,pt   %xcc, etrap;                            \
38 109:     or     %g7, %lo(109b), %g7;                    \
39         call    routine;                                \
40          add    %sp, PTREGS_OFF, %o0;                   \
41         ba,pt   %xcc, rtrap;                            \
42          clr    %l6;
43
44 #define TRAP_SAVEFPU(routine)                           \
45         sethi   %hi(109f), %g7;                         \
46         ba,pt   %xcc, do_fptrap;                        \
47 109:     or     %g7, %lo(109b), %g7;                    \
48         call    routine;                                \
49          add    %sp, PTREGS_OFF, %o0;                   \
50         ba,pt   %xcc, rtrap;                            \
51          clr    %l6;                                    \
52         nop;
53
54 #define TRAP_NOSAVE(routine)                            \
55         ba,pt   %xcc, routine;                          \
56          nop;                                           \
57         nop; nop; nop; nop; nop; nop;
58         
59 #define TRAP_NOSAVE_7INSNS(routine)                     \
60         ba,pt   %xcc, routine;                          \
61          nop;                                           \
62         nop; nop; nop; nop; nop;
63         
64 #define TRAPTL1(routine)                                \
65         sethi   %hi(109f), %g7;                         \
66         ba,pt   %xcc, etraptl1;                         \
67 109:     or     %g7, %lo(109b), %g7;                    \
68         call    routine;                                \
69          add    %sp, PTREGS_OFF, %o0;                   \
70         ba,pt   %xcc, rtrap;                            \
71          clr    %l6;                                    \
72         nop;
73         
74 #define TRAP_ARG(routine, arg)                          \
75         sethi   %hi(109f), %g7;                         \
76         ba,pt   %xcc, etrap;                            \
77 109:     or     %g7, %lo(109b), %g7;                    \
78         add     %sp, PTREGS_OFF, %o0;                   \
79         call    routine;                                \
80          mov    arg, %o1;                               \
81         ba,pt   %xcc, rtrap;                            \
82          clr    %l6;
83         
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;                   \
89         call    routine;                                \
90          mov    arg, %o1;                               \
91         ba,pt   %xcc, rtrap;                            \
92          clr    %l6;
93         
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;                  \
101         nop; nop;
102         
103 #define INDIRECT_SOLARIS_SYSCALL(num)                   \
104         sethi   %hi(109f), %g7;                         \
105         ba,pt   %xcc, etrap;                            \
106 109:     or     %g7, %lo(109b), %g7;                    \
107         ba,pt   %xcc, tl0_solaris + 0xc;                \
108          mov    num, %g1;                               \
109         nop;nop;nop;
110         
111 #define TRAP_UTRAP(handler,lvl)                         \
112         mov     handler, %g3;                           \
113         ba,pt   %xcc, utrap_trap;                       \
114          mov    lvl, %g4;                               \
115         nop;                                            \
116         nop;                                            \
117         nop;                                            \
118         nop;                                            \
119         nop;
120
121 #ifdef CONFIG_SUNOS_EMUL
122 #define SUNOS_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sunos_sys_table)
123 #else
124 #define SUNOS_SYSCALL_TRAP TRAP(sunos_syscall)
125 #endif
126 #ifdef CONFIG_COMPAT
127 #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
128 #else
129 #define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110)
130 #endif
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)
136 #else
137 #define SOLARIS_SYSCALL_TRAP TRAP(solaris_syscall)
138 #endif
139 #define BREAKPOINT_TRAP TRAP(breakpoint_trap)
140
141 #define TRAP_IRQ(routine, level)                        \
142         rdpr    %pil, %g2;                              \
143         wrpr    %g0, 15, %pil;                          \
144         b,pt    %xcc, etrap_irq;                        \
145          rd     %pc, %g7;                               \
146         mov     level, %o0;                             \
147         call    routine;                                \
148          add    %sp, PTREGS_OFF, %o1;                   \
149         ba,a,pt %xcc, rtrap_irq;
150         
151 #define TICK_SMP_IRQ                                    \
152         rdpr    %pil, %g2;                              \
153         wrpr    %g0, 15, %pil;                          \
154         sethi   %hi(109f), %g7;                         \
155         b,pt    %xcc, etrap_irq;                        \
156 109:     or     %g7, %lo(109b), %g7;                    \
157         call    smp_percpu_timer_interrupt;             \
158          add    %sp, PTREGS_OFF, %o0;                   \
159         ba,a,pt %xcc, rtrap_irq;
160
161 #define TRAP_IVEC TRAP_NOSAVE(do_ivec)
162
163 #define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
164
165 #define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
166
167 #define FLUSH_WINDOW_TRAP                                               \
168         ba,pt   %xcc, etrap;                                            \
169          rd     %pc, %g7;                                               \
170         flushw;                                                         \
171         ldx     [%sp + PTREGS_OFF + PT_V9_TNPC], %l1;                   \
172         add     %l1, 4, %l2;                                            \
173         stx     %l1, [%sp + PTREGS_OFF + PT_V9_TPC];                    \
174         ba,pt   %xcc, rtrap_clr_l6;                                     \
175          stx    %l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
176                 
177 #ifdef CONFIG_KPROBES
178 #define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl)
179 #else
180 #define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
181 #endif
182
183 /* Before touching these macros, you owe it to yourself to go and
184  * see how arch/sparc64/kernel/winfixup.S works... -DaveM
185  *
186  * For the user cases we used to use the %asi register, but
187  * it turns out that the "wr xxx, %asi" costs ~5 cycles, so
188  * now we use immediate ASI loads and stores instead.  Kudos
189  * to Greg Onufer for pointing out this performance anomaly.
190  *
191  * Further note that we cannot use the g2, g4, g5, and g7 alternate
192  * globals in the spill routines, check out the save instruction in
193  * arch/sparc64/kernel/etrap.S to see what I mean about g2, and
194  * g4/g5 are the globals which are preserved by etrap processing
195  * for the caller of it.  The g7 register is the return pc for
196  * etrap.  Finally, g6 is the current thread register so we cannot
197  * us it in the spill handlers either.  Most of these rules do not
198  * apply to fill processing, only g6 is not usable.
199  */
200
201 /* Normal kernel spill */
202 #define SPILL_0_NORMAL                                  \
203         stx     %l0, [%sp + STACK_BIAS + 0x00];         \
204         stx     %l1, [%sp + STACK_BIAS + 0x08];         \
205         stx     %l2, [%sp + STACK_BIAS + 0x10];         \
206         stx     %l3, [%sp + STACK_BIAS + 0x18];         \
207         stx     %l4, [%sp + STACK_BIAS + 0x20];         \
208         stx     %l5, [%sp + STACK_BIAS + 0x28];         \
209         stx     %l6, [%sp + STACK_BIAS + 0x30];         \
210         stx     %l7, [%sp + STACK_BIAS + 0x38];         \
211         stx     %i0, [%sp + STACK_BIAS + 0x40];         \
212         stx     %i1, [%sp + STACK_BIAS + 0x48];         \
213         stx     %i2, [%sp + STACK_BIAS + 0x50];         \
214         stx     %i3, [%sp + STACK_BIAS + 0x58];         \
215         stx     %i4, [%sp + STACK_BIAS + 0x60];         \
216         stx     %i5, [%sp + STACK_BIAS + 0x68];         \
217         stx     %i6, [%sp + STACK_BIAS + 0x70];         \
218         stx     %i7, [%sp + STACK_BIAS + 0x78];         \
219         saved; retry; nop; nop; nop; nop; nop; nop;     \
220         nop; nop; nop; nop; nop; nop; nop; nop;
221
222 /* Normal 64bit spill */
223 #define SPILL_1_GENERIC(ASI)                            \
224         add     %sp, STACK_BIAS + 0x00, %g1;            \
225         stxa    %l0, [%g1 + %g0] ASI;                   \
226         mov     0x08, %g3;                              \
227         stxa    %l1, [%g1 + %g3] ASI;                   \
228         add     %g1, 0x10, %g1;                         \
229         stxa    %l2, [%g1 + %g0] ASI;                   \
230         stxa    %l3, [%g1 + %g3] ASI;                   \
231         add     %g1, 0x10, %g1;                         \
232         stxa    %l4, [%g1 + %g0] ASI;                   \
233         stxa    %l5, [%g1 + %g3] ASI;                   \
234         add     %g1, 0x10, %g1;                         \
235         stxa    %l6, [%g1 + %g0] ASI;                   \
236         stxa    %l7, [%g1 + %g3] ASI;                   \
237         add     %g1, 0x10, %g1;                         \
238         stxa    %i0, [%g1 + %g0] ASI;                   \
239         stxa    %i1, [%g1 + %g3] ASI;                   \
240         add     %g1, 0x10, %g1;                         \
241         stxa    %i2, [%g1 + %g0] ASI;                   \
242         stxa    %i3, [%g1 + %g3] ASI;                   \
243         add     %g1, 0x10, %g1;                         \
244         stxa    %i4, [%g1 + %g0] ASI;                   \
245         stxa    %i5, [%g1 + %g3] ASI;                   \
246         add     %g1, 0x10, %g1;                         \
247         stxa    %i6, [%g1 + %g0] ASI;                   \
248         stxa    %i7, [%g1 + %g3] ASI;                   \
249         saved;                                          \
250         retry; nop; nop;                                \
251         b,a,pt  %xcc, spill_fixup_dax;                  \
252         b,a,pt  %xcc, spill_fixup_mna;                  \
253         b,a,pt  %xcc, spill_fixup;
254
255 /* Normal 32bit spill */
256 #define SPILL_2_GENERIC(ASI)                            \
257         srl     %sp, 0, %sp;                            \
258         stwa    %l0, [%sp + %g0] ASI;                   \
259         mov     0x04, %g3;                              \
260         stwa    %l1, [%sp + %g3] ASI;                   \
261         add     %sp, 0x08, %g1;                         \
262         stwa    %l2, [%g1 + %g0] ASI;                   \
263         stwa    %l3, [%g1 + %g3] ASI;                   \
264         add     %g1, 0x08, %g1;                         \
265         stwa    %l4, [%g1 + %g0] ASI;                   \
266         stwa    %l5, [%g1 + %g3] ASI;                   \
267         add     %g1, 0x08, %g1;                         \
268         stwa    %l6, [%g1 + %g0] ASI;                   \
269         stwa    %l7, [%g1 + %g3] ASI;                   \
270         add     %g1, 0x08, %g1;                         \
271         stwa    %i0, [%g1 + %g0] ASI;                   \
272         stwa    %i1, [%g1 + %g3] ASI;                   \
273         add     %g1, 0x08, %g1;                         \
274         stwa    %i2, [%g1 + %g0] ASI;                   \
275         stwa    %i3, [%g1 + %g3] ASI;                   \
276         add     %g1, 0x08, %g1;                         \
277         stwa    %i4, [%g1 + %g0] ASI;                   \
278         stwa    %i5, [%g1 + %g3] ASI;                   \
279         add     %g1, 0x08, %g1;                         \
280         stwa    %i6, [%g1 + %g0] ASI;                   \
281         stwa    %i7, [%g1 + %g3] ASI;                   \
282         saved;                                          \
283         retry; nop; nop;                                \
284         b,a,pt  %xcc, spill_fixup_dax;                  \
285         b,a,pt  %xcc, spill_fixup_mna;                  \
286         b,a,pt  %xcc, spill_fixup;
287
288 #define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
289 #define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
290 #define SPILL_3_NORMAL SPILL_0_NORMAL
291 #define SPILL_4_NORMAL SPILL_0_NORMAL
292 #define SPILL_5_NORMAL SPILL_0_NORMAL
293 #define SPILL_6_NORMAL SPILL_0_NORMAL
294 #define SPILL_7_NORMAL SPILL_0_NORMAL
295
296 #define SPILL_0_OTHER SPILL_0_NORMAL
297 #define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
298 #define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
299 #define SPILL_3_OTHER SPILL_3_NORMAL
300 #define SPILL_4_OTHER SPILL_4_NORMAL
301 #define SPILL_5_OTHER SPILL_5_NORMAL
302 #define SPILL_6_OTHER SPILL_6_NORMAL
303 #define SPILL_7_OTHER SPILL_7_NORMAL
304
305 /* Normal kernel fill */
306 #define FILL_0_NORMAL                                   \
307         ldx     [%sp + STACK_BIAS + 0x00], %l0;         \
308         ldx     [%sp + STACK_BIAS + 0x08], %l1;         \
309         ldx     [%sp + STACK_BIAS + 0x10], %l2;         \
310         ldx     [%sp + STACK_BIAS + 0x18], %l3;         \
311         ldx     [%sp + STACK_BIAS + 0x20], %l4;         \
312         ldx     [%sp + STACK_BIAS + 0x28], %l5;         \
313         ldx     [%sp + STACK_BIAS + 0x30], %l6;         \
314         ldx     [%sp + STACK_BIAS + 0x38], %l7;         \
315         ldx     [%sp + STACK_BIAS + 0x40], %i0;         \
316         ldx     [%sp + STACK_BIAS + 0x48], %i1;         \
317         ldx     [%sp + STACK_BIAS + 0x50], %i2;         \
318         ldx     [%sp + STACK_BIAS + 0x58], %i3;         \
319         ldx     [%sp + STACK_BIAS + 0x60], %i4;         \
320         ldx     [%sp + STACK_BIAS + 0x68], %i5;         \
321         ldx     [%sp + STACK_BIAS + 0x70], %i6;         \
322         ldx     [%sp + STACK_BIAS + 0x78], %i7;         \
323         restored; retry; nop; nop; nop; nop; nop; nop;  \
324         nop; nop; nop; nop; nop; nop; nop; nop;
325
326 /* Normal 64bit fill */
327 #define FILL_1_GENERIC(ASI)                             \
328         add     %sp, STACK_BIAS + 0x00, %g1;            \
329         ldxa    [%g1 + %g0] ASI, %l0;                   \
330         mov     0x08, %g2;                              \
331         mov     0x10, %g3;                              \
332         ldxa    [%g1 + %g2] ASI, %l1;                   \
333         mov     0x18, %g5;                              \
334         ldxa    [%g1 + %g3] ASI, %l2;                   \
335         ldxa    [%g1 + %g5] ASI, %l3;                   \
336         add     %g1, 0x20, %g1;                         \
337         ldxa    [%g1 + %g0] ASI, %l4;                   \
338         ldxa    [%g1 + %g2] ASI, %l5;                   \
339         ldxa    [%g1 + %g3] ASI, %l6;                   \
340         ldxa    [%g1 + %g5] ASI, %l7;                   \
341         add     %g1, 0x20, %g1;                         \
342         ldxa    [%g1 + %g0] ASI, %i0;                   \
343         ldxa    [%g1 + %g2] ASI, %i1;                   \
344         ldxa    [%g1 + %g3] ASI, %i2;                   \
345         ldxa    [%g1 + %g5] ASI, %i3;                   \
346         add     %g1, 0x20, %g1;                         \
347         ldxa    [%g1 + %g0] ASI, %i4;                   \
348         ldxa    [%g1 + %g2] ASI, %i5;                   \
349         ldxa    [%g1 + %g3] ASI, %i6;                   \
350         ldxa    [%g1 + %g5] ASI, %i7;                   \
351         restored;                                       \
352         retry; nop; nop; nop; nop;                      \
353         b,a,pt  %xcc, fill_fixup_dax;                   \
354         b,a,pt  %xcc, fill_fixup_mna;                   \
355         b,a,pt  %xcc, fill_fixup;
356
357 /* Normal 32bit fill */
358 #define FILL_2_GENERIC(ASI)                             \
359         srl     %sp, 0, %sp;                            \
360         lduwa   [%sp + %g0] ASI, %l0;                   \
361         mov     0x04, %g2;                              \
362         mov     0x08, %g3;                              \
363         lduwa   [%sp + %g2] ASI, %l1;                   \
364         mov     0x0c, %g5;                              \
365         lduwa   [%sp + %g3] ASI, %l2;                   \
366         lduwa   [%sp + %g5] ASI, %l3;                   \
367         add     %sp, 0x10, %g1;                         \
368         lduwa   [%g1 + %g0] ASI, %l4;                   \
369         lduwa   [%g1 + %g2] ASI, %l5;                   \
370         lduwa   [%g1 + %g3] ASI, %l6;                   \
371         lduwa   [%g1 + %g5] ASI, %l7;                   \
372         add     %g1, 0x10, %g1;                         \
373         lduwa   [%g1 + %g0] ASI, %i0;                   \
374         lduwa   [%g1 + %g2] ASI, %i1;                   \
375         lduwa   [%g1 + %g3] ASI, %i2;                   \
376         lduwa   [%g1 + %g5] ASI, %i3;                   \
377         add     %g1, 0x10, %g1;                         \
378         lduwa   [%g1 + %g0] ASI, %i4;                   \
379         lduwa   [%g1 + %g2] ASI, %i5;                   \
380         lduwa   [%g1 + %g3] ASI, %i6;                   \
381         lduwa   [%g1 + %g5] ASI, %i7;                   \
382         restored;                                       \
383         retry; nop; nop; nop; nop;                      \
384         b,a,pt  %xcc, fill_fixup_dax;                   \
385         b,a,pt  %xcc, fill_fixup_mna;                   \
386         b,a,pt  %xcc, fill_fixup;
387
388 #define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
389 #define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
390 #define FILL_3_NORMAL FILL_0_NORMAL
391 #define FILL_4_NORMAL FILL_0_NORMAL
392 #define FILL_5_NORMAL FILL_0_NORMAL
393 #define FILL_6_NORMAL FILL_0_NORMAL
394 #define FILL_7_NORMAL FILL_0_NORMAL
395
396 #define FILL_0_OTHER FILL_0_NORMAL
397 #define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
398 #define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
399 #define FILL_3_OTHER FILL_3_NORMAL
400 #define FILL_4_OTHER FILL_4_NORMAL
401 #define FILL_5_OTHER FILL_5_NORMAL
402 #define FILL_6_OTHER FILL_6_NORMAL
403 #define FILL_7_OTHER FILL_7_NORMAL
404
405 #endif /* !(_SPARC64_TTABLE_H) */