1 #ifndef _SPARC64_PTRACE_H
2 #define _SPARC64_PTRACE_H
4 #include <asm/pstate.h>
6 /* This struct defines the way the registers are stored on the
7 * stack during a system call and basically all traps.
10 /* This magic value must have the low 9 bits clear,
11 * as that is where we encode the %tt value, see below.
13 #define PT_REGS_MAGIC 0x57ac6c00
17 #include <linux/types.h>
20 unsigned long u_regs
[16]; /* globals and ins */
26 /* We encode a magic number, PT_REGS_MAGIC, along
27 * with the %tt (trap type) register value at trap
28 * entry time. The magic number allows us to identify
29 * accurately a trap stack frame in the stack
30 * unwinder, and the %tt value allows us to test
31 * things like "in a system call" etc. for an arbitray
34 * The PT_REGS_MAGIC is choosen such that it can be
35 * loaded completely using just a sethi instruction.
45 unsigned int u_regs
[16]; /* globals and ins */
64 #define UREG_FP UREG_I6
65 #define UREG_RETPC UREG_I7
67 /* A V9 register window */
69 unsigned long locals
[8];
73 /* A 32-bit register window. */
75 unsigned int locals
[8];
79 /* A V9 Sparc stack frame */
81 unsigned long locals
[8];
83 struct sparc_stackf
*fp
;
84 unsigned long callers_pc
;
86 unsigned long xargs
[6];
87 unsigned long xxargs
[1];
90 /* A 32-bit Sparc stack frame */
91 struct sparc_stackf32
{
92 unsigned int locals
[8];
95 unsigned int callers_pc
;
96 unsigned int structptr
;
97 unsigned int xargs
[6];
98 unsigned int xxargs
[1];
102 unsigned long locals
[8];
103 unsigned long ins
[8];
104 unsigned long _unused
;
105 struct pt_regs
*regs
;
108 #define TRACEREG_SZ sizeof(struct pt_regs)
109 #define STACKFRAME_SZ sizeof(struct sparc_stackf)
111 #define TRACEREG32_SZ sizeof(struct pt_regs32)
112 #define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
116 #include <asm/system.h>
118 static inline int pt_regs_trap_type(struct pt_regs
*regs
)
120 return regs
->magic
& 0x1ff;
123 static inline bool pt_regs_is_syscall(struct pt_regs
*regs
)
125 return (regs
->tstate
& TSTATE_SYSCALL
);
128 static inline bool pt_regs_clear_syscall(struct pt_regs
*regs
)
130 return (regs
->tstate
&= ~TSTATE_SYSCALL
);
133 #define arch_ptrace_stop_needed(exit_code, info) \
134 ({ flush_user_windows(); \
135 get_thread_wsaved() != 0; \
138 #define arch_ptrace_stop(exit_code, info) \
139 synchronize_user_stack()
141 struct global_reg_snapshot
{
142 unsigned long tstate
;
148 struct thread_info
*thread
;
152 #define __ARCH_WANT_COMPAT_SYS_PTRACE
154 #define force_successful_syscall_return() \
155 do { current_thread_info()->syscall_noerror = 1; \
157 #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
158 #define instruction_pointer(regs) ((regs)->tpc)
159 #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
160 #define regs_return_value(regs) ((regs)->u_regs[UREG_I0])
162 extern unsigned long profile_pc(struct pt_regs
*);
164 #define profile_pc(regs) instruction_pointer(regs)
166 extern void show_regs(struct pt_regs
*);
169 #else /* __ASSEMBLY__ */
170 /* For assembly code. */
171 #define TRACEREG_SZ 0xa0
172 #define STACKFRAME_SZ 0xc0
174 #define TRACEREG32_SZ 0x50
175 #define STACKFRAME32_SZ 0x60
179 #define STACK_BIAS 2047
182 /* These are for pt_regs. */
183 #define PT_V9_G0 0x00
184 #define PT_V9_G1 0x08
185 #define PT_V9_G2 0x10
186 #define PT_V9_G3 0x18
187 #define PT_V9_G4 0x20
188 #define PT_V9_G5 0x28
189 #define PT_V9_G6 0x30
190 #define PT_V9_G7 0x38
191 #define PT_V9_I0 0x40
192 #define PT_V9_I1 0x48
193 #define PT_V9_I2 0x50
194 #define PT_V9_I3 0x58
195 #define PT_V9_I4 0x60
196 #define PT_V9_I5 0x68
197 #define PT_V9_I6 0x70
198 #define PT_V9_FP PT_V9_I6
199 #define PT_V9_I7 0x78
200 #define PT_V9_TSTATE 0x80
201 #define PT_V9_TPC 0x88
202 #define PT_V9_TNPC 0x90
204 #define PT_V9_MAGIC 0x9c
205 #define PT_TSTATE PT_V9_TSTATE
206 #define PT_TPC PT_V9_TPC
207 #define PT_TNPC PT_V9_TNPC
209 /* These for pt_regs32. */
233 /* Reg_window offsets */
234 #define RW_V9_L0 0x00
235 #define RW_V9_L1 0x08
236 #define RW_V9_L2 0x10
237 #define RW_V9_L3 0x18
238 #define RW_V9_L4 0x20
239 #define RW_V9_L5 0x28
240 #define RW_V9_L6 0x30
241 #define RW_V9_L7 0x38
242 #define RW_V9_I0 0x40
243 #define RW_V9_I1 0x48
244 #define RW_V9_I2 0x50
245 #define RW_V9_I3 0x58
246 #define RW_V9_I4 0x60
247 #define RW_V9_I5 0x68
248 #define RW_V9_I6 0x70
249 #define RW_V9_I7 0x78
268 /* Stack_frame offsets */
269 #define SF_V9_L0 0x00
270 #define SF_V9_L1 0x08
271 #define SF_V9_L2 0x10
272 #define SF_V9_L3 0x18
273 #define SF_V9_L4 0x20
274 #define SF_V9_L5 0x28
275 #define SF_V9_L6 0x30
276 #define SF_V9_L7 0x38
277 #define SF_V9_I0 0x40
278 #define SF_V9_I1 0x48
279 #define SF_V9_I2 0x50
280 #define SF_V9_I3 0x58
281 #define SF_V9_I4 0x60
282 #define SF_V9_I5 0x68
283 #define SF_V9_FP 0x70
284 #define SF_V9_PC 0x78
285 #define SF_V9_RETP 0x80
286 #define SF_V9_XARG0 0x88
287 #define SF_V9_XARG1 0x90
288 #define SF_V9_XARG2 0x98
289 #define SF_V9_XARG3 0xa0
290 #define SF_V9_XARG4 0xa8
291 #define SF_V9_XARG5 0xb0
292 #define SF_V9_XXARG 0xb8
311 #define SF_XARG0 0x44
312 #define SF_XARG1 0x48
313 #define SF_XARG2 0x4c
314 #define SF_XARG3 0x50
315 #define SF_XARG4 0x54
316 #define SF_XARG5 0x58
317 #define SF_XXARG 0x5c
321 /* global_reg_snapshot offsets */
322 #define GR_SNAP_TSTATE 0x00
323 #define GR_SNAP_TPC 0x08
324 #define GR_SNAP_TNPC 0x10
325 #define GR_SNAP_O7 0x18
326 #define GR_SNAP_I7 0x20
327 #define GR_SNAP_RPC 0x28
328 #define GR_SNAP_THREAD 0x30
329 #define GR_SNAP_PAD1 0x38
331 #endif /* __KERNEL__ */
333 /* Stuff for the ptrace system call */
334 #define PTRACE_SPARC_DETACH 11
335 #define PTRACE_GETREGS 12
336 #define PTRACE_SETREGS 13
337 #define PTRACE_GETFPREGS 14
338 #define PTRACE_SETFPREGS 15
339 #define PTRACE_READDATA 16
340 #define PTRACE_WRITEDATA 17
341 #define PTRACE_READTEXT 18
342 #define PTRACE_WRITETEXT 19
343 #define PTRACE_GETFPAREGS 20
344 #define PTRACE_SETFPAREGS 21
346 /* There are for debugging 64-bit processes, either from a 32 or 64 bit
347 * parent. Thus their complements are for debugging 32-bit processes only.
350 #define PTRACE_GETREGS64 22
351 #define PTRACE_SETREGS64 23
352 /* PTRACE_SYSCALL is 24 */
353 #define PTRACE_GETFPREGS64 25
354 #define PTRACE_SETFPREGS64 26
356 #endif /* !(_SPARC64_PTRACE_H) */