hw_irq.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
  3. */
  4. #ifndef _ASM_POWERPC_HW_IRQ_H
  5. #define _ASM_POWERPC_HW_IRQ_H
  6. #ifdef __KERNEL__
  7. #include <linux/errno.h>
  8. #include <linux/compiler.h>
  9. #include <asm/ptrace.h>
  10. #include <asm/processor.h>
  11. #ifdef CONFIG_PPC64
  12. /*
  13. * PACA flags in paca->irq_happened.
  14. *
  15. * This bits are set when interrupts occur while soft-disabled
  16. * and allow a proper replay. Additionally, PACA_IRQ_HARD_DIS
  17. * is set whenever we manually hard disable.
  18. */
  19. #define PACA_IRQ_HARD_DIS 0x01
  20. #define PACA_IRQ_DBELL 0x02
  21. #define PACA_IRQ_EE 0x04
  22. #define PACA_IRQ_DEC 0x08 /* Or FIT */
  23. #define PACA_IRQ_EE_EDGE 0x10 /* BookE only */
  24. #endif /* CONFIG_PPC64 */
  25. #ifndef __ASSEMBLY__
  26. extern void __replay_interrupt(unsigned int vector);
  27. extern void timer_interrupt(struct pt_regs *);
  28. extern void performance_monitor_exception(struct pt_regs *regs);
  29. #ifdef CONFIG_PPC64
  30. #include <asm/paca.h>
  31. static inline unsigned long arch_local_save_flags(void)
  32. {
  33. unsigned long flags;
  34. asm volatile(
  35. "lbz %0,%1(13)"
  36. : "=r" (flags)
  37. : "i" (offsetof(struct paca_struct, soft_enabled)));
  38. return flags;
  39. }
  40. static inline unsigned long arch_local_irq_disable(void)
  41. {
  42. unsigned long flags, zero;
  43. asm volatile(
  44. "li %1,0; lbz %0,%2(13); stb %1,%2(13)"
  45. : "=r" (flags), "=&r" (zero)
  46. : "i" (offsetof(struct paca_struct, soft_enabled))
  47. : "memory");
  48. return flags;
  49. }
  50. extern void arch_local_irq_restore(unsigned long);
  51. static inline void arch_local_irq_enable(void)
  52. {
  53. arch_local_irq_restore(1);
  54. }
  55. static inline unsigned long arch_local_irq_save(void)
  56. {
  57. return arch_local_irq_disable();
  58. }
  59. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  60. {
  61. return flags == 0;
  62. }
  63. static inline bool arch_irqs_disabled(void)
  64. {
  65. return arch_irqs_disabled_flags(arch_local_save_flags());
  66. }
  67. #ifdef CONFIG_PPC_BOOK3E
  68. #define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory");
  69. #define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory");
  70. #else
  71. #define __hard_irq_enable() __mtmsrd(local_paca->kernel_msr | MSR_EE, 1)
  72. #define __hard_irq_disable() __mtmsrd(local_paca->kernel_msr, 1)
  73. #endif
  74. static inline void hard_irq_disable(void)
  75. {
  76. __hard_irq_disable();
  77. get_paca()->soft_enabled = 0;
  78. get_paca()->irq_happened |= PACA_IRQ_HARD_DIS;
  79. }
  80. /* include/linux/interrupt.h needs hard_irq_disable to be a macro */
  81. #define hard_irq_disable hard_irq_disable
  82. /*
  83. * This is called by asynchronous interrupts to conditionally
  84. * re-enable hard interrupts when soft-disabled after having
  85. * cleared the source of the interrupt
  86. */
  87. static inline void may_hard_irq_enable(void)
  88. {
  89. get_paca()->irq_happened &= ~PACA_IRQ_HARD_DIS;
  90. if (!(get_paca()->irq_happened & PACA_IRQ_EE))
  91. __hard_irq_enable();
  92. }
  93. static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
  94. {
  95. return !regs->softe;
  96. }
  97. #else /* CONFIG_PPC64 */
  98. #define SET_MSR_EE(x) mtmsr(x)
  99. static inline unsigned long arch_local_save_flags(void)
  100. {
  101. return mfmsr();
  102. }
  103. static inline void arch_local_irq_restore(unsigned long flags)
  104. {
  105. #if defined(CONFIG_BOOKE)
  106. asm volatile("wrtee %0" : : "r" (flags) : "memory");
  107. #else
  108. mtmsr(flags);
  109. #endif
  110. }
  111. static inline unsigned long arch_local_irq_save(void)
  112. {
  113. unsigned long flags = arch_local_save_flags();
  114. #ifdef CONFIG_BOOKE
  115. asm volatile("wrteei 0" : : : "memory");
  116. #else
  117. SET_MSR_EE(flags & ~MSR_EE);
  118. #endif
  119. return flags;
  120. }
  121. static inline void arch_local_irq_disable(void)
  122. {
  123. #ifdef CONFIG_BOOKE
  124. asm volatile("wrteei 0" : : : "memory");
  125. #else
  126. arch_local_irq_save();
  127. #endif
  128. }
  129. static inline void arch_local_irq_enable(void)
  130. {
  131. #ifdef CONFIG_BOOKE
  132. asm volatile("wrteei 1" : : : "memory");
  133. #else
  134. unsigned long msr = mfmsr();
  135. SET_MSR_EE(msr | MSR_EE);
  136. #endif
  137. }
  138. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  139. {
  140. return (flags & MSR_EE) == 0;
  141. }
  142. static inline bool arch_irqs_disabled(void)
  143. {
  144. return arch_irqs_disabled_flags(arch_local_save_flags());
  145. }
  146. #define hard_irq_disable() arch_local_irq_disable()
  147. static inline bool arch_irq_disabled_regs(struct pt_regs *regs)
  148. {
  149. return !(regs->msr & MSR_EE);
  150. }
  151. static inline void may_hard_irq_enable(void) { }
  152. #endif /* CONFIG_PPC64 */
  153. #define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
  154. /*
  155. * interrupt-retrigger: should we handle this via lost interrupts and IPIs
  156. * or should we not care like we do now ? --BenH.
  157. */
  158. struct irq_chip;
  159. #endif /* __ASSEMBLY__ */
  160. #endif /* __KERNEL__ */
  161. #endif /* _ASM_POWERPC_HW_IRQ_H */