ftrace.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Blackfin ftrace code
  3. *
  4. * Copyright 2009 Analog Devices Inc.
  5. * Licensed under the GPL-2 or later.
  6. */
  7. #ifndef __ASM_BFIN_FTRACE_H__
  8. #define __ASM_BFIN_FTRACE_H__
  9. #define MCOUNT_INSN_SIZE 6 /* sizeof "[++sp] = rets; call __mcount;" */
  10. #ifndef __ASSEMBLY__
  11. #ifdef CONFIG_DYNAMIC_FTRACE
  12. extern void _mcount(void);
  13. #define MCOUNT_ADDR ((unsigned long)_mcount)
  14. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  15. {
  16. return addr;
  17. }
  18. struct dyn_arch_ftrace {
  19. /* No extra data needed for Blackfin */
  20. };
  21. #endif
  22. #ifdef CONFIG_FRAME_POINTER
  23. #include <linux/mm.h>
  24. extern inline void *return_address(unsigned int level)
  25. {
  26. unsigned long *endstack, *fp, *ret_addr;
  27. unsigned int current_level = 0;
  28. if (level == 0)
  29. return __builtin_return_address(0);
  30. fp = (unsigned long *)__builtin_frame_address(0);
  31. endstack = (unsigned long *)PAGE_ALIGN((unsigned long)&level);
  32. while (((unsigned long)fp & 0x3) == 0 && fp &&
  33. (fp + 1) < endstack && current_level < level) {
  34. fp = (unsigned long *)*fp;
  35. current_level++;
  36. }
  37. if (((unsigned long)fp & 0x3) == 0 && fp &&
  38. (fp + 1) < endstack)
  39. ret_addr = (unsigned long *)*(fp + 1);
  40. else
  41. ret_addr = NULL;
  42. return ret_addr;
  43. }
  44. #else
  45. extern inline void *return_address(unsigned int level)
  46. {
  47. return NULL;
  48. }
  49. #endif /* CONFIG_FRAME_POINTER */
  50. #define ftrace_return_address(n) return_address(n)
  51. #endif /* __ASSEMBLY__ */
  52. #endif