sim_irq.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 1999, 2005 MIPS Technologies, Inc. All rights reserved.
  3. *
  4. * This program is free software; you can distribute it and/or modify it
  5. * under the terms of the GNU General Public License (Version 2) as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. * for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along
  14. * with this program; if not, write to the Free Software Foundation, Inc.,
  15. * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
  16. *
  17. * Interrupt exception dispatch code.
  18. *
  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. #include <asm/mips-boards/simint.h>
  26. .text
  27. .set noreorder
  28. .set noat
  29. .align 5
  30. NESTED(simIRQ, PT_SIZE, sp)
  31. SAVE_ALL
  32. CLI
  33. .set at
  34. mfc0 s0, CP0_CAUSE # get irq bits
  35. mfc0 s1, CP0_STATUS # get irq mask
  36. andi s0, ST0_IM # CAUSE.CE may be non-zero!
  37. and s0, s1
  38. #if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
  39. .set mips32
  40. clz a0, s0
  41. .set mips0
  42. negu a0
  43. addu a0, 31-CAUSEB_IP
  44. bltz a0, spurious
  45. #else
  46. beqz s0, spurious
  47. li a0, 7
  48. and t0, s0, 0xf000
  49. sltiu t0, t0, 1
  50. sll t0, 2
  51. subu a0, t0
  52. sll s0, t0
  53. and t0, s0, 0xc000
  54. sltiu t0, t0, 1
  55. sll t0, 1
  56. subu a0, t0
  57. sll s0, t0
  58. and t0, s0, 0x8000
  59. sltiu t0, t0, 1
  60. # sll t0, 0
  61. subu a0, t0
  62. # sll s0, t0
  63. #endif
  64. #ifdef CASCADE_IRQ
  65. li a1, CASCADE_IRQ
  66. bne a0, a1, 1f
  67. addu a0, MIPSCPU_INT_BASE
  68. jal CASCADE_DISPATCH
  69. move a0, sp
  70. j ret_from_irq
  71. nop
  72. 1:
  73. #else
  74. addu a0, MIPSCPU_INT_BASE
  75. #endif
  76. jal do_IRQ
  77. move a1, sp
  78. j ret_from_irq
  79. nop
  80. spurious:
  81. j spurious_interrupt
  82. nop
  83. END(simIRQ)