irq.h 3.4 KB

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