1 #ifndef __SPARC_PTRACE_H
2 #define __SPARC_PTRACE_H
4 #include <uapi/asm/ptrace.h>
6 #if defined(__sparc__) && defined(__arch64__)
9 #include <linux/threads.h>
10 #include <asm/switch_to.h>
12 static inline int pt_regs_trap_type(struct pt_regs
*regs
)
14 return regs
->magic
& 0x1ff;
17 static inline bool pt_regs_is_syscall(struct pt_regs
*regs
)
19 return (regs
->tstate
& TSTATE_SYSCALL
);
22 static inline bool pt_regs_clear_syscall(struct pt_regs
*regs
)
24 return (regs
->tstate
&= ~TSTATE_SYSCALL
);
27 #define arch_ptrace_stop_needed(exit_code, info) \
28 ({ flush_user_windows(); \
29 get_thread_wsaved() != 0; \
32 #define arch_ptrace_stop(exit_code, info) \
33 synchronize_user_stack()
35 struct global_reg_snapshot
{
42 struct thread_info
*thread
;
45 extern struct global_reg_snapshot global_reg_snapshot
[NR_CPUS
];
47 #define force_successful_syscall_return() \
48 do { current_thread_info()->syscall_noerror = 1; \
50 #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
51 #define instruction_pointer(regs) ((regs)->tpc)
52 #define instruction_pointer_set(regs, val) ((regs)->tpc = (val))
53 #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
54 static inline int is_syscall_success(struct pt_regs
*regs
)
56 return !(regs
->tstate
& (TSTATE_XCARRY
| TSTATE_ICARRY
));
59 static inline long regs_return_value(struct pt_regs
*regs
)
61 return regs
->u_regs
[UREG_I0
];
64 extern unsigned long profile_pc(struct pt_regs
*);
66 #define profile_pc(regs) instruction_pointer(regs)
68 #else /* __ASSEMBLY__ */
69 #endif /* __ASSEMBLY__ */
70 #else /* (defined(__sparc__) && defined(__arch64__)) */
72 #include <asm/switch_to.h>
74 static inline bool pt_regs_is_syscall(struct pt_regs
*regs
)
76 return (regs
->psr
& PSR_SYSCALL
);
79 static inline bool pt_regs_clear_syscall(struct pt_regs
*regs
)
81 return (regs
->psr
&= ~PSR_SYSCALL
);
84 #define arch_ptrace_stop_needed(exit_code, info) \
85 ({ flush_user_windows(); \
86 current_thread_info()->w_saved != 0; \
89 #define arch_ptrace_stop(exit_code, info) \
90 synchronize_user_stack()
92 #define user_mode(regs) (!((regs)->psr & PSR_PS))
93 #define instruction_pointer(regs) ((regs)->pc)
94 #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
95 unsigned long profile_pc(struct pt_regs
*);
96 #else /* (!__ASSEMBLY__) */
97 #endif /* (!__ASSEMBLY__) */
98 #endif /* (defined(__sparc__) && defined(__arch64__)) */
99 #define STACK_BIAS 2047
101 /* global_reg_snapshot offsets */
102 #define GR_SNAP_TSTATE 0x00
103 #define GR_SNAP_TPC 0x08
104 #define GR_SNAP_TNPC 0x10
105 #define GR_SNAP_O7 0x18
106 #define GR_SNAP_I7 0x20
107 #define GR_SNAP_RPC 0x28
108 #define GR_SNAP_THREAD 0x30
109 #define GR_SNAP_PAD1 0x38
111 #endif /* !(__SPARC_PTRACE_H) */