irqflags.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 __raw_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 __raw_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. #define __raw_local_irq_ssm(__mask) \
  28. ({ \
  29. asm volatile("ssm %0" : : "Q" (__mask) : "memory"); \
  30. })
  31. /* interrupt control.. */
  32. static inline unsigned long raw_local_irq_enable(void)
  33. {
  34. return __raw_local_irq_stosm(0x03);
  35. }
  36. static inline unsigned long raw_local_irq_disable(void)
  37. {
  38. return __raw_local_irq_stnsm(0xfc);
  39. }
  40. #define raw_local_save_flags(x) \
  41. do { \
  42. typecheck(unsigned long, x); \
  43. (x) = __raw_local_irq_stosm(0x00); \
  44. } while (0)
  45. static inline void raw_local_irq_restore(unsigned long flags)
  46. {
  47. __raw_local_irq_ssm(flags);
  48. }
  49. static inline int raw_irqs_disabled_flags(unsigned long flags)
  50. {
  51. return !(flags & (3UL << (BITS_PER_LONG - 8)));
  52. }
  53. /* For spinlocks etc */
  54. #define raw_local_irq_save(x) ((x) = raw_local_irq_disable())
  55. #endif /* __ASM_IRQFLAGS_H */