int-handler.S 7.5 KB

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