irqflags.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * IRQ flags handling
  3. */
  4. #ifndef _ASM_IRQFLAGS_H
  5. #define _ASM_IRQFLAGS_H
  6. #ifndef __ASSEMBLY__
  7. /*
  8. * Get definitions for arch_local_save_flags(x), etc.
  9. */
  10. #include <asm/hw_irq.h>
  11. #else
  12. #ifdef CONFIG_TRACE_IRQFLAGS
  13. #ifdef CONFIG_IRQSOFF_TRACER
  14. /*
  15. * Since the ftrace irqsoff latency trace checks CALLER_ADDR1,
  16. * which is the stack frame here, we need to force a stack frame
  17. * in case we came from user space.
  18. */
  19. #define TRACE_WITH_FRAME_BUFFER(func) \
  20. mflr r0; \
  21. stdu r1, -STACK_FRAME_OVERHEAD(r1); \
  22. std r0, 16(r1); \
  23. stdu r1, -STACK_FRAME_OVERHEAD(r1); \
  24. bl func; \
  25. ld r1, 0(r1); \
  26. ld r1, 0(r1);
  27. #else
  28. #define TRACE_WITH_FRAME_BUFFER(func) \
  29. bl func;
  30. #endif
  31. /*
  32. * These are calls to C code, so the caller must be prepared for volatiles to
  33. * be clobbered.
  34. */
  35. #define TRACE_ENABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_on)
  36. #define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(trace_hardirqs_off)
  37. /*
  38. * This is used by assembly code to soft-disable interrupts first and
  39. * reconcile irq state.
  40. *
  41. * NB: This may call C code, so the caller must be prepared for volatiles to
  42. * be clobbered.
  43. */
  44. #define RECONCILE_IRQ_STATE(__rA, __rB) \
  45. lbz __rA,PACASOFTIRQEN(r13); \
  46. lbz __rB,PACAIRQHAPPENED(r13); \
  47. cmpwi cr0,__rA,0; \
  48. li __rA,0; \
  49. ori __rB,__rB,PACA_IRQ_HARD_DIS; \
  50. stb __rB,PACAIRQHAPPENED(r13); \
  51. beq 44f; \
  52. stb __rA,PACASOFTIRQEN(r13); \
  53. TRACE_DISABLE_INTS; \
  54. 44:
  55. #else
  56. #define TRACE_ENABLE_INTS
  57. #define TRACE_DISABLE_INTS
  58. #define RECONCILE_IRQ_STATE(__rA, __rB) \
  59. lbz __rA,PACAIRQHAPPENED(r13); \
  60. li __rB,0; \
  61. ori __rA,__rA,PACA_IRQ_HARD_DIS; \
  62. stb __rB,PACASOFTIRQEN(r13); \
  63. stb __rA,PACAIRQHAPPENED(r13)
  64. #endif
  65. #endif
  66. #endif