int-handler.S 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*
  2. * arch/mips/dec/int-handler.S
  3. *
  4. * Copyright (C) 1995, 1996, 1997 Paul M. Antoine and Harald Koerfgen
  5. * Copyright (C) 2000, 2001, 2002, 2003, 2005 Maciej W. Rozycki
  6. *
  7. * Written by Ralf Baechle and Andreas Busse, modified for DECstation
  8. * support by Paul Antoine and Harald Koerfgen.
  9. *
  10. * completly rewritten:
  11. * Copyright (C) 1998 Harald Koerfgen
  12. *
  13. * Rewritten extensively for controller-driven IRQ support
  14. * by Maciej W. Rozycki.
  15. */
  16. #include <asm/addrspace.h>
  17. #include <asm/asm.h>
  18. #include <asm/mipsregs.h>
  19. #include <asm/regdef.h>
  20. #include <asm/stackframe.h>
  21. #include <asm/dec/interrupts.h>
  22. #include <asm/dec/ioasic_addrs.h>
  23. #include <asm/dec/ioasic_ints.h>
  24. #include <asm/dec/kn01.h>
  25. #include <asm/dec/kn02.h>
  26. #include <asm/dec/kn02xa.h>
  27. #include <asm/dec/kn03.h>
  28. #define KN02_CSR_BASE CKSEG1ADDR(KN02_SLOT_BASE + KN02_CSR)
  29. #define KN02XA_IOASIC_BASE CKSEG1ADDR(KN02XA_SLOT_BASE + IOASIC_IOCTL)
  30. #define KN03_IOASIC_BASE CKSEG1ADDR(KN03_SLOT_BASE + IOASIC_IOCTL)
  31. .text
  32. .set noreorder
  33. /*
  34. * plat_irq_dispatch: Interrupt handler for DECstations
  35. *
  36. * We follow the model in the Indy interrupt code by David Miller, where he
  37. * says: a lot of complication here is taken away because:
  38. *
  39. * 1) We handle one interrupt and return, sitting in a loop
  40. * and moving across all the pending IRQ bits in the cause
  41. * register is _NOT_ the answer, the common case is one
  42. * pending IRQ so optimize in that direction.
  43. *
  44. * 2) We need not check against bits in the status register
  45. * IRQ mask, that would make this routine slow as hell.
  46. *
  47. * 3) Linux only thinks in terms of all IRQs on or all IRQs
  48. * off, nothing in between like BSD spl() brain-damage.
  49. *
  50. * Furthermore, the IRQs on the DECstations look basically (barring
  51. * software IRQs which we don't use at all) like...
  52. *
  53. * DS2100/3100's, aka kn01, aka Pmax:
  54. *
  55. * MIPS IRQ Source
  56. * -------- ------
  57. * 0 Software (ignored)
  58. * 1 Software (ignored)
  59. * 2 SCSI
  60. * 3 Lance Ethernet
  61. * 4 DZ11 serial
  62. * 5 RTC
  63. * 6 Memory Controller & Video
  64. * 7 FPU
  65. *
  66. * DS5000/200, aka kn02, aka 3max:
  67. *
  68. * MIPS IRQ Source
  69. * -------- ------
  70. * 0 Software (ignored)
  71. * 1 Software (ignored)
  72. * 2 TurboChannel
  73. * 3 RTC
  74. * 4 Reserved
  75. * 5 Memory Controller
  76. * 6 Reserved
  77. * 7 FPU
  78. *
  79. * DS5000/1xx's, aka kn02ba, aka 3min:
  80. *
  81. * MIPS IRQ Source
  82. * -------- ------
  83. * 0 Software (ignored)
  84. * 1 Software (ignored)
  85. * 2 TurboChannel Slot 0
  86. * 3 TurboChannel Slot 1
  87. * 4 TurboChannel Slot 2
  88. * 5 TurboChannel Slot 3 (ASIC)
  89. * 6 Halt button
  90. * 7 FPU/R4k timer
  91. *
  92. * DS5000/2x's, aka kn02ca, aka maxine:
  93. *
  94. * MIPS IRQ Source
  95. * -------- ------
  96. * 0 Software (ignored)
  97. * 1 Software (ignored)
  98. * 2 Periodic Interrupt (100usec)
  99. * 3 RTC
  100. * 4 I/O write timeout
  101. * 5 TurboChannel (ASIC)
  102. * 6 Halt Keycode from Access.Bus keyboard (CTRL-ALT-ENTER)
  103. * 7 FPU/R4k timer
  104. *
  105. * DS5000/2xx's, aka kn03, aka 3maxplus:
  106. *
  107. * MIPS IRQ Source
  108. * -------- ------
  109. * 0 Software (ignored)
  110. * 1 Software (ignored)
  111. * 2 System Board (ASIC)
  112. * 3 RTC
  113. * 4 Reserved
  114. * 5 Memory
  115. * 6 Halt Button
  116. * 7 FPU/R4k timer
  117. *
  118. * We handle the IRQ according to _our_ priority (see setup.c),
  119. * then we just return. If multiple IRQs are pending then we will
  120. * just take another exception, big deal.
  121. */
  122. .align 5
  123. NESTED(plat_irq_dispatch, PT_SIZE, ra)
  124. .set noreorder
  125. /*
  126. * Get pending Interrupts
  127. */
  128. mfc0 t0,CP0_CAUSE # get pending interrupts
  129. mfc0 t1,CP0_STATUS
  130. #ifdef CONFIG_32BIT
  131. lw t2,cpu_fpu_mask
  132. #endif
  133. andi t0,ST0_IM # CAUSE.CE may be non-zero!
  134. and t0,t1 # isolate allowed ones
  135. beqz t0,spurious
  136. #ifdef CONFIG_32BIT
  137. and t2,t0
  138. bnez t2,fpu # handle FPU immediately
  139. #endif
  140. /*
  141. * Find irq with highest priority
  142. */
  143. PTR_LA t1,cpu_mask_nr_tbl
  144. 1: lw t2,(t1)
  145. nop
  146. and t2,t0
  147. beqz t2,1b
  148. addu t1,2*PTRSIZE # delay slot
  149. /*
  150. * Do the low-level stuff
  151. */
  152. lw a0,(-PTRSIZE)(t1)
  153. nop
  154. bgez a0,handle_it # irq_nr >= 0?
  155. # irq_nr < 0: it is an address
  156. nop
  157. jr a0
  158. # a trick to save a branch:
  159. lui t2,(KN03_IOASIC_BASE>>16)&0xffff
  160. # upper part of IOASIC Address
  161. /*
  162. * Handle "IRQ Controller" Interrupts
  163. * Masked Interrupts are still visible and have to be masked "by hand".
  164. */
  165. FEXPORT(kn02_io_int) # 3max
  166. lui t0,(KN02_CSR_BASE>>16)&0xffff
  167. # get interrupt status and mask
  168. lw t0,(t0)
  169. nop
  170. andi t1,t0,KN02_IRQ_ALL
  171. b 1f
  172. srl t0,16 # shift interrupt mask
  173. FEXPORT(kn02xa_io_int) # 3min/maxine
  174. lui t2,(KN02XA_IOASIC_BASE>>16)&0xffff
  175. # upper part of IOASIC Address
  176. FEXPORT(kn03_io_int) # 3max+ (t2 loaded earlier)
  177. lw t0,IO_REG_SIR(t2) # get status: IOASIC sir
  178. lw t1,IO_REG_SIMR(t2) # get mask: IOASIC simr
  179. nop
  180. 1: and t0,t1 # mask out allowed ones
  181. beqz t0,spurious
  182. /*
  183. * Find irq with highest priority
  184. */
  185. PTR_LA t1,asic_mask_nr_tbl
  186. 2: lw t2,(t1)
  187. nop
  188. and t2,t0
  189. beq zero,t2,2b
  190. addu t1,2*PTRSIZE # delay slot
  191. /*
  192. * Do the low-level stuff
  193. */
  194. lw a0,%lo(-PTRSIZE)(t1)
  195. nop
  196. bgez a0,handle_it # irq_nr >= 0?
  197. # irq_nr < 0: it is an address
  198. nop
  199. jr a0
  200. nop # delay slot
  201. /*
  202. * Dispatch low-priority interrupts. We reconsider all status
  203. * bits again, which looks like a lose, but it makes the code
  204. * simple and O(log n), so it gets compensated.
  205. */
  206. FEXPORT(cpu_all_int) # HALT, timers, software junk
  207. li a0,DEC_CPU_IRQ_BASE
  208. srl t0,CAUSEB_IP
  209. li t1,CAUSEF_IP>>CAUSEB_IP # mask
  210. b 1f
  211. li t2,4 # nr of bits / 2
  212. FEXPORT(kn02_all_int) # impossible ?
  213. li a0,KN02_IRQ_BASE
  214. li t1,KN02_IRQ_ALL # mask
  215. b 1f
  216. li t2,4 # nr of bits / 2
  217. FEXPORT(asic_all_int) # various I/O ASIC junk
  218. li a0,IO_IRQ_BASE
  219. li t1,IO_IRQ_ALL # mask
  220. b 1f
  221. li t2,8 # nr of bits / 2
  222. /*
  223. * Dispatch DMA interrupts -- O(log n).
  224. */
  225. FEXPORT(asic_dma_int) # I/O ASIC DMA events
  226. li a0,IO_IRQ_BASE+IO_INR_DMA
  227. srl t0,IO_INR_DMA
  228. li t1,IO_IRQ_DMA>>IO_INR_DMA # mask
  229. li t2,8 # nr of bits / 2
  230. /*
  231. * Find irq with highest priority.
  232. * Highest irq number takes precedence.
  233. */
  234. 1: srlv t3,t1,t2
  235. 2: xor t1,t3
  236. and t3,t0,t1
  237. beqz t3,3f
  238. nop
  239. move t0,t3
  240. addu a0,t2
  241. 3: srl t2,1
  242. bnez t2,2b
  243. srlv t3,t1,t2
  244. handle_it:
  245. j dec_irq_dispatch
  246. nop
  247. #ifdef CONFIG_32BIT
  248. fpu:
  249. j handle_fpe_int
  250. nop
  251. #endif
  252. spurious:
  253. j spurious_interrupt
  254. nop
  255. END(plat_irq_dispatch)
  256. /*
  257. * Generic unimplemented interrupt routines -- cpu_mask_nr_tbl
  258. * and asic_mask_nr_tbl are initialized to point all interrupts here.
  259. * The tables are then filled in by machine-specific initialisation
  260. * in dec_setup().
  261. */
  262. FEXPORT(dec_intr_unimplemented)
  263. move a1,t0 # cheats way of printing an arg!
  264. PANIC("Unimplemented cpu interrupt! CP0_CAUSE: 0x%08x");
  265. FEXPORT(asic_intr_unimplemented)
  266. move a1,t0 # cheats way of printing an arg!
  267. PANIC("Unimplemented asic interrupt! ASIC ISR: 0x%08x");