sim_IRQ.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * Carsten Langgaard, carstenl@mips.com
  3. * Copyright (C) 1999, 2000 MIPS Technologies, Inc. All rights reserved.
  4. *
  5. * This program is free software; you can distribute it and/or modify it
  6. * under the terms of the GNU General Public License (Version 2) as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  17. *
  18. * Interrupt exception dispatch code.
  19. */
  20. #include <linux/config.h>
  21. #include <asm/asm.h>
  22. #include <asm/mipsregs.h>
  23. #include <asm/regdef.h>
  24. #include <asm/stackframe.h>
  25. /* A lot of complication here is taken away because:
  26. *
  27. * 1) We handle one interrupt and return, sitting in a loop and moving across
  28. * all the pending IRQ bits in the cause register is _NOT_ the answer, the
  29. * common case is one pending IRQ so optimize in that direction.
  30. *
  31. * 2) We need not check against bits in the status register IRQ mask, that
  32. * would make this routine slow as hell.
  33. *
  34. * 3) Linux only thinks in terms of all IRQs on or all IRQs off, nothing in
  35. * between like BSD spl() brain-damage.
  36. *
  37. * Furthermore, the IRQs on the MIPS board look basically (barring software
  38. * IRQs which we don't use at all and all external interrupt sources are
  39. * combined together on hardware interrupt 0 (MIPS IRQ 2)) like:
  40. *
  41. * MIPS IRQ Source
  42. * -------- ------
  43. * 0 Software (ignored)
  44. * 1 Software (ignored)
  45. * 2 Combined hardware interrupt (hw0)
  46. * 3 Hardware (ignored)
  47. * 4 Hardware (ignored)
  48. * 5 Hardware (ignored)
  49. * 6 Hardware (ignored)
  50. * 7 R4k timer (what we use)
  51. *
  52. * Note: On the SEAD board thing are a little bit different.
  53. * Here IRQ 2 (hw0) is wired to the UART0 and IRQ 3 (hw1) is wired
  54. * wired to UART1.
  55. *
  56. * We handle the IRQ according to _our_ priority which is:
  57. *
  58. * Highest ---- R4k Timer
  59. * Lowest ---- Combined hardware interrupt
  60. *
  61. * then we just return, if multiple IRQs are pending then we will just take
  62. * another exception, big deal.
  63. */
  64. .text
  65. .set noreorder
  66. .set noat
  67. .align 5
  68. NESTED(mipsIRQ, PT_SIZE, sp)
  69. SAVE_ALL
  70. CLI
  71. .set at
  72. mfc0 s0, CP0_CAUSE # get irq bits
  73. mfc0 s1, CP0_STATUS # get irq mask
  74. and s0, s1
  75. /* First we check for r4k counter/timer IRQ. */
  76. andi a0, s0, CAUSEF_IP7
  77. beq a0, zero, 1f
  78. andi a0, s0, CAUSEF_IP2 # delay slot, check hw0 interrupt
  79. /* Wheee, a timer interrupt. */
  80. move a0, sp
  81. jal mips_timer_interrupt
  82. nop
  83. j ret_from_irq
  84. nop
  85. 1:
  86. #if defined(CONFIG_MIPS_SEAD)
  87. beq a0, zero, 1f
  88. andi a0, s0, CAUSEF_IP3 # delay slot, check hw1 interrupt
  89. #else
  90. beq a0, zero, 1f # delay slot, check hw3 interrupt
  91. andi a0, s0, CAUSEF_IP5
  92. #endif
  93. /* Wheee, combined hardware level zero interrupt. */
  94. #if defined(CONFIG_MIPS_ATLAS)
  95. jal atlas_hw0_irqdispatch
  96. #elif defined(CONFIG_MIPS_MALTA)
  97. jal malta_hw0_irqdispatch
  98. #elif defined(CONFIG_MIPS_SEAD)
  99. jal sead_hw0_irqdispatch
  100. #else
  101. #error "MIPS board not supported\n"
  102. #endif
  103. move a0, sp # delay slot
  104. j ret_from_irq
  105. nop # delay slot
  106. 1:
  107. #if defined(CONFIG_MIPS_SEAD)
  108. beq a0, zero, 1f
  109. andi a0, s0, CAUSEF_IP5 # delay slot, check hw3 interrupt
  110. jal sead_hw1_irqdispatch
  111. move a0, sp # delay slot
  112. j ret_from_irq
  113. nop # delay slot
  114. 1:
  115. #endif
  116. #if defined(CONFIG_MIPS_MALTA)
  117. beq a0, zero, 1f # check hw3 (coreHI) interrupt
  118. nop
  119. jal corehi_irqdispatch
  120. move a0, sp
  121. j ret_from_irq
  122. nop
  123. 1:
  124. #endif
  125. /*
  126. * Here by mistake? This is possible, what can happen is that by the
  127. * time we take the exception the IRQ pin goes low, so just leave if
  128. * this is the case.
  129. */
  130. move a1,s0
  131. PRINT("Got interrupt: c0_cause = %08x\n")
  132. mfc0 a1, CP0_EPC
  133. PRINT("c0_epc = %08x\n")
  134. j ret_from_irq
  135. nop
  136. END(mipsIRQ)