ftrace_32.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * Split from entry_32.S
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #include <linux/magic.h>
  10. #include <asm/reg.h>
  11. #include <asm/ppc_asm.h>
  12. #include <asm/asm-offsets.h>
  13. #include <asm/ftrace.h>
  14. #include <asm/export.h>
  15. _GLOBAL(mcount)
  16. _GLOBAL(_mcount)
  17. /*
  18. * It is required that _mcount on PPC32 must preserve the
  19. * link register. But we have r0 to play with. We use r0
  20. * to push the return address back to the caller of mcount
  21. * into the ctr register, restore the link register and
  22. * then jump back using the ctr register.
  23. */
  24. mflr r0
  25. mtctr r0
  26. lwz r0, 4(r1)
  27. mtlr r0
  28. bctr
  29. _GLOBAL(ftrace_caller)
  30. MCOUNT_SAVE_FRAME
  31. /* r3 ends up with link register */
  32. subi r3, r3, MCOUNT_INSN_SIZE
  33. .globl ftrace_call
  34. ftrace_call:
  35. bl ftrace_stub
  36. nop
  37. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  38. .globl ftrace_graph_call
  39. ftrace_graph_call:
  40. b ftrace_graph_stub
  41. _GLOBAL(ftrace_graph_stub)
  42. #endif
  43. MCOUNT_RESTORE_FRAME
  44. /* old link register ends up in ctr reg */
  45. bctr
  46. EXPORT_SYMBOL(_mcount)
  47. _GLOBAL(ftrace_stub)
  48. blr
  49. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  50. _GLOBAL(ftrace_graph_caller)
  51. /* load r4 with local address */
  52. lwz r4, 44(r1)
  53. subi r4, r4, MCOUNT_INSN_SIZE
  54. /* Grab the LR out of the caller stack frame */
  55. lwz r3,52(r1)
  56. bl prepare_ftrace_return
  57. nop
  58. /*
  59. * prepare_ftrace_return gives us the address we divert to.
  60. * Change the LR in the callers stack frame to this.
  61. */
  62. stw r3,52(r1)
  63. MCOUNT_RESTORE_FRAME
  64. /* old link register ends up in ctr reg */
  65. bctr
  66. _GLOBAL(return_to_handler)
  67. /* need to save return values */
  68. stwu r1, -32(r1)
  69. stw r3, 20(r1)
  70. stw r4, 16(r1)
  71. stw r31, 12(r1)
  72. mr r31, r1
  73. bl ftrace_return_to_handler
  74. nop
  75. /* return value has real return address */
  76. mtlr r3
  77. lwz r3, 20(r1)
  78. lwz r4, 16(r1)
  79. lwz r31,12(r1)
  80. lwz r1, 0(r1)
  81. /* Jump back to real return address */
  82. blr
  83. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */