xtensa_intr_asm.S 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*******************************************************************************
  2. Copyright (c) 2006-2015 Cadence Design Systems Inc.
  3. Permission is hereby granted, free of charge, to any person obtaining
  4. a copy of this software and associated documentation files (the
  5. "Software"), to deal in the Software without restriction, including
  6. without limitation the rights to use, copy, modify, merge, publish,
  7. distribute, sublicense, and/or sell copies of the Software, and to
  8. permit persons to whom the Software is furnished to do so, subject to
  9. the following conditions:
  10. The above copyright notice and this permission notice shall be included
  11. in all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  15. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  16. CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  17. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  18. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. ******************************************************************************/
  20. /******************************************************************************
  21. Xtensa interrupt handling data and assembly routines.
  22. Also see xtensa_intr.c and xtensa_vectors.S.
  23. ******************************************************************************/
  24. #include <xtensa/hal.h>
  25. #include <xtensa/config/core.h>
  26. #include "xtensa/xtensa_context.h"
  27. #include "freertos/FreeRTOSConfig.h"
  28. #if XCHAL_HAVE_INTERRUPTS
  29. /*
  30. -------------------------------------------------------------------------------
  31. INTENABLE virtualization information.
  32. -------------------------------------------------------------------------------
  33. */
  34. #if XT_USE_SWPRI
  35. /* Warning - this is not multicore-compatible. */
  36. .data
  37. .global _xt_intdata
  38. .align 8
  39. _xt_intdata:
  40. .global _xt_intenable
  41. .type _xt_intenable,@object
  42. .size _xt_intenable,4
  43. .global _xt_vpri_mask
  44. .type _xt_vpri_mask,@object
  45. .size _xt_vpri_mask,4
  46. _xt_intenable: .word 0 /* Virtual INTENABLE */
  47. _xt_vpri_mask: .word 0xFFFFFFFF /* Virtual priority mask */
  48. #endif
  49. /*
  50. -------------------------------------------------------------------------------
  51. Table of C-callable interrupt handlers for each interrupt. Note that not all
  52. slots can be filled, because interrupts at level > EXCM_LEVEL will not be
  53. dispatched to a C handler by default.
  54. Stored as:
  55. int 0 cpu 0
  56. int 0 cpu 1
  57. ...
  58. int 0 cpu n
  59. int 1 cpu 0
  60. int 1 cpu 1
  61. etc
  62. -------------------------------------------------------------------------------
  63. */
  64. .data
  65. .global _xt_interrupt_table
  66. .align 8
  67. _xt_interrupt_table:
  68. .set i, 0
  69. .rept XCHAL_NUM_INTERRUPTS*portNUM_PROCESSORS
  70. .word xt_unhandled_interrupt /* handler address */
  71. .word i /* handler arg (default: intnum) */
  72. .set i, i+1
  73. .endr
  74. #endif /* XCHAL_HAVE_INTERRUPTS */
  75. #if XCHAL_HAVE_EXCEPTIONS
  76. /*
  77. -------------------------------------------------------------------------------
  78. Table of C-callable exception handlers for each exception. Note that not all
  79. slots will be active, because some exceptions (e.g. coprocessor exceptions)
  80. are always handled by the OS and cannot be hooked by user handlers.
  81. Stored as:
  82. exc 0 cpu 0
  83. exc 0 cpu 1
  84. ...
  85. exc 0 cpu n
  86. exc 1 cpu 0
  87. exc 1 cpu 1
  88. etc
  89. -------------------------------------------------------------------------------
  90. */
  91. .data
  92. .global _xt_exception_table
  93. .align 4
  94. _xt_exception_table:
  95. .rept XCHAL_EXCCAUSE_NUM * portNUM_PROCESSORS
  96. .word xt_unhandled_exception /* handler address */
  97. .endr
  98. #endif
  99. /*
  100. -------------------------------------------------------------------------------
  101. unsigned int xt_ints_on ( unsigned int mask )
  102. Enables a set of interrupts. Does not simply set INTENABLE directly, but
  103. computes it as a function of the current virtual priority if XT_USE_SWPRI is
  104. enabled.
  105. Can be called from interrupt handlers.
  106. -------------------------------------------------------------------------------
  107. */
  108. .text
  109. .align 4
  110. .global xt_ints_on
  111. .type xt_ints_on,@function
  112. xt_ints_on:
  113. ENTRY0
  114. #if XCHAL_HAVE_INTERRUPTS
  115. #if XT_USE_SWPRI
  116. movi a3, 0
  117. movi a4, _xt_intdata
  118. xsr a3, INTENABLE /* Disables all interrupts */
  119. rsync
  120. l32i a3, a4, 0 /* a3 = _xt_intenable */
  121. l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
  122. or a5, a3, a2 /* a5 = _xt_intenable | mask */
  123. s32i a5, a4, 0 /* _xt_intenable |= mask */
  124. and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
  125. wsr a5, INTENABLE /* Reenable interrupts */
  126. mov a2, a3 /* Previous mask */
  127. #else
  128. movi a3, 0
  129. xsr a3, INTENABLE /* Disables all interrupts */
  130. rsync
  131. or a2, a3, a2 /* set bits in mask */
  132. wsr a2, INTENABLE /* Re-enable ints */
  133. rsync
  134. mov a2, a3 /* return prev mask */
  135. #endif
  136. #else
  137. movi a2, 0 /* Return zero */
  138. #endif
  139. RET0
  140. .size xt_ints_on, . - xt_ints_on
  141. /*
  142. -------------------------------------------------------------------------------
  143. unsigned int xt_ints_off ( unsigned int mask )
  144. Disables a set of interrupts. Does not simply set INTENABLE directly,
  145. but computes it as a function of the current virtual priority if XT_USE_SWPRI is
  146. enabled.
  147. Can be called from interrupt handlers.
  148. -------------------------------------------------------------------------------
  149. */
  150. .text
  151. .align 4
  152. .global xt_ints_off
  153. .type xt_ints_off,@function
  154. xt_ints_off:
  155. ENTRY0
  156. #if XCHAL_HAVE_INTERRUPTS
  157. #if XT_USE_SWPRI
  158. movi a3, 0
  159. movi a4, _xt_intdata
  160. xsr a3, INTENABLE /* Disables all interrupts */
  161. rsync
  162. l32i a3, a4, 0 /* a3 = _xt_intenable */
  163. l32i a6, a4, 4 /* a6 = _xt_vpri_mask */
  164. or a5, a3, a2 /* a5 = _xt_intenable | mask */
  165. xor a5, a5, a2 /* a5 = _xt_intenable & ~mask */
  166. s32i a5, a4, 0 /* _xt_intenable &= ~mask */
  167. and a5, a5, a6 /* a5 = _xt_intenable & _xt_vpri_mask */
  168. wsr a5, INTENABLE /* Reenable interrupts */
  169. mov a2, a3 /* Previous mask */
  170. #else
  171. movi a4, 0
  172. xsr a4, INTENABLE /* Disables all interrupts */
  173. rsync
  174. or a3, a4, a2 /* set bits in mask */
  175. xor a3, a3, a2 /* invert bits in mask set in mask, essentially clearing them */
  176. wsr a3, INTENABLE /* Re-enable ints */
  177. rsync
  178. mov a2, a4 /* return prev mask */
  179. #endif
  180. #else
  181. movi a2, 0 /* return zero */
  182. #endif
  183. RET0
  184. .size xt_ints_off, . - xt_ints_off