irqflags.h 1.6 KB

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