interrupt.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003 by Ralf Baechle
  7. * Copyright (C) 1996 by Paul M. Antoine
  8. * Copyright (C) 1999 Silicon Graphics
  9. * Copyright (C) 2000 MIPS Technologies, Inc.
  10. */
  11. #ifndef _ASM_INTERRUPT_H
  12. #define _ASM_INTERRUPT_H
  13. #include <linux/config.h>
  14. #include <asm/hazards.h>
  15. __asm__ (
  16. " .macro local_irq_enable \n"
  17. " .set push \n"
  18. " .set reorder \n"
  19. " .set noat \n"
  20. #ifdef CONFIG_CPU_MIPSR2
  21. " ei \n"
  22. #else
  23. " mfc0 $1,$12 \n"
  24. " ori $1,0x1f \n"
  25. " xori $1,0x1e \n"
  26. " mtc0 $1,$12 \n"
  27. #endif
  28. " irq_enable_hazard \n"
  29. " .set pop \n"
  30. " .endm");
  31. static inline void local_irq_enable(void)
  32. {
  33. __asm__ __volatile__(
  34. "local_irq_enable"
  35. : /* no outputs */
  36. : /* no inputs */
  37. : "memory");
  38. }
  39. /*
  40. * For cli() we have to insert nops to make sure that the new value
  41. * has actually arrived in the status register before the end of this
  42. * macro.
  43. * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
  44. * no nops at all.
  45. */
  46. /*
  47. * For TX49, operating only IE bit is not enough.
  48. *
  49. * If mfc0 $12 follows store and the mfc0 is last instruction of a
  50. * page and fetching the next instruction causes TLB miss, the result
  51. * of the mfc0 might wrongly contain EXL bit.
  52. *
  53. * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
  54. *
  55. * Workaround: mask EXL bit of the result or place a nop before mfc0.
  56. */
  57. __asm__ (
  58. " .macro local_irq_disable\n"
  59. " .set push \n"
  60. " .set noat \n"
  61. #ifdef CONFIG_CPU_MIPSR2
  62. " di \n"
  63. #else
  64. " mfc0 $1,$12 \n"
  65. " ori $1,0x1f \n"
  66. " xori $1,0x1f \n"
  67. " .set noreorder \n"
  68. " mtc0 $1,$12 \n"
  69. #endif
  70. " irq_disable_hazard \n"
  71. " .set pop \n"
  72. " .endm \n");
  73. static inline void local_irq_disable(void)
  74. {
  75. __asm__ __volatile__(
  76. "local_irq_disable"
  77. : /* no outputs */
  78. : /* no inputs */
  79. : "memory");
  80. }
  81. __asm__ (
  82. " .macro local_save_flags flags \n"
  83. " .set push \n"
  84. " .set reorder \n"
  85. " mfc0 \\flags, $12 \n"
  86. " .set pop \n"
  87. " .endm \n");
  88. #define local_save_flags(x) \
  89. __asm__ __volatile__( \
  90. "local_save_flags %0" \
  91. : "=r" (x))
  92. __asm__ (
  93. " .macro local_irq_save result \n"
  94. " .set push \n"
  95. " .set reorder \n"
  96. " .set noat \n"
  97. #ifdef CONFIG_CPU_MIPSR2
  98. " di \\result \n"
  99. " andi \\result, 1 \n"
  100. #else
  101. " mfc0 \\result, $12 \n"
  102. " ori $1, \\result, 0x1f \n"
  103. " xori $1, 0x1f \n"
  104. " .set noreorder \n"
  105. " mtc0 $1, $12 \n"
  106. #endif
  107. " irq_disable_hazard \n"
  108. " .set pop \n"
  109. " .endm \n");
  110. #define local_irq_save(x) \
  111. __asm__ __volatile__( \
  112. "local_irq_save\t%0" \
  113. : "=r" (x) \
  114. : /* no inputs */ \
  115. : "memory")
  116. __asm__ (
  117. " .macro local_irq_restore flags \n"
  118. " .set push \n"
  119. " .set noreorder \n"
  120. " .set noat \n"
  121. #if defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
  122. /*
  123. * Slow, but doesn't suffer from a relativly unlikely race
  124. * condition we're having since days 1.
  125. */
  126. " beqz \\flags, 1f \n"
  127. " di \n"
  128. " ei \n"
  129. "1: \n"
  130. #elif defined(CONFIG_CPU_MIPSR2)
  131. /*
  132. * Fast, dangerous. Life is fun, life is good.
  133. */
  134. " mfc0 $1, $12 \n"
  135. " ins $1, \\flags, 0, 1 \n"
  136. " mtc0 $1, $12 \n"
  137. #else
  138. " mfc0 $1, $12 \n"
  139. " andi \\flags, 1 \n"
  140. " ori $1, 0x1f \n"
  141. " xori $1, 0x1f \n"
  142. " or \\flags, $1 \n"
  143. " mtc0 \\flags, $12 \n"
  144. #endif
  145. " irq_disable_hazard \n"
  146. " .set pop \n"
  147. " .endm \n");
  148. #define local_irq_restore(flags) \
  149. do { \
  150. unsigned long __tmp1; \
  151. \
  152. __asm__ __volatile__( \
  153. "local_irq_restore\t%0" \
  154. : "=r" (__tmp1) \
  155. : "0" (flags) \
  156. : "memory"); \
  157. } while(0)
  158. #define irqs_disabled() \
  159. ({ \
  160. unsigned long flags; \
  161. local_save_flags(flags); \
  162. !(flags & 1); \
  163. })
  164. #endif /* _ASM_INTERRUPT_H */