162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _SPARC64_TTABLE_H
362306a36Sopenharmony_ci#define _SPARC64_TTABLE_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <asm/utrap.h>
662306a36Sopenharmony_ci#include <asm/pil.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifdef __ASSEMBLY__
962306a36Sopenharmony_ci#include <asm/thread_info.h>
1062306a36Sopenharmony_ci#endif
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#define BOOT_KERNEL b sparc64_boot; nop; nop; nop; nop; nop; nop; nop;
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/* We need a "cleaned" instruction... */
1562306a36Sopenharmony_ci#define CLEAN_WINDOW							\
1662306a36Sopenharmony_ci	rdpr	%cleanwin, %l0;		add	%l0, 1, %l0;		\
1762306a36Sopenharmony_ci	wrpr	%l0, 0x0, %cleanwin;					\
1862306a36Sopenharmony_ci	clr	%o0;	clr	%o1;	clr	%o2;	clr	%o3;	\
1962306a36Sopenharmony_ci	clr	%o4;	clr	%o5;	clr	%o6;	clr	%o7;	\
2062306a36Sopenharmony_ci	clr	%l0;	clr	%l1;	clr	%l2;	clr	%l3;	\
2162306a36Sopenharmony_ci	clr	%l4;	clr	%l5;	clr	%l6;	clr	%l7;	\
2262306a36Sopenharmony_ci	retry;								\
2362306a36Sopenharmony_ci	nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;nop;
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci#define TRAP(routine)					\
2662306a36Sopenharmony_ci	sethi	%hi(109f), %g7;				\
2762306a36Sopenharmony_ci	ba,pt	%xcc, etrap;				\
2862306a36Sopenharmony_ci109:	 or	%g7, %lo(109b), %g7;			\
2962306a36Sopenharmony_ci	call	routine;				\
3062306a36Sopenharmony_ci	 add	%sp, PTREGS_OFF, %o0;			\
3162306a36Sopenharmony_ci	ba,pt	%xcc, rtrap;				\
3262306a36Sopenharmony_ci	 nop;						\
3362306a36Sopenharmony_ci	nop;
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define TRAP_7INSNS(routine)				\
3662306a36Sopenharmony_ci	sethi	%hi(109f), %g7;				\
3762306a36Sopenharmony_ci	ba,pt	%xcc, etrap;				\
3862306a36Sopenharmony_ci109:	 or	%g7, %lo(109b), %g7;			\
3962306a36Sopenharmony_ci	call	routine;				\
4062306a36Sopenharmony_ci	 add	%sp, PTREGS_OFF, %o0;			\
4162306a36Sopenharmony_ci	ba,pt	%xcc, rtrap;				\
4262306a36Sopenharmony_ci	 nop;
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci#define TRAP_SAVEFPU(routine)				\
4562306a36Sopenharmony_ci	sethi	%hi(109f), %g7;				\
4662306a36Sopenharmony_ci	ba,pt	%xcc, do_fptrap;			\
4762306a36Sopenharmony_ci109:	 or	%g7, %lo(109b), %g7;			\
4862306a36Sopenharmony_ci	call	routine;				\
4962306a36Sopenharmony_ci	 add	%sp, PTREGS_OFF, %o0;			\
5062306a36Sopenharmony_ci	ba,pt	%xcc, rtrap;				\
5162306a36Sopenharmony_ci	 nop;						\
5262306a36Sopenharmony_ci	nop;
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci#define TRAP_NOSAVE(routine)				\
5562306a36Sopenharmony_ci	ba,pt	%xcc, routine;				\
5662306a36Sopenharmony_ci	 nop;						\
5762306a36Sopenharmony_ci	nop; nop; nop; nop; nop; nop;
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#define TRAP_NOSAVE_7INSNS(routine)			\
6062306a36Sopenharmony_ci	ba,pt	%xcc, routine;				\
6162306a36Sopenharmony_ci	 nop;						\
6262306a36Sopenharmony_ci	nop; nop; nop; nop; nop;
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci#define TRAPTL1(routine)				\
6562306a36Sopenharmony_ci	sethi	%hi(109f), %g7;				\
6662306a36Sopenharmony_ci	ba,pt	%xcc, etraptl1;				\
6762306a36Sopenharmony_ci109:	 or	%g7, %lo(109b), %g7;			\
6862306a36Sopenharmony_ci	call	routine;				\
6962306a36Sopenharmony_ci	 add	%sp, PTREGS_OFF, %o0;			\
7062306a36Sopenharmony_ci	ba,pt	%xcc, rtrap;				\
7162306a36Sopenharmony_ci	 nop;						\
7262306a36Sopenharmony_ci	nop;
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define TRAP_ARG(routine, arg)				\
7562306a36Sopenharmony_ci	sethi	%hi(109f), %g7;				\
7662306a36Sopenharmony_ci	ba,pt	%xcc, etrap;				\
7762306a36Sopenharmony_ci109:	 or	%g7, %lo(109b), %g7;			\
7862306a36Sopenharmony_ci	add	%sp, PTREGS_OFF, %o0;			\
7962306a36Sopenharmony_ci	call	routine;				\
8062306a36Sopenharmony_ci	 mov	arg, %o1;				\
8162306a36Sopenharmony_ci	ba,pt	%xcc, rtrap;				\
8262306a36Sopenharmony_ci	 nop;
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci#define TRAPTL1_ARG(routine, arg)			\
8562306a36Sopenharmony_ci	sethi	%hi(109f), %g7;				\
8662306a36Sopenharmony_ci	ba,pt	%xcc, etraptl1;				\
8762306a36Sopenharmony_ci109:	 or	%g7, %lo(109b), %g7;			\
8862306a36Sopenharmony_ci	add	%sp, PTREGS_OFF, %o0;			\
8962306a36Sopenharmony_ci	call	routine;				\
9062306a36Sopenharmony_ci	 mov	arg, %o1;				\
9162306a36Sopenharmony_ci	ba,pt	%xcc, rtrap;				\
9262306a36Sopenharmony_ci	 nop;
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define SYSCALL_TRAP(routine, systbl)			\
9562306a36Sopenharmony_ci	rdpr	%pil, %g2;				\
9662306a36Sopenharmony_ci	mov	TSTATE_SYSCALL, %g3;			\
9762306a36Sopenharmony_ci	sethi	%hi(109f), %g7;				\
9862306a36Sopenharmony_ci	ba,pt	%xcc, etrap_syscall;			\
9962306a36Sopenharmony_ci109:	 or	%g7, %lo(109b), %g7;			\
10062306a36Sopenharmony_ci	sethi	%hi(systbl), %l7;			\
10162306a36Sopenharmony_ci	ba,pt	%xcc, routine;				\
10262306a36Sopenharmony_ci	 or	%l7, %lo(systbl), %l7;
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci#define TRAP_UTRAP(handler,lvl)				\
10562306a36Sopenharmony_ci	mov	handler, %g3;				\
10662306a36Sopenharmony_ci	ba,pt	%xcc, utrap_trap;			\
10762306a36Sopenharmony_ci	 mov	lvl, %g4;				\
10862306a36Sopenharmony_ci	nop;						\
10962306a36Sopenharmony_ci	nop;						\
11062306a36Sopenharmony_ci	nop;						\
11162306a36Sopenharmony_ci	nop;						\
11262306a36Sopenharmony_ci	nop;
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci#ifdef CONFIG_COMPAT
11562306a36Sopenharmony_ci#define	LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32)
11662306a36Sopenharmony_ci#else
11762306a36Sopenharmony_ci#define	LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110)
11862306a36Sopenharmony_ci#endif
11962306a36Sopenharmony_ci#define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64)
12062306a36Sopenharmony_ci#define GETCC_TRAP TRAP(getcc)
12162306a36Sopenharmony_ci#define SETCC_TRAP TRAP(setcc)
12262306a36Sopenharmony_ci#define BREAKPOINT_TRAP TRAP(breakpoint_trap)
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci#ifdef CONFIG_TRACE_IRQFLAGS
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci#define TRAP_IRQ(routine, level)			\
12762306a36Sopenharmony_ci	rdpr	%pil, %g2;				\
12862306a36Sopenharmony_ci	wrpr	%g0, PIL_NORMAL_MAX, %pil;		\
12962306a36Sopenharmony_ci	sethi	%hi(1f-4), %g7;				\
13062306a36Sopenharmony_ci	ba,pt	%xcc, etrap_irq;			\
13162306a36Sopenharmony_ci	 or	%g7, %lo(1f-4), %g7;			\
13262306a36Sopenharmony_ci	nop;						\
13362306a36Sopenharmony_ci	nop;						\
13462306a36Sopenharmony_ci	nop;						\
13562306a36Sopenharmony_ci	.subsection	2;				\
13662306a36Sopenharmony_ci1:	call	trace_hardirqs_off;			\
13762306a36Sopenharmony_ci	 nop;						\
13862306a36Sopenharmony_ci	mov	level, %o0;				\
13962306a36Sopenharmony_ci	call	routine;				\
14062306a36Sopenharmony_ci	 add	%sp, PTREGS_OFF, %o1;			\
14162306a36Sopenharmony_ci	ba,a,pt	%xcc, rtrap_irq;			\
14262306a36Sopenharmony_ci	.previous;
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci#else
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci#define TRAP_IRQ(routine, level)			\
14762306a36Sopenharmony_ci	rdpr	%pil, %g2;				\
14862306a36Sopenharmony_ci	wrpr	%g0, PIL_NORMAL_MAX, %pil;		\
14962306a36Sopenharmony_ci	ba,pt	%xcc, etrap_irq;			\
15062306a36Sopenharmony_ci	 rd	%pc, %g7;				\
15162306a36Sopenharmony_ci	mov	level, %o0;				\
15262306a36Sopenharmony_ci	call	routine;				\
15362306a36Sopenharmony_ci	 add	%sp, PTREGS_OFF, %o1;			\
15462306a36Sopenharmony_ci	ba,a,pt	%xcc, rtrap_irq;
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci#endif
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#define TRAP_NMI_IRQ(routine, level)			\
15962306a36Sopenharmony_ci	rdpr	%pil, %g2;				\
16062306a36Sopenharmony_ci	wrpr	%g0, PIL_NMI, %pil;			\
16162306a36Sopenharmony_ci	ba,pt	%xcc, etrap_irq;			\
16262306a36Sopenharmony_ci	 rd	%pc, %g7;				\
16362306a36Sopenharmony_ci	mov	level, %o0;				\
16462306a36Sopenharmony_ci	call	routine;				\
16562306a36Sopenharmony_ci	 add	%sp, PTREGS_OFF, %o1;			\
16662306a36Sopenharmony_ci	ba,a,pt	%xcc, rtrap_nmi;
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci#define TRAP_IVEC TRAP_NOSAVE(do_ivec)
16962306a36Sopenharmony_ci
17062306a36Sopenharmony_ci#define BTRAP(lvl) TRAP_ARG(bad_trap, lvl)
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci#define BTRAPTL1(lvl) TRAPTL1_ARG(bad_trap_tl1, lvl)
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci#define FLUSH_WINDOW_TRAP						\
17562306a36Sopenharmony_ci	ba,pt	%xcc, etrap;						\
17662306a36Sopenharmony_ci	 rd	%pc, %g7;						\
17762306a36Sopenharmony_ci	flushw;								\
17862306a36Sopenharmony_ci	ldx	[%sp + PTREGS_OFF + PT_V9_TNPC], %l1;			\
17962306a36Sopenharmony_ci	add	%l1, 4, %l2;						\
18062306a36Sopenharmony_ci	stx	%l1, [%sp + PTREGS_OFF + PT_V9_TPC];			\
18162306a36Sopenharmony_ci	ba,pt	%xcc, rtrap;						\
18262306a36Sopenharmony_ci	 stx	%l2, [%sp + PTREGS_OFF + PT_V9_TNPC];
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_ci#ifdef CONFIG_KPROBES
18562306a36Sopenharmony_ci#define KPROBES_TRAP(lvl) TRAP_IRQ(kprobe_trap, lvl)
18662306a36Sopenharmony_ci#else
18762306a36Sopenharmony_ci#define KPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
18862306a36Sopenharmony_ci#endif
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci#ifdef CONFIG_UPROBES
19162306a36Sopenharmony_ci#define UPROBES_TRAP(lvl) TRAP_ARG(uprobe_trap, lvl)
19262306a36Sopenharmony_ci#else
19362306a36Sopenharmony_ci#define UPROBES_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
19462306a36Sopenharmony_ci#endif
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci#ifdef CONFIG_KGDB
19762306a36Sopenharmony_ci#define KGDB_TRAP(lvl) TRAP_IRQ(kgdb_trap, lvl)
19862306a36Sopenharmony_ci#else
19962306a36Sopenharmony_ci#define KGDB_TRAP(lvl) TRAP_ARG(bad_trap, lvl)
20062306a36Sopenharmony_ci#endif
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci#define SUN4V_ITSB_MISS					\
20362306a36Sopenharmony_ci	ldxa	[%g0] ASI_SCRATCHPAD, %g2;		\
20462306a36Sopenharmony_ci	ldx	[%g2 + HV_FAULT_I_ADDR_OFFSET], %g4;	\
20562306a36Sopenharmony_ci	ldx	[%g2 + HV_FAULT_I_CTX_OFFSET], %g5;	\
20662306a36Sopenharmony_ci	srlx	%g4, 22, %g6;				\
20762306a36Sopenharmony_ci	ba,pt	%xcc, sun4v_itsb_miss;			\
20862306a36Sopenharmony_ci	 nop;						\
20962306a36Sopenharmony_ci	nop;						\
21062306a36Sopenharmony_ci	nop;
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci#define SUN4V_DTSB_MISS					\
21362306a36Sopenharmony_ci	ldxa	[%g0] ASI_SCRATCHPAD, %g2;		\
21462306a36Sopenharmony_ci	ldx	[%g2 + HV_FAULT_D_ADDR_OFFSET], %g4;	\
21562306a36Sopenharmony_ci	ldx	[%g2 + HV_FAULT_D_CTX_OFFSET], %g5;	\
21662306a36Sopenharmony_ci	srlx	%g4, 22, %g6;				\
21762306a36Sopenharmony_ci	ba,pt	%xcc, sun4v_dtsb_miss;			\
21862306a36Sopenharmony_ci	 nop;						\
21962306a36Sopenharmony_ci	nop;						\
22062306a36Sopenharmony_ci	nop;
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci#define SUN4V_MCD_PRECISE				\
22362306a36Sopenharmony_ci	ldxa	[%g0] ASI_SCRATCHPAD, %g2;		\
22462306a36Sopenharmony_ci	ldx	[%g2 + HV_FAULT_D_ADDR_OFFSET], %g4;	\
22562306a36Sopenharmony_ci	ldx	[%g2 + HV_FAULT_D_CTX_OFFSET], %g5;	\
22662306a36Sopenharmony_ci	ba,pt	%xcc, etrap;				\
22762306a36Sopenharmony_ci	 rd	%pc, %g7;				\
22862306a36Sopenharmony_ci	ba,pt	%xcc, sun4v_mcd_detect_precise;		\
22962306a36Sopenharmony_ci	 nop;						\
23062306a36Sopenharmony_ci	nop;
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci/* Before touching these macros, you owe it to yourself to go and
23362306a36Sopenharmony_ci * see how arch/sparc64/kernel/winfixup.S works... -DaveM
23462306a36Sopenharmony_ci *
23562306a36Sopenharmony_ci * For the user cases we used to use the %asi register, but
23662306a36Sopenharmony_ci * it turns out that the "wr xxx, %asi" costs ~5 cycles, so
23762306a36Sopenharmony_ci * now we use immediate ASI loads and stores instead.  Kudos
23862306a36Sopenharmony_ci * to Greg Onufer for pointing out this performance anomaly.
23962306a36Sopenharmony_ci *
24062306a36Sopenharmony_ci * Further note that we cannot use the g2, g4, g5, and g7 alternate
24162306a36Sopenharmony_ci * globals in the spill routines, check out the save instruction in
24262306a36Sopenharmony_ci * arch/sparc64/kernel/etrap.S to see what I mean about g2, and
24362306a36Sopenharmony_ci * g4/g5 are the globals which are preserved by etrap processing
24462306a36Sopenharmony_ci * for the caller of it.  The g7 register is the return pc for
24562306a36Sopenharmony_ci * etrap.  Finally, g6 is the current thread register so we cannot
24662306a36Sopenharmony_ci * us it in the spill handlers either.  Most of these rules do not
24762306a36Sopenharmony_ci * apply to fill processing, only g6 is not usable.
24862306a36Sopenharmony_ci */
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci/* Normal kernel spill */
25162306a36Sopenharmony_ci#define SPILL_0_NORMAL					\
25262306a36Sopenharmony_ci	stx	%l0, [%sp + STACK_BIAS + 0x00];		\
25362306a36Sopenharmony_ci	stx	%l1, [%sp + STACK_BIAS + 0x08];		\
25462306a36Sopenharmony_ci	stx	%l2, [%sp + STACK_BIAS + 0x10];		\
25562306a36Sopenharmony_ci	stx	%l3, [%sp + STACK_BIAS + 0x18];		\
25662306a36Sopenharmony_ci	stx	%l4, [%sp + STACK_BIAS + 0x20];		\
25762306a36Sopenharmony_ci	stx	%l5, [%sp + STACK_BIAS + 0x28];		\
25862306a36Sopenharmony_ci	stx	%l6, [%sp + STACK_BIAS + 0x30];		\
25962306a36Sopenharmony_ci	stx	%l7, [%sp + STACK_BIAS + 0x38];		\
26062306a36Sopenharmony_ci	stx	%i0, [%sp + STACK_BIAS + 0x40];		\
26162306a36Sopenharmony_ci	stx	%i1, [%sp + STACK_BIAS + 0x48];		\
26262306a36Sopenharmony_ci	stx	%i2, [%sp + STACK_BIAS + 0x50];		\
26362306a36Sopenharmony_ci	stx	%i3, [%sp + STACK_BIAS + 0x58];		\
26462306a36Sopenharmony_ci	stx	%i4, [%sp + STACK_BIAS + 0x60];		\
26562306a36Sopenharmony_ci	stx	%i5, [%sp + STACK_BIAS + 0x68];		\
26662306a36Sopenharmony_ci	stx	%i6, [%sp + STACK_BIAS + 0x70];		\
26762306a36Sopenharmony_ci	stx	%i7, [%sp + STACK_BIAS + 0x78];		\
26862306a36Sopenharmony_ci	saved; retry; nop; nop; nop; nop; nop; nop;	\
26962306a36Sopenharmony_ci	nop; nop; nop; nop; nop; nop; nop; nop;
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci#define SPILL_0_NORMAL_ETRAP				\
27262306a36Sopenharmony_cietrap_kernel_spill:					\
27362306a36Sopenharmony_ci	stx	%l0, [%sp + STACK_BIAS + 0x00];		\
27462306a36Sopenharmony_ci	stx	%l1, [%sp + STACK_BIAS + 0x08];		\
27562306a36Sopenharmony_ci	stx	%l2, [%sp + STACK_BIAS + 0x10];		\
27662306a36Sopenharmony_ci	stx	%l3, [%sp + STACK_BIAS + 0x18];		\
27762306a36Sopenharmony_ci	stx	%l4, [%sp + STACK_BIAS + 0x20];		\
27862306a36Sopenharmony_ci	stx	%l5, [%sp + STACK_BIAS + 0x28];		\
27962306a36Sopenharmony_ci	stx	%l6, [%sp + STACK_BIAS + 0x30];		\
28062306a36Sopenharmony_ci	stx	%l7, [%sp + STACK_BIAS + 0x38];		\
28162306a36Sopenharmony_ci	stx	%i0, [%sp + STACK_BIAS + 0x40];		\
28262306a36Sopenharmony_ci	stx	%i1, [%sp + STACK_BIAS + 0x48];		\
28362306a36Sopenharmony_ci	stx	%i2, [%sp + STACK_BIAS + 0x50];		\
28462306a36Sopenharmony_ci	stx	%i3, [%sp + STACK_BIAS + 0x58];		\
28562306a36Sopenharmony_ci	stx	%i4, [%sp + STACK_BIAS + 0x60];		\
28662306a36Sopenharmony_ci	stx	%i5, [%sp + STACK_BIAS + 0x68];		\
28762306a36Sopenharmony_ci	stx	%i6, [%sp + STACK_BIAS + 0x70];		\
28862306a36Sopenharmony_ci	stx	%i7, [%sp + STACK_BIAS + 0x78];		\
28962306a36Sopenharmony_ci	saved;						\
29062306a36Sopenharmony_ci	sub	%g1, 2, %g1;				\
29162306a36Sopenharmony_ci	ba,pt	%xcc, etrap_save;			\
29262306a36Sopenharmony_ci	wrpr	%g1, %cwp;				\
29362306a36Sopenharmony_ci	nop; nop; nop; nop; nop; nop; nop; nop;		\
29462306a36Sopenharmony_ci	nop; nop; nop; nop;
29562306a36Sopenharmony_ci
29662306a36Sopenharmony_ci/* Normal 64bit spill */
29762306a36Sopenharmony_ci#define SPILL_1_GENERIC(ASI)				\
29862306a36Sopenharmony_ci	add	%sp, STACK_BIAS + 0x00, %g1;		\
29962306a36Sopenharmony_ci	stxa	%l0, [%g1 + %g0] ASI;			\
30062306a36Sopenharmony_ci	mov	0x08, %g3;				\
30162306a36Sopenharmony_ci	stxa	%l1, [%g1 + %g3] ASI;			\
30262306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
30362306a36Sopenharmony_ci	stxa	%l2, [%g1 + %g0] ASI;			\
30462306a36Sopenharmony_ci	stxa	%l3, [%g1 + %g3] ASI;			\
30562306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
30662306a36Sopenharmony_ci	stxa	%l4, [%g1 + %g0] ASI;			\
30762306a36Sopenharmony_ci	stxa	%l5, [%g1 + %g3] ASI;			\
30862306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
30962306a36Sopenharmony_ci	stxa	%l6, [%g1 + %g0] ASI;			\
31062306a36Sopenharmony_ci	stxa	%l7, [%g1 + %g3] ASI;			\
31162306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
31262306a36Sopenharmony_ci	stxa	%i0, [%g1 + %g0] ASI;			\
31362306a36Sopenharmony_ci	stxa	%i1, [%g1 + %g3] ASI;			\
31462306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
31562306a36Sopenharmony_ci	stxa	%i2, [%g1 + %g0] ASI;			\
31662306a36Sopenharmony_ci	stxa	%i3, [%g1 + %g3] ASI;			\
31762306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
31862306a36Sopenharmony_ci	stxa	%i4, [%g1 + %g0] ASI;			\
31962306a36Sopenharmony_ci	stxa	%i5, [%g1 + %g3] ASI;			\
32062306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
32162306a36Sopenharmony_ci	stxa	%i6, [%g1 + %g0] ASI;			\
32262306a36Sopenharmony_ci	stxa	%i7, [%g1 + %g3] ASI;			\
32362306a36Sopenharmony_ci	saved;						\
32462306a36Sopenharmony_ci	retry; nop; nop;				\
32562306a36Sopenharmony_ci	b,a,pt	%xcc, spill_fixup_dax;			\
32662306a36Sopenharmony_ci	b,a,pt	%xcc, spill_fixup_mna;			\
32762306a36Sopenharmony_ci	b,a,pt	%xcc, spill_fixup;
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci#define SPILL_1_GENERIC_ETRAP				\
33062306a36Sopenharmony_cietrap_user_spill_64bit:					\
33162306a36Sopenharmony_ci	stxa	%l0, [%sp + STACK_BIAS + 0x00] %asi;	\
33262306a36Sopenharmony_ci	stxa	%l1, [%sp + STACK_BIAS + 0x08] %asi;	\
33362306a36Sopenharmony_ci	stxa	%l2, [%sp + STACK_BIAS + 0x10] %asi;	\
33462306a36Sopenharmony_ci	stxa	%l3, [%sp + STACK_BIAS + 0x18] %asi;	\
33562306a36Sopenharmony_ci	stxa	%l4, [%sp + STACK_BIAS + 0x20] %asi;	\
33662306a36Sopenharmony_ci	stxa	%l5, [%sp + STACK_BIAS + 0x28] %asi;	\
33762306a36Sopenharmony_ci	stxa	%l6, [%sp + STACK_BIAS + 0x30] %asi;	\
33862306a36Sopenharmony_ci	stxa	%l7, [%sp + STACK_BIAS + 0x38] %asi;	\
33962306a36Sopenharmony_ci	stxa	%i0, [%sp + STACK_BIAS + 0x40] %asi;	\
34062306a36Sopenharmony_ci	stxa	%i1, [%sp + STACK_BIAS + 0x48] %asi;	\
34162306a36Sopenharmony_ci	stxa	%i2, [%sp + STACK_BIAS + 0x50] %asi;	\
34262306a36Sopenharmony_ci	stxa	%i3, [%sp + STACK_BIAS + 0x58] %asi;	\
34362306a36Sopenharmony_ci	stxa	%i4, [%sp + STACK_BIAS + 0x60] %asi;	\
34462306a36Sopenharmony_ci	stxa	%i5, [%sp + STACK_BIAS + 0x68] %asi;	\
34562306a36Sopenharmony_ci	stxa	%i6, [%sp + STACK_BIAS + 0x70] %asi;	\
34662306a36Sopenharmony_ci	stxa	%i7, [%sp + STACK_BIAS + 0x78] %asi;	\
34762306a36Sopenharmony_ci	saved;						\
34862306a36Sopenharmony_ci	sub	%g1, 2, %g1;				\
34962306a36Sopenharmony_ci	ba,pt	%xcc, etrap_save;			\
35062306a36Sopenharmony_ci	 wrpr	%g1, %cwp;				\
35162306a36Sopenharmony_ci	nop; nop; nop; nop; nop;			\
35262306a36Sopenharmony_ci	nop; nop; nop; nop;				\
35362306a36Sopenharmony_ci	ba,a,pt	%xcc, etrap_spill_fixup_64bit;		\
35462306a36Sopenharmony_ci	ba,a,pt	%xcc, etrap_spill_fixup_64bit;		\
35562306a36Sopenharmony_ci	ba,a,pt	%xcc, etrap_spill_fixup_64bit;
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ci#define SPILL_1_GENERIC_ETRAP_FIXUP			\
35862306a36Sopenharmony_cietrap_spill_fixup_64bit:				\
35962306a36Sopenharmony_ci	ldub	[%g6 + TI_WSAVED], %g1;			\
36062306a36Sopenharmony_ci	sll	%g1, 3, %g3;				\
36162306a36Sopenharmony_ci	add	%g6, %g3, %g3;				\
36262306a36Sopenharmony_ci	stx	%sp, [%g3 + TI_RWIN_SPTRS];		\
36362306a36Sopenharmony_ci	sll	%g1, 7, %g3;				\
36462306a36Sopenharmony_ci	add	%g6, %g3, %g3;				\
36562306a36Sopenharmony_ci	stx	%l0, [%g3 + TI_REG_WINDOW + 0x00];	\
36662306a36Sopenharmony_ci	stx	%l1, [%g3 + TI_REG_WINDOW + 0x08];	\
36762306a36Sopenharmony_ci	stx	%l2, [%g3 + TI_REG_WINDOW + 0x10];	\
36862306a36Sopenharmony_ci	stx	%l3, [%g3 + TI_REG_WINDOW + 0x18];	\
36962306a36Sopenharmony_ci	stx	%l4, [%g3 + TI_REG_WINDOW + 0x20];	\
37062306a36Sopenharmony_ci	stx	%l5, [%g3 + TI_REG_WINDOW + 0x28];	\
37162306a36Sopenharmony_ci	stx	%l6, [%g3 + TI_REG_WINDOW + 0x30];	\
37262306a36Sopenharmony_ci	stx	%l7, [%g3 + TI_REG_WINDOW + 0x38];	\
37362306a36Sopenharmony_ci	stx	%i0, [%g3 + TI_REG_WINDOW + 0x40];	\
37462306a36Sopenharmony_ci	stx	%i1, [%g3 + TI_REG_WINDOW + 0x48];	\
37562306a36Sopenharmony_ci	stx	%i2, [%g3 + TI_REG_WINDOW + 0x50];	\
37662306a36Sopenharmony_ci	stx	%i3, [%g3 + TI_REG_WINDOW + 0x58];	\
37762306a36Sopenharmony_ci	stx	%i4, [%g3 + TI_REG_WINDOW + 0x60];	\
37862306a36Sopenharmony_ci	stx	%i5, [%g3 + TI_REG_WINDOW + 0x68];	\
37962306a36Sopenharmony_ci	stx	%i6, [%g3 + TI_REG_WINDOW + 0x70];	\
38062306a36Sopenharmony_ci	stx	%i7, [%g3 + TI_REG_WINDOW + 0x78];	\
38162306a36Sopenharmony_ci	add	%g1, 1, %g1;				\
38262306a36Sopenharmony_ci	stb	%g1, [%g6 + TI_WSAVED];			\
38362306a36Sopenharmony_ci	saved;						\
38462306a36Sopenharmony_ci	rdpr	%cwp, %g1;				\
38562306a36Sopenharmony_ci	sub	%g1, 2, %g1;				\
38662306a36Sopenharmony_ci	ba,pt	%xcc, etrap_save;			\
38762306a36Sopenharmony_ci	 wrpr	%g1, %cwp;				\
38862306a36Sopenharmony_ci	nop; nop; nop
38962306a36Sopenharmony_ci
39062306a36Sopenharmony_ci/* Normal 32bit spill */
39162306a36Sopenharmony_ci#define SPILL_2_GENERIC(ASI)				\
39262306a36Sopenharmony_ci	and	%sp, 1, %g3;				\
39362306a36Sopenharmony_ci	brnz,pn	%g3, (. - (128 + 4));			\
39462306a36Sopenharmony_ci	 srl	%sp, 0, %sp;				\
39562306a36Sopenharmony_ci	stwa	%l0, [%sp + %g0] ASI;			\
39662306a36Sopenharmony_ci	mov	0x04, %g3;				\
39762306a36Sopenharmony_ci	stwa	%l1, [%sp + %g3] ASI;			\
39862306a36Sopenharmony_ci	add	%sp, 0x08, %g1;				\
39962306a36Sopenharmony_ci	stwa	%l2, [%g1 + %g0] ASI;			\
40062306a36Sopenharmony_ci	stwa	%l3, [%g1 + %g3] ASI;			\
40162306a36Sopenharmony_ci	add	%g1, 0x08, %g1;				\
40262306a36Sopenharmony_ci	stwa	%l4, [%g1 + %g0] ASI;			\
40362306a36Sopenharmony_ci	stwa	%l5, [%g1 + %g3] ASI;			\
40462306a36Sopenharmony_ci	add	%g1, 0x08, %g1;				\
40562306a36Sopenharmony_ci	stwa	%l6, [%g1 + %g0] ASI;			\
40662306a36Sopenharmony_ci	stwa	%l7, [%g1 + %g3] ASI;			\
40762306a36Sopenharmony_ci	add	%g1, 0x08, %g1;				\
40862306a36Sopenharmony_ci	stwa	%i0, [%g1 + %g0] ASI;			\
40962306a36Sopenharmony_ci	stwa	%i1, [%g1 + %g3] ASI;			\
41062306a36Sopenharmony_ci	add	%g1, 0x08, %g1;				\
41162306a36Sopenharmony_ci	stwa	%i2, [%g1 + %g0] ASI;			\
41262306a36Sopenharmony_ci	stwa	%i3, [%g1 + %g3] ASI;			\
41362306a36Sopenharmony_ci	add	%g1, 0x08, %g1;				\
41462306a36Sopenharmony_ci	stwa	%i4, [%g1 + %g0] ASI;			\
41562306a36Sopenharmony_ci	stwa	%i5, [%g1 + %g3] ASI;			\
41662306a36Sopenharmony_ci	add	%g1, 0x08, %g1;				\
41762306a36Sopenharmony_ci	stwa	%i6, [%g1 + %g0] ASI;			\
41862306a36Sopenharmony_ci	stwa	%i7, [%g1 + %g3] ASI;			\
41962306a36Sopenharmony_ci	saved;						\
42062306a36Sopenharmony_ci        retry;						\
42162306a36Sopenharmony_ci	b,a,pt	%xcc, spill_fixup_dax;			\
42262306a36Sopenharmony_ci	b,a,pt	%xcc, spill_fixup_mna;			\
42362306a36Sopenharmony_ci	b,a,pt	%xcc, spill_fixup;
42462306a36Sopenharmony_ci
42562306a36Sopenharmony_ci#define SPILL_2_GENERIC_ETRAP		\
42662306a36Sopenharmony_cietrap_user_spill_32bit:			\
42762306a36Sopenharmony_ci	and	%sp, 1, %g3;		\
42862306a36Sopenharmony_ci	brnz,pn	%g3, etrap_user_spill_64bit;	\
42962306a36Sopenharmony_ci	 srl	%sp, 0, %sp;		\
43062306a36Sopenharmony_ci	stwa	%l0, [%sp + 0x00] %asi;	\
43162306a36Sopenharmony_ci	stwa	%l1, [%sp + 0x04] %asi;	\
43262306a36Sopenharmony_ci	stwa	%l2, [%sp + 0x08] %asi;	\
43362306a36Sopenharmony_ci	stwa	%l3, [%sp + 0x0c] %asi;	\
43462306a36Sopenharmony_ci	stwa	%l4, [%sp + 0x10] %asi;	\
43562306a36Sopenharmony_ci	stwa	%l5, [%sp + 0x14] %asi;	\
43662306a36Sopenharmony_ci	stwa	%l6, [%sp + 0x18] %asi;	\
43762306a36Sopenharmony_ci	stwa	%l7, [%sp + 0x1c] %asi;	\
43862306a36Sopenharmony_ci	stwa	%i0, [%sp + 0x20] %asi;	\
43962306a36Sopenharmony_ci	stwa	%i1, [%sp + 0x24] %asi;	\
44062306a36Sopenharmony_ci	stwa	%i2, [%sp + 0x28] %asi;	\
44162306a36Sopenharmony_ci	stwa	%i3, [%sp + 0x2c] %asi;	\
44262306a36Sopenharmony_ci	stwa	%i4, [%sp + 0x30] %asi;	\
44362306a36Sopenharmony_ci	stwa	%i5, [%sp + 0x34] %asi;	\
44462306a36Sopenharmony_ci	stwa	%i6, [%sp + 0x38] %asi;	\
44562306a36Sopenharmony_ci	stwa	%i7, [%sp + 0x3c] %asi;	\
44662306a36Sopenharmony_ci	saved;				\
44762306a36Sopenharmony_ci	sub	%g1, 2, %g1;		\
44862306a36Sopenharmony_ci	ba,pt	%xcc, etrap_save;	\
44962306a36Sopenharmony_ci	 wrpr	%g1, %cwp;		\
45062306a36Sopenharmony_ci	nop; nop; nop; nop;		\
45162306a36Sopenharmony_ci	nop; nop;			\
45262306a36Sopenharmony_ci	ba,a,pt	%xcc, etrap_spill_fixup_32bit; \
45362306a36Sopenharmony_ci	ba,a,pt	%xcc, etrap_spill_fixup_32bit; \
45462306a36Sopenharmony_ci	ba,a,pt	%xcc, etrap_spill_fixup_32bit;
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_ci#define SPILL_2_GENERIC_ETRAP_FIXUP			\
45762306a36Sopenharmony_cietrap_spill_fixup_32bit:				\
45862306a36Sopenharmony_ci	ldub	[%g6 + TI_WSAVED], %g1;			\
45962306a36Sopenharmony_ci	sll	%g1, 3, %g3;				\
46062306a36Sopenharmony_ci	add	%g6, %g3, %g3;				\
46162306a36Sopenharmony_ci	stx	%sp, [%g3 + TI_RWIN_SPTRS];		\
46262306a36Sopenharmony_ci	sll	%g1, 7, %g3;				\
46362306a36Sopenharmony_ci	add	%g6, %g3, %g3;				\
46462306a36Sopenharmony_ci	stw	%l0, [%g3 + TI_REG_WINDOW + 0x00];	\
46562306a36Sopenharmony_ci	stw	%l1, [%g3 + TI_REG_WINDOW + 0x04];	\
46662306a36Sopenharmony_ci	stw	%l2, [%g3 + TI_REG_WINDOW + 0x08];	\
46762306a36Sopenharmony_ci	stw	%l3, [%g3 + TI_REG_WINDOW + 0x0c];	\
46862306a36Sopenharmony_ci	stw	%l4, [%g3 + TI_REG_WINDOW + 0x10];	\
46962306a36Sopenharmony_ci	stw	%l5, [%g3 + TI_REG_WINDOW + 0x14];	\
47062306a36Sopenharmony_ci	stw	%l6, [%g3 + TI_REG_WINDOW + 0x18];	\
47162306a36Sopenharmony_ci	stw	%l7, [%g3 + TI_REG_WINDOW + 0x1c];	\
47262306a36Sopenharmony_ci	stw	%i0, [%g3 + TI_REG_WINDOW + 0x20];	\
47362306a36Sopenharmony_ci	stw	%i1, [%g3 + TI_REG_WINDOW + 0x24];	\
47462306a36Sopenharmony_ci	stw	%i2, [%g3 + TI_REG_WINDOW + 0x28];	\
47562306a36Sopenharmony_ci	stw	%i3, [%g3 + TI_REG_WINDOW + 0x2c];	\
47662306a36Sopenharmony_ci	stw	%i4, [%g3 + TI_REG_WINDOW + 0x30];	\
47762306a36Sopenharmony_ci	stw	%i5, [%g3 + TI_REG_WINDOW + 0x34];	\
47862306a36Sopenharmony_ci	stw	%i6, [%g3 + TI_REG_WINDOW + 0x38];	\
47962306a36Sopenharmony_ci	stw	%i7, [%g3 + TI_REG_WINDOW + 0x3c];	\
48062306a36Sopenharmony_ci	add	%g1, 1, %g1;				\
48162306a36Sopenharmony_ci	stb	%g1, [%g6 + TI_WSAVED];			\
48262306a36Sopenharmony_ci	saved;						\
48362306a36Sopenharmony_ci	rdpr	%cwp, %g1;				\
48462306a36Sopenharmony_ci	sub	%g1, 2, %g1;				\
48562306a36Sopenharmony_ci	ba,pt	%xcc, etrap_save;			\
48662306a36Sopenharmony_ci	 wrpr	%g1, %cwp;				\
48762306a36Sopenharmony_ci	nop; nop; nop
48862306a36Sopenharmony_ci
48962306a36Sopenharmony_ci#define SPILL_1_NORMAL SPILL_1_GENERIC(ASI_AIUP)
49062306a36Sopenharmony_ci#define SPILL_2_NORMAL SPILL_2_GENERIC(ASI_AIUP)
49162306a36Sopenharmony_ci#define SPILL_3_NORMAL SPILL_0_NORMAL
49262306a36Sopenharmony_ci#define SPILL_4_NORMAL SPILL_0_NORMAL
49362306a36Sopenharmony_ci#define SPILL_5_NORMAL SPILL_0_NORMAL
49462306a36Sopenharmony_ci#define SPILL_6_NORMAL SPILL_0_NORMAL
49562306a36Sopenharmony_ci#define SPILL_7_NORMAL SPILL_0_NORMAL
49662306a36Sopenharmony_ci
49762306a36Sopenharmony_ci#define SPILL_0_OTHER SPILL_0_NORMAL
49862306a36Sopenharmony_ci#define SPILL_1_OTHER SPILL_1_GENERIC(ASI_AIUS)
49962306a36Sopenharmony_ci#define SPILL_2_OTHER SPILL_2_GENERIC(ASI_AIUS)
50062306a36Sopenharmony_ci#define SPILL_3_OTHER SPILL_3_NORMAL
50162306a36Sopenharmony_ci#define SPILL_4_OTHER SPILL_4_NORMAL
50262306a36Sopenharmony_ci#define SPILL_5_OTHER SPILL_5_NORMAL
50362306a36Sopenharmony_ci#define SPILL_6_OTHER SPILL_6_NORMAL
50462306a36Sopenharmony_ci#define SPILL_7_OTHER SPILL_7_NORMAL
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_ci/* Normal kernel fill */
50762306a36Sopenharmony_ci#define FILL_0_NORMAL					\
50862306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x00], %l0;		\
50962306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x08], %l1;		\
51062306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x10], %l2;		\
51162306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x18], %l3;		\
51262306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x20], %l4;		\
51362306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x28], %l5;		\
51462306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x30], %l6;		\
51562306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x38], %l7;		\
51662306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x40], %i0;		\
51762306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x48], %i1;		\
51862306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x50], %i2;		\
51962306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x58], %i3;		\
52062306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x60], %i4;		\
52162306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x68], %i5;		\
52262306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x70], %i6;		\
52362306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x78], %i7;		\
52462306a36Sopenharmony_ci	restored; retry; nop; nop; nop; nop; nop; nop;	\
52562306a36Sopenharmony_ci	nop; nop; nop; nop; nop; nop; nop; nop;
52662306a36Sopenharmony_ci
52762306a36Sopenharmony_ci#define FILL_0_NORMAL_RTRAP				\
52862306a36Sopenharmony_cikern_rtt_fill:						\
52962306a36Sopenharmony_ci	rdpr	%cwp, %g1;				\
53062306a36Sopenharmony_ci	sub	%g1, 1, %g1;				\
53162306a36Sopenharmony_ci	wrpr	%g1, %cwp;				\
53262306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x00], %l0;		\
53362306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x08], %l1;		\
53462306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x10], %l2;		\
53562306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x18], %l3;		\
53662306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x20], %l4;		\
53762306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x28], %l5;		\
53862306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x30], %l6;		\
53962306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x38], %l7;		\
54062306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x40], %i0;		\
54162306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x48], %i1;		\
54262306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x50], %i2;		\
54362306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x58], %i3;		\
54462306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x60], %i4;		\
54562306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x68], %i5;		\
54662306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x70], %i6;		\
54762306a36Sopenharmony_ci	ldx	[%sp + STACK_BIAS + 0x78], %i7;		\
54862306a36Sopenharmony_ci	restored;					\
54962306a36Sopenharmony_ci	add	%g1, 1, %g1;				\
55062306a36Sopenharmony_ci	ba,pt	%xcc, kern_rtt_restore;			\
55162306a36Sopenharmony_ci	 wrpr	%g1, %cwp;				\
55262306a36Sopenharmony_ci	nop; nop; nop; nop; nop;			\
55362306a36Sopenharmony_ci	nop; nop; nop; nop;
55462306a36Sopenharmony_ci
55562306a36Sopenharmony_ci
55662306a36Sopenharmony_ci/* Normal 64bit fill */
55762306a36Sopenharmony_ci#define FILL_1_GENERIC(ASI)				\
55862306a36Sopenharmony_ci	add	%sp, STACK_BIAS + 0x00, %g1;		\
55962306a36Sopenharmony_ci	ldxa	[%g1 + %g0] ASI, %l0;			\
56062306a36Sopenharmony_ci	mov	0x08, %g2;				\
56162306a36Sopenharmony_ci	mov	0x10, %g3;				\
56262306a36Sopenharmony_ci	ldxa	[%g1 + %g2] ASI, %l1;			\
56362306a36Sopenharmony_ci	mov	0x18, %g5;				\
56462306a36Sopenharmony_ci	ldxa	[%g1 + %g3] ASI, %l2;			\
56562306a36Sopenharmony_ci	ldxa	[%g1 + %g5] ASI, %l3;			\
56662306a36Sopenharmony_ci	add	%g1, 0x20, %g1;				\
56762306a36Sopenharmony_ci	ldxa	[%g1 + %g0] ASI, %l4;			\
56862306a36Sopenharmony_ci	ldxa	[%g1 + %g2] ASI, %l5;			\
56962306a36Sopenharmony_ci	ldxa	[%g1 + %g3] ASI, %l6;			\
57062306a36Sopenharmony_ci	ldxa	[%g1 + %g5] ASI, %l7;			\
57162306a36Sopenharmony_ci	add	%g1, 0x20, %g1;				\
57262306a36Sopenharmony_ci	ldxa	[%g1 + %g0] ASI, %i0;			\
57362306a36Sopenharmony_ci	ldxa	[%g1 + %g2] ASI, %i1;			\
57462306a36Sopenharmony_ci	ldxa	[%g1 + %g3] ASI, %i2;			\
57562306a36Sopenharmony_ci	ldxa	[%g1 + %g5] ASI, %i3;			\
57662306a36Sopenharmony_ci	add	%g1, 0x20, %g1;				\
57762306a36Sopenharmony_ci	ldxa	[%g1 + %g0] ASI, %i4;			\
57862306a36Sopenharmony_ci	ldxa	[%g1 + %g2] ASI, %i5;			\
57962306a36Sopenharmony_ci	ldxa	[%g1 + %g3] ASI, %i6;			\
58062306a36Sopenharmony_ci	ldxa	[%g1 + %g5] ASI, %i7;			\
58162306a36Sopenharmony_ci	restored;					\
58262306a36Sopenharmony_ci	retry; nop; nop; nop; nop;			\
58362306a36Sopenharmony_ci	b,a,pt	%xcc, fill_fixup_dax;			\
58462306a36Sopenharmony_ci	b,a,pt	%xcc, fill_fixup_mna;			\
58562306a36Sopenharmony_ci	b,a,pt	%xcc, fill_fixup;
58662306a36Sopenharmony_ci
58762306a36Sopenharmony_ci#define FILL_1_GENERIC_RTRAP				\
58862306a36Sopenharmony_ciuser_rtt_fill_64bit:					\
58962306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x00] %asi, %l0;	\
59062306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x08] %asi, %l1;	\
59162306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x10] %asi, %l2;	\
59262306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x18] %asi, %l3;	\
59362306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x20] %asi, %l4;	\
59462306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x28] %asi, %l5;	\
59562306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x30] %asi, %l6;	\
59662306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x38] %asi, %l7;	\
59762306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x40] %asi, %i0;	\
59862306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x48] %asi, %i1;	\
59962306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x50] %asi, %i2;	\
60062306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x58] %asi, %i3;	\
60162306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x60] %asi, %i4;	\
60262306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x68] %asi, %i5;	\
60362306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x70] %asi, %i6;	\
60462306a36Sopenharmony_ci	ldxa	[%sp + STACK_BIAS + 0x78] %asi, %i7;	\
60562306a36Sopenharmony_ci	ba,pt	%xcc, user_rtt_pre_restore;		\
60662306a36Sopenharmony_ci	 restored;					\
60762306a36Sopenharmony_ci	nop; nop; nop; nop; nop; nop;			\
60862306a36Sopenharmony_ci	nop; nop; nop; nop; nop;			\
60962306a36Sopenharmony_ci	ba,a,pt	%xcc, user_rtt_fill_fixup_dax;		\
61062306a36Sopenharmony_ci	ba,a,pt	%xcc, user_rtt_fill_fixup_mna;		\
61162306a36Sopenharmony_ci	ba,a,pt	%xcc, user_rtt_fill_fixup;
61262306a36Sopenharmony_ci
61362306a36Sopenharmony_ci
61462306a36Sopenharmony_ci/* Normal 32bit fill */
61562306a36Sopenharmony_ci#define FILL_2_GENERIC(ASI)				\
61662306a36Sopenharmony_ci	and	%sp, 1, %g3;				\
61762306a36Sopenharmony_ci	brnz,pn	%g3, (. - (128 + 4));			\
61862306a36Sopenharmony_ci	 srl	%sp, 0, %sp;				\
61962306a36Sopenharmony_ci	lduwa	[%sp + %g0] ASI, %l0;			\
62062306a36Sopenharmony_ci	mov	0x04, %g2;				\
62162306a36Sopenharmony_ci	mov	0x08, %g3;				\
62262306a36Sopenharmony_ci	lduwa	[%sp + %g2] ASI, %l1;			\
62362306a36Sopenharmony_ci	mov	0x0c, %g5;				\
62462306a36Sopenharmony_ci	lduwa	[%sp + %g3] ASI, %l2;			\
62562306a36Sopenharmony_ci	lduwa	[%sp + %g5] ASI, %l3;			\
62662306a36Sopenharmony_ci	add	%sp, 0x10, %g1;				\
62762306a36Sopenharmony_ci	lduwa	[%g1 + %g0] ASI, %l4;			\
62862306a36Sopenharmony_ci	lduwa	[%g1 + %g2] ASI, %l5;			\
62962306a36Sopenharmony_ci	lduwa	[%g1 + %g3] ASI, %l6;			\
63062306a36Sopenharmony_ci	lduwa	[%g1 + %g5] ASI, %l7;			\
63162306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
63262306a36Sopenharmony_ci	lduwa	[%g1 + %g0] ASI, %i0;			\
63362306a36Sopenharmony_ci	lduwa	[%g1 + %g2] ASI, %i1;			\
63462306a36Sopenharmony_ci	lduwa	[%g1 + %g3] ASI, %i2;			\
63562306a36Sopenharmony_ci	lduwa	[%g1 + %g5] ASI, %i3;			\
63662306a36Sopenharmony_ci	add	%g1, 0x10, %g1;				\
63762306a36Sopenharmony_ci	lduwa	[%g1 + %g0] ASI, %i4;			\
63862306a36Sopenharmony_ci	lduwa	[%g1 + %g2] ASI, %i5;			\
63962306a36Sopenharmony_ci	lduwa	[%g1 + %g3] ASI, %i6;			\
64062306a36Sopenharmony_ci	lduwa	[%g1 + %g5] ASI, %i7;			\
64162306a36Sopenharmony_ci	restored;					\
64262306a36Sopenharmony_ci	retry; nop; nop;				\
64362306a36Sopenharmony_ci	b,a,pt	%xcc, fill_fixup_dax;			\
64462306a36Sopenharmony_ci	b,a,pt	%xcc, fill_fixup_mna;			\
64562306a36Sopenharmony_ci	b,a,pt	%xcc, fill_fixup;
64662306a36Sopenharmony_ci
64762306a36Sopenharmony_ci#define FILL_2_GENERIC_RTRAP				\
64862306a36Sopenharmony_ciuser_rtt_fill_32bit:					\
64962306a36Sopenharmony_ci	and	%sp, 1, %g3;				\
65062306a36Sopenharmony_ci	brnz,pn	%g3, user_rtt_fill_64bit;		\
65162306a36Sopenharmony_ci	 srl	%sp, 0, %sp;				\
65262306a36Sopenharmony_ci	lduwa	[%sp + 0x00] %asi, %l0;			\
65362306a36Sopenharmony_ci	lduwa	[%sp + 0x04] %asi, %l1;			\
65462306a36Sopenharmony_ci	lduwa	[%sp + 0x08] %asi, %l2;			\
65562306a36Sopenharmony_ci	lduwa	[%sp + 0x0c] %asi, %l3;			\
65662306a36Sopenharmony_ci	lduwa	[%sp + 0x10] %asi, %l4;			\
65762306a36Sopenharmony_ci	lduwa	[%sp + 0x14] %asi, %l5;			\
65862306a36Sopenharmony_ci	lduwa	[%sp + 0x18] %asi, %l6;			\
65962306a36Sopenharmony_ci	lduwa	[%sp + 0x1c] %asi, %l7;			\
66062306a36Sopenharmony_ci	lduwa	[%sp + 0x20] %asi, %i0;			\
66162306a36Sopenharmony_ci	lduwa	[%sp + 0x24] %asi, %i1;			\
66262306a36Sopenharmony_ci	lduwa	[%sp + 0x28] %asi, %i2;			\
66362306a36Sopenharmony_ci	lduwa	[%sp + 0x2c] %asi, %i3;			\
66462306a36Sopenharmony_ci	lduwa	[%sp + 0x30] %asi, %i4;			\
66562306a36Sopenharmony_ci	lduwa	[%sp + 0x34] %asi, %i5;			\
66662306a36Sopenharmony_ci	lduwa	[%sp + 0x38] %asi, %i6;			\
66762306a36Sopenharmony_ci	lduwa	[%sp + 0x3c] %asi, %i7;			\
66862306a36Sopenharmony_ci	ba,pt	%xcc, user_rtt_pre_restore;		\
66962306a36Sopenharmony_ci	 restored;					\
67062306a36Sopenharmony_ci	nop; nop; nop; nop; nop;			\
67162306a36Sopenharmony_ci	nop; nop; nop;					\
67262306a36Sopenharmony_ci	ba,a,pt	%xcc, user_rtt_fill_fixup_dax;		\
67362306a36Sopenharmony_ci	ba,a,pt	%xcc, user_rtt_fill_fixup_mna;		\
67462306a36Sopenharmony_ci	ba,a,pt	%xcc, user_rtt_fill_fixup;
67562306a36Sopenharmony_ci
67662306a36Sopenharmony_ci
67762306a36Sopenharmony_ci#define FILL_1_NORMAL FILL_1_GENERIC(ASI_AIUP)
67862306a36Sopenharmony_ci#define FILL_2_NORMAL FILL_2_GENERIC(ASI_AIUP)
67962306a36Sopenharmony_ci#define FILL_3_NORMAL FILL_0_NORMAL
68062306a36Sopenharmony_ci#define FILL_4_NORMAL FILL_0_NORMAL
68162306a36Sopenharmony_ci#define FILL_5_NORMAL FILL_0_NORMAL
68262306a36Sopenharmony_ci#define FILL_6_NORMAL FILL_0_NORMAL
68362306a36Sopenharmony_ci#define FILL_7_NORMAL FILL_0_NORMAL
68462306a36Sopenharmony_ci
68562306a36Sopenharmony_ci#define FILL_0_OTHER FILL_0_NORMAL
68662306a36Sopenharmony_ci#define FILL_1_OTHER FILL_1_GENERIC(ASI_AIUS)
68762306a36Sopenharmony_ci#define FILL_2_OTHER FILL_2_GENERIC(ASI_AIUS)
68862306a36Sopenharmony_ci#define FILL_3_OTHER FILL_3_NORMAL
68962306a36Sopenharmony_ci#define FILL_4_OTHER FILL_4_NORMAL
69062306a36Sopenharmony_ci#define FILL_5_OTHER FILL_5_NORMAL
69162306a36Sopenharmony_ci#define FILL_6_OTHER FILL_6_NORMAL
69262306a36Sopenharmony_ci#define FILL_7_OTHER FILL_7_NORMAL
69362306a36Sopenharmony_ci
69462306a36Sopenharmony_ci#endif /* !(_SPARC64_TTABLE_H) */
695