Import 2.3.18pre1
[davej-history.git] / include / asm-sparc64 / ttable.h
blob4289e581ce8f3e9355c3b85c5f14fe171d99f689
1 /* $Id: ttable.h,v 1.13 1999/08/31 19:25:50 davem Exp $ */
2 #ifndef _SPARC64_TTABLE_H
3 #define _SPARC64_TTABLE_H
5 #include <linux/config.h>
6 #include <asm/asm_offsets.h>
7 #include <asm/utrap.h>
9 #define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop;
11 /* We need a "cleaned" instruction... */
12 #define CLEAN_WINDOW \
13 rdpr %cleanwin, %l0; add %l0, 1, %l0; \
14 wrpr %l0, 0x0, %cleanwin; \
15 clr %o0; clr %o1; clr %o2; clr %o3; \
16 clr %o4; clr %o5; clr %o6; clr %o7; \
17 clr %l0; clr %l1; clr %l2; clr %l3; \
18 clr %l4; clr %l5; clr %l6; clr %l7; \
19 retry; \
20 nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
22 #define TRAP(routine) \
23 sethi %hi(109f), %g7; \
24 ba,pt %xcc, etrap; \
25 109: or %g7, %lo(109b), %g7; \
26 call routine; \
27 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
28 ba,pt %xcc, rtrap; \
29 clr %l6; \
30 nop;
32 #define TRAP_SAVEFPU(routine) \
33 sethi %hi(109f), %g7; \
34 ba,pt %xcc, do_fptrap; \
35 109: or %g7, %lo(109b), %g7; \
36 call routine; \
37 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
38 ba,pt %xcc, rtrap; \
39 clr %l6; \
40 nop;
42 #define TRAP_NOSAVE(routine) \
43 ba,pt %xcc, routine; \
44 nop; \
45 nop; nop; nop; nop; nop; nop;
47 #define TRAPTL1(routine) \
48 sethi %hi(109f), %g7; \
49 ba,pt %xcc, etraptl1; \
50 109: or %g7, %lo(109b), %g7; \
51 call routine; \
52 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
53 ba,pt %xcc, rtrap; \
54 clr %l6; \
55 nop;
57 #define TRAPTL1_CEE \
58 ldxa [%g0] ASI_AFSR, %g1; \
59 membar #Sync; \
60 stxa %g1, [%g0] ASI_AFSR; \
61 membar #Sync; \
62 retry; nop; nop; nop;
64 #define TRAP_ARG(routine, arg) \
65 sethi %hi(109f), %g7; \
66 ba,pt %xcc, etrap; \
67 109: or %g7, %lo(109b), %g7; \
68 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
69 call routine; \
70 mov arg, %o1; \
71 ba,pt %xcc, rtrap; \
72 clr %l6;
74 #define TRAPTL1_ARG(routine, arg) \
75 sethi %hi(109f), %g7; \
76 ba,pt %xcc, etraptl1; \
77 109: or %g7, %lo(109b), %g7; \
78 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
79 call routine; \
80 mov arg, %o1; \
81 ba,pt %xcc, rtrap; \
82 clr %l6;
84 #define SYSCALL_TRAP(routine, systbl) \
85 sethi %hi(109f), %g7; \
86 ba,pt %xcc, scetrap; \
87 109: or %g7, %lo(109b), %g7; \
88 call routine; \
89 sethi %hi(systbl), %l7; \
90 nop; nop; nop;
92 #define INDIRECT_SOLARIS_SYSCALL(num) \
93 sethi %hi(109f), %g7; \
94 ba,pt %xcc, etrap; \
95 109: or %g7, %lo(109b), %g7; \
96 ba,pt %xcc, tl0_solaris + 0xc; \
97 mov num, %g1; \
98 nop;nop;nop;
100 #define TRAP_UTRAP(handler,lvl) \
101 ldx [%g6 + AOFF_task_thread + AOFF_thread_utraps], %g1; \
102 sethi %hi(109f), %g7; \
103 brz,pn %g1, utrap; \
104 or %g7, %lo(109f), %g7; \
105 ba,pt %xcc, utrap; \
106 109: ldx [%g1 + handler*8], %g1; \
107 ba,pt %xcc, utrap_ill; \
108 mov lvl, %o1;
110 #define SUNOS_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sunos_sys_table)
111 #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
112 #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
113 #define GETCC_TRAP TRAP(getcc)
114 #define SETCC_TRAP TRAP(setcc)
115 #ifdef CONFIG_SOLARIS_EMUL
116 #define SOLARIS_SYSCALL_TRAP TRAP(solaris_sparc_syscall)
117 #else
118 #define SOLARIS_SYSCALL_TRAP TRAP(solaris_syscall)
119 #endif
120 /* FIXME: Write these actually */
121 #define NETBSD_SYSCALL_TRAP TRAP(netbsd_syscall)
122 #define BREAKPOINT_TRAP TRAP(breakpoint_trap)
124 #define TRAP_IRQ(routine, level) \
125 rdpr %pil, %g2; \
126 wrpr %g0, 15, %pil; \
127 b,pt %xcc, etrap_irq; \
128 rd %pc, %g7; \
129 mov level, %o0; \
130 call routine; \
131 add %sp, STACK_BIAS + REGWIN_SZ, %o1; \
132 ba,a,pt %xcc, rtrap_clr_l6;
134 #define TICK_SMP_IRQ \
135 rdpr %pil, %g2; \
136 wrpr %g0, 15, %pil; \
137 sethi %hi(109f), %g7; \
138 b,pt %xcc, etrap_irq; \
139 109: or %g7, %lo(109b), %g7; \
140 call smp_percpu_timer_interrupt; \
141 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
142 ba,a,pt %xcc, rtrap_clr_l6;
144 #define TRAP_IVEC TRAP_NOSAVE(do_ivec)
146 #define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
148 #define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
150 #define FLUSH_WINDOW_TRAP \
151 ba,pt %xcc, etrap; \
152 rd %pc, %g7; \
153 flushw; \
154 ldx [%sp + STACK_BIAS + REGWIN_SZ + PT_V9_TNPC], %l1; \
155 add %l1, 4, %l2; \
156 stx %l1, [%sp + STACK_BIAS + REGWIN_SZ + PT_V9_TPC]; \
157 ba,pt %xcc, rtrap_clr_l6; \
158 stx %l2, [%sp + STACK_BIAS + REGWIN_SZ + PT_V9_TNPC];
160 /* Before touching these macros, you owe it to yourself to go and
161 * see how arch/sparc64/kernel/winfixup.S works... -DaveM
164 /* Normal kernel spill */
165 #define SPILL_0_NORMAL \
166 stx %l0, [%sp + STACK_BIAS + 0x00]; \
167 stx %l1, [%sp + STACK_BIAS + 0x08]; \
168 stx %l2, [%sp + STACK_BIAS + 0x10]; \
169 stx %l3, [%sp + STACK_BIAS + 0x18]; \
170 stx %l4, [%sp + STACK_BIAS + 0x20]; \
171 stx %l5, [%sp + STACK_BIAS + 0x28]; \
172 stx %l6, [%sp + STACK_BIAS + 0x30]; \
173 stx %l7, [%sp + STACK_BIAS + 0x38]; \
174 stx %i0, [%sp + STACK_BIAS + 0x40]; \
175 stx %i1, [%sp + STACK_BIAS + 0x48]; \
176 stx %i2, [%sp + STACK_BIAS + 0x50]; \
177 stx %i3, [%sp + STACK_BIAS + 0x58]; \
178 stx %i4, [%sp + STACK_BIAS + 0x60]; \
179 stx %i5, [%sp + STACK_BIAS + 0x68]; \
180 stx %i6, [%sp + STACK_BIAS + 0x70]; \
181 stx %i7, [%sp + STACK_BIAS + 0x78]; \
182 saved; retry; nop; nop; nop; nop; nop; nop; \
183 nop; nop; nop; nop; nop; nop; nop; nop;
185 /* Normal 64bit spill */
186 #define SPILL_1_GENERIC(xxx) \
187 wr %g0, xxx, %asi; \
188 stxa %l0, [%sp + STACK_BIAS + 0x00] %asi; \
189 stxa %l1, [%sp + STACK_BIAS + 0x08] %asi; \
190 stxa %l2, [%sp + STACK_BIAS + 0x10] %asi; \
191 stxa %l3, [%sp + STACK_BIAS + 0x18] %asi; \
192 stxa %l4, [%sp + STACK_BIAS + 0x20] %asi; \
193 stxa %l5, [%sp + STACK_BIAS + 0x28] %asi; \
194 stxa %l6, [%sp + STACK_BIAS + 0x30] %asi; \
195 stxa %l7, [%sp + STACK_BIAS + 0x38] %asi; \
196 stxa %i0, [%sp + STACK_BIAS + 0x40] %asi; \
197 stxa %i1, [%sp + STACK_BIAS + 0x48] %asi; \
198 stxa %i2, [%sp + STACK_BIAS + 0x50] %asi; \
199 stxa %i3, [%sp + STACK_BIAS + 0x58] %asi; \
200 stxa %i4, [%sp + STACK_BIAS + 0x60] %asi; \
201 stxa %i5, [%sp + STACK_BIAS + 0x68] %asi; \
202 stxa %i6, [%sp + STACK_BIAS + 0x70] %asi; \
203 stxa %i7, [%sp + STACK_BIAS + 0x78] %asi; \
204 saved; retry; nop; nop; nop; nop; nop; nop; \
205 nop; nop; nop; nop; \
206 b,a,pt %xcc, spill_fixup_dax; \
207 b,a,pt %xcc, spill_fixup_mna; \
208 b,a,pt %xcc, spill_fixup;
210 /* Normal 32bit spill */
211 #define SPILL_2_GENERIC(xxx) \
212 wr %g0, xxx, %asi; \
213 srl %sp, 0, %sp; \
214 stwa %l0, [%sp + 0x00] %asi; \
215 stwa %l1, [%sp + 0x04] %asi; \
216 stwa %l2, [%sp + 0x08] %asi; \
217 stwa %l3, [%sp + 0x0c] %asi; \
218 stwa %l4, [%sp + 0x10] %asi; \
219 stwa %l5, [%sp + 0x14] %asi; \
220 stwa %l6, [%sp + 0x18] %asi; \
221 stwa %l7, [%sp + 0x1c] %asi; \
222 stwa %i0, [%sp + 0x20] %asi; \
223 stwa %i1, [%sp + 0x24] %asi; \
224 stwa %i2, [%sp + 0x28] %asi; \
225 stwa %i3, [%sp + 0x2c] %asi; \
226 stwa %i4, [%sp + 0x30] %asi; \
227 stwa %i5, [%sp + 0x34] %asi; \
228 stwa %i6, [%sp + 0x38] %asi; \
229 stwa %i7, [%sp + 0x3c] %asi; \
230 saved; retry; nop; nop; nop; nop; \
231 nop; nop; nop; nop; nop; \
232 b,a,pt %xcc, spill_fixup_dax; \
233 b,a,pt %xcc, spill_fixup_mna; \
234 b,a,pt %xcc, spill_fixup;
236 #define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
237 #define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
238 #define SPILL_3_NORMAL SPILL_0_NORMAL
239 #define SPILL_4_NORMAL SPILL_0_NORMAL
240 #define SPILL_5_NORMAL SPILL_0_NORMAL
241 #define SPILL_6_NORMAL SPILL_0_NORMAL
242 #define SPILL_7_NORMAL SPILL_0_NORMAL
244 #define SPILL_0_OTHER SPILL_0_NORMAL
245 #define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
246 #define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
247 #define SPILL_3_OTHER SPILL_3_NORMAL
248 #define SPILL_4_OTHER SPILL_4_NORMAL
249 #define SPILL_5_OTHER SPILL_5_NORMAL
250 #define SPILL_6_OTHER SPILL_6_NORMAL
251 #define SPILL_7_OTHER SPILL_7_NORMAL
253 /* Normal kernel fill */
254 #define FILL_0_NORMAL \
255 ldx [%sp + STACK_BIAS + 0x00], %l0; \
256 ldx [%sp + STACK_BIAS + 0x08], %l1; \
257 ldx [%sp + STACK_BIAS + 0x10], %l2; \
258 ldx [%sp + STACK_BIAS + 0x18], %l3; \
259 ldx [%sp + STACK_BIAS + 0x20], %l4; \
260 ldx [%sp + STACK_BIAS + 0x28], %l5; \
261 ldx [%sp + STACK_BIAS + 0x30], %l6; \
262 ldx [%sp + STACK_BIAS + 0x38], %l7; \
263 ldx [%sp + STACK_BIAS + 0x40], %i0; \
264 ldx [%sp + STACK_BIAS + 0x48], %i1; \
265 ldx [%sp + STACK_BIAS + 0x50], %i2; \
266 ldx [%sp + STACK_BIAS + 0x58], %i3; \
267 ldx [%sp + STACK_BIAS + 0x60], %i4; \
268 ldx [%sp + STACK_BIAS + 0x68], %i5; \
269 ldx [%sp + STACK_BIAS + 0x70], %i6; \
270 ldx [%sp + STACK_BIAS + 0x78], %i7; \
271 restored; retry; nop; nop; nop; nop; nop; nop; \
272 nop; nop; nop; nop; nop; nop; nop; nop;
274 /* Normal 64bit fill */
275 #define FILL_1_GENERIC(xxx) \
276 wr %g0, xxx, %asi; \
277 ldxa [%sp + STACK_BIAS + 0x00] %asi, %l0; \
278 ldxa [%sp + STACK_BIAS + 0x08] %asi, %l1; \
279 ldxa [%sp + STACK_BIAS + 0x10] %asi, %l2; \
280 ldxa [%sp + STACK_BIAS + 0x18] %asi, %l3; \
281 ldxa [%sp + STACK_BIAS + 0x20] %asi, %l4; \
282 ldxa [%sp + STACK_BIAS + 0x28] %asi, %l5; \
283 ldxa [%sp + STACK_BIAS + 0x30] %asi, %l6; \
284 ldxa [%sp + STACK_BIAS + 0x38] %asi, %l7; \
285 ldxa [%sp + STACK_BIAS + 0x40] %asi, %i0; \
286 ldxa [%sp + STACK_BIAS + 0x48] %asi, %i1; \
287 ldxa [%sp + STACK_BIAS + 0x50] %asi, %i2; \
288 ldxa [%sp + STACK_BIAS + 0x58] %asi, %i3; \
289 ldxa [%sp + STACK_BIAS + 0x60] %asi, %i4; \
290 ldxa [%sp + STACK_BIAS + 0x68] %asi, %i5; \
291 ldxa [%sp + STACK_BIAS + 0x70] %asi, %i6; \
292 ldxa [%sp + STACK_BIAS + 0x78] %asi, %i7; \
293 restored; retry; nop; nop; nop; nop; nop; nop; \
294 nop; nop; nop; nop; \
295 b,a,pt %xcc, fill_fixup_dax; \
296 b,a,pt %xcc, fill_fixup_mna; \
297 b,a,pt %xcc, fill_fixup;
299 /* Normal 32bit fill */
300 #define FILL_2_GENERIC(xxx) \
301 wr %g0, xxx, %asi; \
302 srl %sp, 0, %sp; \
303 lduwa [%sp + 0x00] %asi, %l0; \
304 lduwa [%sp + 0x04] %asi, %l1; \
305 lduwa [%sp + 0x08] %asi, %l2; \
306 lduwa [%sp + 0x0c] %asi, %l3; \
307 lduwa [%sp + 0x10] %asi, %l4; \
308 lduwa [%sp + 0x14] %asi, %l5; \
309 lduwa [%sp + 0x18] %asi, %l6; \
310 lduwa [%sp + 0x1c] %asi, %l7; \
311 lduwa [%sp + 0x20] %asi, %i0; \
312 lduwa [%sp + 0x24] %asi, %i1; \
313 lduwa [%sp + 0x28] %asi, %i2; \
314 lduwa [%sp + 0x2c] %asi, %i3; \
315 lduwa [%sp + 0x30] %asi, %i4; \
316 lduwa [%sp + 0x34] %asi, %i5; \
317 lduwa [%sp + 0x38] %asi, %i6; \
318 lduwa [%sp + 0x3c] %asi, %i7; \
319 restored; retry; nop; nop; nop; nop; \
320 nop; nop; nop; nop; nop; \
321 b,a,pt %xcc, fill_fixup_dax; \
322 b,a,pt %xcc, fill_fixup_mna; \
323 b,a,pt %xcc, fill_fixup;
325 #define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
326 #define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
327 #define FILL_3_NORMAL FILL_0_NORMAL
328 #define FILL_4_NORMAL FILL_0_NORMAL
329 #define FILL_5_NORMAL FILL_0_NORMAL
330 #define FILL_6_NORMAL FILL_0_NORMAL
331 #define FILL_7_NORMAL FILL_0_NORMAL
333 #define FILL_0_OTHER FILL_0_NORMAL
334 #define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
335 #define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
336 #define FILL_3_OTHER FILL_3_NORMAL
337 #define FILL_4_OTHER FILL_4_NORMAL
338 #define FILL_5_OTHER FILL_5_NORMAL
339 #define FILL_6_OTHER FILL_6_NORMAL
340 #define FILL_7_OTHER FILL_7_NORMAL
342 #endif /* !(_SPARC64_TTABLE_H) */