irqflags.h 1.8 KB

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