irqflags.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef _M68K_IRQFLAGS_H
  2. #define _M68K_IRQFLAGS_H
  3. #include <linux/types.h>
  4. #ifdef CONFIG_MMU
  5. #include <linux/hardirq.h>
  6. #endif
  7. #include <linux/preempt.h>
  8. #include <asm/thread_info.h>
  9. #include <asm/entry.h>
  10. static inline unsigned long arch_local_save_flags(void)
  11. {
  12. unsigned long flags;
  13. asm volatile ("movew %%sr,%0" : "=d" (flags) : : "memory");
  14. return flags;
  15. }
  16. static inline void arch_local_irq_disable(void)
  17. {
  18. #ifdef CONFIG_COLDFIRE
  19. asm volatile (
  20. "move %/sr,%%d0 \n\t"
  21. "ori.l #0x0700,%%d0 \n\t"
  22. "move %%d0,%/sr \n"
  23. : /* no outputs */
  24. :
  25. : "cc", "%d0", "memory");
  26. #else
  27. asm volatile ("oriw #0x0700,%%sr" : : : "memory");
  28. #endif
  29. }
  30. static inline void arch_local_irq_enable(void)
  31. {
  32. #if defined(CONFIG_COLDFIRE)
  33. asm volatile (
  34. "move %/sr,%%d0 \n\t"
  35. "andi.l #0xf8ff,%%d0 \n\t"
  36. "move %%d0,%/sr \n"
  37. : /* no outputs */
  38. :
  39. : "cc", "%d0", "memory");
  40. #else
  41. # if defined(CONFIG_MMU)
  42. if (MACH_IS_Q40 || !hardirq_count())
  43. # endif
  44. asm volatile (
  45. "andiw %0,%%sr"
  46. :
  47. : "i" (ALLOWINT)
  48. : "memory");
  49. #endif
  50. }
  51. static inline unsigned long arch_local_irq_save(void)
  52. {
  53. unsigned long flags = arch_local_save_flags();
  54. arch_local_irq_disable();
  55. return flags;
  56. }
  57. static inline void arch_local_irq_restore(unsigned long flags)
  58. {
  59. asm volatile ("movew %0,%%sr" : : "d" (flags) : "memory");
  60. }
  61. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  62. {
  63. return (flags & ~ALLOWINT) != 0;
  64. }
  65. static inline bool arch_irqs_disabled(void)
  66. {
  67. return arch_irqs_disabled_flags(arch_local_save_flags());
  68. }
  69. #endif /* _M68K_IRQFLAGS_H */