Import 2.3.6
[davej-history.git] / include / asm-sparc64 / ttable.h
blob7619264aed2131c05aa5b1c534b86540a8cdd9cf
1 /* $Id: ttable.h,v 1.11 1999/03/29 12:38:12 jj 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 TRAP_ARG(routine, arg) \
58 sethi %hi(109f), %g7; \
59 ba,pt %xcc, etrap; \
60 109: or %g7, %lo(109b), %g7; \
61 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
62 call routine; \
63 mov arg, %o1; \
64 ba,pt %xcc, rtrap; \
65 clr %l6;
67 #define TRAPTL1_ARG(routine, arg) \
68 sethi %hi(109f), %g7; \
69 ba,pt %xcc, etraptl1; \
70 109: or %g7, %lo(109b), %g7; \
71 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
72 call routine; \
73 mov arg, %o1; \
74 ba,pt %xcc, rtrap; \
75 clr %l6;
77 #define SYSCALL_TRAP(routine, systbl) \
78 sethi %hi(109f), %g7; \
79 ba,pt %xcc, scetrap; \
80 109: or %g7, %lo(109b), %g7; \
81 call routine; \
82 sethi %hi(systbl), %l7; \
83 nop; nop; nop;
85 #define INDIRECT_SOLARIS_SYSCALL(num) \
86 sethi %hi(109f), %g7; \
87 ba,pt %xcc, etrap; \
88 109: or %g7, %lo(109b), %g7; \
89 ba,pt %xcc, tl0_solaris + 0xc; \
90 mov num, %g1; \
91 nop;nop;nop;
93 #define TRAP_UTRAP(handler,lvl) \
94 ldx [%g6 + AOFF_task_tss + AOFF_thread_utraps], %g1; \
95 sethi %hi(109f), %g7; \
96 brz,pn %g1, utrap; \
97 or %g7, %lo(109f), %g7; \
98 ba,pt %xcc, utrap; \
99 109: ldx [%g1 + handler*8], %g1; \
100 ba,pt %xcc, utrap_ill; \
101 mov lvl, %o1;
103 #define SUNOS_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sunos_sys_table)
104 #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
105 #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
106 #define GETCC_TRAP TRAP(getcc)
107 #define SETCC_TRAP TRAP(setcc)
108 #ifdef CONFIG_SOLARIS_EMUL
109 #define SOLARIS_SYSCALL_TRAP TRAP(solaris_sparc_syscall)
110 #else
111 #define SOLARIS_SYSCALL_TRAP TRAP(solaris_syscall)
112 #endif
113 /* FIXME: Write these actually */
114 #define NETBSD_SYSCALL_TRAP TRAP(netbsd_syscall)
115 #define BREAKPOINT_TRAP TRAP(breakpoint_trap)
117 #define TRAP_IRQ(routine, level) \
118 rdpr %pil, %g2; \
119 wrpr %g0, 15, %pil; \
120 b,pt %xcc, etrap_irq; \
121 rd %pc, %g7; \
122 mov level, %o0; \
123 call routine; \
124 add %sp, STACK_BIAS + REGWIN_SZ, %o1; \
125 ba,a,pt %xcc, rtrap_clr_l6;
127 #define TICK_SMP_IRQ \
128 rdpr %pil, %g2; \
129 wrpr %g0, 15, %pil; \
130 sethi %hi(109f), %g7; \
131 b,pt %xcc, etrap_irq; \
132 109: or %g7, %lo(109b), %g7; \
133 call smp_percpu_timer_interrupt; \
134 add %sp, STACK_BIAS + REGWIN_SZ, %o0; \
135 ba,a,pt %xcc, rtrap_clr_l6;
137 #define TRAP_IVEC TRAP_NOSAVE(do_ivec)
139 #define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
141 #define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
143 #define FLUSH_WINDOW_TRAP \
144 ba,pt %xcc, etrap; \
145 rd %pc, %g7; \
146 flushw; \
147 ldx [%sp + STACK_BIAS + REGWIN_SZ + PT_V9_TNPC], %l1; \
148 add %l1, 4, %l2; \
149 stx %l1, [%sp + STACK_BIAS + REGWIN_SZ + PT_V9_TPC]; \
150 ba,pt %xcc, rtrap_clr_l6; \
151 stx %l2, [%sp + STACK_BIAS + REGWIN_SZ + PT_V9_TNPC];
153 /* Before touching these macros, you owe it to yourself to go and
154 * see how arch/sparc64/kernel/winfixup.S works... -DaveM
157 /* Normal kernel spill */
158 #define SPILL_0_NORMAL \
159 stx %l0, [%sp + STACK_BIAS + 0x00]; \
160 stx %l1, [%sp + STACK_BIAS + 0x08]; \
161 stx %l2, [%sp + STACK_BIAS + 0x10]; \
162 stx %l3, [%sp + STACK_BIAS + 0x18]; \
163 stx %l4, [%sp + STACK_BIAS + 0x20]; \
164 stx %l5, [%sp + STACK_BIAS + 0x28]; \
165 stx %l6, [%sp + STACK_BIAS + 0x30]; \
166 stx %l7, [%sp + STACK_BIAS + 0x38]; \
167 stx %i0, [%sp + STACK_BIAS + 0x40]; \
168 stx %i1, [%sp + STACK_BIAS + 0x48]; \
169 stx %i2, [%sp + STACK_BIAS + 0x50]; \
170 stx %i3, [%sp + STACK_BIAS + 0x58]; \
171 stx %i4, [%sp + STACK_BIAS + 0x60]; \
172 stx %i5, [%sp + STACK_BIAS + 0x68]; \
173 stx %i6, [%sp + STACK_BIAS + 0x70]; \
174 stx %i7, [%sp + STACK_BIAS + 0x78]; \
175 saved; retry; nop; nop; nop; nop; nop; nop; \
176 nop; nop; nop; nop; nop; nop; nop; nop;
178 /* Normal 64bit spill */
179 #define SPILL_1_GENERIC(xxx) \
180 wr %g0, xxx, %asi; \
181 stxa %l0, [%sp + STACK_BIAS + 0x00] %asi; \
182 stxa %l1, [%sp + STACK_BIAS + 0x08] %asi; \
183 stxa %l2, [%sp + STACK_BIAS + 0x10] %asi; \
184 stxa %l3, [%sp + STACK_BIAS + 0x18] %asi; \
185 stxa %l4, [%sp + STACK_BIAS + 0x20] %asi; \
186 stxa %l5, [%sp + STACK_BIAS + 0x28] %asi; \
187 stxa %l6, [%sp + STACK_BIAS + 0x30] %asi; \
188 stxa %l7, [%sp + STACK_BIAS + 0x38] %asi; \
189 stxa %i0, [%sp + STACK_BIAS + 0x40] %asi; \
190 stxa %i1, [%sp + STACK_BIAS + 0x48] %asi; \
191 stxa %i2, [%sp + STACK_BIAS + 0x50] %asi; \
192 stxa %i3, [%sp + STACK_BIAS + 0x58] %asi; \
193 stxa %i4, [%sp + STACK_BIAS + 0x60] %asi; \
194 stxa %i5, [%sp + STACK_BIAS + 0x68] %asi; \
195 stxa %i6, [%sp + STACK_BIAS + 0x70] %asi; \
196 stxa %i7, [%sp + STACK_BIAS + 0x78] %asi; \
197 saved; retry; nop; nop; nop; nop; nop; nop; \
198 nop; nop; nop; nop; \
199 b,a,pt %xcc, spill_fixup_dax; \
200 b,a,pt %xcc, spill_fixup_mna; \
201 b,a,pt %xcc, spill_fixup;
203 /* Normal 32bit spill */
204 #define SPILL_2_GENERIC(xxx) \
205 wr %g0, xxx, %asi; \
206 srl %sp, 0, %sp; \
207 stwa %l0, [%sp + 0x00] %asi; \
208 stwa %l1, [%sp + 0x04] %asi; \
209 stwa %l2, [%sp + 0x08] %asi; \
210 stwa %l3, [%sp + 0x0c] %asi; \
211 stwa %l4, [%sp + 0x10] %asi; \
212 stwa %l5, [%sp + 0x14] %asi; \
213 stwa %l6, [%sp + 0x18] %asi; \
214 stwa %l7, [%sp + 0x1c] %asi; \
215 stwa %i0, [%sp + 0x20] %asi; \
216 stwa %i1, [%sp + 0x24] %asi; \
217 stwa %i2, [%sp + 0x28] %asi; \
218 stwa %i3, [%sp + 0x2c] %asi; \
219 stwa %i4, [%sp + 0x30] %asi; \
220 stwa %i5, [%sp + 0x34] %asi; \
221 stwa %i6, [%sp + 0x38] %asi; \
222 stwa %i7, [%sp + 0x3c] %asi; \
223 saved; retry; nop; nop; nop; nop; \
224 nop; nop; nop; nop; nop; \
225 b,a,pt %xcc, spill_fixup_dax; \
226 b,a,pt %xcc, spill_fixup_mna; \
227 b,a,pt %xcc, spill_fixup;
229 #define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
230 #define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
231 #define SPILL_3_NORMAL SPILL_0_NORMAL
232 #define SPILL_4_NORMAL SPILL_0_NORMAL
233 #define SPILL_5_NORMAL SPILL_0_NORMAL
234 #define SPILL_6_NORMAL SPILL_0_NORMAL
235 #define SPILL_7_NORMAL SPILL_0_NORMAL
237 #define SPILL_0_OTHER SPILL_0_NORMAL
238 #define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
239 #define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
240 #define SPILL_3_OTHER SPILL_3_NORMAL
241 #define SPILL_4_OTHER SPILL_4_NORMAL
242 #define SPILL_5_OTHER SPILL_5_NORMAL
243 #define SPILL_6_OTHER SPILL_6_NORMAL
244 #define SPILL_7_OTHER SPILL_7_NORMAL
246 /* Normal kernel fill */
247 #define FILL_0_NORMAL \
248 ldx [%sp + STACK_BIAS + 0x00], %l0; \
249 ldx [%sp + STACK_BIAS + 0x08], %l1; \
250 ldx [%sp + STACK_BIAS + 0x10], %l2; \
251 ldx [%sp + STACK_BIAS + 0x18], %l3; \
252 ldx [%sp + STACK_BIAS + 0x20], %l4; \
253 ldx [%sp + STACK_BIAS + 0x28], %l5; \
254 ldx [%sp + STACK_BIAS + 0x30], %l6; \
255 ldx [%sp + STACK_BIAS + 0x38], %l7; \
256 ldx [%sp + STACK_BIAS + 0x40], %i0; \
257 ldx [%sp + STACK_BIAS + 0x48], %i1; \
258 ldx [%sp + STACK_BIAS + 0x50], %i2; \
259 ldx [%sp + STACK_BIAS + 0x58], %i3; \
260 ldx [%sp + STACK_BIAS + 0x60], %i4; \
261 ldx [%sp + STACK_BIAS + 0x68], %i5; \
262 ldx [%sp + STACK_BIAS + 0x70], %i6; \
263 ldx [%sp + STACK_BIAS + 0x78], %i7; \
264 restored; retry; nop; nop; nop; nop; nop; nop; \
265 nop; nop; nop; nop; nop; nop; nop; nop;
267 /* Normal 64bit fill */
268 #define FILL_1_GENERIC(xxx) \
269 wr %g0, xxx, %asi; \
270 ldxa [%sp + STACK_BIAS + 0x00] %asi, %l0; \
271 ldxa [%sp + STACK_BIAS + 0x08] %asi, %l1; \
272 ldxa [%sp + STACK_BIAS + 0x10] %asi, %l2; \
273 ldxa [%sp + STACK_BIAS + 0x18] %asi, %l3; \
274 ldxa [%sp + STACK_BIAS + 0x20] %asi, %l4; \
275 ldxa [%sp + STACK_BIAS + 0x28] %asi, %l5; \
276 ldxa [%sp + STACK_BIAS + 0x30] %asi, %l6; \
277 ldxa [%sp + STACK_BIAS + 0x38] %asi, %l7; \
278 ldxa [%sp + STACK_BIAS + 0x40] %asi, %i0; \
279 ldxa [%sp + STACK_BIAS + 0x48] %asi, %i1; \
280 ldxa [%sp + STACK_BIAS + 0x50] %asi, %i2; \
281 ldxa [%sp + STACK_BIAS + 0x58] %asi, %i3; \
282 ldxa [%sp + STACK_BIAS + 0x60] %asi, %i4; \
283 ldxa [%sp + STACK_BIAS + 0x68] %asi, %i5; \
284 ldxa [%sp + STACK_BIAS + 0x70] %asi, %i6; \
285 ldxa [%sp + STACK_BIAS + 0x78] %asi, %i7; \
286 restored; retry; nop; nop; nop; nop; nop; nop; \
287 nop; nop; nop; nop; \
288 b,a,pt %xcc, fill_fixup_dax; \
289 b,a,pt %xcc, fill_fixup_mna; \
290 b,a,pt %xcc, fill_fixup;
292 /* Normal 32bit fill */
293 #define FILL_2_GENERIC(xxx) \
294 wr %g0, xxx, %asi; \
295 srl %sp, 0, %sp; \
296 lduwa [%sp + 0x00] %asi, %l0; \
297 lduwa [%sp + 0x04] %asi, %l1; \
298 lduwa [%sp + 0x08] %asi, %l2; \
299 lduwa [%sp + 0x0c] %asi, %l3; \
300 lduwa [%sp + 0x10] %asi, %l4; \
301 lduwa [%sp + 0x14] %asi, %l5; \
302 lduwa [%sp + 0x18] %asi, %l6; \
303 lduwa [%sp + 0x1c] %asi, %l7; \
304 lduwa [%sp + 0x20] %asi, %i0; \
305 lduwa [%sp + 0x24] %asi, %i1; \
306 lduwa [%sp + 0x28] %asi, %i2; \
307 lduwa [%sp + 0x2c] %asi, %i3; \
308 lduwa [%sp + 0x30] %asi, %i4; \
309 lduwa [%sp + 0x34] %asi, %i5; \
310 lduwa [%sp + 0x38] %asi, %i6; \
311 lduwa [%sp + 0x3c] %asi, %i7; \
312 restored; retry; nop; nop; nop; nop; \
313 nop; nop; nop; nop; nop; \
314 b,a,pt %xcc, fill_fixup_dax; \
315 b,a,pt %xcc, fill_fixup_mna; \
316 b,a,pt %xcc, fill_fixup;
318 #define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
319 #define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
320 #define FILL_3_NORMAL FILL_0_NORMAL
321 #define FILL_4_NORMAL FILL_0_NORMAL
322 #define FILL_5_NORMAL FILL_0_NORMAL
323 #define FILL_6_NORMAL FILL_0_NORMAL
324 #define FILL_7_NORMAL FILL_0_NORMAL
326 #define FILL_0_OTHER FILL_0_NORMAL
327 #define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
328 #define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
329 #define FILL_3_OTHER FILL_3_NORMAL
330 #define FILL_4_OTHER FILL_4_NORMAL
331 #define FILL_5_OTHER FILL_5_NORMAL
332 #define FILL_6_OTHER FILL_6_NORMAL
333 #define FILL_7_OTHER FILL_7_NORMAL
335 #endif /* !(_SPARC64_TTABLE_H) */