xref: /OK3568_Linux_fs/kernel/arch/sparc/include/uapi/asm/traps.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * traps.h:  Format of entries for the Sparc trap table.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
6*4882a593Smuzhiyun  */
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #ifndef _UAPI_SPARC_TRAPS_H
9*4882a593Smuzhiyun #define _UAPI_SPARC_TRAPS_H
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #define NUM_SPARC_TRAPS  255
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #ifndef __ASSEMBLY__
14*4882a593Smuzhiyun #endif /* !(__ASSEMBLY__) */
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun /* For patching the trap table at boot time, we need to know how to
17*4882a593Smuzhiyun  * form various common Sparc instructions.  Thus these macros...
18*4882a593Smuzhiyun  */
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun #define SPARC_MOV_CONST_L3(const) (0xa6102000 | (const&0xfff))
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun /* The following assumes that the branch lies before the place we
23*4882a593Smuzhiyun  * are branching to.  This is the case for a trap vector...
24*4882a593Smuzhiyun  * You have been warned.
25*4882a593Smuzhiyun  */
26*4882a593Smuzhiyun #define SPARC_BRANCH(dest_addr, inst_addr) \
27*4882a593Smuzhiyun           (0x10800000 | (((dest_addr-inst_addr)>>2)&0x3fffff))
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #define SPARC_RD_PSR_L0  (0xa1480000)
30*4882a593Smuzhiyun #define SPARC_RD_WIM_L3  (0xa7500000)
31*4882a593Smuzhiyun #define SPARC_NOP (0x01000000)
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /* Various interesting trap levels. */
34*4882a593Smuzhiyun /* First, hardware traps. */
35*4882a593Smuzhiyun #define SP_TRAP_TFLT    0x1          /* Text fault */
36*4882a593Smuzhiyun #define SP_TRAP_II      0x2          /* Illegal Instruction */
37*4882a593Smuzhiyun #define SP_TRAP_PI      0x3          /* Privileged Instruction */
38*4882a593Smuzhiyun #define SP_TRAP_FPD     0x4          /* Floating Point Disabled */
39*4882a593Smuzhiyun #define SP_TRAP_WOVF    0x5          /* Window Overflow */
40*4882a593Smuzhiyun #define SP_TRAP_WUNF    0x6          /* Window Underflow */
41*4882a593Smuzhiyun #define SP_TRAP_MNA     0x7          /* Memory Address Unaligned */
42*4882a593Smuzhiyun #define SP_TRAP_FPE     0x8          /* Floating Point Exception */
43*4882a593Smuzhiyun #define SP_TRAP_DFLT    0x9          /* Data Fault */
44*4882a593Smuzhiyun #define SP_TRAP_TOF     0xa          /* Tag Overflow */
45*4882a593Smuzhiyun #define SP_TRAP_WDOG    0xb          /* Watchpoint Detected */
46*4882a593Smuzhiyun #define SP_TRAP_IRQ1    0x11         /* IRQ level 1 */
47*4882a593Smuzhiyun #define SP_TRAP_IRQ2    0x12         /* IRQ level 2 */
48*4882a593Smuzhiyun #define SP_TRAP_IRQ3    0x13         /* IRQ level 3 */
49*4882a593Smuzhiyun #define SP_TRAP_IRQ4    0x14         /* IRQ level 4 */
50*4882a593Smuzhiyun #define SP_TRAP_IRQ5    0x15         /* IRQ level 5 */
51*4882a593Smuzhiyun #define SP_TRAP_IRQ6    0x16         /* IRQ level 6 */
52*4882a593Smuzhiyun #define SP_TRAP_IRQ7    0x17         /* IRQ level 7 */
53*4882a593Smuzhiyun #define SP_TRAP_IRQ8    0x18         /* IRQ level 8 */
54*4882a593Smuzhiyun #define SP_TRAP_IRQ9    0x19         /* IRQ level 9 */
55*4882a593Smuzhiyun #define SP_TRAP_IRQ10   0x1a         /* IRQ level 10 */
56*4882a593Smuzhiyun #define SP_TRAP_IRQ11   0x1b         /* IRQ level 11 */
57*4882a593Smuzhiyun #define SP_TRAP_IRQ12   0x1c         /* IRQ level 12 */
58*4882a593Smuzhiyun #define SP_TRAP_IRQ13   0x1d         /* IRQ level 13 */
59*4882a593Smuzhiyun #define SP_TRAP_IRQ14   0x1e         /* IRQ level 14 */
60*4882a593Smuzhiyun #define SP_TRAP_IRQ15   0x1f         /* IRQ level 15 Non-maskable */
61*4882a593Smuzhiyun #define SP_TRAP_RACC    0x20         /* Register Access Error ??? */
62*4882a593Smuzhiyun #define SP_TRAP_IACC    0x21         /* Instruction Access Error */
63*4882a593Smuzhiyun #define SP_TRAP_CPDIS   0x24         /* Co-Processor Disabled */
64*4882a593Smuzhiyun #define SP_TRAP_BADFL   0x25         /* Unimplemented Flush Instruction */
65*4882a593Smuzhiyun #define SP_TRAP_CPEXP   0x28         /* Co-Processor Exception */
66*4882a593Smuzhiyun #define SP_TRAP_DACC    0x29         /* Data Access Error */
67*4882a593Smuzhiyun #define SP_TRAP_DIVZ    0x2a         /* Divide By Zero */
68*4882a593Smuzhiyun #define SP_TRAP_DSTORE  0x2b         /* Data Store Error ??? */
69*4882a593Smuzhiyun #define SP_TRAP_DMM     0x2c         /* Data Access MMU Miss ??? */
70*4882a593Smuzhiyun #define SP_TRAP_IMM     0x3c         /* Instruction Access MMU Miss ??? */
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun /* Now the Software Traps... */
73*4882a593Smuzhiyun #define SP_TRAP_SUNOS   0x80         /* SunOS System Call */
74*4882a593Smuzhiyun #define SP_TRAP_SBPT    0x81         /* Software Breakpoint */
75*4882a593Smuzhiyun #define SP_TRAP_SDIVZ   0x82         /* Software Divide-by-Zero trap */
76*4882a593Smuzhiyun #define SP_TRAP_FWIN    0x83         /* Flush Windows */
77*4882a593Smuzhiyun #define SP_TRAP_CWIN    0x84         /* Clean Windows */
78*4882a593Smuzhiyun #define SP_TRAP_RCHK    0x85         /* Range Check */
79*4882a593Smuzhiyun #define SP_TRAP_FUNA    0x86         /* Fix Unaligned Access */
80*4882a593Smuzhiyun #define SP_TRAP_IOWFL   0x87         /* Integer Overflow */
81*4882a593Smuzhiyun #define SP_TRAP_SOLARIS 0x88         /* Solaris System Call */
82*4882a593Smuzhiyun #define SP_TRAP_NETBSD  0x89         /* NetBSD System Call */
83*4882a593Smuzhiyun #define SP_TRAP_LINUX   0x90         /* Linux System Call */
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun /* Names used for compatibility with SunOS */
86*4882a593Smuzhiyun #define ST_SYSCALL              0x00
87*4882a593Smuzhiyun #define ST_BREAKPOINT           0x01
88*4882a593Smuzhiyun #define ST_DIV0                 0x02
89*4882a593Smuzhiyun #define ST_FLUSH_WINDOWS        0x03
90*4882a593Smuzhiyun #define ST_CLEAN_WINDOWS        0x04
91*4882a593Smuzhiyun #define ST_RANGE_CHECK          0x05
92*4882a593Smuzhiyun #define ST_FIX_ALIGN            0x06
93*4882a593Smuzhiyun #define ST_INT_OVERFLOW         0x07
94*4882a593Smuzhiyun 
95*4882a593Smuzhiyun /* Special traps... */
96*4882a593Smuzhiyun #define SP_TRAP_KBPT1   0xfe         /* KADB/PROM Breakpoint one */
97*4882a593Smuzhiyun #define SP_TRAP_KBPT2   0xff         /* KADB/PROM Breakpoint two */
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun /* Handy Macros */
100*4882a593Smuzhiyun /* Is this a trap we never expect to get? */
101*4882a593Smuzhiyun #define BAD_TRAP_P(level) \
102*4882a593Smuzhiyun         ((level > SP_TRAP_WDOG && level < SP_TRAP_IRQ1) || \
103*4882a593Smuzhiyun 	 (level > SP_TRAP_IACC && level < SP_TRAP_CPDIS) || \
104*4882a593Smuzhiyun 	 (level > SP_TRAP_BADFL && level < SP_TRAP_CPEXP) || \
105*4882a593Smuzhiyun 	 (level > SP_TRAP_DMM && level < SP_TRAP_IMM) || \
106*4882a593Smuzhiyun 	 (level > SP_TRAP_IMM && level < SP_TRAP_SUNOS) || \
107*4882a593Smuzhiyun 	 (level > SP_TRAP_LINUX && level < SP_TRAP_KBPT1))
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun /* Is this a Hardware trap? */
110*4882a593Smuzhiyun #define HW_TRAP_P(level) ((level > 0) && (level < SP_TRAP_SUNOS))
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun /* Is this a Software trap? */
113*4882a593Smuzhiyun #define SW_TRAP_P(level) ((level >= SP_TRAP_SUNOS) && (level <= SP_TRAP_KBPT2))
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun /* Is this a system call for some OS we know about? */
116*4882a593Smuzhiyun #define SCALL_TRAP_P(level) ((level == SP_TRAP_SUNOS) || \
117*4882a593Smuzhiyun 			     (level == SP_TRAP_SOLARIS) || \
118*4882a593Smuzhiyun 			     (level == SP_TRAP_NETBSD) || \
119*4882a593Smuzhiyun 			     (level == SP_TRAP_LINUX))
120*4882a593Smuzhiyun 
121*4882a593Smuzhiyun #endif /* _UAPI_SPARC_TRAPS_H */
122