irq.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #ifndef _ASM_ARCH_IRQ_H
  2. #define _ASM_ARCH_IRQ_H
  3. #include <hwregs/intr_vect.h>
  4. /* Number of non-cpu interrupts. */
  5. #define NR_IRQS NBR_INTR_VECT /* Exceptions + IRQs */
  6. #define FIRST_IRQ 0x31 /* Exception number for first IRQ */
  7. #define NR_REAL_IRQS (NBR_INTR_VECT - FIRST_IRQ) /* IRQs */
  8. #if NR_REAL_IRQS > 32
  9. #define MACH_IRQS 64
  10. #else
  11. #define MACH_IRQS 32
  12. #endif
  13. #ifndef __ASSEMBLY__
  14. /* Global IRQ vector. */
  15. typedef void (*irqvectptr)(void);
  16. struct etrax_interrupt_vector {
  17. irqvectptr v[256];
  18. };
  19. extern struct etrax_interrupt_vector *etrax_irv; /* head.S */
  20. void mask_irq(int irq);
  21. void unmask_irq(int irq);
  22. void set_exception_vector(int n, irqvectptr addr);
  23. /* Save registers so that they match pt_regs. */
  24. #define SAVE_ALL \
  25. "subq 12,$sp\n\t" \
  26. "move $erp,[$sp]\n\t" \
  27. "subq 4,$sp\n\t" \
  28. "move $srp,[$sp]\n\t" \
  29. "subq 4,$sp\n\t" \
  30. "move $ccs,[$sp]\n\t" \
  31. "subq 4,$sp\n\t" \
  32. "move $spc,[$sp]\n\t" \
  33. "subq 4,$sp\n\t" \
  34. "move $mof,[$sp]\n\t" \
  35. "subq 4,$sp\n\t" \
  36. "move $srs,[$sp]\n\t" \
  37. "subq 4,$sp\n\t" \
  38. "move.d $acr,[$sp]\n\t" \
  39. "subq 14*4,$sp\n\t" \
  40. "movem $r13,[$sp]\n\t" \
  41. "subq 4,$sp\n\t" \
  42. "move.d $r10,[$sp]\n"
  43. #define STR2(x) #x
  44. #define STR(x) STR2(x)
  45. #define IRQ_NAME2(nr) nr##_interrupt(void)
  46. #define IRQ_NAME(nr) IRQ_NAME2(IRQ##nr)
  47. /*
  48. * The reason for setting the S-bit when debugging the kernel is that we want
  49. * hardware breakpoints to remain active while we are in an exception handler.
  50. * Note that we cannot simply copy S1, since we may come here from user-space,
  51. * or any context where the S-bit wasn't set.
  52. */
  53. #ifdef CONFIG_ETRAX_KGDB
  54. #define KGDB_FIXUP \
  55. "move $ccs, $r10\n\t" \
  56. "or.d (1<<9), $r10\n\t" \
  57. "move $r10, $ccs\n\t"
  58. #else
  59. #define KGDB_FIXUP ""
  60. #endif
  61. /*
  62. * Make sure the causing IRQ is blocked, then call do_IRQ. After that, unblock
  63. * and jump to ret_from_intr which is found in entry.S.
  64. *
  65. * The reason for blocking the IRQ is to allow an sti() before the handler,
  66. * which will acknowledge the interrupt, is run. The actual blocking is made
  67. * by crisv32_do_IRQ.
  68. */
  69. #define BUILD_IRQ(nr) \
  70. void IRQ_NAME(nr); \
  71. __asm__ ( \
  72. ".text\n\t" \
  73. "IRQ" #nr "_interrupt:\n\t" \
  74. SAVE_ALL \
  75. KGDB_FIXUP \
  76. "move.d "#nr",$r10\n\t" \
  77. "move.d $sp, $r12\n\t" \
  78. "jsr crisv32_do_IRQ\n\t" \
  79. "moveq 1, $r11\n\t" \
  80. "jump ret_from_intr\n\t" \
  81. "nop\n\t");
  82. /*
  83. * This is subtle. The timer interrupt is crucial and it should not be disabled
  84. * for too long. However, if it had been a normal interrupt as per BUILD_IRQ, it
  85. * would have been BLOCK'ed, and then softirq's are run before we return here to
  86. * UNBLOCK. If the softirq's take too much time to run, the timer irq won't run
  87. * and the watchdog will kill us.
  88. *
  89. * Furthermore, if a lot of other irq's occur before we return here, the
  90. * multiple_irq handler is run and it prioritizes the timer interrupt. However
  91. * if we had BLOCK'edit here, we would not get the multiple_irq at all.
  92. *
  93. * The non-blocking here is based on the knowledge that the timer interrupt is
  94. * registred as a fast interrupt (IRQF_DISABLED) so that we _know_ there will not
  95. * be an sti() before the timer irq handler is run to acknowledge the interrupt.
  96. */
  97. #define BUILD_TIMER_IRQ(nr, mask) \
  98. void IRQ_NAME(nr); \
  99. __asm__ ( \
  100. ".text\n\t" \
  101. "IRQ" #nr "_interrupt:\n\t" \
  102. SAVE_ALL \
  103. KGDB_FIXUP \
  104. "move.d "#nr",$r10\n\t" \
  105. "move.d $sp,$r12\n\t" \
  106. "jsr crisv32_do_IRQ\n\t" \
  107. "moveq 0,$r11\n\t" \
  108. "jump ret_from_intr\n\t" \
  109. "nop\n\t");
  110. #endif /* __ASSEMBLY__ */
  111. #endif /* _ASM_ARCH_IRQ_H */