1*6f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 254579826SDavid Howells /* 354579826SDavid Howells * traps.h: Format of entries for the Sparc trap table. 454579826SDavid Howells * 554579826SDavid Howells * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 654579826SDavid Howells */ 754579826SDavid Howells 854579826SDavid Howells #ifndef _UAPI_SPARC_TRAPS_H 954579826SDavid Howells #define _UAPI_SPARC_TRAPS_H 1054579826SDavid Howells 1154579826SDavid Howells #define NUM_SPARC_TRAPS 255 1254579826SDavid Howells 1354579826SDavid Howells #ifndef __ASSEMBLY__ 1454579826SDavid Howells #endif /* !(__ASSEMBLY__) */ 1554579826SDavid Howells 1654579826SDavid Howells /* For patching the trap table at boot time, we need to know how to 1754579826SDavid Howells * form various common Sparc instructions. Thus these macros... 1854579826SDavid Howells */ 1954579826SDavid Howells 2054579826SDavid Howells #define SPARC_MOV_CONST_L3(const) (0xa6102000 | (const&0xfff)) 2154579826SDavid Howells 2254579826SDavid Howells /* The following assumes that the branch lies before the place we 2354579826SDavid Howells * are branching to. This is the case for a trap vector... 2454579826SDavid Howells * You have been warned. 2554579826SDavid Howells */ 2654579826SDavid Howells #define SPARC_BRANCH(dest_addr, inst_addr) \ 2754579826SDavid Howells (0x10800000 | (((dest_addr-inst_addr)>>2)&0x3fffff)) 2854579826SDavid Howells 2954579826SDavid Howells #define SPARC_RD_PSR_L0 (0xa1480000) 3054579826SDavid Howells #define SPARC_RD_WIM_L3 (0xa7500000) 3154579826SDavid Howells #define SPARC_NOP (0x01000000) 3254579826SDavid Howells 3354579826SDavid Howells /* Various interesting trap levels. */ 3454579826SDavid Howells /* First, hardware traps. */ 3554579826SDavid Howells #define SP_TRAP_TFLT 0x1 /* Text fault */ 3654579826SDavid Howells #define SP_TRAP_II 0x2 /* Illegal Instruction */ 3754579826SDavid Howells #define SP_TRAP_PI 0x3 /* Privileged Instruction */ 3854579826SDavid Howells #define SP_TRAP_FPD 0x4 /* Floating Point Disabled */ 3954579826SDavid Howells #define SP_TRAP_WOVF 0x5 /* Window Overflow */ 4054579826SDavid Howells #define SP_TRAP_WUNF 0x6 /* Window Underflow */ 4154579826SDavid Howells #define SP_TRAP_MNA 0x7 /* Memory Address Unaligned */ 4254579826SDavid Howells #define SP_TRAP_FPE 0x8 /* Floating Point Exception */ 4354579826SDavid Howells #define SP_TRAP_DFLT 0x9 /* Data Fault */ 4454579826SDavid Howells #define SP_TRAP_TOF 0xa /* Tag Overflow */ 4554579826SDavid Howells #define SP_TRAP_WDOG 0xb /* Watchpoint Detected */ 4654579826SDavid Howells #define SP_TRAP_IRQ1 0x11 /* IRQ level 1 */ 4754579826SDavid Howells #define SP_TRAP_IRQ2 0x12 /* IRQ level 2 */ 4854579826SDavid Howells #define SP_TRAP_IRQ3 0x13 /* IRQ level 3 */ 4954579826SDavid Howells #define SP_TRAP_IRQ4 0x14 /* IRQ level 4 */ 5054579826SDavid Howells #define SP_TRAP_IRQ5 0x15 /* IRQ level 5 */ 5154579826SDavid Howells #define SP_TRAP_IRQ6 0x16 /* IRQ level 6 */ 5254579826SDavid Howells #define SP_TRAP_IRQ7 0x17 /* IRQ level 7 */ 5354579826SDavid Howells #define SP_TRAP_IRQ8 0x18 /* IRQ level 8 */ 5454579826SDavid Howells #define SP_TRAP_IRQ9 0x19 /* IRQ level 9 */ 5554579826SDavid Howells #define SP_TRAP_IRQ10 0x1a /* IRQ level 10 */ 5654579826SDavid Howells #define SP_TRAP_IRQ11 0x1b /* IRQ level 11 */ 5754579826SDavid Howells #define SP_TRAP_IRQ12 0x1c /* IRQ level 12 */ 5854579826SDavid Howells #define SP_TRAP_IRQ13 0x1d /* IRQ level 13 */ 5954579826SDavid Howells #define SP_TRAP_IRQ14 0x1e /* IRQ level 14 */ 6054579826SDavid Howells #define SP_TRAP_IRQ15 0x1f /* IRQ level 15 Non-maskable */ 6154579826SDavid Howells #define SP_TRAP_RACC 0x20 /* Register Access Error ??? */ 6254579826SDavid Howells #define SP_TRAP_IACC 0x21 /* Instruction Access Error */ 6354579826SDavid Howells #define SP_TRAP_CPDIS 0x24 /* Co-Processor Disabled */ 6454579826SDavid Howells #define SP_TRAP_BADFL 0x25 /* Unimplemented Flush Instruction */ 6554579826SDavid Howells #define SP_TRAP_CPEXP 0x28 /* Co-Processor Exception */ 6654579826SDavid Howells #define SP_TRAP_DACC 0x29 /* Data Access Error */ 6754579826SDavid Howells #define SP_TRAP_DIVZ 0x2a /* Divide By Zero */ 6854579826SDavid Howells #define SP_TRAP_DSTORE 0x2b /* Data Store Error ??? */ 6954579826SDavid Howells #define SP_TRAP_DMM 0x2c /* Data Access MMU Miss ??? */ 7054579826SDavid Howells #define SP_TRAP_IMM 0x3c /* Instruction Access MMU Miss ??? */ 7154579826SDavid Howells 7254579826SDavid Howells /* Now the Software Traps... */ 7354579826SDavid Howells #define SP_TRAP_SUNOS 0x80 /* SunOS System Call */ 7454579826SDavid Howells #define SP_TRAP_SBPT 0x81 /* Software Breakpoint */ 7554579826SDavid Howells #define SP_TRAP_SDIVZ 0x82 /* Software Divide-by-Zero trap */ 7654579826SDavid Howells #define SP_TRAP_FWIN 0x83 /* Flush Windows */ 7754579826SDavid Howells #define SP_TRAP_CWIN 0x84 /* Clean Windows */ 7854579826SDavid Howells #define SP_TRAP_RCHK 0x85 /* Range Check */ 7954579826SDavid Howells #define SP_TRAP_FUNA 0x86 /* Fix Unaligned Access */ 8054579826SDavid Howells #define SP_TRAP_IOWFL 0x87 /* Integer Overflow */ 8154579826SDavid Howells #define SP_TRAP_SOLARIS 0x88 /* Solaris System Call */ 8254579826SDavid Howells #define SP_TRAP_NETBSD 0x89 /* NetBSD System Call */ 8354579826SDavid Howells #define SP_TRAP_LINUX 0x90 /* Linux System Call */ 8454579826SDavid Howells 8554579826SDavid Howells /* Names used for compatibility with SunOS */ 8654579826SDavid Howells #define ST_SYSCALL 0x00 8754579826SDavid Howells #define ST_BREAKPOINT 0x01 8854579826SDavid Howells #define ST_DIV0 0x02 8954579826SDavid Howells #define ST_FLUSH_WINDOWS 0x03 9054579826SDavid Howells #define ST_CLEAN_WINDOWS 0x04 9154579826SDavid Howells #define ST_RANGE_CHECK 0x05 9254579826SDavid Howells #define ST_FIX_ALIGN 0x06 9354579826SDavid Howells #define ST_INT_OVERFLOW 0x07 9454579826SDavid Howells 9554579826SDavid Howells /* Special traps... */ 9654579826SDavid Howells #define SP_TRAP_KBPT1 0xfe /* KADB/PROM Breakpoint one */ 9754579826SDavid Howells #define SP_TRAP_KBPT2 0xff /* KADB/PROM Breakpoint two */ 9854579826SDavid Howells 9954579826SDavid Howells /* Handy Macros */ 10054579826SDavid Howells /* Is this a trap we never expect to get? */ 10154579826SDavid Howells #define BAD_TRAP_P(level) \ 10254579826SDavid Howells ((level > SP_TRAP_WDOG && level < SP_TRAP_IRQ1) || \ 10354579826SDavid Howells (level > SP_TRAP_IACC && level < SP_TRAP_CPDIS) || \ 10454579826SDavid Howells (level > SP_TRAP_BADFL && level < SP_TRAP_CPEXP) || \ 10554579826SDavid Howells (level > SP_TRAP_DMM && level < SP_TRAP_IMM) || \ 10654579826SDavid Howells (level > SP_TRAP_IMM && level < SP_TRAP_SUNOS) || \ 10754579826SDavid Howells (level > SP_TRAP_LINUX && level < SP_TRAP_KBPT1)) 10854579826SDavid Howells 10954579826SDavid Howells /* Is this a Hardware trap? */ 11054579826SDavid Howells #define HW_TRAP_P(level) ((level > 0) && (level < SP_TRAP_SUNOS)) 11154579826SDavid Howells 11254579826SDavid Howells /* Is this a Software trap? */ 11354579826SDavid Howells #define SW_TRAP_P(level) ((level >= SP_TRAP_SUNOS) && (level <= SP_TRAP_KBPT2)) 11454579826SDavid Howells 11554579826SDavid Howells /* Is this a system call for some OS we know about? */ 11654579826SDavid Howells #define SCALL_TRAP_P(level) ((level == SP_TRAP_SUNOS) || \ 11754579826SDavid Howells (level == SP_TRAP_SOLARIS) || \ 11854579826SDavid Howells (level == SP_TRAP_NETBSD) || \ 11954579826SDavid Howells (level == SP_TRAP_LINUX)) 12054579826SDavid Howells 12154579826SDavid Howells #endif /* _UAPI_SPARC_TRAPS_H */ 122