r4k_genex.S
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:4k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  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 - 1999 by Ralf Baechle
  7.  * Copyright (C) 1999 Silicon Graphics
  8.  *
  9.  * Low level exception handling
  10.  */
  11. #define __ASSEMBLY__
  12. #include <linux/init.h>
  13. #include <asm/asm.h>
  14. #include <asm/regdef.h>
  15. #include <asm/fpregdef.h>
  16. #include <asm/mipsregs.h>
  17. #include <asm/stackframe.h>
  18. #include <asm/r4kcacheops.h>
  19. .macro __build_clear_none
  20. .endm
  21. .macro __build_clear_sti
  22. STI
  23. .endm
  24. .macro __build_clear_cli
  25. CLI
  26. .endm
  27. .macro __build_clear_fpe
  28. cfc1 a1, fcr31
  29. li a2, ~(0x3f << 13)
  30. and a2, a1
  31. ctc1 a2, fcr31
  32. STI
  33. .endm
  34. .macro __build_clear_ade
  35. dmfc0 t0, CP0_BADVADDR
  36. sd t0, PT_BVADDR(sp)
  37. KMODE
  38. .endm
  39. .macro __BUILD_silent exception
  40. .endm
  41. /* Gas tries to parse the PRINT argument as a string containing
  42.    string escapes and emits bogus warnings if it believes to
  43.    recognize an unknown escape code.  So make the arguments
  44.    start with an n and gas will believe n is ok ...  */
  45. .macro __BUILD_verbose nexception
  46. ld a1, PT_EPC(sp)
  47. PRINT("Got nexception at %016lx12")
  48. .endm
  49. .macro __BUILD_count exception
  50. .set reorder
  51. ld t0,exception_count_exception
  52. daddiu t0, 1
  53. sd t0,exception_count_exception
  54. .set noreorder
  55. .comm exception_countexception, 8, 8
  56. .endm
  57. .macro BUILD_HANDLER exception handler clear verbose
  58. .align 5
  59. NESTED(handle_exception, PT_SIZE, sp)
  60. .set noat
  61. SAVE_ALL
  62. #if DEBUG_MIPS64
  63. jal dodebug2
  64. ld $4, PT_R4(sp)
  65. ld $5, PT_R5(sp)
  66. ld $6, PT_R6(sp)
  67. ld $7, PT_R7(sp)
  68. ld $2, PT_R2(sp)
  69. #endif
  70. __BUILD_clear_clear
  71. .set at
  72. __BUILD_verbose exception
  73. move a0, sp
  74. jal do_handler
  75. j ret_from_sys_call
  76.  nop
  77. END(handle_exception)
  78. .endm
  79. BUILD_HANDLER adel ade ade silent /* #4  */
  80. BUILD_HANDLER ades ade ade silent /* #5  */
  81. BUILD_HANDLER ibe ibe cli silent /* #6  */
  82. BUILD_HANDLER dbe dbe cli silent /* #7  */
  83. BUILD_HANDLER bp bp sti silent /* #9  */
  84. BUILD_HANDLER ri ri sti silent /* #10 */
  85. BUILD_HANDLER cpu cpu sti silent /* #11 */
  86. BUILD_HANDLER ov ov sti silent /* #12 */
  87. BUILD_HANDLER tr tr sti silent /* #13 */
  88. BUILD_HANDLER fpe fpe fpe silent /* #15 */
  89. BUILD_HANDLER watch watch sti verbose /* #23 */
  90. BUILD_HANDLER reserved reserved sti verbose /* others */
  91. __INIT
  92. /* General exception handler for CPUs with virtual coherency exception.
  93.  *
  94.  * Be careful when changing this, it has to be at most 128 bytes to fit
  95.  * into space reserved for the exception handler.
  96.  */
  97. NESTED(except_vec3_r4000, 0, sp)
  98. .set noat
  99. mfc0 k1, CP0_CAUSE
  100. andi k1, k1, 0x7c
  101. li k0, 31<<2
  102. beq k1, k0, handle_vced
  103.  li k0, 14<<2
  104. beq k1, k0, handle_vcei
  105.  dsll k1, k1, 1
  106. ld k0, exception_handlers(k1)
  107. jr k0
  108. /*
  109.  * Big shit, we now may have two dirty primary cache lines for the same
  110.  * physical address.  We can savely invalidate the line pointed to by
  111.  * c0_badvaddr because after return from this exception handler the load /
  112.  * store will be re-executed.
  113.  */
  114. handle_vced:
  115. mfc0 k0, CP0_BADVADDR
  116. li k1, -4 # Is this ...
  117. and k0, k1 # ... really needed?
  118. mtc0 zero, CP0_TAGLO
  119. cache Index_Store_Tag_D,(k0)
  120. cache Hit_Writeback_Inv_SD,(k0)
  121. lui k0, %hi(vced_count)
  122. lw k1, %lo(vced_count)(k0)
  123. addiu k1, 1
  124. sw k1, %lo(vced_count)(k0)
  125. eret
  126. handle_vcei:
  127. mfc0 k0, CP0_BADVADDR
  128. cache Hit_Writeback_Inv_SD,(k0) # also cleans pi
  129. lui k0, %hi(vcei_count)
  130. lw k1, %lo(vcei_count)(k0)
  131. addiu k1, 1
  132. sw k1, %lo(vcei_count)(k0)
  133. eret
  134. END(except_vec3_r4000)
  135. .set at
  136. /* General exception vector for all other CPUs. */
  137. NESTED(except_vec3_generic, 0, sp)
  138. .set noat
  139. mfc0 k1, CP0_CAUSE
  140. andi k1, k1, 0x7c
  141. dsll k1, k1, 1
  142. ld k0, exception_handlers(k1)
  143. jr k0
  144.  nop
  145. END(except_vec3_generic)
  146. .set at
  147. /*
  148.  * Special interrupt vector for embedded MIPS.  This is a dedicated interrupt
  149.  * vector which reduces interrupt processing overhead.  The jump instruction
  150.  * will be inserted here at initialization time.  This handler may only be 8
  151.  * bytes in size!
  152.  */
  153. NESTED(except_vec4, 0, sp)
  154. 1: j 1b /* Dummy, will be replaced */
  155.  nop
  156. END(except_vec4)
  157. __FINIT