interrupt.S 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. /*
  2. * File: arch/blackfin/mach-common/interrupt.S
  3. * Based on:
  4. * Author: D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>
  5. * Kenneth Albanowski <kjahds@kjahds.com>
  6. *
  7. * Created: ?
  8. * Description: Interrupt Entries
  9. *
  10. * Modified:
  11. * Copyright 2004-2006 Analog Devices Inc.
  12. *
  13. * Bugs: Enter bugs at http://blackfin.uclinux.org/
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU General Public License
  26. * along with this program; if not, see the file COPYING, or write
  27. * to the Free Software Foundation, Inc.,
  28. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  29. */
  30. #include <asm/blackfin.h>
  31. #include <mach/irq.h>
  32. #include <linux/linkage.h>
  33. #include <asm/entry.h>
  34. #include <asm/asm-offsets.h>
  35. #include <asm/trace.h>
  36. #include <asm/traps.h>
  37. #include <asm/thread_info.h>
  38. #include <asm/context.S>
  39. .extern _ret_from_exception
  40. #ifdef CONFIG_I_ENTRY_L1
  41. .section .l1.text
  42. #else
  43. .text
  44. #endif
  45. .align 4 /* just in case */
  46. /* Common interrupt entry code. First we do CLI, then push
  47. * RETI, to keep interrupts disabled, but to allow this state to be changed
  48. * by local_bh_enable.
  49. * R0 contains the interrupt number, while R1 may contain the value of IPEND,
  50. * or garbage if IPEND won't be needed by the ISR. */
  51. __common_int_entry:
  52. [--sp] = fp;
  53. [--sp] = usp;
  54. [--sp] = i0;
  55. [--sp] = i1;
  56. [--sp] = i2;
  57. [--sp] = i3;
  58. [--sp] = m0;
  59. [--sp] = m1;
  60. [--sp] = m2;
  61. [--sp] = m3;
  62. [--sp] = l0;
  63. [--sp] = l1;
  64. [--sp] = l2;
  65. [--sp] = l3;
  66. [--sp] = b0;
  67. [--sp] = b1;
  68. [--sp] = b2;
  69. [--sp] = b3;
  70. [--sp] = a0.x;
  71. [--sp] = a0.w;
  72. [--sp] = a1.x;
  73. [--sp] = a1.w;
  74. [--sp] = LC0;
  75. [--sp] = LC1;
  76. [--sp] = LT0;
  77. [--sp] = LT1;
  78. [--sp] = LB0;
  79. [--sp] = LB1;
  80. [--sp] = ASTAT;
  81. [--sp] = r0; /* Skip reserved */
  82. [--sp] = RETS;
  83. r2 = RETI;
  84. [--sp] = r2;
  85. [--sp] = RETX;
  86. [--sp] = RETN;
  87. [--sp] = RETE;
  88. [--sp] = SEQSTAT;
  89. [--sp] = r1; /* IPEND - R1 may or may not be set up before jumping here. */
  90. /* Switch to other method of keeping interrupts disabled. */
  91. #ifdef CONFIG_DEBUG_HWERR
  92. r1 = 0x3f;
  93. sti r1;
  94. #else
  95. cli r1;
  96. #endif
  97. [--sp] = RETI; /* orig_pc */
  98. /* Clear all L registers. */
  99. r1 = 0 (x);
  100. l0 = r1;
  101. l1 = r1;
  102. l2 = r1;
  103. l3 = r1;
  104. #ifdef CONFIG_FRAME_POINTER
  105. fp = 0;
  106. #endif
  107. ANOMALY_283_315_WORKAROUND(p5, r7)
  108. r1 = sp;
  109. SP += -12;
  110. #ifdef CONFIG_IPIPE
  111. call ___ipipe_grab_irq
  112. SP += 12;
  113. cc = r0 == 0;
  114. if cc jump .Lcommon_restore_context;
  115. #else /* CONFIG_IPIPE */
  116. call _do_irq;
  117. SP += 12;
  118. #endif /* CONFIG_IPIPE */
  119. call _return_from_int;
  120. .Lcommon_restore_context:
  121. RESTORE_CONTEXT
  122. rti;
  123. /* interrupt routine for ivhw - 5 */
  124. ENTRY(_evt_ivhw)
  125. /* In case a single action kicks off multiple memory transactions, (like
  126. * a cache line fetch, - this can cause multiple hardware errors, let's
  127. * catch them all. First - make sure all the actions are complete, and
  128. * the core sees the hardware errors.
  129. */
  130. SSYNC;
  131. SSYNC;
  132. SAVE_ALL_SYS
  133. #ifdef CONFIG_FRAME_POINTER
  134. fp = 0;
  135. #endif
  136. ANOMALY_283_315_WORKAROUND(p5, r7)
  137. /* Handle all stacked hardware errors
  138. * To make sure we don't hang forever, only do it 10 times
  139. */
  140. R0 = 0;
  141. R2 = 10;
  142. 1:
  143. P0.L = LO(ILAT);
  144. P0.H = HI(ILAT);
  145. R1 = [P0];
  146. CC = BITTST(R1, EVT_IVHW_P);
  147. IF ! CC JUMP 2f;
  148. /* OK a hardware error is pending - clear it */
  149. R1 = EVT_IVHW_P;
  150. [P0] = R1;
  151. R0 += 1;
  152. CC = R1 == R2;
  153. if CC JUMP 2f;
  154. JUMP 1b;
  155. 2:
  156. # We are going to dump something out, so make sure we print IPEND properly
  157. p2.l = lo(IPEND);
  158. p2.h = hi(IPEND);
  159. r0 = [p2];
  160. [sp + PT_IPEND] = r0;
  161. /* set the EXCAUSE to HWERR for trap_c */
  162. r0 = [sp + PT_SEQSTAT];
  163. R1.L = LO(VEC_HWERR);
  164. R1.H = HI(VEC_HWERR);
  165. R0 = R0 | R1;
  166. [sp + PT_SEQSTAT] = R0;
  167. r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
  168. SP += -12;
  169. call _trap_c;
  170. SP += 12;
  171. #ifdef EBIU_ERRMST
  172. /* make sure EBIU_ERRMST is clear */
  173. p0.l = LO(EBIU_ERRMST);
  174. p0.h = HI(EBIU_ERRMST);
  175. r0.l = (CORE_ERROR | CORE_MERROR);
  176. w[p0] = r0.l;
  177. #endif
  178. call _ret_from_exception;
  179. .Lcommon_restore_all_sys:
  180. RESTORE_ALL_SYS
  181. rti;
  182. ENDPROC(_evt_ivhw)
  183. /* Interrupt routine for evt2 (NMI).
  184. * We don't actually use this, so just return.
  185. * For inner circle type details, please see:
  186. * http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:nmi
  187. */
  188. ENTRY(_evt_nmi)
  189. .weak _evt_nmi
  190. rtn;
  191. ENDPROC(_evt_nmi)
  192. /* interrupt routine for core timer - 6 */
  193. ENTRY(_evt_timer)
  194. TIMER_INTERRUPT_ENTRY(EVT_IVTMR_P)
  195. /* interrupt routine for evt7 - 7 */
  196. ENTRY(_evt_evt7)
  197. INTERRUPT_ENTRY(EVT_IVG7_P)
  198. ENTRY(_evt_evt8)
  199. INTERRUPT_ENTRY(EVT_IVG8_P)
  200. ENTRY(_evt_evt9)
  201. INTERRUPT_ENTRY(EVT_IVG9_P)
  202. ENTRY(_evt_evt10)
  203. INTERRUPT_ENTRY(EVT_IVG10_P)
  204. ENTRY(_evt_evt11)
  205. INTERRUPT_ENTRY(EVT_IVG11_P)
  206. ENTRY(_evt_evt12)
  207. INTERRUPT_ENTRY(EVT_IVG12_P)
  208. ENTRY(_evt_evt13)
  209. INTERRUPT_ENTRY(EVT_IVG13_P)
  210. /* interrupt routine for system_call - 15 */
  211. ENTRY(_evt_system_call)
  212. SAVE_CONTEXT_SYSCALL
  213. #ifdef CONFIG_FRAME_POINTER
  214. fp = 0;
  215. #endif
  216. call _system_call;
  217. jump .Lcommon_restore_context;
  218. ENDPROC(_evt_system_call)
  219. #ifdef CONFIG_IPIPE
  220. /*
  221. * __ipipe_call_irqtail: lowers the current priority level to EVT15
  222. * before running a user-defined routine, then raises the priority
  223. * level to EVT14 to prepare the caller for a normal interrupt
  224. * return through RTI.
  225. *
  226. * We currently use this facility in two occasions:
  227. *
  228. * - to branch to __ipipe_irq_tail_hook as requested by a high
  229. * priority domain after the pipeline delivered an interrupt,
  230. * e.g. such as Xenomai, in order to start its rescheduling
  231. * procedure, since we may not switch tasks when IRQ levels are
  232. * nested on the Blackfin, so we have to fake an interrupt return
  233. * so that we may reschedule immediately.
  234. *
  235. * - to branch to sync_root_irqs, in order to play any interrupt
  236. * pending for the root domain (i.e. the Linux kernel). This lowers
  237. * the core priority level enough so that Linux IRQ handlers may
  238. * never delay interrupts handled by high priority domains; we defer
  239. * those handlers until this point instead. This is a substitute
  240. * to using a threaded interrupt model for the Linux kernel.
  241. *
  242. * r0: address of user-defined routine
  243. * context: caller must have preempted EVT15, hw interrupts must be off.
  244. */
  245. ENTRY(___ipipe_call_irqtail)
  246. p0 = r0;
  247. r0.l = 1f;
  248. r0.h = 1f;
  249. reti = r0;
  250. rti;
  251. 1:
  252. [--sp] = rets;
  253. [--sp] = ( r7:4, p5:3 );
  254. sp += -12;
  255. call (p0);
  256. sp += 12;
  257. ( r7:4, p5:3 ) = [sp++];
  258. rets = [sp++];
  259. #ifdef CONFIG_DEBUG_HWERR
  260. /* enable irq14 & hwerr interrupt, until we transition to _evt_evt14 */
  261. r0 = (EVT_IVG14 | EVT_IVHW | \
  262. EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
  263. #else
  264. /* Only enable irq14 interrupt, until we transition to _evt_evt14 */
  265. r0 = (EVT_IVG14 | \
  266. EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
  267. #endif
  268. sti r0;
  269. raise 14; /* Branches to _evt_evt14 */
  270. 2:
  271. jump 2b; /* Likely paranoid. */
  272. ENDPROC(___ipipe_call_irqtail)
  273. #endif /* CONFIG_IPIPE */