irqflags.h 1.6 KB

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