irqflags_64.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * include/asm/irqflags.h
  3. *
  4. * IRQ flags handling
  5. *
  6. * This file gets included from lowlevel asm headers too, to provide
  7. * wrapped versions of the local_irq_*() APIs, based on the
  8. * raw_local_irq_*() functions from the lowlevel headers.
  9. */
  10. #ifndef _ASM_IRQFLAGS_H
  11. #define _ASM_IRQFLAGS_H
  12. #include <asm/pil.h>
  13. #ifndef __ASSEMBLY__
  14. static inline unsigned long __raw_local_save_flags(void)
  15. {
  16. unsigned long flags;
  17. __asm__ __volatile__(
  18. "rdpr %%pil, %0"
  19. : "=r" (flags)
  20. );
  21. return flags;
  22. }
  23. #define raw_local_save_flags(flags) \
  24. do { (flags) = __raw_local_save_flags(); } while (0)
  25. static inline void raw_local_irq_restore(unsigned long flags)
  26. {
  27. __asm__ __volatile__(
  28. "wrpr %0, %%pil"
  29. : /* no output */
  30. : "r" (flags)
  31. : "memory"
  32. );
  33. }
  34. static inline void raw_local_irq_disable(void)
  35. {
  36. __asm__ __volatile__(
  37. "wrpr %0, %%pil"
  38. : /* no outputs */
  39. : "i" (PIL_NORMAL_MAX)
  40. : "memory"
  41. );
  42. }
  43. static inline void raw_local_irq_enable(void)
  44. {
  45. __asm__ __volatile__(
  46. "wrpr 0, %%pil"
  47. : /* no outputs */
  48. : /* no inputs */
  49. : "memory"
  50. );
  51. }
  52. static inline int raw_irqs_disabled_flags(unsigned long flags)
  53. {
  54. return (flags > 0);
  55. }
  56. static inline int raw_irqs_disabled(void)
  57. {
  58. unsigned long flags = __raw_local_save_flags();
  59. return raw_irqs_disabled_flags(flags);
  60. }
  61. /*
  62. * For spinlocks, etc:
  63. */
  64. static inline unsigned long __raw_local_irq_save(void)
  65. {
  66. unsigned long flags = __raw_local_save_flags();
  67. raw_local_irq_disable();
  68. return flags;
  69. }
  70. #define raw_local_irq_save(flags) \
  71. do { (flags) = __raw_local_irq_save(); } while (0)
  72. #endif /* (__ASSEMBLY__) */
  73. #endif /* !(_ASM_IRQFLAGS_H) */