int-handler.S
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #include <asm/asm.h>
  2. #include <asm/mipsregs.h>
  3. #include <asm/regdef.h>
  4. #include <asm/stackframe.h>
  5. .text
  6. .set    mips1
  7. .set    reorder
  8. .set    macro
  9. .set    noat
  10. .align 5
  11. # MIPS has 16 exception vectors numbered 0 to 15
  12. # vector number 0 is for interrupts and the others are for various exceptions
  13. # The following code is installed as the handler for exception 0
  14. # There are 8 possible interrupts that can cause this exception.
  15. # The cause register indicates which are pending
  16. # The status register indicates which are enabled
  17. # This code segment basically will decipher which interrup occurred (7 downto 0)
  18. # and pass an integer indicating which was the highest priority pending interrupt
  19. # to the do_IRQ routine.
  20. NESTED(hpIRQ, PT_SIZE, sp)
  21. SAVE_ALL
  22. CLI # Important: mark KERNEL mode !
  23. /*
  24.  * Get pending interrupts
  25.  */
  26. mfc0 t0,CP0_CAUSE # get pending interrupts
  27. mfc0 t1,CP0_STATUS # get enabled interrupts
  28. and t0,t1 # isolate allowed ones
  29. andi t0,0xff00 # isolate pending bits
  30. sll t0,16 # shift the pending bits down
  31. beqz t0,3f # no pending intrs, then spurious
  32. nop # delay slot
  33. /*
  34.  * Find irq with highest priority
  35.  * FIXME: This is slow - use binary search
  36.  */
  37. la a0,7
  38. 1: bltz t0,2f # found pending irq
  39. subu a0,1
  40. sll t0,1
  41. b 1b
  42. nop # delay slot
  43. call_do_IRQ:
  44. 2: move a1,sp
  45. jal do_IRQ
  46. nop # delay slot
  47. j       ret_from_irq
  48. nop
  49. /*
  50. mfc0 t0,CP0_STATUS # disable interrupts
  51. ori t0,1
  52. xori t0,1
  53. mtc0 t0,CP0_STATUS
  54. la      a1, ret_from_irq
  55. jr a1
  56. */
  57. 3: j spurious_interrupt
  58. END(hpIRQ)