arc_exc_asm.S 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /* ------------------------------------------
  2. * Copyright (c) 2016, Synopsys, Inc. All rights reserved.
  3. * Redistribution and use in source and binary forms, with or without modification,
  4. * are permitted provided that the following conditions are met:
  5. * 1) Redistributions of source code must retain the above copyright notice, this
  6. * list of conditions and the following disclaimer.
  7. * 2) Redistributions in binary form must reproduce the above copyright notice,
  8. * this list of conditions and the following disclaimer in the documentation and/or
  9. * other materials provided with the distribution.
  10. * 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
  11. * be used to endorse or promote products derived from this software without
  12. * specific prior written permission.
  13. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  14. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  17. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  18. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  19. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  20. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  21. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  22. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. *
  24. * \version 2016.05
  25. * \date 2014-07-15
  26. * \author Wayne Ren(Wei.Ren@synopsys.com)
  27. --------------------------------------------- */
  28. /**
  29. * \file
  30. * \ingroup ARC_HAL_EXCEPTION_CPU
  31. * \brief assembly part of exception and interrupt processing
  32. */
  33. /**
  34. * \addtogroup ARC_HAL_EXCEPTION_CPU
  35. * @{
  36. */
  37. /* function documentation */
  38. /**
  39. * \fn void exc_entry_cpu(void)
  40. * \brief default entry of CPU exceptions, such as TLB miss and swap.
  41. *
  42. * \fn void exc_entry_int(void)
  43. * \brief normal interrupt exception entry.
  44. * In default, all interrupt exceptions are installed with normal entry.
  45. * If FIRQ is required, exc_entry_firq should be the entry.
  46. *
  47. * \fn void exc_entry_firq(void)
  48. * \brief firq exception entry
  49. */
  50. /** }@ */
  51. /** @cond EXCEPTION_ASM */
  52. #define __ASSEMBLY__
  53. #include "inc/arc/arc.h"
  54. #include "inc/arc/arc_asm_common.h"
  55. .file "arc_exc_asm.S"
  56. /* entry for cpu exception handling */
  57. .text
  58. .global exc_entry_cpu
  59. .weak exc_entry_cpu
  60. .align 4
  61. exc_entry_cpu:
  62. EXCEPTION_PROLOGUE
  63. mov r3, sp /* as exception handler's para(exc_frame) */
  64. /* exc_nest_count +1 */
  65. ld r0, [exc_nest_count]
  66. add r0, r0, 1
  67. st r0, [exc_nest_count]
  68. /* find the exception cause */
  69. lr r0, [AUX_ECR]
  70. lsr r0, r0, 16
  71. bmsk r0, r0, 7
  72. mov r1, exc_int_handler_table
  73. ld.as r2, [r1, r0]
  74. mov r0, r3
  75. jl [r2] /* jump to exception handler where interrupts are not allowed! */
  76. /* interrupts are not allowed */
  77. exc_return:
  78. /* exc_nest_count -1 */
  79. ld r0, [exc_nest_count]
  80. sub r0, r0, 1
  81. st r0, [exc_nest_count]
  82. EXCEPTION_EPILOGUE
  83. rtie
  84. /****** entry for normal interrupt exception handling ******/
  85. .global exc_entry_int
  86. .weak exc_entry_int
  87. .align 4
  88. exc_entry_int:
  89. clri /* disable interrupt */
  90. #if ARC_FEATURE_FIRQ == 1
  91. #if ARC_FEATURE_RGF_NUM_BANKS > 1
  92. lr r0, [AUX_IRQ_ACT] /* check whether it is P0 interrupt */
  93. btst r0, 0
  94. bnz exc_entry_firq
  95. #else
  96. PUSH r10
  97. lr r10, [AUX_IRQ_ACT]
  98. btst r10, 0
  99. POP r10
  100. bnz exc_entry_firq
  101. #endif
  102. #endif
  103. INTERRUPT_PROLOGUE /* save scratch regs, this will be affected */
  104. /* exc_nest_count +1 */
  105. ld r0, [exc_nest_count]
  106. add r0, r0, 1
  107. st r0, [exc_nest_count]
  108. lr r0, [AUX_IRQ_CAUSE]
  109. mov r1, exc_int_handler_table
  110. ld.as r2, [r1, r0] /* r2 = _kernel_exc_tbl + irqno *4 */
  111. /* for the case of software triggered interrupt */
  112. lr r3, [AUX_IRQ_HINT]
  113. cmp r3, r0
  114. bne.d irq_hint_handled
  115. xor r3, r3, r3
  116. sr r3, [AUX_IRQ_HINT]
  117. irq_hint_handled:
  118. seti /* enable higher priority interrupt */
  119. mov r0, sp
  120. jl [r2] /* jump to interrupt handler */
  121. /* no interrupts are allowed from here */
  122. int_return:
  123. clri /* disable interrupt */
  124. /* exc_nest_count -1 */
  125. ld r0, [exc_nest_count]
  126. sub r0, r0, 1
  127. st r0, [exc_nest_count]
  128. INTERRUPT_EPILOGUE
  129. rtie
  130. /****** entry for fast irq exception handling ******/
  131. .global exc_entry_firq
  132. .weak exc_entry_firq
  133. .align 4
  134. exc_entry_firq:
  135. clri /* disable interrupt */
  136. SAVE_FIQ_EXC_REGS
  137. /* exc_nest_count +1 */
  138. ld r0, [exc_nest_count]
  139. add r0, r0, 1
  140. st r0, [exc_nest_count]
  141. lr r0, [AUX_IRQ_CAUSE]
  142. mov r1, exc_int_handler_table
  143. ld.as r2, [r1, r0] /* r2 = _kernel_exc_tbl + irqno *4 */
  144. /* for the case of software triggered interrupt */
  145. lr r3, [AUX_IRQ_HINT]
  146. cmp r3, r0
  147. bne.d firq_hint_handled
  148. xor r3, r3, r3
  149. sr r3, [AUX_IRQ_HINT]
  150. firq_hint_handled:
  151. jl [r2] /* jump to interrupt handler */
  152. /* no interrupts are allowed from here */
  153. firq_return:
  154. /* exc_nest_count -1 */
  155. ld r0, [exc_nest_count]
  156. sub r0, r0, 1
  157. st r0, [exc_nest_count]
  158. RESTORE_FIQ_EXC_REGS
  159. rtie
  160. /** @endcond */