irq.h 3.4 KB

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