irqflags.h 2.5 KB

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