irqflags.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright IBM Corp. 2006, 2010
  3. * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
  4. */
  5. #ifndef __ASM_IRQFLAGS_H
  6. #define __ASM_IRQFLAGS_H
  7. #include <linux/types.h>
  8. #define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8))
  9. /* store then OR system mask. */
  10. #define __arch_local_irq_stosm(__or) \
  11. ({ \
  12. unsigned long __mask; \
  13. asm volatile( \
  14. " stosm %0,%1" \
  15. : "=Q" (__mask) : "i" (__or) : "memory"); \
  16. __mask; \
  17. })
  18. /* store then AND system mask. */
  19. #define __arch_local_irq_stnsm(__and) \
  20. ({ \
  21. unsigned long __mask; \
  22. asm volatile( \
  23. " stnsm %0,%1" \
  24. : "=Q" (__mask) : "i" (__and) : "memory"); \
  25. __mask; \
  26. })
  27. /* set system mask. */
  28. static inline notrace void __arch_local_irq_ssm(unsigned long flags)
  29. {
  30. asm volatile("ssm %0" : : "Q" (flags) : "memory");
  31. }
  32. static inline notrace unsigned long arch_local_save_flags(void)
  33. {
  34. return __arch_local_irq_stnsm(0xff);
  35. }
  36. static inline notrace unsigned long arch_local_irq_save(void)
  37. {
  38. return __arch_local_irq_stnsm(0xfc);
  39. }
  40. static inline notrace void arch_local_irq_disable(void)
  41. {
  42. arch_local_irq_save();
  43. }
  44. static inline notrace void arch_local_irq_enable(void)
  45. {
  46. __arch_local_irq_stosm(0x03);
  47. }
  48. /* This only restores external and I/O interrupt state */
  49. static inline notrace void arch_local_irq_restore(unsigned long flags)
  50. {
  51. /* only disabled->disabled and disabled->enabled is valid */
  52. if (flags & ARCH_IRQ_ENABLED)
  53. arch_local_irq_enable();
  54. }
  55. static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
  56. {
  57. return !(flags & ARCH_IRQ_ENABLED);
  58. }
  59. static inline notrace bool arch_irqs_disabled(void)
  60. {
  61. return arch_irqs_disabled_flags(arch_local_save_flags());
  62. }
  63. #endif /* __ASM_IRQFLAGS_H */