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.
40 static inline int pt_regs_trap_type(struct pt_regs
*regs
)
42 return regs
->magic
& 0x1ff;
45 static inline bool pt_regs_is_syscall(struct pt_regs
*regs
)
47 return (regs
->tstate
& TSTATE_SYSCALL
);
50 static inline bool pt_regs_clear_syscall(struct pt_regs
*regs
)
52 return (regs
->tstate
&= ~TSTATE_SYSCALL
);
60 unsigned int u_regs
[16]; /* globals and ins */
79 #define UREG_FP UREG_I6
80 #define UREG_RETPC UREG_I7
82 /* A V9 register window */
84 unsigned long locals
[8];
88 /* A 32-bit register window. */
90 unsigned int locals
[8];
94 /* A V9 Sparc stack frame */
96 unsigned long locals
[8];
98 struct sparc_stackf
*fp
;
99 unsigned long callers_pc
;
101 unsigned long xargs
[6];
102 unsigned long xxargs
[1];
105 /* A 32-bit Sparc stack frame */
106 struct sparc_stackf32
{
107 unsigned int locals
[8];
110 unsigned int callers_pc
;
111 unsigned int structptr
;
112 unsigned int xargs
[6];
113 unsigned int xxargs
[1];
117 unsigned long locals
[8];
118 unsigned long ins
[8];
119 unsigned long _unused
;
120 struct pt_regs
*regs
;
123 #define TRACEREG_SZ sizeof(struct pt_regs)
124 #define STACKFRAME_SZ sizeof(struct sparc_stackf)
126 #define TRACEREG32_SZ sizeof(struct pt_regs32)
127 #define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
131 struct global_reg_snapshot
{
132 unsigned long tstate
;
137 struct thread_info
*thread
;
142 #define __ARCH_WANT_COMPAT_SYS_PTRACE
144 #define force_successful_syscall_return() \
145 do { current_thread_info()->syscall_noerror = 1; \
147 #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
148 #define instruction_pointer(regs) ((regs)->tpc)
149 #define regs_return_value(regs) ((regs)->u_regs[UREG_I0])
151 extern unsigned long profile_pc(struct pt_regs
*);
153 #define profile_pc(regs) instruction_pointer(regs)
155 extern void show_regs(struct pt_regs
*);
156 extern void __show_regs(struct pt_regs
*);
159 #else /* __ASSEMBLY__ */
160 /* For assembly code. */
161 #define TRACEREG_SZ 0xa0
162 #define STACKFRAME_SZ 0xc0
164 #define TRACEREG32_SZ 0x50
165 #define STACKFRAME32_SZ 0x60
169 #define STACK_BIAS 2047
172 /* These are for pt_regs. */
173 #define PT_V9_G0 0x00
174 #define PT_V9_G1 0x08
175 #define PT_V9_G2 0x10
176 #define PT_V9_G3 0x18
177 #define PT_V9_G4 0x20
178 #define PT_V9_G5 0x28
179 #define PT_V9_G6 0x30
180 #define PT_V9_G7 0x38
181 #define PT_V9_I0 0x40
182 #define PT_V9_I1 0x48
183 #define PT_V9_I2 0x50
184 #define PT_V9_I3 0x58
185 #define PT_V9_I4 0x60
186 #define PT_V9_I5 0x68
187 #define PT_V9_I6 0x70
188 #define PT_V9_FP PT_V9_I6
189 #define PT_V9_I7 0x78
190 #define PT_V9_TSTATE 0x80
191 #define PT_V9_TPC 0x88
192 #define PT_V9_TNPC 0x90
194 #define PT_V9_MAGIC 0x9c
195 #define PT_TSTATE PT_V9_TSTATE
196 #define PT_TPC PT_V9_TPC
197 #define PT_TNPC PT_V9_TNPC
199 /* These for pt_regs32. */
223 /* Reg_window offsets */
224 #define RW_V9_L0 0x00
225 #define RW_V9_L1 0x08
226 #define RW_V9_L2 0x10
227 #define RW_V9_L3 0x18
228 #define RW_V9_L4 0x20
229 #define RW_V9_L5 0x28
230 #define RW_V9_L6 0x30
231 #define RW_V9_L7 0x38
232 #define RW_V9_I0 0x40
233 #define RW_V9_I1 0x48
234 #define RW_V9_I2 0x50
235 #define RW_V9_I3 0x58
236 #define RW_V9_I4 0x60
237 #define RW_V9_I5 0x68
238 #define RW_V9_I6 0x70
239 #define RW_V9_I7 0x78
258 /* Stack_frame offsets */
259 #define SF_V9_L0 0x00
260 #define SF_V9_L1 0x08
261 #define SF_V9_L2 0x10
262 #define SF_V9_L3 0x18
263 #define SF_V9_L4 0x20
264 #define SF_V9_L5 0x28
265 #define SF_V9_L6 0x30
266 #define SF_V9_L7 0x38
267 #define SF_V9_I0 0x40
268 #define SF_V9_I1 0x48
269 #define SF_V9_I2 0x50
270 #define SF_V9_I3 0x58
271 #define SF_V9_I4 0x60
272 #define SF_V9_I5 0x68
273 #define SF_V9_FP 0x70
274 #define SF_V9_PC 0x78
275 #define SF_V9_RETP 0x80
276 #define SF_V9_XARG0 0x88
277 #define SF_V9_XARG1 0x90
278 #define SF_V9_XARG2 0x98
279 #define SF_V9_XARG3 0xa0
280 #define SF_V9_XARG4 0xa8
281 #define SF_V9_XARG5 0xb0
282 #define SF_V9_XXARG 0xb8
301 #define SF_XARG0 0x44
302 #define SF_XARG1 0x48
303 #define SF_XARG2 0x4c
304 #define SF_XARG3 0x50
305 #define SF_XARG4 0x54
306 #define SF_XARG5 0x58
307 #define SF_XXARG 0x5c
311 /* global_reg_snapshot offsets */
312 #define GR_SNAP_TSTATE 0x00
313 #define GR_SNAP_TPC 0x08
314 #define GR_SNAP_TNPC 0x10
315 #define GR_SNAP_O7 0x18
316 #define GR_SNAP_I7 0x20
317 #define GR_SNAP_THREAD 0x28
318 #define GR_SNAP_PAD1 0x30
319 #define GR_SNAP_PAD2 0x38
321 #endif /* __KERNEL__ */
323 /* Stuff for the ptrace system call */
324 #define PTRACE_SPARC_DETACH 11
325 #define PTRACE_GETREGS 12
326 #define PTRACE_SETREGS 13
327 #define PTRACE_GETFPREGS 14
328 #define PTRACE_SETFPREGS 15
329 #define PTRACE_READDATA 16
330 #define PTRACE_WRITEDATA 17
331 #define PTRACE_READTEXT 18
332 #define PTRACE_WRITETEXT 19
333 #define PTRACE_GETFPAREGS 20
334 #define PTRACE_SETFPAREGS 21
336 /* There are for debugging 64-bit processes, either from a 32 or 64 bit
337 * parent. Thus their complements are for debugging 32-bit processes only.
340 #define PTRACE_GETREGS64 22
341 #define PTRACE_SETREGS64 23
342 /* PTRACE_SYSCALL is 24 */
343 #define PTRACE_GETFPREGS64 25
344 #define PTRACE_SETFPREGS64 26
346 #endif /* !(_SPARC64_PTRACE_H) */