mcount.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * arch/sh/lib/mcount.S
  3. *
  4. * Copyright (C) 2008 Paul Mundt
  5. * Copyright (C) 2008 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. MCOUNT_ENTER()
  36. #ifdef CONFIG_DYNAMIC_FTRACE
  37. .globl mcount_call
  38. mcount_call:
  39. mov.l .Lftrace_stub, r6
  40. #else
  41. mov.l .Lftrace_trace_function, r6
  42. mov.l ftrace_stub, r7
  43. cmp/eq r6, r7
  44. bt skip_trace
  45. mov.l @r6, r6
  46. #endif
  47. jsr @r6
  48. nop
  49. skip_trace:
  50. MCOUNT_LEAVE()
  51. .align 2
  52. .Lftrace_trace_function:
  53. .long ftrace_trace_function
  54. #ifdef CONFIG_DYNAMIC_FTRACE
  55. .globl ftrace_caller
  56. ftrace_caller:
  57. MCOUNT_ENTER()
  58. .globl ftrace_call
  59. ftrace_call:
  60. mov.l .Lftrace_stub, r6
  61. jsr @r6
  62. nop
  63. MCOUNT_LEAVE()
  64. #endif /* CONFIG_DYNAMIC_FTRACE */
  65. /*
  66. * NOTE: From here on the locations of the .Lftrace_stub label and
  67. * ftrace_stub itself are fixed. Adding additional data here will skew
  68. * the displacement for the memory table and break the block replacement.
  69. * Place new labels either after the ftrace_stub body, or before
  70. * ftrace_caller. You have been warned.
  71. */
  72. .align 2
  73. .Lftrace_stub:
  74. .long ftrace_stub
  75. .globl ftrace_stub
  76. ftrace_stub:
  77. rts
  78. nop