int-handler.S 7.8 KB

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