irqflags.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (C) 2006 Atmark Techno, Inc.
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. */
  8. #ifndef _ASM_MICROBLAZE_IRQFLAGS_H
  9. #define _ASM_MICROBLAZE_IRQFLAGS_H
  10. #include <linux/irqflags.h>
  11. # if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
  12. # define local_irq_save(flags) \
  13. do { \
  14. asm volatile ("# local_irq_save \n\t" \
  15. "msrclr %0, %1 \n\t" \
  16. "nop \n\t" \
  17. : "=r"(flags) \
  18. : "i"(MSR_IE) \
  19. : "memory"); \
  20. } while (0)
  21. # define local_irq_disable() \
  22. do { \
  23. asm volatile ("# local_irq_disable \n\t" \
  24. "msrclr r0, %0 \n\t" \
  25. "nop \n\t" \
  26. : \
  27. : "i"(MSR_IE) \
  28. : "memory"); \
  29. } while (0)
  30. # define local_irq_enable() \
  31. do { \
  32. asm volatile ("# local_irq_enable \n\t" \
  33. "msrset r0, %0 \n\t" \
  34. "nop \n\t" \
  35. : \
  36. : "i"(MSR_IE) \
  37. : "memory"); \
  38. } while (0)
  39. # else /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 0 */
  40. # define local_irq_save(flags) \
  41. do { \
  42. register unsigned tmp; \
  43. asm volatile ("# local_irq_save \n\t" \
  44. "mfs %0, rmsr \n\t" \
  45. "nop \n\t" \
  46. "andi %1, %0, %2 \n\t" \
  47. "mts rmsr, %1 \n\t" \
  48. "nop \n\t" \
  49. : "=r"(flags), "=r" (tmp) \
  50. : "i"(~MSR_IE) \
  51. : "memory"); \
  52. } while (0)
  53. # define local_irq_disable() \
  54. do { \
  55. register unsigned tmp; \
  56. asm volatile ("# local_irq_disable \n\t" \
  57. "mfs %0, rmsr \n\t" \
  58. "nop \n\t" \
  59. "andi %0, %0, %1 \n\t" \
  60. "mts rmsr, %0 \n\t" \
  61. "nop \n\t" \
  62. : "=r"(tmp) \
  63. : "i"(~MSR_IE) \
  64. : "memory"); \
  65. } while (0)
  66. # define local_irq_enable() \
  67. do { \
  68. register unsigned tmp; \
  69. asm volatile ("# local_irq_enable \n\t" \
  70. "mfs %0, rmsr \n\t" \
  71. "nop \n\t" \
  72. "ori %0, %0, %1 \n\t" \
  73. "mts rmsr, %0 \n\t" \
  74. "nop \n\t" \
  75. : "=r"(tmp) \
  76. : "i"(MSR_IE) \
  77. : "memory"); \
  78. } while (0)
  79. # endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */
  80. #define local_save_flags(flags) \
  81. do { \
  82. asm volatile ("# local_save_flags \n\t" \
  83. "mfs %0, rmsr \n\t" \
  84. "nop \n\t" \
  85. : "=r"(flags) \
  86. : \
  87. : "memory"); \
  88. } while (0)
  89. #define local_irq_restore(flags) \
  90. do { \
  91. asm volatile ("# local_irq_restore \n\t"\
  92. "mts rmsr, %0 \n\t" \
  93. "nop \n\t" \
  94. : \
  95. : "r"(flags) \
  96. : "memory"); \
  97. } while (0)
  98. static inline int irqs_disabled(void)
  99. {
  100. unsigned long flags;
  101. local_save_flags(flags);
  102. return ((flags & MSR_IE) == 0);
  103. }
  104. #define raw_irqs_disabled irqs_disabled
  105. #define raw_irqs_disabled_flags(flags) ((flags) == 0)
  106. #endif /* _ASM_MICROBLAZE_IRQFLAGS_H */