irqflags.h 2.0 KB

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