traps.h 5.1 KB

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