irqflags.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #include <asm/registers.h>
  12. # if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
  13. # define raw_local_irq_save(flags) \
  14. do { \
  15. asm volatile (" msrclr %0, %1; \
  16. nop;" \
  17. : "=r"(flags) \
  18. : "i"(MSR_IE) \
  19. : "memory"); \
  20. } while (0)
  21. # define raw_local_irq_disable() \
  22. do { \
  23. asm volatile (" msrclr r0, %0; \
  24. nop;" \
  25. : \
  26. : "i"(MSR_IE) \
  27. : "memory"); \
  28. } while (0)
  29. # define raw_local_irq_enable() \
  30. do { \
  31. asm volatile (" msrset r0, %0; \
  32. nop;" \
  33. : \
  34. : "i"(MSR_IE) \
  35. : "memory"); \
  36. } while (0)
  37. # else /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR == 0 */
  38. # define raw_local_irq_save(flags) \
  39. do { \
  40. register unsigned tmp; \
  41. asm volatile (" mfs %0, rmsr; \
  42. nop; \
  43. andi %1, %0, %2; \
  44. mts rmsr, %1; \
  45. nop;" \
  46. : "=r"(flags), "=r" (tmp) \
  47. : "i"(~MSR_IE) \
  48. : "memory"); \
  49. } while (0)
  50. # define raw_local_irq_disable() \
  51. do { \
  52. register unsigned tmp; \
  53. asm volatile (" mfs %0, rmsr; \
  54. nop; \
  55. andi %0, %0, %1; \
  56. mts rmsr, %0; \
  57. nop;" \
  58. : "=r"(tmp) \
  59. : "i"(~MSR_IE) \
  60. : "memory"); \
  61. } while (0)
  62. # define raw_local_irq_enable() \
  63. do { \
  64. register unsigned tmp; \
  65. asm volatile (" mfs %0, rmsr; \
  66. nop; \
  67. ori %0, %0, %1; \
  68. mts rmsr, %0; \
  69. nop;" \
  70. : "=r"(tmp) \
  71. : "i"(MSR_IE) \
  72. : "memory"); \
  73. } while (0)
  74. # endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */
  75. #define raw_local_irq_restore(flags) \
  76. do { \
  77. asm volatile (" mts rmsr, %0; \
  78. nop;" \
  79. : \
  80. : "r"(flags) \
  81. : "memory"); \
  82. } while (0)
  83. static inline unsigned long get_msr(void)
  84. {
  85. unsigned long flags;
  86. asm volatile (" mfs %0, rmsr; \
  87. nop;" \
  88. : "=r"(flags) \
  89. : \
  90. : "memory"); \
  91. return flags;
  92. }
  93. #define raw_local_save_flags(flags) ((flags) = get_msr())
  94. #define raw_irqs_disabled() ((get_msr() & MSR_IE) == 0)
  95. #define raw_irqs_disabled_flags(flags) ((flags & MSR_IE) == 0)
  96. #endif /* _ASM_MICROBLAZE_IRQFLAGS_H */