irqflags_64.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. * arch_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 notrace unsigned long arch_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. static inline notrace void arch_local_irq_restore(unsigned long flags)
  24. {
  25. __asm__ __volatile__(
  26. "wrpr %0, %%pil"
  27. : /* no output */
  28. : "r" (flags)
  29. : "memory"
  30. );
  31. }
  32. static inline notrace void arch_local_irq_disable(void)
  33. {
  34. __asm__ __volatile__(
  35. "wrpr %0, %%pil"
  36. : /* no outputs */
  37. : "i" (PIL_NORMAL_MAX)
  38. : "memory"
  39. );
  40. }
  41. static inline notrace void arch_local_irq_enable(void)
  42. {
  43. __asm__ __volatile__(
  44. "wrpr 0, %%pil"
  45. : /* no outputs */
  46. : /* no inputs */
  47. : "memory"
  48. );
  49. }
  50. static inline notrace int arch_irqs_disabled_flags(unsigned long flags)
  51. {
  52. return (flags > 0);
  53. }
  54. static inline notrace int arch_irqs_disabled(void)
  55. {
  56. return arch_irqs_disabled_flags(arch_local_save_flags());
  57. }
  58. static inline notrace unsigned long arch_local_irq_save(void)
  59. {
  60. unsigned long flags, tmp;
  61. /* Disable interrupts to PIL_NORMAL_MAX unless we already
  62. * are using PIL_NMI, in which case PIL_NMI is retained.
  63. *
  64. * The only values we ever program into the %pil are 0,
  65. * PIL_NORMAL_MAX and PIL_NMI.
  66. *
  67. * Since PIL_NMI is the largest %pil value and all bits are
  68. * set in it (0xf), it doesn't matter what PIL_NORMAL_MAX
  69. * actually is.
  70. */
  71. __asm__ __volatile__(
  72. "rdpr %%pil, %0\n\t"
  73. "or %0, %2, %1\n\t"
  74. "wrpr %1, 0x0, %%pil"
  75. : "=r" (flags), "=r" (tmp)
  76. : "i" (PIL_NORMAL_MAX)
  77. : "memory"
  78. );
  79. return flags;
  80. }
  81. #endif /* (__ASSEMBLY__) */
  82. #endif /* !(_ASM_IRQFLAGS_H) */