irqflags.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Xtensa IRQ flags handling functions
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2001 - 2005 Tensilica Inc.
  9. */
  10. #ifndef _XTENSA_IRQFLAGS_H
  11. #define _XTENSA_IRQFLAGS_H
  12. #include <linux/types.h>
  13. static inline unsigned long arch_local_save_flags(void)
  14. {
  15. unsigned long flags;
  16. asm volatile("rsr %0,"__stringify(PS) : "=a" (flags));
  17. return flags;
  18. }
  19. static inline unsigned long arch_local_irq_save(void)
  20. {
  21. unsigned long flags;
  22. asm volatile("rsil %0, "__stringify(LOCKLEVEL)
  23. : "=a" (flags) :: "memory");
  24. return flags;
  25. }
  26. static inline void arch_local_irq_disable(void)
  27. {
  28. arch_local_irq_save();
  29. }
  30. static inline void arch_local_irq_enable(void)
  31. {
  32. unsigned long flags;
  33. asm volatile("rsil %0, 0" : "=a" (flags) :: "memory");
  34. }
  35. static inline void arch_local_irq_restore(unsigned long flags)
  36. {
  37. asm volatile("wsr %0, "__stringify(PS)" ; rsync"
  38. :: "a" (flags) : "memory");
  39. }
  40. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  41. {
  42. return (flags & 0xf) != 0;
  43. }
  44. static inline bool arch_irqs_disabled(void)
  45. {
  46. return arch_irqs_disabled_flags(arch_local_save_flags());
  47. }
  48. #endif /* _XTENSA_IRQFLAGS_H */