genex.S 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994 - 2000, 2001, 2003 Ralf Baechle
  7. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
  8. * Copyright (C) 2001 MIPS Technologies, Inc.
  9. * Copyright (C) 2002 Maciej W. Rozycki
  10. */
  11. #include <linux/config.h>
  12. #include <linux/init.h>
  13. #include <asm/asm.h>
  14. #include <asm/cacheops.h>
  15. #include <asm/regdef.h>
  16. #include <asm/fpregdef.h>
  17. #include <asm/mipsregs.h>
  18. #include <asm/stackframe.h>
  19. #include <asm/war.h>
  20. #define PANIC_PIC(msg) \
  21. .set push; \
  22. .set reorder; \
  23. PTR_LA a0,8f; \
  24. .set noat; \
  25. PTR_LA AT, panic; \
  26. jr AT; \
  27. 9: b 9b; \
  28. .set pop; \
  29. TEXT(msg)
  30. __INIT
  31. NESTED(except_vec0_generic, 0, sp)
  32. PANIC_PIC("Exception vector 0 called")
  33. END(except_vec0_generic)
  34. NESTED(except_vec1_generic, 0, sp)
  35. PANIC_PIC("Exception vector 1 called")
  36. END(except_vec1_generic)
  37. /*
  38. * General exception vector for all other CPUs.
  39. *
  40. * Be careful when changing this, it has to be at most 128 bytes
  41. * to fit into space reserved for the exception handler.
  42. */
  43. NESTED(except_vec3_generic, 0, sp)
  44. .set push
  45. .set noat
  46. #if R5432_CP0_INTERRUPT_WAR
  47. mfc0 k0, CP0_INDEX
  48. #endif
  49. mfc0 k1, CP0_CAUSE
  50. andi k1, k1, 0x7c
  51. #ifdef CONFIG_64BIT
  52. dsll k1, k1, 1
  53. #endif
  54. PTR_L k0, exception_handlers(k1)
  55. jr k0
  56. .set pop
  57. END(except_vec3_generic)
  58. /*
  59. * General exception handler for CPUs with virtual coherency exception.
  60. *
  61. * Be careful when changing this, it has to be at most 256 (as a special
  62. * exception) bytes to fit into space reserved for the exception handler.
  63. */
  64. NESTED(except_vec3_r4000, 0, sp)
  65. .set push
  66. .set mips3
  67. .set noat
  68. mfc0 k1, CP0_CAUSE
  69. li k0, 31<<2
  70. andi k1, k1, 0x7c
  71. .set push
  72. .set noreorder
  73. .set nomacro
  74. beq k1, k0, handle_vced
  75. li k0, 14<<2
  76. beq k1, k0, handle_vcei
  77. #ifdef CONFIG_64BIT
  78. dsll k1, k1, 1
  79. #endif
  80. .set pop
  81. PTR_L k0, exception_handlers(k1)
  82. jr k0
  83. /*
  84. * Big shit, we now may have two dirty primary cache lines for the same
  85. * physical address. We can savely invalidate the line pointed to by
  86. * c0_badvaddr because after return from this exception handler the
  87. * load / store will be re-executed.
  88. */
  89. handle_vced:
  90. DMFC0 k0, CP0_BADVADDR
  91. li k1, -4 # Is this ...
  92. and k0, k1 # ... really needed?
  93. mtc0 zero, CP0_TAGLO
  94. cache Index_Store_Tag_D,(k0)
  95. cache Hit_Writeback_Inv_SD,(k0)
  96. #ifdef CONFIG_PROC_FS
  97. PTR_LA k0, vced_count
  98. lw k1, (k0)
  99. addiu k1, 1
  100. sw k1, (k0)
  101. #endif
  102. eret
  103. handle_vcei:
  104. MFC0 k0, CP0_BADVADDR
  105. cache Hit_Writeback_Inv_SD, (k0) # also cleans pi
  106. #ifdef CONFIG_PROC_FS
  107. PTR_LA k0, vcei_count
  108. lw k1, (k0)
  109. addiu k1, 1
  110. sw k1, (k0)
  111. #endif
  112. eret
  113. .set pop
  114. END(except_vec3_r4000)
  115. /*
  116. * Special interrupt vector for MIPS64 ISA & embedded MIPS processors.
  117. * This is a dedicated interrupt exception vector which reduces the
  118. * interrupt processing overhead. The jump instruction will be replaced
  119. * at the initialization time.
  120. *
  121. * Be careful when changing this, it has to be at most 128 bytes
  122. * to fit into space reserved for the exception handler.
  123. */
  124. NESTED(except_vec4, 0, sp)
  125. 1: j 1b /* Dummy, will be replaced */
  126. END(except_vec4)
  127. /*
  128. * EJTAG debug exception handler.
  129. * The EJTAG debug exception entry point is 0xbfc00480, which
  130. * normally is in the boot PROM, so the boot PROM must do a
  131. * unconditional jump to this vector.
  132. */
  133. NESTED(except_vec_ejtag_debug, 0, sp)
  134. j ejtag_debug_handler
  135. END(except_vec_ejtag_debug)
  136. __FINIT
  137. /*
  138. * EJTAG debug exception handler.
  139. */
  140. NESTED(ejtag_debug_handler, PT_SIZE, sp)
  141. .set push
  142. .set noat
  143. MTC0 k0, CP0_DESAVE
  144. mfc0 k0, CP0_DEBUG
  145. sll k0, k0, 30 # Check for SDBBP.
  146. bgez k0, ejtag_return
  147. PTR_LA k0, ejtag_debug_buffer
  148. LONG_S k1, 0(k0)
  149. SAVE_ALL
  150. move a0, sp
  151. jal ejtag_exception_handler
  152. RESTORE_ALL
  153. PTR_LA k0, ejtag_debug_buffer
  154. LONG_L k1, 0(k0)
  155. ejtag_return:
  156. MFC0 k0, CP0_DESAVE
  157. .set mips32
  158. deret
  159. .set pop
  160. END(ejtag_debug_handler)
  161. /*
  162. * This buffer is reserved for the use of the EJTAG debug
  163. * handler.
  164. */
  165. .data
  166. EXPORT(ejtag_debug_buffer)
  167. .fill LONGSIZE
  168. .previous
  169. __INIT
  170. /*
  171. * NMI debug exception handler for MIPS reference boards.
  172. * The NMI debug exception entry point is 0xbfc00000, which
  173. * normally is in the boot PROM, so the boot PROM must do a
  174. * unconditional jump to this vector.
  175. */
  176. NESTED(except_vec_nmi, 0, sp)
  177. j nmi_handler
  178. END(except_vec_nmi)
  179. __FINIT
  180. NESTED(nmi_handler, PT_SIZE, sp)
  181. .set push
  182. .set noat
  183. .set mips3
  184. SAVE_ALL
  185. move a0, sp
  186. jal nmi_exception_handler
  187. RESTORE_ALL
  188. eret
  189. .set pop
  190. END(nmi_handler)
  191. .macro __build_clear_none
  192. .endm
  193. .macro __build_clear_sti
  194. STI
  195. .endm
  196. .macro __build_clear_cli
  197. CLI
  198. .endm
  199. .macro __build_clear_fpe
  200. cfc1 a1, fcr31
  201. li a2, ~(0x3f << 12)
  202. and a2, a1
  203. ctc1 a2, fcr31
  204. STI
  205. .endm
  206. .macro __build_clear_ade
  207. MFC0 t0, CP0_BADVADDR
  208. PTR_S t0, PT_BVADDR(sp)
  209. KMODE
  210. .endm
  211. .macro __BUILD_silent exception
  212. .endm
  213. /* Gas tries to parse the PRINT argument as a string containing
  214. string escapes and emits bogus warnings if it believes to
  215. recognize an unknown escape code. So make the arguments
  216. start with an n and gas will believe \n is ok ... */
  217. .macro __BUILD_verbose nexception
  218. LONG_L a1, PT_EPC(sp)
  219. #ifdef CONFIG_32BIT
  220. PRINT("Got \nexception at %08lx\012")
  221. #endif
  222. #ifdef CONFIG_64BIT
  223. PRINT("Got \nexception at %016lx\012")
  224. #endif
  225. .endm
  226. .macro __BUILD_count exception
  227. LONG_L t0,exception_count_\exception
  228. LONG_ADDIU t0, 1
  229. LONG_S t0,exception_count_\exception
  230. .comm exception_count\exception, 8, 8
  231. .endm
  232. .macro __BUILD_HANDLER exception handler clear verbose ext
  233. .align 5
  234. NESTED(handle_\exception, PT_SIZE, sp)
  235. .set noat
  236. SAVE_ALL
  237. FEXPORT(handle_\exception\ext)
  238. __BUILD_clear_\clear
  239. .set at
  240. __BUILD_\verbose \exception
  241. move a0, sp
  242. jal do_\handler
  243. j ret_from_exception
  244. END(handle_\exception)
  245. .endm
  246. .macro BUILD_HANDLER exception handler clear verbose
  247. __BUILD_HANDLER \exception \handler \clear \verbose _int
  248. .endm
  249. BUILD_HANDLER adel ade ade silent /* #4 */
  250. BUILD_HANDLER ades ade ade silent /* #5 */
  251. BUILD_HANDLER ibe be cli silent /* #6 */
  252. BUILD_HANDLER dbe be cli silent /* #7 */
  253. BUILD_HANDLER bp bp sti silent /* #9 */
  254. BUILD_HANDLER ri ri sti silent /* #10 */
  255. BUILD_HANDLER cpu cpu sti silent /* #11 */
  256. BUILD_HANDLER ov ov sti silent /* #12 */
  257. BUILD_HANDLER tr tr sti silent /* #13 */
  258. BUILD_HANDLER fpe fpe fpe silent /* #15 */
  259. BUILD_HANDLER mdmx mdmx sti silent /* #22 */
  260. BUILD_HANDLER watch watch sti verbose /* #23 */
  261. BUILD_HANDLER mcheck mcheck cli verbose /* #24 */
  262. BUILD_HANDLER reserved reserved sti verbose /* others */
  263. #ifdef CONFIG_64BIT
  264. /* A temporary overflow handler used by check_daddi(). */
  265. __INIT
  266. BUILD_HANDLER daddi_ov daddi_ov none silent /* #12 */
  267. #endif