1 #ifndef __SPARC_PTRACE_H
2 #define __SPARC_PTRACE_H
4 #if defined(__sparc__) && defined(__arch64__)
6 #include <asm/pstate.h>
8 /* This struct defines the way the registers are stored on the
9 * stack during a system call and basically all traps.
12 /* This magic value must have the low 9 bits clear,
13 * as that is where we encode the %tt value, see below.
15 #define PT_REGS_MAGIC 0x57ac6c00
19 #include <linux/types.h>
22 unsigned long u_regs[16]; /* globals and ins */
28 /* We encode a magic number, PT_REGS_MAGIC, along
29 * with the %tt (trap type) register value at trap
30 * entry time. The magic number allows us to identify
31 * accurately a trap stack frame in the stack
32 * unwinder, and the %tt value allows us to test
33 * things like "in a system call" etc. for an arbitray
36 * The PT_REGS_MAGIC is choosen such that it can be
37 * loaded completely using just a sethi instruction.
47 unsigned int u_regs[16]; /* globals and ins */
50 /* A V9 register window */
52 unsigned long locals[8];
56 /* A 32-bit register window. */
58 unsigned int locals[8];
62 /* A V9 Sparc stack frame */
64 unsigned long locals[8];
66 struct sparc_stackf *fp;
67 unsigned long callers_pc;
69 unsigned long xargs[6];
70 unsigned long xxargs[1];
73 /* A 32-bit Sparc stack frame */
74 struct sparc_stackf32 {
75 unsigned int locals[8];
78 unsigned int callers_pc;
79 unsigned int structptr;
80 unsigned int xargs[6];
81 unsigned int xxargs[1];
85 unsigned long locals[8];
87 unsigned long _unused;
90 #endif /* (!__ASSEMBLY__) */
96 /* This struct defines the way the registers are stored on the
97 * stack during a system call and basically all traps.
106 unsigned long u_regs[16]; /* globals and ins */
109 /* A 32-bit register window. */
110 struct reg_window32 {
111 unsigned long locals[8];
112 unsigned long ins[8];
115 /* A Sparc stack frame */
116 struct sparc_stackf {
117 unsigned long locals[8];
118 unsigned long ins[6];
119 struct sparc_stackf *fp;
120 unsigned long callers_pc;
122 unsigned long xargs[6];
123 unsigned long xxargs[1];
125 #endif /* (!__ASSEMBLY__) */
127 #endif /* (defined(__sparc__) && defined(__arch64__))*/
131 #define TRACEREG_SZ sizeof(struct pt_regs)
132 #define STACKFRAME_SZ sizeof(struct sparc_stackf)
134 #define TRACEREG32_SZ sizeof(struct pt_regs32)
135 #define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
137 #endif /* (!__ASSEMBLY__) */
155 #define UREG_FP UREG_I6
156 #define UREG_RETPC UREG_I7
158 #if defined(__sparc__) && defined(__arch64__)
165 #include <linux/threads.h>
166 #include <asm/system.h>
168 static inline int pt_regs_trap_type(struct pt_regs *regs)
170 return regs->magic & 0x1ff;
173 static inline bool pt_regs_is_syscall(struct pt_regs *regs)
175 return (regs->tstate & TSTATE_SYSCALL);
178 static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
180 return (regs->tstate &= ~TSTATE_SYSCALL);
183 #define arch_ptrace_stop_needed(exit_code, info) \
184 ({ flush_user_windows(); \
185 get_thread_wsaved() != 0; \
188 #define arch_ptrace_stop(exit_code, info) \
189 synchronize_user_stack()
191 struct global_reg_snapshot {
192 unsigned long tstate;
198 struct thread_info *thread;
201 extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
203 #define force_successful_syscall_return() \
204 do { current_thread_info()->syscall_noerror = 1; \
206 #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
207 #define instruction_pointer(regs) ((regs)->tpc)
208 #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
209 #define regs_return_value(regs) ((regs)->u_regs[UREG_I0])
211 extern unsigned long profile_pc(struct pt_regs *);
213 #define profile_pc(regs) instruction_pointer(regs)
215 extern void show_regs(struct pt_regs *);
216 #endif /* (__KERNEL__) */
218 #else /* __ASSEMBLY__ */
219 /* For assembly code. */
220 #define TRACEREG_SZ 0xa0
221 #define STACKFRAME_SZ 0xc0
223 #define TRACEREG32_SZ 0x50
224 #define STACKFRAME32_SZ 0x60
225 #endif /* __ASSEMBLY__ */
227 #else /* (defined(__sparc__) && defined(__arch64__)) */
235 #include <asm/system.h>
237 static inline bool pt_regs_is_syscall(struct pt_regs *regs)
239 return (regs->psr & PSR_SYSCALL);
242 static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
244 return (regs->psr &= ~PSR_SYSCALL);
247 #define arch_ptrace_stop_needed(exit_code, info) \
248 ({ flush_user_windows(); \
249 current_thread_info()->w_saved != 0; \
252 #define arch_ptrace_stop(exit_code, info) \
253 synchronize_user_stack()
255 #define user_mode(regs) (!((regs)->psr & PSR_PS))
256 #define instruction_pointer(regs) ((regs)->pc)
257 #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
258 unsigned long profile_pc(struct pt_regs *);
259 extern void show_regs(struct pt_regs *);
260 #endif /* (__KERNEL__) */
262 #else /* (!__ASSEMBLY__) */
263 /* For assembly code. */
264 #define TRACEREG_SZ 0x50
265 #define STACKFRAME_SZ 0x60
266 #endif /* (!__ASSEMBLY__) */
268 #endif /* (defined(__sparc__) && defined(__arch64__)) */
271 #define STACK_BIAS 2047
274 /* These are for pt_regs. */
275 #define PT_V9_G0 0x00
276 #define PT_V9_G1 0x08
277 #define PT_V9_G2 0x10
278 #define PT_V9_G3 0x18
279 #define PT_V9_G4 0x20
280 #define PT_V9_G5 0x28
281 #define PT_V9_G6 0x30
282 #define PT_V9_G7 0x38
283 #define PT_V9_I0 0x40
284 #define PT_V9_I1 0x48
285 #define PT_V9_I2 0x50
286 #define PT_V9_I3 0x58
287 #define PT_V9_I4 0x60
288 #define PT_V9_I5 0x68
289 #define PT_V9_I6 0x70
290 #define PT_V9_FP PT_V9_I6
291 #define PT_V9_I7 0x78
292 #define PT_V9_TSTATE 0x80
293 #define PT_V9_TPC 0x88
294 #define PT_V9_TNPC 0x90
296 #define PT_V9_MAGIC 0x9c
297 #define PT_TSTATE PT_V9_TSTATE
298 #define PT_TPC PT_V9_TPC
299 #define PT_TNPC PT_V9_TNPC
301 /* These for pt_regs32. */
325 /* Reg_window offsets */
326 #define RW_V9_L0 0x00
327 #define RW_V9_L1 0x08
328 #define RW_V9_L2 0x10
329 #define RW_V9_L3 0x18
330 #define RW_V9_L4 0x20
331 #define RW_V9_L5 0x28
332 #define RW_V9_L6 0x30
333 #define RW_V9_L7 0x38
334 #define RW_V9_I0 0x40
335 #define RW_V9_I1 0x48
336 #define RW_V9_I2 0x50
337 #define RW_V9_I3 0x58
338 #define RW_V9_I4 0x60
339 #define RW_V9_I5 0x68
340 #define RW_V9_I6 0x70
341 #define RW_V9_I7 0x78
360 /* Stack_frame offsets */
361 #define SF_V9_L0 0x00
362 #define SF_V9_L1 0x08
363 #define SF_V9_L2 0x10
364 #define SF_V9_L3 0x18
365 #define SF_V9_L4 0x20
366 #define SF_V9_L5 0x28
367 #define SF_V9_L6 0x30
368 #define SF_V9_L7 0x38
369 #define SF_V9_I0 0x40
370 #define SF_V9_I1 0x48
371 #define SF_V9_I2 0x50
372 #define SF_V9_I3 0x58
373 #define SF_V9_I4 0x60
374 #define SF_V9_I5 0x68
375 #define SF_V9_FP 0x70
376 #define SF_V9_PC 0x78
377 #define SF_V9_RETP 0x80
378 #define SF_V9_XARG0 0x88
379 #define SF_V9_XARG1 0x90
380 #define SF_V9_XARG2 0x98
381 #define SF_V9_XARG3 0xa0
382 #define SF_V9_XARG4 0xa8
383 #define SF_V9_XARG5 0xb0
384 #define SF_V9_XXARG 0xb8
403 #define SF_XARG0 0x44
404 #define SF_XARG1 0x48
405 #define SF_XARG2 0x4c
406 #define SF_XARG3 0x50
407 #define SF_XARG4 0x54
408 #define SF_XARG5 0x58
409 #define SF_XXARG 0x5c
413 /* global_reg_snapshot offsets */
414 #define GR_SNAP_TSTATE 0x00
415 #define GR_SNAP_TPC 0x08
416 #define GR_SNAP_TNPC 0x10
417 #define GR_SNAP_O7 0x18
418 #define GR_SNAP_I7 0x20
419 #define GR_SNAP_RPC 0x28
420 #define GR_SNAP_THREAD 0x30
421 #define GR_SNAP_PAD1 0x38
423 #endif /* __KERNEL__ */
425 /* Stuff for the ptrace system call */
426 #define PTRACE_SPARC_DETACH 11
427 #define PTRACE_GETREGS 12
428 #define PTRACE_SETREGS 13
429 #define PTRACE_GETFPREGS 14
430 #define PTRACE_SETFPREGS 15
431 #define PTRACE_READDATA 16
432 #define PTRACE_WRITEDATA 17
433 #define PTRACE_READTEXT 18
434 #define PTRACE_WRITETEXT 19
435 #define PTRACE_GETFPAREGS 20
436 #define PTRACE_SETFPAREGS 21
438 /* There are for debugging 64-bit processes, either from a 32 or 64 bit
439 * parent. Thus their complements are for debugging 32-bit processes only.
442 #define PTRACE_GETREGS64 22
443 #define PTRACE_SETREGS64 23
444 /* PTRACE_SYSCALL is 24 */
445 #define PTRACE_GETFPREGS64 25
446 #define PTRACE_SETFPREGS64 26
448 #endif /* !(__SPARC_PTRACE_H) */