irqflags.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * include/asm-sparc64/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. #ifndef __ASSEMBLY__
  13. static inline unsigned long __raw_local_save_flags(void)
  14. {
  15. unsigned long flags;
  16. __asm__ __volatile__(
  17. "rdpr %%pil, %0"
  18. : "=r" (flags)
  19. );
  20. return flags;
  21. }
  22. #define raw_local_save_flags(flags) \
  23. do { (flags) = __raw_local_save_flags(); } while (0)
  24. static inline void raw_local_irq_restore(unsigned long flags)
  25. {
  26. __asm__ __volatile__(
  27. "wrpr %0, %%pil"
  28. : /* no output */
  29. : "r" (flags)
  30. : "memory"
  31. );
  32. }
  33. static inline void raw_local_irq_disable(void)
  34. {
  35. __asm__ __volatile__(
  36. "wrpr 15, %%pil"
  37. : /* no outputs */
  38. : /* no inputs */
  39. : "memory"
  40. );
  41. }
  42. static inline void raw_local_irq_enable(void)
  43. {
  44. __asm__ __volatile__(
  45. "wrpr 0, %%pil"
  46. : /* no outputs */
  47. : /* no inputs */
  48. : "memory"
  49. );
  50. }
  51. static inline int raw_irqs_disabled_flags(unsigned long flags)
  52. {
  53. return (flags > 0);
  54. }
  55. static inline int raw_irqs_disabled(void)
  56. {
  57. unsigned long flags = __raw_local_save_flags();
  58. return raw_irqs_disabled_flags(flags);
  59. }
  60. /*
  61. * For spinlocks, etc:
  62. */
  63. static inline unsigned long __raw_local_irq_save(void)
  64. {
  65. unsigned long flags = __raw_local_save_flags();
  66. raw_local_irq_disable();
  67. return flags;
  68. }
  69. #define raw_local_irq_save(flags) \
  70. do { (flags) = __raw_local_irq_save(); } while (0)
  71. #endif /* (__ASSEMBLY__) */
  72. #endif /* !(_ASM_IRQFLAGS_H) */