irqflags.h 2.1 KB

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