irqflags.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * include/asm-i386/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. #define raw_local_save_flags(x) do { typecheck(unsigned long,x); __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */); } while (0)
  13. #define raw_local_irq_restore(x) do { typecheck(unsigned long,x); __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc"); } while (0)
  14. #define raw_local_irq_disable() __asm__ __volatile__("cli": : :"memory")
  15. #define raw_local_irq_enable() __asm__ __volatile__("sti": : :"memory")
  16. /* used in the idle loop; sti takes one instruction cycle to complete */
  17. #define raw_safe_halt() __asm__ __volatile__("sti; hlt": : :"memory")
  18. /* used when interrupts are already enabled or to shutdown the processor */
  19. #define halt() __asm__ __volatile__("hlt": : :"memory")
  20. #define raw_irqs_disabled_flags(flags) (!((flags) & (1<<9)))
  21. /* For spinlocks etc */
  22. #define raw_local_irq_save(x) __asm__ __volatile__("pushfl ; popl %0 ; cli":"=g" (x): /* no input */ :"memory")
  23. /*
  24. * Do the CPU's IRQ-state tracing from assembly code. We call a
  25. * C function, so save all the C-clobbered registers:
  26. */
  27. #ifdef CONFIG_TRACE_IRQFLAGS
  28. # define TRACE_IRQS_ON \
  29. pushl %eax; \
  30. pushl %ecx; \
  31. pushl %edx; \
  32. call trace_hardirqs_on; \
  33. popl %edx; \
  34. popl %ecx; \
  35. popl %eax;
  36. # define TRACE_IRQS_OFF \
  37. pushl %eax; \
  38. pushl %ecx; \
  39. pushl %edx; \
  40. call trace_hardirqs_off; \
  41. popl %edx; \
  42. popl %ecx; \
  43. popl %eax;
  44. #else
  45. # define TRACE_IRQS_ON
  46. # define TRACE_IRQS_OFF
  47. #endif
  48. #endif