irqflags.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifdef CONFIG_IA64_DEBUG_IRQ
  12. extern unsigned long last_cli_ip;
  13. static inline void arch_maybe_save_ip(unsigned long flags)
  14. {
  15. if (flags & IA64_PSR_I)
  16. last_cli_ip = ia64_getreg(_IA64_REG_IP);
  17. }
  18. #else
  19. #define arch_maybe_save_ip(flags) do {} while (0)
  20. #endif
  21. /*
  22. * - clearing psr.i is implicitly serialized (visible by next insn)
  23. * - setting psr.i requires data serialization
  24. * - we need a stop-bit before reading PSR because we sometimes
  25. * write a floating-point register right before reading the PSR
  26. * and that writes to PSR.mfl
  27. */
  28. static inline unsigned long arch_local_save_flags(void)
  29. {
  30. ia64_stop();
  31. #ifdef CONFIG_PARAVIRT
  32. return ia64_get_psr_i();
  33. #else
  34. return ia64_getreg(_IA64_REG_PSR);
  35. #endif
  36. }
  37. static inline unsigned long arch_local_irq_save(void)
  38. {
  39. unsigned long flags = arch_local_save_flags();
  40. ia64_stop();
  41. ia64_rsm(IA64_PSR_I);
  42. arch_maybe_save_ip(flags);
  43. return flags;
  44. }
  45. static inline void arch_local_irq_disable(void)
  46. {
  47. #ifdef CONFIG_IA64_DEBUG_IRQ
  48. arch_local_irq_save();
  49. #else
  50. ia64_stop();
  51. ia64_rsm(IA64_PSR_I);
  52. #endif
  53. }
  54. static inline void arch_local_irq_enable(void)
  55. {
  56. ia64_stop();
  57. ia64_ssm(IA64_PSR_I);
  58. ia64_srlz_d();
  59. }
  60. static inline void arch_local_irq_restore(unsigned long flags)
  61. {
  62. #ifdef CONFIG_IA64_DEBUG_IRQ
  63. unsigned long old_psr = arch_local_save_flags();
  64. #endif
  65. ia64_intrin_local_irq_restore(flags & IA64_PSR_I);
  66. arch_maybe_save_ip(old_psr & ~flags);
  67. }
  68. static inline bool arch_irqs_disabled_flags(unsigned long flags)
  69. {
  70. return (flags & IA64_PSR_I) == 0;
  71. }
  72. static inline bool arch_irqs_disabled(void)
  73. {
  74. return arch_irqs_disabled_flags(arch_local_save_flags());
  75. }
  76. static inline void arch_safe_halt(void)
  77. {
  78. ia64_pal_halt_light(); /* PAL_HALT_LIGHT */
  79. }
  80. #endif /* _ASM_IA64_IRQFLAGS_H */