irqflags.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __PARISC_IRQFLAGS_H
  3. #define __PARISC_IRQFLAGS_H
  4. #include <linux/types.h>
  5. #include <asm/psw.h>
  6. static inline unsigned long arch_local_save_flags(void)
  7. {
  8. unsigned long flags;
  9. asm volatile("ssm 0, %0" : "=r" (flags) : : "memory");
  10. return flags;
  11. }
  12. static inline void arch_local_irq_disable(void)
  13. {
  14. asm volatile("rsm %0,%%r0\n" : : "i" (PSW_I) : "memory");
  15. }
  16. static inline void arch_local_irq_enable(void)
  17. {
  18. asm volatile("ssm %0,%%r0\n" : : "i" (PSW_I) : "memory");
  19. }
  20. static inline unsigned long arch_local_irq_save(void)
  21. {
  22. unsigned long flags;
  23. asm volatile("rsm %1,%0" : "=r" (flags) : "i" (PSW_I) : "memory");
  24. return flags;
  25. }
  26. static inline void arch_local_irq_restore(unsigned long flags)
  27. {
  28. /* warn if IRQs are on although they should be off */
  29. if (IS_ENABLED(CONFIG_LIGHTWEIGHT_SPINLOCK_CHECK))
  30. if (arch_local_save_flags() & PSW_I)
  31. asm volatile("break 6,6\n"); /* SPINLOCK_BREAK_INSN */
  32. asm volatile("mtsm %0" : : "r" (flags) : "memory");
  33. }
  34. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  35. {
  36. return (flags & PSW_I) == 0;
  37. }
  38. static inline bool arch_irqs_disabled(void)
  39. {
  40. return arch_irqs_disabled_flags(arch_local_save_flags());
  41. }
  42. #endif /* __PARISC_IRQFLAGS_H */