ftrace.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive for
  4. * more details.
  5. *
  6. * Copyright (C) 2009 DSLab, Lanzhou University, China
  7. * Author: Wu Zhangjin <wuzhangjin@gmail.com>
  8. */
  9. #ifndef _ASM_MIPS_FTRACE_H
  10. #define _ASM_MIPS_FTRACE_H
  11. #ifdef CONFIG_FUNCTION_TRACER
  12. #define MCOUNT_ADDR ((unsigned long)(_mcount))
  13. #define MCOUNT_INSN_SIZE 4 /* sizeof mcount call */
  14. #ifndef __ASSEMBLY__
  15. extern void _mcount(void);
  16. #define mcount _mcount
  17. #define safe_load(load, src, dst, error) \
  18. do { \
  19. asm volatile ( \
  20. "1: " load " %[tmp_dst], 0(%[tmp_src])\n" \
  21. " li %[tmp_err], 0\n" \
  22. "2: .insn\n" \
  23. \
  24. ".section .fixup, \"ax\"\n" \
  25. "3: li %[tmp_err], 1\n" \
  26. " j 2b\n" \
  27. ".previous\n" \
  28. \
  29. ".section\t__ex_table,\"a\"\n\t" \
  30. STR(PTR) "\t1b, 3b\n\t" \
  31. ".previous\n" \
  32. \
  33. : [tmp_dst] "=&r" (dst), [tmp_err] "=r" (error)\
  34. : [tmp_src] "r" (src) \
  35. : "memory" \
  36. ); \
  37. } while (0)
  38. #define safe_store(store, src, dst, error) \
  39. do { \
  40. asm volatile ( \
  41. "1: " store " %[tmp_src], 0(%[tmp_dst])\n"\
  42. " li %[tmp_err], 0\n" \
  43. "2: .insn\n" \
  44. \
  45. ".section .fixup, \"ax\"\n" \
  46. "3: li %[tmp_err], 1\n" \
  47. " j 2b\n" \
  48. ".previous\n" \
  49. \
  50. ".section\t__ex_table,\"a\"\n\t"\
  51. STR(PTR) "\t1b, 3b\n\t" \
  52. ".previous\n" \
  53. \
  54. : [tmp_err] "=r" (error) \
  55. : [tmp_dst] "r" (dst), [tmp_src] "r" (src)\
  56. : "memory" \
  57. ); \
  58. } while (0)
  59. #define safe_load_code(dst, src, error) \
  60. safe_load(STR(lw), src, dst, error)
  61. #define safe_store_code(src, dst, error) \
  62. safe_store(STR(sw), src, dst, error)
  63. #define safe_load_stack(dst, src, error) \
  64. safe_load(STR(PTR_L), src, dst, error)
  65. #define safe_store_stack(src, dst, error) \
  66. safe_store(STR(PTR_S), src, dst, error)
  67. #ifdef CONFIG_DYNAMIC_FTRACE
  68. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  69. {
  70. return addr;
  71. }
  72. struct dyn_arch_ftrace {
  73. };
  74. #endif /* CONFIG_DYNAMIC_FTRACE */
  75. #endif /* __ASSEMBLY__ */
  76. #endif /* CONFIG_FUNCTION_TRACER */
  77. #endif /* _ASM_MIPS_FTRACE_H */