mcount-dyn.S 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2017 Andes Technology Corporation */
  3. #include <linux/init.h>
  4. #include <linux/linkage.h>
  5. #include <asm/asm.h>
  6. #include <asm/csr.h>
  7. #include <asm/unistd.h>
  8. #include <asm/thread_info.h>
  9. #include <asm/asm-offsets.h>
  10. #include <asm-generic/export.h>
  11. #include <asm/ftrace.h>
  12. .text
  13. #define FENTRY_RA_OFFSET 8
  14. #define ABI_SIZE_ON_STACK 80
  15. #define ABI_A0 0
  16. #define ABI_A1 8
  17. #define ABI_A2 16
  18. #define ABI_A3 24
  19. #define ABI_A4 32
  20. #define ABI_A5 40
  21. #define ABI_A6 48
  22. #define ABI_A7 56
  23. #define ABI_T0 64
  24. #define ABI_RA 72
  25. .macro SAVE_ABI
  26. addi sp, sp, -ABI_SIZE_ON_STACK
  27. REG_S a0, ABI_A0(sp)
  28. REG_S a1, ABI_A1(sp)
  29. REG_S a2, ABI_A2(sp)
  30. REG_S a3, ABI_A3(sp)
  31. REG_S a4, ABI_A4(sp)
  32. REG_S a5, ABI_A5(sp)
  33. REG_S a6, ABI_A6(sp)
  34. REG_S a7, ABI_A7(sp)
  35. REG_S t0, ABI_T0(sp)
  36. REG_S ra, ABI_RA(sp)
  37. .endm
  38. .macro RESTORE_ABI
  39. REG_L a0, ABI_A0(sp)
  40. REG_L a1, ABI_A1(sp)
  41. REG_L a2, ABI_A2(sp)
  42. REG_L a3, ABI_A3(sp)
  43. REG_L a4, ABI_A4(sp)
  44. REG_L a5, ABI_A5(sp)
  45. REG_L a6, ABI_A6(sp)
  46. REG_L a7, ABI_A7(sp)
  47. REG_L t0, ABI_T0(sp)
  48. REG_L ra, ABI_RA(sp)
  49. addi sp, sp, ABI_SIZE_ON_STACK
  50. .endm
  51. #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
  52. .macro SAVE_ALL
  53. addi sp, sp, -PT_SIZE_ON_STACK
  54. REG_S t0, PT_EPC(sp)
  55. REG_S x1, PT_RA(sp)
  56. REG_S x2, PT_SP(sp)
  57. REG_S x3, PT_GP(sp)
  58. REG_S x4, PT_TP(sp)
  59. REG_S x5, PT_T0(sp)
  60. REG_S x6, PT_T1(sp)
  61. REG_S x7, PT_T2(sp)
  62. REG_S x8, PT_S0(sp)
  63. REG_S x9, PT_S1(sp)
  64. REG_S x10, PT_A0(sp)
  65. REG_S x11, PT_A1(sp)
  66. REG_S x12, PT_A2(sp)
  67. REG_S x13, PT_A3(sp)
  68. REG_S x14, PT_A4(sp)
  69. REG_S x15, PT_A5(sp)
  70. REG_S x16, PT_A6(sp)
  71. REG_S x17, PT_A7(sp)
  72. REG_S x18, PT_S2(sp)
  73. REG_S x19, PT_S3(sp)
  74. REG_S x20, PT_S4(sp)
  75. REG_S x21, PT_S5(sp)
  76. REG_S x22, PT_S6(sp)
  77. REG_S x23, PT_S7(sp)
  78. REG_S x24, PT_S8(sp)
  79. REG_S x25, PT_S9(sp)
  80. REG_S x26, PT_S10(sp)
  81. REG_S x27, PT_S11(sp)
  82. REG_S x28, PT_T3(sp)
  83. REG_S x29, PT_T4(sp)
  84. REG_S x30, PT_T5(sp)
  85. REG_S x31, PT_T6(sp)
  86. .endm
  87. .macro RESTORE_ALL
  88. REG_L t0, PT_EPC(sp)
  89. REG_L x1, PT_RA(sp)
  90. REG_L x2, PT_SP(sp)
  91. REG_L x3, PT_GP(sp)
  92. REG_L x4, PT_TP(sp)
  93. REG_L x6, PT_T1(sp)
  94. REG_L x7, PT_T2(sp)
  95. REG_L x8, PT_S0(sp)
  96. REG_L x9, PT_S1(sp)
  97. REG_L x10, PT_A0(sp)
  98. REG_L x11, PT_A1(sp)
  99. REG_L x12, PT_A2(sp)
  100. REG_L x13, PT_A3(sp)
  101. REG_L x14, PT_A4(sp)
  102. REG_L x15, PT_A5(sp)
  103. REG_L x16, PT_A6(sp)
  104. REG_L x17, PT_A7(sp)
  105. REG_L x18, PT_S2(sp)
  106. REG_L x19, PT_S3(sp)
  107. REG_L x20, PT_S4(sp)
  108. REG_L x21, PT_S5(sp)
  109. REG_L x22, PT_S6(sp)
  110. REG_L x23, PT_S7(sp)
  111. REG_L x24, PT_S8(sp)
  112. REG_L x25, PT_S9(sp)
  113. REG_L x26, PT_S10(sp)
  114. REG_L x27, PT_S11(sp)
  115. REG_L x28, PT_T3(sp)
  116. REG_L x29, PT_T4(sp)
  117. REG_L x30, PT_T5(sp)
  118. REG_L x31, PT_T6(sp)
  119. addi sp, sp, PT_SIZE_ON_STACK
  120. .endm
  121. #endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */
  122. ENTRY(ftrace_caller)
  123. SAVE_ABI
  124. addi a0, t0, -FENTRY_RA_OFFSET
  125. la a1, function_trace_op
  126. REG_L a2, 0(a1)
  127. mv a1, ra
  128. mv a3, sp
  129. ftrace_call:
  130. .global ftrace_call
  131. call ftrace_stub
  132. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  133. addi a0, sp, ABI_RA
  134. REG_L a1, ABI_T0(sp)
  135. addi a1, a1, -FENTRY_RA_OFFSET
  136. #ifdef HAVE_FUNCTION_GRAPH_FP_TEST
  137. mv a2, s0
  138. #endif
  139. ftrace_graph_call:
  140. .global ftrace_graph_call
  141. call ftrace_stub
  142. #endif
  143. RESTORE_ABI
  144. jr t0
  145. ENDPROC(ftrace_caller)
  146. #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
  147. ENTRY(ftrace_regs_caller)
  148. SAVE_ALL
  149. addi a0, t0, -FENTRY_RA_OFFSET
  150. la a1, function_trace_op
  151. REG_L a2, 0(a1)
  152. mv a1, ra
  153. mv a3, sp
  154. ftrace_regs_call:
  155. .global ftrace_regs_call
  156. call ftrace_stub
  157. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  158. addi a0, sp, PT_RA
  159. REG_L a1, PT_EPC(sp)
  160. addi a1, a1, -FENTRY_RA_OFFSET
  161. #ifdef HAVE_FUNCTION_GRAPH_FP_TEST
  162. mv a2, s0
  163. #endif
  164. ftrace_graph_regs_call:
  165. .global ftrace_graph_regs_call
  166. call ftrace_stub
  167. #endif
  168. RESTORE_ALL
  169. jr t0
  170. ENDPROC(ftrace_regs_caller)
  171. #endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */