irqflags.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright (C) 2004-2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_AVR32_IRQFLAGS_H
  9. #define __ASM_AVR32_IRQFLAGS_H
  10. #include <linux/types.h>
  11. #include <asm/sysreg.h>
  12. static inline unsigned long arch_local_save_flags(void)
  13. {
  14. return sysreg_read(SR);
  15. }
  16. /*
  17. * This will restore ALL status register flags, not only the interrupt
  18. * mask flag.
  19. *
  20. * The empty asm statement informs the compiler of this fact while
  21. * also serving as a barrier.
  22. */
  23. static inline void arch_local_irq_restore(unsigned long flags)
  24. {
  25. sysreg_write(SR, flags);
  26. asm volatile("" : : : "memory", "cc");
  27. }
  28. static inline void arch_local_irq_disable(void)
  29. {
  30. asm volatile("ssrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory");
  31. }
  32. static inline void arch_local_irq_enable(void)
  33. {
  34. asm volatile("csrf %0" : : "n"(SYSREG_GM_OFFSET) : "memory");
  35. }
  36. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  37. {
  38. return (flags & SYSREG_BIT(GM)) != 0;
  39. }
  40. static inline bool arch_irqs_disabled(void)
  41. {
  42. return arch_irqs_disabled_flags(arch_local_save_flags());
  43. }
  44. static inline unsigned long arch_local_irq_save(void)
  45. {
  46. unsigned long flags = arch_local_save_flags();
  47. arch_local_irq_disable();
  48. return flags;
  49. }
  50. #endif /* __ASM_AVR32_IRQFLAGS_H */