irqflags.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * include/asm-x86_64/irqflags.h
  3. *
  4. * IRQ flags handling
  5. *
  6. * This file gets included from lowlevel asm headers too, to provide
  7. * wrapped versions of the local_irq_*() APIs, based on the
  8. * raw_local_irq_*() macros from the lowlevel headers.
  9. */
  10. #ifndef _ASM_IRQFLAGS_H
  11. #define _ASM_IRQFLAGS_H
  12. #ifndef __ASSEMBLY__
  13. /* interrupt control.. */
  14. #define raw_local_save_flags(x) do { warn_if_not_ulong(x); __asm__ __volatile__("# save_flags \n\t pushfq ; popq %q0":"=g" (x): /* no input */ :"memory"); } while (0)
  15. #define raw_local_irq_restore(x) __asm__ __volatile__("# restore_flags \n\t pushq %0 ; popfq": /* no output */ :"g" (x):"memory", "cc")
  16. #ifdef CONFIG_X86_VSMP
  17. /* Interrupt control for VSMP architecture */
  18. #define raw_local_irq_disable() do { unsigned long flags; raw_local_save_flags(flags); raw_local_irq_restore((flags & ~(1 << 9)) | (1 << 18)); } while (0)
  19. #define raw_local_irq_enable() do { unsigned long flags; raw_local_save_flags(flags); raw_local_irq_restore((flags | (1 << 9)) & ~(1 << 18)); } while (0)
  20. #define raw_irqs_disabled_flags(flags) \
  21. ({ \
  22. (flags & (1<<18)) || !(flags & (1<<9)); \
  23. })
  24. /* For spinlocks etc */
  25. #define raw_local_irq_save(x) do { raw_local_save_flags(x); raw_local_irq_restore((x & ~(1 << 9)) | (1 << 18)); } while (0)
  26. #else /* CONFIG_X86_VSMP */
  27. #define raw_local_irq_disable() __asm__ __volatile__("cli": : :"memory")
  28. #define raw_local_irq_enable() __asm__ __volatile__("sti": : :"memory")
  29. #define raw_irqs_disabled_flags(flags) \
  30. ({ \
  31. !(flags & (1<<9)); \
  32. })
  33. /* For spinlocks etc */
  34. #define raw_local_irq_save(x) do { warn_if_not_ulong(x); __asm__ __volatile__("# raw_local_irq_save \n\t pushfq ; popq %0 ; cli":"=g" (x): /* no input */ :"memory"); } while (0)
  35. #endif
  36. #define raw_irqs_disabled() \
  37. ({ \
  38. unsigned long flags; \
  39. raw_local_save_flags(flags); \
  40. raw_irqs_disabled_flags(flags); \
  41. })
  42. /* used in the idle loop; sti takes one instruction cycle to complete */
  43. #define raw_safe_halt() __asm__ __volatile__("sti; hlt": : :"memory")
  44. /* used when interrupts are already enabled or to shutdown the processor */
  45. #define halt() __asm__ __volatile__("hlt": : :"memory")
  46. #else /* __ASSEMBLY__: */
  47. # define TRACE_IRQS_ON
  48. # define TRACE_IRQS_OFF
  49. #endif
  50. #endif