xref: /OK3568_Linux_fs/kernel/arch/sparc/include/asm/head_32.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __SPARC_HEAD_H
3*4882a593Smuzhiyun #define __SPARC_HEAD_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #define KERNBASE        0xf0000000  /* First address the kernel will eventually be */
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #define WRITE_PAUSE      nop; nop; nop; /* Have to do this after %wim/%psr chg */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /* Here are some trap goodies */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun /* Generic trap entry. */
12*4882a593Smuzhiyun #define TRAP_ENTRY(type, label) \
13*4882a593Smuzhiyun 	rd %psr, %l0; b label; rd %wim, %l3; nop;
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun /* Data/text faults */
16*4882a593Smuzhiyun #define SRMMU_TFAULT rd %psr, %l0; rd %wim, %l3; b srmmu_fault; mov 1, %l7;
17*4882a593Smuzhiyun #define SRMMU_DFAULT rd %psr, %l0; rd %wim, %l3; b srmmu_fault; mov 0, %l7;
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun /* This is for traps we should NEVER get. */
20*4882a593Smuzhiyun #define BAD_TRAP(num) \
21*4882a593Smuzhiyun         rd %psr, %l0; mov num, %l7; b bad_trap_handler; rd %wim, %l3;
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /* This is for traps when we want just skip the instruction which caused it */
24*4882a593Smuzhiyun #define SKIP_TRAP(type, name) \
25*4882a593Smuzhiyun 	jmpl %l2, %g0; rett %l2 + 4; nop; nop;
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /* Notice that for the system calls we pull a trick.  We load up a
28*4882a593Smuzhiyun  * different pointer to the system call vector table in %l7, but call
29*4882a593Smuzhiyun  * the same generic system call low-level entry point.  The trap table
30*4882a593Smuzhiyun  * entry sequences are also HyperSparc pipeline friendly ;-)
31*4882a593Smuzhiyun  */
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /* Software trap for Linux system calls. */
34*4882a593Smuzhiyun #define LINUX_SYSCALL_TRAP \
35*4882a593Smuzhiyun         sethi %hi(sys_call_table), %l7; \
36*4882a593Smuzhiyun         or %l7, %lo(sys_call_table), %l7; \
37*4882a593Smuzhiyun         b linux_sparc_syscall; \
38*4882a593Smuzhiyun         rd %psr, %l0;
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun #define BREAKPOINT_TRAP \
41*4882a593Smuzhiyun 	b breakpoint_trap; \
42*4882a593Smuzhiyun 	rd %psr,%l0; \
43*4882a593Smuzhiyun 	nop; \
44*4882a593Smuzhiyun 	nop;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #ifdef CONFIG_KGDB
47*4882a593Smuzhiyun #define KGDB_TRAP(num)                  \
48*4882a593Smuzhiyun 	mov num, %l7;                   \
49*4882a593Smuzhiyun 	b kgdb_trap_low;                \
50*4882a593Smuzhiyun 	rd %psr,%l0;                    \
51*4882a593Smuzhiyun 	nop;
52*4882a593Smuzhiyun #else
53*4882a593Smuzhiyun #define KGDB_TRAP(num) \
54*4882a593Smuzhiyun 	BAD_TRAP(num)
55*4882a593Smuzhiyun #endif
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun /* The Get Condition Codes software trap for userland. */
58*4882a593Smuzhiyun #define GETCC_TRAP \
59*4882a593Smuzhiyun         b getcc_trap_handler; rd %psr, %l0; nop; nop;
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /* The Set Condition Codes software trap for userland. */
62*4882a593Smuzhiyun #define SETCC_TRAP \
63*4882a593Smuzhiyun         b setcc_trap_handler; rd %psr, %l0; nop; nop;
64*4882a593Smuzhiyun 
65*4882a593Smuzhiyun /* The Get PSR software trap for userland. */
66*4882a593Smuzhiyun #define GETPSR_TRAP \
67*4882a593Smuzhiyun 	rd %psr, %i0; jmp %l2; rett %l2 + 4; nop;
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun /* This is for hard interrupts from level 1-14, 15 is non-maskable (nmi) and
70*4882a593Smuzhiyun  * gets handled with another macro.
71*4882a593Smuzhiyun  */
72*4882a593Smuzhiyun #define TRAP_ENTRY_INTERRUPT(int_level) \
73*4882a593Smuzhiyun         mov int_level, %l7; rd %psr, %l0; b real_irq_entry; rd %wim, %l3;
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun /* Window overflows/underflows are special and we need to try to be as
76*4882a593Smuzhiyun  * efficient as possible here....
77*4882a593Smuzhiyun  */
78*4882a593Smuzhiyun #define WINDOW_SPILL \
79*4882a593Smuzhiyun         rd %psr, %l0; rd %wim, %l3; b spill_window_entry; andcc %l0, PSR_PS, %g0;
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun #define WINDOW_FILL \
82*4882a593Smuzhiyun         rd %psr, %l0; rd %wim, %l3; b fill_window_entry; andcc %l0, PSR_PS, %g0;
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun #endif /* __SPARC_HEAD_H */
85