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