irqflags.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /* store then OR system mask. */
  9. #define __arch_local_irq_stosm(__or) \
  10. ({ \
  11. unsigned long __mask; \
  12. asm volatile( \
  13. " stosm %0,%1" \
  14. : "=Q" (__mask) : "i" (__or) : "memory"); \
  15. __mask; \
  16. })
  17. /* store then AND system mask. */
  18. #define __arch_local_irq_stnsm(__and) \
  19. ({ \
  20. unsigned long __mask; \
  21. asm volatile( \
  22. " stnsm %0,%1" \
  23. : "=Q" (__mask) : "i" (__and) : "memory"); \
  24. __mask; \
  25. })
  26. /* set system mask. */
  27. static inline void __arch_local_irq_ssm(unsigned long flags)
  28. {
  29. asm volatile("ssm %0" : : "Q" (flags) : "memory");
  30. }
  31. static inline unsigned long arch_local_save_flags(void)
  32. {
  33. return __arch_local_irq_stosm(0x00);
  34. }
  35. static inline unsigned long arch_local_irq_save(void)
  36. {
  37. return __arch_local_irq_stnsm(0xfc);
  38. }
  39. static inline void arch_local_irq_disable(void)
  40. {
  41. arch_local_irq_save();
  42. }
  43. static inline void arch_local_irq_enable(void)
  44. {
  45. __arch_local_irq_stosm(0x03);
  46. }
  47. static inline void arch_local_irq_restore(unsigned long flags)
  48. {
  49. __arch_local_irq_ssm(flags);
  50. }
  51. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  52. {
  53. return !(flags & (3UL << (BITS_PER_LONG - 8)));
  54. }
  55. static inline bool arch_irqs_disabled(void)
  56. {
  57. return arch_irqs_disabled_flags(arch_local_save_flags());
  58. }
  59. #endif /* __ASM_IRQFLAGS_H */