ftrace.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_FRAME_POINTER
  12. #include <linux/mm.h>
  13. extern inline void *return_address(unsigned int level)
  14. {
  15. unsigned long *endstack, *fp, *ret_addr;
  16. unsigned int current_level = 0;
  17. if (level == 0)
  18. return __builtin_return_address(0);
  19. fp = (unsigned long *)__builtin_frame_address(0);
  20. endstack = (unsigned long *)PAGE_ALIGN((unsigned long)&level);
  21. while (((unsigned long)fp & 0x3) == 0 && fp &&
  22. (fp + 1) < endstack && current_level < level) {
  23. fp = (unsigned long *)*fp;
  24. current_level++;
  25. }
  26. if (((unsigned long)fp & 0x3) == 0 && fp &&
  27. (fp + 1) < endstack)
  28. ret_addr = (unsigned long *)*(fp + 1);
  29. else
  30. ret_addr = NULL;
  31. return ret_addr;
  32. }
  33. #else
  34. extern inline void *return_address(unsigned int level)
  35. {
  36. return NULL;
  37. }
  38. #endif /* CONFIG_FRAME_POINTER */
  39. #define HAVE_ARCH_CALLER_ADDR
  40. /* inline function or macro may lead to unexpected result */
  41. #define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0))
  42. #define CALLER_ADDR1 ((unsigned long)return_address(1))
  43. #define CALLER_ADDR2 ((unsigned long)return_address(2))
  44. #define CALLER_ADDR3 ((unsigned long)return_address(3))
  45. #define CALLER_ADDR4 ((unsigned long)return_address(4))
  46. #define CALLER_ADDR5 ((unsigned long)return_address(5))
  47. #define CALLER_ADDR6 ((unsigned long)return_address(6))
  48. #endif /* __ASSEMBLY__ */
  49. #endif