irqflags.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
  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 as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. */
  18. #ifndef _ASM_IRQFLAGS_H
  19. #define _ASM_IRQFLAGS_H
  20. #include <asm/registers.h>
  21. static inline unsigned long arch_local_save_flags(void)
  22. {
  23. return RDCTL(CTL_STATUS);
  24. }
  25. /*
  26. * This will restore ALL status register flags, not only the interrupt
  27. * mask flag.
  28. */
  29. static inline void arch_local_irq_restore(unsigned long flags)
  30. {
  31. WRCTL(CTL_STATUS, flags);
  32. }
  33. static inline void arch_local_irq_disable(void)
  34. {
  35. unsigned long flags;
  36. flags = arch_local_save_flags();
  37. arch_local_irq_restore(flags & ~STATUS_PIE);
  38. }
  39. static inline void arch_local_irq_enable(void)
  40. {
  41. unsigned long flags;
  42. flags = arch_local_save_flags();
  43. arch_local_irq_restore(flags | STATUS_PIE);
  44. }
  45. static inline int arch_irqs_disabled_flags(unsigned long flags)
  46. {
  47. return (flags & STATUS_PIE) == 0;
  48. }
  49. static inline int arch_irqs_disabled(void)
  50. {
  51. return arch_irqs_disabled_flags(arch_local_save_flags());
  52. }
  53. static inline unsigned long arch_local_irq_save(void)
  54. {
  55. unsigned long flags;
  56. flags = arch_local_save_flags();
  57. arch_local_irq_restore(flags & ~STATUS_PIE);
  58. return flags;
  59. }
  60. #endif /* _ASM_IRQFLAGS_H */