irqflags.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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/types.h>
  11. #include <asm/registers.h>
  12. #if CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR
  13. static inline notrace unsigned long arch_local_irq_save(void)
  14. {
  15. unsigned long flags;
  16. asm volatile(" msrclr %0, %1 \n"
  17. " nop \n"
  18. : "=r"(flags)
  19. : "i"(MSR_IE)
  20. : "memory");
  21. return flags;
  22. }
  23. static inline notrace void arch_local_irq_disable(void)
  24. {
  25. /* this uses r0 without declaring it - is that correct? */
  26. asm volatile(" msrclr r0, %0 \n"
  27. " nop \n"
  28. :
  29. : "i"(MSR_IE)
  30. : "memory");
  31. }
  32. static inline notrace void arch_local_irq_enable(void)
  33. {
  34. /* this uses r0 without declaring it - is that correct? */
  35. asm volatile(" msrset r0, %0 \n"
  36. " nop \n"
  37. :
  38. : "i"(MSR_IE)
  39. : "memory");
  40. }
  41. #else /* !CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */
  42. static inline notrace unsigned long arch_local_irq_save(void)
  43. {
  44. unsigned long flags, tmp;
  45. asm volatile (" mfs %0, rmsr \n"
  46. " nop \n"
  47. " andi %1, %0, %2 \n"
  48. " mts rmsr, %1 \n"
  49. " nop \n"
  50. : "=r"(flags), "=r"(tmp)
  51. : "i"(~MSR_IE)
  52. : "memory");
  53. return flags;
  54. }
  55. static inline notrace void arch_local_irq_disable(void)
  56. {
  57. unsigned long tmp;
  58. asm volatile(" mfs %0, rmsr \n"
  59. " nop \n"
  60. " andi %0, %0, %1 \n"
  61. " mts rmsr, %0 \n"
  62. " nop \n"
  63. : "=r"(tmp)
  64. : "i"(~MSR_IE)
  65. : "memory");
  66. }
  67. static inline notrace void arch_local_irq_enable(void)
  68. {
  69. unsigned long tmp;
  70. asm volatile(" mfs %0, rmsr \n"
  71. " nop \n"
  72. " ori %0, %0, %1 \n"
  73. " mts rmsr, %0 \n"
  74. " nop \n"
  75. : "=r"(tmp)
  76. : "i"(MSR_IE)
  77. : "memory");
  78. }
  79. #endif /* CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR */
  80. static inline notrace unsigned long arch_local_save_flags(void)
  81. {
  82. unsigned long flags;
  83. asm volatile(" mfs %0, rmsr \n"
  84. " nop \n"
  85. : "=r"(flags)
  86. :
  87. : "memory");
  88. return flags;
  89. }
  90. static inline notrace void arch_local_irq_restore(unsigned long flags)
  91. {
  92. asm volatile(" mts rmsr, %0 \n"
  93. " nop \n"
  94. :
  95. : "r"(flags)
  96. : "memory");
  97. }
  98. static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
  99. {
  100. return (flags & MSR_IE) == 0;
  101. }
  102. static inline notrace bool arch_irqs_disabled(void)
  103. {
  104. return arch_irqs_disabled_flags(arch_local_save_flags());
  105. }
  106. #endif /* _ASM_MICROBLAZE_IRQFLAGS_H */