1 #ifndef __BACKTRACE_H
2 #define __BACKTRACE_H
3 
4 #ifndef __ASSEMBLY__
5 #include <cpuport.h>
6 
7 /* Unwind reason code according the the ARM EABI documents */
8 enum unwind_reason_code
9 {
10     URC_OK = 0,         /* operation completed successfully */
11     URC_CONTINUE_UNWIND = 8,
12     URC_FAILURE = 9         /* unspecified failure of some kind */
13 };
14 
15 struct unwind_idx
16 {
17     unsigned long addr_offset;
18     unsigned long insn;
19 };
20 
21 struct unwind_table
22 {
23     const struct unwind_idx *start;
24     const struct unwind_idx *origin;
25     const struct unwind_idx *stop;
26     unsigned long begin_addr;
27     unsigned long end_addr;
28 };
29 
30 struct stackframe
31 {
32     /*
33      * FP member should hold R7 when CONFIG_THUMB2_KERNEL is enabled
34      * and R11 otherwise.
35      */
36     unsigned long fp;
37     unsigned long sp;
38     unsigned long lr;
39     unsigned long pc;
40 };
41 
42 struct pt_regs
43 {
44     unsigned long uregs[18];
45 };
46 
47 #define ARM_cpsr    uregs[16]
48 #define ARM_pc      uregs[15]
49 #define ARM_lr      uregs[14]
50 #define ARM_sp      uregs[13]
51 #define ARM_ip      uregs[12]
52 #define ARM_fp      uregs[11]
53 #define ARM_r10     uregs[10]
54 #define ARM_r9      uregs[9]
55 #define ARM_r8      uregs[8]
56 #define ARM_r7      uregs[7]
57 #define ARM_r6      uregs[6]
58 #define ARM_r5      uregs[5]
59 #define ARM_r4      uregs[4]
60 #define ARM_r3      uregs[3]
61 #define ARM_r2      uregs[2]
62 #define ARM_r1      uregs[1]
63 #define ARM_r0      uregs[0]
64 #define ARM_ORIG_r0 uregs[17]
65 
66 #define instruction_pointer(regs)   (regs)->ARM_pc
67 
68 #ifdef CONFIG_THUMB2_KERNEL
69 #define frame_pointer(regs) (regs)->ARM_r7
70 #else
71 #define frame_pointer(regs) (regs)->ARM_fp
72 #endif
73 
74 int unwind_frame(struct stackframe *frame, const struct unwind_idx **origin_idx, const struct unwind_idx exidx_start[], const struct unwind_idx exidx_end[]);
75 void unwind_backtrace(struct pt_regs *regs, const struct unwind_idx exidx_start[], const struct unwind_idx exidx_end[]);
76 
77 void rt_unwind(struct rt_hw_exp_stack *regs, unsigned int pc_adj);
78 rt_err_t rt_backtrace(void);
79 
80 #endif  /* !__ASSEMBLY__ */
81 
82 #endif  /* __BACKTRACE_H */
83 
84