irqflags.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef _ASM_SCORE_IRQFLAGS_H
  2. #define _ASM_SCORE_IRQFLAGS_H
  3. #ifndef __ASSEMBLY__
  4. #include <linux/types.h>
  5. static inline unsigned long arch_local_save_flags(void)
  6. {
  7. unsigned long flags;
  8. asm volatile(
  9. " mfcr r8, cr0 \n"
  10. " nop \n"
  11. " nop \n"
  12. " mv %0, r8 \n"
  13. " nop \n"
  14. " nop \n"
  15. " nop \n"
  16. " nop \n"
  17. " nop \n"
  18. " ldi r9, 0x1 \n"
  19. " and %0, %0, r9 \n"
  20. : "=r" (flags)
  21. :
  22. : "r8", "r9");
  23. return flags;
  24. }
  25. static inline unsigned long arch_local_irq_save(void)
  26. {
  27. unsigned long flags;
  28. asm volatile(
  29. " mfcr r8, cr0 \n"
  30. " li r9, 0xfffffffe \n"
  31. " nop \n"
  32. " mv %0, r8 \n"
  33. " and r8, r8, r9 \n"
  34. " mtcr r8, cr0 \n"
  35. " nop \n"
  36. " nop \n"
  37. " nop \n"
  38. " nop \n"
  39. " nop \n"
  40. : "=r" (flags)
  41. :
  42. : "r8", "r9", "memory");
  43. return flags;
  44. }
  45. static inline void arch_local_irq_restore(unsigned long flags)
  46. {
  47. asm volatile(
  48. " mfcr r8, cr0 \n"
  49. " ldi r9, 0x1 \n"
  50. " and %0, %0, r9 \n"
  51. " or r8, r8, %0 \n"
  52. " mtcr r8, cr0 \n"
  53. " nop \n"
  54. " nop \n"
  55. " nop \n"
  56. " nop \n"
  57. " nop \n"
  58. :
  59. : "r"(flags)
  60. : "r8", "r9", "memory");
  61. }
  62. static inline void arch_local_irq_enable(void)
  63. {
  64. asm volatile(
  65. " mfcr r8,cr0 \n"
  66. " nop \n"
  67. " nop \n"
  68. " ori r8,0x1 \n"
  69. " mtcr r8,cr0 \n"
  70. " nop \n"
  71. " nop \n"
  72. " nop \n"
  73. " nop \n"
  74. " nop \n"
  75. :
  76. :
  77. : "r8", "memory");
  78. }
  79. static inline void arch_local_irq_disable(void)
  80. {
  81. asm volatile(
  82. " mfcr r8,cr0 \n"
  83. " nop \n"
  84. " nop \n"
  85. " srli r8,r8,1 \n"
  86. " slli r8,r8,1 \n"
  87. " mtcr r8,cr0 \n"
  88. " nop \n"
  89. " nop \n"
  90. " nop \n"
  91. " nop \n"
  92. " nop \n"
  93. :
  94. :
  95. : "r8", "memory");
  96. }
  97. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  98. {
  99. return !(flags & 1);
  100. }
  101. static inline bool arch_irqs_disabled(void)
  102. {
  103. return arch_irqs_disabled_flags(arch_local_save_flags());
  104. }
  105. #endif /* __ASSEMBLY__ */
  106. #endif /* _ASM_SCORE_IRQFLAGS_H */