mcount.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * arch/sh/lib/mcount.S
  3. *
  4. * Copyright (C) 2008 Paul Mundt
  5. * Copyright (C) 2008, 2009 Matt Fleming
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <asm/ftrace.h>
  12. #define MCOUNT_ENTER() \
  13. mov.l r4, @-r15; \
  14. mov.l r5, @-r15; \
  15. mov.l r6, @-r15; \
  16. mov.l r7, @-r15; \
  17. sts.l pr, @-r15; \
  18. \
  19. mov.l @(20,r15),r4; \
  20. sts pr, r5
  21. #define MCOUNT_LEAVE() \
  22. lds.l @r15+, pr; \
  23. mov.l @r15+, r7; \
  24. mov.l @r15+, r6; \
  25. mov.l @r15+, r5; \
  26. rts; \
  27. mov.l @r15+, r4
  28. .align 2
  29. .globl _mcount
  30. .type _mcount,@function
  31. .globl mcount
  32. .type mcount,@function
  33. _mcount:
  34. mcount:
  35. #ifndef CONFIG_DYNAMIC_FTRACE
  36. mov.l .Lfunction_trace_stop, r0
  37. mov.l @r0, r0
  38. tst r0, r0
  39. bf ftrace_stub
  40. #endif
  41. MCOUNT_ENTER()
  42. #ifdef CONFIG_DYNAMIC_FTRACE
  43. .globl mcount_call
  44. mcount_call:
  45. mov.l .Lftrace_stub, r6
  46. #else
  47. mov.l .Lftrace_trace_function, r6
  48. mov.l ftrace_stub, r7
  49. cmp/eq r6, r7
  50. bt skip_trace
  51. mov.l @r6, r6
  52. #endif
  53. jsr @r6
  54. nop
  55. skip_trace:
  56. MCOUNT_LEAVE()
  57. .align 2
  58. .Lftrace_trace_function:
  59. .long ftrace_trace_function
  60. #ifdef CONFIG_DYNAMIC_FTRACE
  61. .globl ftrace_caller
  62. ftrace_caller:
  63. mov.l .Lfunction_trace_stop, r0
  64. mov.l @r0, r0
  65. tst r0, r0
  66. bf ftrace_stub
  67. MCOUNT_ENTER()
  68. .globl ftrace_call
  69. ftrace_call:
  70. mov.l .Lftrace_stub, r6
  71. jsr @r6
  72. nop
  73. MCOUNT_LEAVE()
  74. #endif /* CONFIG_DYNAMIC_FTRACE */
  75. /*
  76. * NOTE: From here on the locations of the .Lftrace_stub label and
  77. * ftrace_stub itself are fixed. Adding additional data here will skew
  78. * the displacement for the memory table and break the block replacement.
  79. * Place new labels either after the ftrace_stub body, or before
  80. * ftrace_caller. You have been warned.
  81. */
  82. .align 2
  83. .Lftrace_stub:
  84. .long ftrace_stub
  85. .globl ftrace_stub
  86. ftrace_stub:
  87. rts
  88. nop
  89. .align 2
  90. .Lfunction_trace_stop:
  91. .long function_trace_stop