irqflags.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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, -32(r1); \
  22. std r0, 16(r1); \
  23. stdu r1, -32(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. * Most of the CPU's IRQ-state tracing is done from assembly code; we
  33. * have to call a C function so call a wrapper that saves all the
  34. * C-clobbered registers.
  35. */
  36. #define TRACE_ENABLE_INTS TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_on)
  37. #define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_off)
  38. /*
  39. * This is used by assembly code to soft-disable interrupts
  40. */
  41. #define SOFT_DISABLE_INTS(__rA, __rB) \
  42. lbz __rA,PACASOFTIRQEN(r13); \
  43. lbz __rB,PACAIRQHAPPENED(r13); \
  44. cmpwi cr0,__rA,0; \
  45. li __rA,0; \
  46. ori __rB,__rB,PACA_IRQ_HARD_DIS; \
  47. stb __rB,PACAIRQHAPPENED(r13); \
  48. beq 44f; \
  49. stb __rA,PACASOFTIRQEN(r13); \
  50. TRACE_DISABLE_INTS; \
  51. 44:
  52. #else
  53. #define TRACE_ENABLE_INTS
  54. #define TRACE_DISABLE_INTS
  55. #define SOFT_DISABLE_INTS(__rA, __rB) \
  56. lbz __rA,PACAIRQHAPPENED(r13); \
  57. li __rB,0; \
  58. ori __rA,__rA,PACA_IRQ_HARD_DIS; \
  59. stb __rB,PACASOFTIRQEN(r13); \
  60. stb __rA,PACAIRQHAPPENED(r13)
  61. #endif
  62. #endif
  63. #endif