irqflags.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * IRQ flags defines.
  4. *
  5. * Copyright (C) 1998-2003 Hewlett-Packard Co
  6. * David Mosberger-Tang <davidm@hpl.hp.com>
  7. * Copyright (C) 1999 Asit Mallick <asit.k.mallick@intel.com>
  8. * Copyright (C) 1999 Don Dugger <don.dugger@intel.com>
  9. */
  10. #ifndef _ASM_IA64_IRQFLAGS_H
  11. #define _ASM_IA64_IRQFLAGS_H
  12. #include <asm/pal.h>
  13. #include <asm/kregs.h>
  14. #ifdef CONFIG_IA64_DEBUG_IRQ
  15. extern unsigned long last_cli_ip;
  16. static inline void arch_maybe_save_ip(unsigned long flags)
  17. {
  18. if (flags & IA64_PSR_I)
  19. last_cli_ip = ia64_getreg(_IA64_REG_IP);
  20. }
  21. #else
  22. #define arch_maybe_save_ip(flags) do {} while (0)
  23. #endif
  24. /*
  25. * - clearing psr.i is implicitly serialized (visible by next insn)
  26. * - setting psr.i requires data serialization
  27. * - we need a stop-bit before reading PSR because we sometimes
  28. * write a floating-point register right before reading the PSR
  29. * and that writes to PSR.mfl
  30. */
  31. static inline unsigned long arch_local_save_flags(void)
  32. {
  33. ia64_stop();
  34. #ifdef CONFIG_PARAVIRT
  35. return ia64_get_psr_i();
  36. #else
  37. return ia64_getreg(_IA64_REG_PSR);
  38. #endif
  39. }
  40. static inline unsigned long arch_local_irq_save(void)
  41. {
  42. unsigned long flags = arch_local_save_flags();
  43. ia64_stop();
  44. ia64_rsm(IA64_PSR_I);
  45. arch_maybe_save_ip(flags);
  46. return flags;
  47. }
  48. static inline void arch_local_irq_disable(void)
  49. {
  50. #ifdef CONFIG_IA64_DEBUG_IRQ
  51. arch_local_irq_save();
  52. #else
  53. ia64_stop();
  54. ia64_rsm(IA64_PSR_I);
  55. #endif
  56. }
  57. static inline void arch_local_irq_enable(void)
  58. {
  59. ia64_stop();
  60. ia64_ssm(IA64_PSR_I);
  61. ia64_srlz_d();
  62. }
  63. static inline void arch_local_irq_restore(unsigned long flags)
  64. {
  65. #ifdef CONFIG_IA64_DEBUG_IRQ
  66. unsigned long old_psr = arch_local_save_flags();
  67. #endif
  68. ia64_intrin_local_irq_restore(flags & IA64_PSR_I);
  69. arch_maybe_save_ip(old_psr & ~flags);
  70. }
  71. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  72. {
  73. return (flags & IA64_PSR_I) == 0;
  74. }
  75. static inline bool arch_irqs_disabled(void)
  76. {
  77. return arch_irqs_disabled_flags(arch_local_save_flags());
  78. }
  79. static inline void arch_safe_halt(void)
  80. {
  81. arch_local_irq_enable();
  82. ia64_pal_halt_light(); /* PAL_HALT_LIGHT */
  83. }
  84. #endif /* _ASM_IA64_IRQFLAGS_H */