intexc.asm 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. ;
  2. ; Copyright (c) 2021, Shenzhen Academy of Aerospace Technology
  3. ;
  4. ; SPDX-License-Identifier: Apache-2.0
  5. ;
  6. ; Change Logs:
  7. ; Date Author Notes
  8. ; 2021-11-16 Dystopia the first version
  9. ;
  10. ;-----------------------------------------------------------
  11. ; interrupt and execption handler for C6000 DSP
  12. ;-----------------------------------------------------------
  13. ;-----------------------------------------------------------
  14. ; macro definition
  15. ;-----------------------------------------------------------
  16. DP .set B14
  17. SP .set B15
  18. ;
  19. ;-----------------------------------------------------------
  20. ;
  21. .include "contextinc.asm"
  22. ;-----------------------------------------------------------
  23. ; global function
  24. ;-----------------------------------------------------------
  25. .global _nmi_handler
  26. .global _bad_handler
  27. .global _int4_handler
  28. .global _int5_handler
  29. .global _int6_handler
  30. .global _int7_handler
  31. .global _int8_handler
  32. .global _int9_handler
  33. .global _int10_handler
  34. .global _int11_handler
  35. .global _int12_handler
  36. .global _int13_handler
  37. .global _int14_handler
  38. .global _int15_handler
  39. ;
  40. ;-----------------------------------------------------------
  41. ;
  42. ;-----------------------------------------------------------
  43. ; extern function
  44. ;-----------------------------------------------------------
  45. .ref hw_nmi_handler
  46. .ref hw_bad_handler
  47. .ref hw_int4_handler
  48. .ref hw_int5_handler
  49. .ref hw_int6_handler
  50. .ref hw_int7_handler
  51. .ref hw_int8_handler
  52. .ref hw_int9_handler
  53. .ref hw_int10_handler
  54. .ref hw_int11_handler
  55. .ref hw_int12_handler
  56. .ref hw_int13_handler
  57. .ref hw_int14_handler
  58. .ref hw_int15_handler
  59. .ref rt_hw_process_exception
  60. .ref rt_interrupt_context_restore
  61. ;
  62. ;-----------------------------------------------------------
  63. ;
  64. ;-----------------------------------------------------------
  65. ; extern variable
  66. ;-----------------------------------------------------------
  67. .ref rt_system_stack_top
  68. ;
  69. ;-----------------------------------------------------------
  70. ;
  71. ;-----------------------------------------------------------
  72. ; interrupt macro definition
  73. ;-----------------------------------------------------------
  74. RT_INTERRUPT_ENTRY .macro
  75. SAVE_ALL IRP,ITSR
  76. .endm
  77. RT_CALL_INT .macro __isr
  78. CALLP __isr,B3
  79. B .S1 rt_interrupt_context_restore
  80. NOP 5
  81. .endm
  82. ;-----------------------------------------------------------
  83. ; execption macro definition
  84. ;-----------------------------------------------------------
  85. RT_EXECPTION_ENTRY .macro
  86. SAVE_ALL NRP,NTSR
  87. .endm
  88. RT_EXECPTION_EXIT .macro
  89. RESTORE_ALL NRP,NTSR
  90. B .S2 NRP ; return from execption
  91. NOP 5
  92. .endm
  93. ;
  94. ;-----------------------------------------------------------
  95. ;
  96. .sect ".text"
  97. ;
  98. ;-----------------------------------------------------------
  99. ;
  100. ;-----------------------------------------------------------
  101. ; handler NMI interrupt
  102. ;-----------------------------------------------------------
  103. _nmi_handler:
  104. ;{
  105. RT_EXECPTION_ENTRY
  106. MVC .S2 EFR,B2
  107. CMPEQ .L2 1,B2,B2
  108. || MVC .S2 TSR,B1
  109. MV .D1X B2,A2
  110. || CLR .S2 B1,10,10,B1
  111. MVC .S2 B1,TSR
  112. [!A2] MVKL .S1 rt_hw_process_exception,A0
  113. ||[B2] MVKL .S2 rt_hw_software_exception,B1
  114. [!A2] MVKH .S1 rt_hw_process_exception,A0
  115. ||[B2] MVKH .S2 rt_hw_software_exception,B1
  116. [!B2] B .S2X A0
  117. [B2] B .S2 B1
  118. [!B2] ADDAW .D2 SP,2,B1
  119. [!B2] MV .D1X B1,A4
  120. ADDKPC .S2 ret_from_trap,B3,2
  121. ;
  122. ; return from trap
  123. ;
  124. ret_from_trap:
  125. MV .D2X A4,B0
  126. [!B0] MVKL .S2 ret_from_exception,B3
  127. [!B0] MVKH .S2 ret_from_exception,B3
  128. [!B0] BNOP .S2 B3,5
  129. ;
  130. ; return from trap restore exception context
  131. ;
  132. ret_from_exception:
  133. RT_EXECPTION_EXIT
  134. ;
  135. rt_hw_software_exception:
  136. MVKL .S1 rt_hw_process_exception,A0
  137. MVKH .S1 rt_hw_process_exception,A0
  138. B .S2X A0
  139. ADDAW .D2 SP,2,B1
  140. MV .D1X B1,A4
  141. ADDKPC .S2 ret_from_trap,B3,2
  142. NOP 2
  143. ;}
  144. ;-----------------------------------------------------------
  145. ; handler bad interrupt
  146. ;-----------------------------------------------------------
  147. _bad_handler:
  148. ;{
  149. RT_INTERRUPT_ENTRY
  150. RT_CALL_INT hw_bad_handler
  151. ;}
  152. ;-----------------------------------------------------------
  153. ; handler INT4 interrupt
  154. ;-----------------------------------------------------------
  155. _int4_handler:
  156. ;{
  157. RT_INTERRUPT_ENTRY
  158. RT_CALL_INT hw_int4_handler
  159. ;}
  160. ;-----------------------------------------------------------
  161. ; handler INT5 interrupt
  162. ;-----------------------------------------------------------
  163. _int5_handler:
  164. ;{
  165. RT_INTERRUPT_ENTRY
  166. RT_CALL_INT hw_int5_handler
  167. ;}
  168. ;-----------------------------------------------------------
  169. ; handler INT6 interrupt
  170. ;-----------------------------------------------------------
  171. _int6_handler:
  172. ;{
  173. RT_INTERRUPT_ENTRY
  174. RT_CALL_INT hw_int6_handler
  175. ;}
  176. ;-----------------------------------------------------------
  177. ; handler INT7 interrupt
  178. ;-----------------------------------------------------------
  179. _int7_handler:
  180. ;{
  181. RT_INTERRUPT_ENTRY
  182. RT_CALL_INT hw_int7_handler
  183. ;}
  184. ;-----------------------------------------------------------
  185. ; handler INT8 interrupt
  186. ;-----------------------------------------------------------
  187. _int8_handler:
  188. ;{
  189. RT_INTERRUPT_ENTRY
  190. RT_CALL_INT hw_int8_handler
  191. ;}
  192. ;-----------------------------------------------------------
  193. ; handler INT9 interrupt
  194. ;-----------------------------------------------------------
  195. _int9_handler:
  196. ;{
  197. RT_INTERRUPT_ENTRY
  198. RT_CALL_INT hw_int9_handler
  199. ;}
  200. ;-----------------------------------------------------------
  201. ; handler INT10 interrupt
  202. ;-----------------------------------------------------------
  203. _int10_handler:
  204. ;{
  205. RT_INTERRUPT_ENTRY
  206. RT_CALL_INT hw_int10_handler
  207. ;}
  208. ;-----------------------------------------------------------
  209. ; handler INT11 interrupt
  210. ;-----------------------------------------------------------
  211. _int11_handler:
  212. ;{
  213. RT_INTERRUPT_ENTRY
  214. RT_CALL_INT hw_int11_handler
  215. ;}
  216. ;-----------------------------------------------------------
  217. ; handler INT12 interrupt
  218. ;-----------------------------------------------------------
  219. _int12_handler:
  220. ;{
  221. RT_INTERRUPT_ENTRY
  222. RT_CALL_INT hw_int12_handler
  223. ;}
  224. ;-----------------------------------------------------------
  225. ; handler INT13 interrupt
  226. ;-----------------------------------------------------------
  227. _int13_handler:
  228. ;{
  229. RT_INTERRUPT_ENTRY
  230. RT_CALL_INT hw_int13_handler
  231. ;}
  232. ;-----------------------------------------------------------
  233. ; handler INT14 interrupt
  234. ;-----------------------------------------------------------
  235. _int14_handler:
  236. ;{
  237. RT_INTERRUPT_ENTRY
  238. RT_CALL_INT hw_int14_handler
  239. ;}
  240. ;-----------------------------------------------------------
  241. ; handler INT15 interrupt
  242. ;-----------------------------------------------------------
  243. _int15_handler:
  244. ;{
  245. RT_INTERRUPT_ENTRY
  246. RT_CALL_INT hw_int15_handler
  247. ;}
  248. .end