irqflags.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <[email protected]>
  7. * Copyright (C) 1999 Asit Mallick <[email protected]>
  8. * Copyright (C) 1999 Don Dugger <[email protected]>
  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. return ia64_getreg(_IA64_REG_PSR);
  35. }
  36. static inline unsigned long arch_local_irq_save(void)
  37. {
  38. unsigned long flags = arch_local_save_flags();
  39. ia64_stop();
  40. ia64_rsm(IA64_PSR_I);
  41. arch_maybe_save_ip(flags);
  42. return flags;
  43. }
  44. static inline void arch_local_irq_disable(void)
  45. {
  46. #ifdef CONFIG_IA64_DEBUG_IRQ
  47. arch_local_irq_save();
  48. #else
  49. ia64_stop();
  50. ia64_rsm(IA64_PSR_I);
  51. #endif
  52. }
  53. static inline void arch_local_irq_enable(void)
  54. {
  55. ia64_stop();
  56. ia64_ssm(IA64_PSR_I);
  57. ia64_srlz_d();
  58. }
  59. static inline void arch_local_irq_restore(unsigned long flags)
  60. {
  61. #ifdef CONFIG_IA64_DEBUG_IRQ
  62. unsigned long old_psr = arch_local_save_flags();
  63. #endif
  64. ia64_intrin_local_irq_restore(flags & IA64_PSR_I);
  65. arch_maybe_save_ip(old_psr & ~flags);
  66. }
  67. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  68. {
  69. return (flags & IA64_PSR_I) == 0;
  70. }
  71. static inline bool arch_irqs_disabled(void)
  72. {
  73. return arch_irqs_disabled_flags(arch_local_save_flags());
  74. }
  75. static inline void arch_safe_halt(void)
  76. {
  77. arch_local_irq_enable();
  78. ia64_pal_halt_light(); /* PAL_HALT_LIGHT */
  79. }
  80. #endif /* _ASM_IA64_IRQFLAGS_H */