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 #define current_pt_regs() \
36 ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
38 struct global_reg_snapshot
{
45 struct thread_info
*thread
;
49 struct global_pmu_snapshot
{
54 union global_cpu_snapshot
{
55 struct global_reg_snapshot reg
;
56 struct global_pmu_snapshot pmu
;
59 extern union global_cpu_snapshot global_cpu_snapshot
[NR_CPUS
];
61 #define force_successful_syscall_return() set_thread_noerror(1)
62 #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
63 #define instruction_pointer(regs) ((regs)->tpc)
64 #define instruction_pointer_set(regs, val) do { \
65 (regs)->tpc = (val); \
66 (regs)->tnpc = (val)+4; \
68 #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
69 static inline int is_syscall_success(struct pt_regs
*regs
)
71 return !(regs
->tstate
& (TSTATE_XCARRY
| TSTATE_ICARRY
));
74 static inline long regs_return_value(struct pt_regs
*regs
)
76 return regs
->u_regs
[UREG_I0
];
79 unsigned long profile_pc(struct pt_regs
*);
81 #define profile_pc(regs) instruction_pointer(regs)
84 #define MAX_REG_OFFSET (offsetof(struct pt_regs, magic))
86 int regs_query_register_offset(const char *name
);
87 unsigned long regs_get_kernel_stack_nth(struct pt_regs
*regs
, unsigned int n
);
90 * regs_get_register() - get register value from its offset
91 * @regs: pt_regs from which register value is gotten
92 * @offset: offset number of the register.
94 * regs_get_register returns the value of a register whose
95 * offset from @regs. The @offset is the offset of the register
96 * in struct pt_regs. If @offset is bigger than MAX_REG_OFFSET,
99 static inline unsigned long regs_get_register(struct pt_regs
*regs
,
100 unsigned long offset
)
102 if (unlikely(offset
>= MAX_REG_OFFSET
))
104 if (offset
== PT_V9_Y
)
105 return *(unsigned int *)((unsigned long)regs
+ offset
);
106 return *(unsigned long *)((unsigned long)regs
+ offset
);
109 /* Valid only for Kernel mode traps. */
110 static inline unsigned long kernel_stack_pointer(struct pt_regs
*regs
)
112 return regs
->u_regs
[UREG_I6
];
114 #else /* __ASSEMBLY__ */
115 #endif /* __ASSEMBLY__ */
116 #else /* (defined(__sparc__) && defined(__arch64__)) */
118 #include <asm/switch_to.h>
120 static inline bool pt_regs_is_syscall(struct pt_regs
*regs
)
122 return (regs
->psr
& PSR_SYSCALL
);
125 static inline bool pt_regs_clear_syscall(struct pt_regs
*regs
)
127 return (regs
->psr
&= ~PSR_SYSCALL
);
130 #define arch_ptrace_stop_needed(exit_code, info) \
131 ({ flush_user_windows(); \
132 current_thread_info()->w_saved != 0; \
135 #define arch_ptrace_stop(exit_code, info) \
136 synchronize_user_stack()
138 #define current_pt_regs() \
139 ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
141 #define user_mode(regs) (!((regs)->psr & PSR_PS))
142 #define instruction_pointer(regs) ((regs)->pc)
143 #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
144 unsigned long profile_pc(struct pt_regs
*);
145 #else /* (!__ASSEMBLY__) */
146 #endif /* (!__ASSEMBLY__) */
147 #endif /* (defined(__sparc__) && defined(__arch64__)) */
148 #define STACK_BIAS 2047
150 /* global_reg_snapshot offsets */
151 #define GR_SNAP_TSTATE 0x00
152 #define GR_SNAP_TPC 0x08
153 #define GR_SNAP_TNPC 0x10
154 #define GR_SNAP_O7 0x18
155 #define GR_SNAP_I7 0x20
156 #define GR_SNAP_RPC 0x28
157 #define GR_SNAP_THREAD 0x30
158 #define GR_SNAP_PAD1 0x38
160 #endif /* !(__SPARC_PTRACE_H) */