aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/sparc/include/asm/Kbuild2
-rw-r--r--arch/sparc/include/asm/ptrace.h448
-rw-r--r--arch/sparc/include/asm/ptrace_32.h186
-rw-r--r--arch/sparc/include/asm/ptrace_64.h356
4 files changed, 444 insertions, 548 deletions
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild
index b0a3814a816..f79249facc6 100644
--- a/arch/sparc/include/asm/Kbuild
+++ b/arch/sparc/include/asm/Kbuild
@@ -3,8 +3,6 @@ include include/asm-generic/Kbuild.asm
3 3
4header-y += ipcbuf_32.h 4header-y += ipcbuf_32.h
5header-y += ipcbuf_64.h 5header-y += ipcbuf_64.h
6header-y += ptrace_32.h
7header-y += ptrace_64.h
8header-y += siginfo_32.h 6header-y += siginfo_32.h
9header-y += siginfo_64.h 7header-y += siginfo_64.h
10 8
diff --git a/arch/sparc/include/asm/ptrace.h b/arch/sparc/include/asm/ptrace.h
index 6dcbe2eed2e..30b0b797dc0 100644
--- a/arch/sparc/include/asm/ptrace.h
+++ b/arch/sparc/include/asm/ptrace.h
@@ -1,8 +1,448 @@
1#ifndef ___ASM_SPARC_PTRACE_H 1#ifndef __SPARC_PTRACE_H
2#define ___ASM_SPARC_PTRACE_H 2#define __SPARC_PTRACE_H
3
3#if defined(__sparc__) && defined(__arch64__) 4#if defined(__sparc__) && defined(__arch64__)
4#include <asm/ptrace_64.h> 5/* 64 bit sparc */
6#include <asm/pstate.h>
7
8/* This struct defines the way the registers are stored on the
9 * stack during a system call and basically all traps.
10 */
11
12/* This magic value must have the low 9 bits clear,
13 * as that is where we encode the %tt value, see below.
14 */
15#define PT_REGS_MAGIC 0x57ac6c00
16
17#ifndef __ASSEMBLY__
18
19#include <linux/types.h>
20
21struct pt_regs {
22 unsigned long u_regs[16]; /* globals and ins */
23 unsigned long tstate;
24 unsigned long tpc;
25 unsigned long tnpc;
26 unsigned int y;
27
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
34 * process.
35 *
36 * The PT_REGS_MAGIC is choosen such that it can be
37 * loaded completely using just a sethi instruction.
38 */
39 unsigned int magic;
40};
41
42struct pt_regs32 {
43 unsigned int psr;
44 unsigned int pc;
45 unsigned int npc;
46 unsigned int y;
47 unsigned int u_regs[16]; /* globals and ins */
48};
49
50/* A V9 register window */
51struct reg_window {
52 unsigned long locals[8];
53 unsigned long ins[8];
54};
55
56/* A 32-bit register window. */
57struct reg_window32 {
58 unsigned int locals[8];
59 unsigned int ins[8];
60};
61
62/* A V9 Sparc stack frame */
63struct sparc_stackf {
64 unsigned long locals[8];
65 unsigned long ins[6];
66 struct sparc_stackf *fp;
67 unsigned long callers_pc;
68 char *structptr;
69 unsigned long xargs[6];
70 unsigned long xxargs[1];
71};
72
73/* A 32-bit Sparc stack frame */
74struct sparc_stackf32 {
75 unsigned int locals[8];
76 unsigned int ins[6];
77 unsigned int fp;
78 unsigned int callers_pc;
79 unsigned int structptr;
80 unsigned int xargs[6];
81 unsigned int xxargs[1];
82};
83
84struct sparc_trapf {
85 unsigned long locals[8];
86 unsigned long ins[8];
87 unsigned long _unused;
88 struct pt_regs *regs;
89};
90#endif /* (!__ASSEMBLY__) */
5#else 91#else
6#include <asm/ptrace_32.h> 92/* 32 bit sparc */
93
94#include <asm/psr.h>
95
96/* This struct defines the way the registers are stored on the
97 * stack during a system call and basically all traps.
98 */
99#ifndef __ASSEMBLY__
100
101struct pt_regs {
102 unsigned long psr;
103 unsigned long pc;
104 unsigned long npc;
105 unsigned long y;
106 unsigned long u_regs[16]; /* globals and ins */
107};
108
109/* A 32-bit register window. */
110struct reg_window32 {
111 unsigned long locals[8];
112 unsigned long ins[8];
113};
114
115/* A Sparc stack frame */
116struct sparc_stackf {
117 unsigned long locals[8];
118 unsigned long ins[6];
119 struct sparc_stackf *fp;
120 unsigned long callers_pc;
121 char *structptr;
122 unsigned long xargs[6];
123 unsigned long xxargs[1];
124};
125#endif /* (!__ASSEMBLY__) */
126
127#endif /* (defined(__sparc__) && defined(__arch64__))*/
128
129#ifndef __ASSEMBLY__
130
131#define TRACEREG_SZ sizeof(struct pt_regs)
132#define STACKFRAME_SZ sizeof(struct sparc_stackf)
133
134#define TRACEREG32_SZ sizeof(struct pt_regs32)
135#define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
136
137#endif /* (!__ASSEMBLY__) */
138
139#define UREG_G0 0
140#define UREG_G1 1
141#define UREG_G2 2
142#define UREG_G3 3
143#define UREG_G4 4
144#define UREG_G5 5
145#define UREG_G6 6
146#define UREG_G7 7
147#define UREG_I0 8
148#define UREG_I1 9
149#define UREG_I2 10
150#define UREG_I3 11
151#define UREG_I4 12
152#define UREG_I5 13
153#define UREG_I6 14
154#define UREG_I7 15
155#define UREG_FP UREG_I6
156#define UREG_RETPC UREG_I7
157
158#if defined(__sparc__) && defined(__arch64__)
159/* 64 bit sparc */
160
161#ifndef __ASSEMBLY__
162
163#ifdef __KERNEL__
164
165#include <linux/threads.h>
166#include <asm/system.h>
167
168static inline int pt_regs_trap_type(struct pt_regs *regs)
169{
170 return regs->magic & 0x1ff;
171}
172
173static inline bool pt_regs_is_syscall(struct pt_regs *regs)
174{
175 return (regs->tstate & TSTATE_SYSCALL);
176}
177
178static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
179{
180 return (regs->tstate &= ~TSTATE_SYSCALL);
181}
182
183#define arch_ptrace_stop_needed(exit_code, info) \
184({ flush_user_windows(); \
185 get_thread_wsaved() != 0; \
186})
187
188#define arch_ptrace_stop(exit_code, info) \
189 synchronize_user_stack()
190
191struct global_reg_snapshot {
192 unsigned long tstate;
193 unsigned long tpc;
194 unsigned long tnpc;
195 unsigned long o7;
196 unsigned long i7;
197 unsigned long rpc;
198 struct thread_info *thread;
199 unsigned long pad1;
200};
201extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
202
203#define force_successful_syscall_return() \
204do { current_thread_info()->syscall_noerror = 1; \
205} while (0)
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])
210#ifdef CONFIG_SMP
211extern unsigned long profile_pc(struct pt_regs *);
212#else
213#define profile_pc(regs) instruction_pointer(regs)
7#endif 214#endif
215extern void show_regs(struct pt_regs *);
216#endif /* (__KERNEL__) */
217
218#else /* __ASSEMBLY__ */
219/* For assembly code. */
220#define TRACEREG_SZ 0xa0
221#define STACKFRAME_SZ 0xc0
222
223#define TRACEREG32_SZ 0x50
224#define STACKFRAME32_SZ 0x60
225#endif /* __ASSEMBLY__ */
226
227#else /* (defined(__sparc__) && defined(__arch64__)) */
228
229/* 32 bit sparc */
230
231#ifndef __ASSEMBLY__
232
233#ifdef __KERNEL__
234
235#include <asm/system.h>
236
237static inline bool pt_regs_is_syscall(struct pt_regs *regs)
238{
239 return (regs->psr & PSR_SYSCALL);
240}
241
242static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
243{
244 return (regs->psr &= ~PSR_SYSCALL);
245}
246
247#define arch_ptrace_stop_needed(exit_code, info) \
248({ flush_user_windows(); \
249 current_thread_info()->w_saved != 0; \
250})
251
252#define arch_ptrace_stop(exit_code, info) \
253 synchronize_user_stack()
254
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])
258unsigned long profile_pc(struct pt_regs *);
259extern void show_regs(struct pt_regs *);
260#endif /* (__KERNEL__) */
261
262#else /* (!__ASSEMBLY__) */
263/* For assembly code. */
264#define TRACEREG_SZ 0x50
265#define STACKFRAME_SZ 0x60
266#endif /* (!__ASSEMBLY__) */
267
268#endif /* (defined(__sparc__) && defined(__arch64__)) */
269
270#ifdef __KERNEL__
271#define STACK_BIAS 2047
8#endif 272#endif
273
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
295#define PT_V9_Y 0x98
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
300
301/* These for pt_regs32. */
302#define PT_PSR 0x0
303#define PT_PC 0x4
304#define PT_NPC 0x8
305#define PT_Y 0xc
306#define PT_G0 0x10
307#define PT_WIM PT_G0
308#define PT_G1 0x14
309#define PT_G2 0x18
310#define PT_G3 0x1c
311#define PT_G4 0x20
312#define PT_G5 0x24
313#define PT_G6 0x28
314#define PT_G7 0x2c
315#define PT_I0 0x30
316#define PT_I1 0x34
317#define PT_I2 0x38
318#define PT_I3 0x3c
319#define PT_I4 0x40
320#define PT_I5 0x44
321#define PT_I6 0x48
322#define PT_FP PT_I6
323#define PT_I7 0x4c
324
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
342
343#define RW_L0 0x00
344#define RW_L1 0x04
345#define RW_L2 0x08
346#define RW_L3 0x0c
347#define RW_L4 0x10
348#define RW_L5 0x14
349#define RW_L6 0x18
350#define RW_L7 0x1c
351#define RW_I0 0x20
352#define RW_I1 0x24
353#define RW_I2 0x28
354#define RW_I3 0x2c
355#define RW_I4 0x30
356#define RW_I5 0x34
357#define RW_I6 0x38
358#define RW_I7 0x3c
359
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
385
386#define SF_L0 0x00
387#define SF_L1 0x04
388#define SF_L2 0x08
389#define SF_L3 0x0c
390#define SF_L4 0x10
391#define SF_L5 0x14
392#define SF_L6 0x18
393#define SF_L7 0x1c
394#define SF_I0 0x20
395#define SF_I1 0x24
396#define SF_I2 0x28
397#define SF_I3 0x2c
398#define SF_I4 0x30
399#define SF_I5 0x34
400#define SF_FP 0x38
401#define SF_PC 0x3c
402#define SF_RETP 0x40
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
410
411#ifdef __KERNEL__
412
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
422
423#endif /* __KERNEL__ */
424
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
437
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.
440 */
441
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
447
448#endif /* !(__SPARC_PTRACE_H) */
diff --git a/arch/sparc/include/asm/ptrace_32.h b/arch/sparc/include/asm/ptrace_32.h
deleted file mode 100644
index acb2d89d93e..00000000000
--- a/arch/sparc/include/asm/ptrace_32.h
+++ /dev/null
@@ -1,186 +0,0 @@
1#ifndef _SPARC_PTRACE_H
2#define _SPARC_PTRACE_H
3
4#include <asm/psr.h>
5
6/* This struct defines the way the registers are stored on the
7 * stack during a system call and basically all traps.
8 */
9
10#ifndef __ASSEMBLY__
11
12#include <linux/types.h>
13
14struct pt_regs {
15 unsigned long psr;
16 unsigned long pc;
17 unsigned long npc;
18 unsigned long y;
19 unsigned long u_regs[16]; /* globals and ins */
20};
21
22#define UREG_G0 0
23#define UREG_G1 1
24#define UREG_G2 2
25#define UREG_G3 3
26#define UREG_G4 4
27#define UREG_G5 5
28#define UREG_G6 6
29#define UREG_G7 7
30#define UREG_I0 8
31#define UREG_I1 9
32#define UREG_I2 10
33#define UREG_I3 11
34#define UREG_I4 12
35#define UREG_I5 13
36#define UREG_I6 14
37#define UREG_I7 15
38#define UREG_WIM UREG_G0
39#define UREG_FADDR UREG_G0
40#define UREG_FP UREG_I6
41#define UREG_RETPC UREG_I7
42
43/* A register window */
44struct reg_window32 {
45 unsigned long locals[8];
46 unsigned long ins[8];
47};
48
49/* A Sparc stack frame */
50struct sparc_stackf {
51 unsigned long locals[8];
52 unsigned long ins[6];
53 struct sparc_stackf *fp;
54 unsigned long callers_pc;
55 char *structptr;
56 unsigned long xargs[6];
57 unsigned long xxargs[1];
58};
59
60#define TRACEREG_SZ sizeof(struct pt_regs)
61#define STACKFRAME_SZ sizeof(struct sparc_stackf)
62
63#ifdef __KERNEL__
64
65#include <asm/system.h>
66
67static inline bool pt_regs_is_syscall(struct pt_regs *regs)
68{
69 return (regs->psr & PSR_SYSCALL);
70}
71
72static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
73{
74 return (regs->psr &= ~PSR_SYSCALL);
75}
76
77#define arch_ptrace_stop_needed(exit_code, info) \
78({ flush_user_windows(); \
79 current_thread_info()->w_saved != 0; \
80})
81
82#define arch_ptrace_stop(exit_code, info) \
83 synchronize_user_stack()
84
85#define user_mode(regs) (!((regs)->psr & PSR_PS))
86#define instruction_pointer(regs) ((regs)->pc)
87#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
88unsigned long profile_pc(struct pt_regs *);
89extern void show_regs(struct pt_regs *);
90#endif
91
92#else /* __ASSEMBLY__ */
93/* For assembly code. */
94#define TRACEREG_SZ 0x50
95#define STACKFRAME_SZ 0x60
96#endif
97
98/*
99 * The asm-offsets.h is a generated file, so we cannot include it.
100 * It may be OK for glibc headers, but it's utterly pointless for C code.
101 * The assembly code using those offsets has to include it explicitly.
102 */
103/* #include <asm/asm-offsets.h> */
104
105/* These are for pt_regs. */
106#define PT_PSR 0x0
107#define PT_PC 0x4
108#define PT_NPC 0x8
109#define PT_Y 0xc
110#define PT_G0 0x10
111#define PT_WIM PT_G0
112#define PT_G1 0x14
113#define PT_G2 0x18
114#define PT_G3 0x1c
115#define PT_G4 0x20
116#define PT_G5 0x24
117#define PT_G6 0x28
118#define PT_G7 0x2c
119#define PT_I0 0x30
120#define PT_I1 0x34
121#define PT_I2 0x38
122#define PT_I3 0x3c
123#define PT_I4 0x40
124#define PT_I5 0x44
125#define PT_I6 0x48
126#define PT_FP PT_I6
127#define PT_I7 0x4c
128
129/* Reg_window offsets */
130#define RW_L0 0x00
131#define RW_L1 0x04
132#define RW_L2 0x08
133#define RW_L3 0x0c
134#define RW_L4 0x10
135#define RW_L5 0x14
136#define RW_L6 0x18
137#define RW_L7 0x1c
138#define RW_I0 0x20
139#define RW_I1 0x24
140#define RW_I2 0x28
141#define RW_I3 0x2c
142#define RW_I4 0x30
143#define RW_I5 0x34
144#define RW_I6 0x38
145#define RW_I7 0x3c
146
147/* Stack_frame offsets */
148#define SF_L0 0x00
149#define SF_L1 0x04
150#define SF_L2 0x08
151#define SF_L3 0x0c
152#define SF_L4 0x10
153#define SF_L5 0x14
154#define SF_L6 0x18
155#define SF_L7 0x1c
156#define SF_I0 0x20
157#define SF_I1 0x24
158#define SF_I2 0x28
159#define SF_I3 0x2c
160#define SF_I4 0x30
161#define SF_I5 0x34
162#define SF_FP 0x38
163#define SF_PC 0x3c
164#define SF_RETP 0x40
165#define SF_XARG0 0x44
166#define SF_XARG1 0x48
167#define SF_XARG2 0x4c
168#define SF_XARG3 0x50
169#define SF_XARG4 0x54
170#define SF_XARG5 0x58
171#define SF_XXARG 0x5c
172
173/* Stuff for the ptrace system call */
174#define PTRACE_SPARC_DETACH 11
175#define PTRACE_GETREGS 12
176#define PTRACE_SETREGS 13
177#define PTRACE_GETFPREGS 14
178#define PTRACE_SETFPREGS 15
179#define PTRACE_READDATA 16
180#define PTRACE_WRITEDATA 17
181#define PTRACE_READTEXT 18
182#define PTRACE_WRITETEXT 19
183#define PTRACE_GETFPAREGS 20
184#define PTRACE_SETFPAREGS 21
185
186#endif /* !(_SPARC_PTRACE_H) */
diff --git a/arch/sparc/include/asm/ptrace_64.h b/arch/sparc/include/asm/ptrace_64.h
deleted file mode 100644
index cd6fbfc2043..00000000000
--- a/arch/sparc/include/asm/ptrace_64.h
+++ /dev/null
@@ -1,356 +0,0 @@
1#ifndef _SPARC64_PTRACE_H
2#define _SPARC64_PTRACE_H
3
4#include <asm/pstate.h>
5
6/* This struct defines the way the registers are stored on the
7 * stack during a system call and basically all traps.
8 */
9
10/* This magic value must have the low 9 bits clear,
11 * as that is where we encode the %tt value, see below.
12 */
13#define PT_REGS_MAGIC 0x57ac6c00
14
15#ifndef __ASSEMBLY__
16
17#include <linux/types.h>
18
19struct pt_regs {
20 unsigned long u_regs[16]; /* globals and ins */
21 unsigned long tstate;
22 unsigned long tpc;
23 unsigned long tnpc;
24 unsigned int y;
25
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
32 * process.
33 *
34 * The PT_REGS_MAGIC is choosen such that it can be
35 * loaded completely using just a sethi instruction.
36 */
37 unsigned int magic;
38};
39
40struct pt_regs32 {
41 unsigned int psr;
42 unsigned int pc;
43 unsigned int npc;
44 unsigned int y;
45 unsigned int u_regs[16]; /* globals and ins */
46};
47
48#define UREG_G0 0
49#define UREG_G1 1
50#define UREG_G2 2
51#define UREG_G3 3
52#define UREG_G4 4
53#define UREG_G5 5
54#define UREG_G6 6
55#define UREG_G7 7
56#define UREG_I0 8
57#define UREG_I1 9
58#define UREG_I2 10
59#define UREG_I3 11
60#define UREG_I4 12
61#define UREG_I5 13
62#define UREG_I6 14
63#define UREG_I7 15
64#define UREG_FP UREG_I6
65#define UREG_RETPC UREG_I7
66
67/* A V9 register window */
68struct reg_window {
69 unsigned long locals[8];
70 unsigned long ins[8];
71};
72
73/* A 32-bit register window. */
74struct reg_window32 {
75 unsigned int locals[8];
76 unsigned int ins[8];
77};
78
79/* A V9 Sparc stack frame */
80struct sparc_stackf {
81 unsigned long locals[8];
82 unsigned long ins[6];
83 struct sparc_stackf *fp;
84 unsigned long callers_pc;
85 char *structptr;
86 unsigned long xargs[6];
87 unsigned long xxargs[1];
88};
89
90/* A 32-bit Sparc stack frame */
91struct sparc_stackf32 {
92 unsigned int locals[8];
93 unsigned int ins[6];
94 unsigned int fp;
95 unsigned int callers_pc;
96 unsigned int structptr;
97 unsigned int xargs[6];
98 unsigned int xxargs[1];
99};
100
101struct sparc_trapf {
102 unsigned long locals[8];
103 unsigned long ins[8];
104 unsigned long _unused;
105 struct pt_regs *regs;
106};
107
108#define TRACEREG_SZ sizeof(struct pt_regs)
109#define STACKFRAME_SZ sizeof(struct sparc_stackf)
110
111#define TRACEREG32_SZ sizeof(struct pt_regs32)
112#define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
113
114#ifdef __KERNEL__
115
116#include <linux/threads.h>
117#include <asm/system.h>
118
119static inline int pt_regs_trap_type(struct pt_regs *regs)
120{
121 return regs->magic & 0x1ff;
122}
123
124static inline bool pt_regs_is_syscall(struct pt_regs *regs)
125{
126 return (regs->tstate & TSTATE_SYSCALL);
127}
128
129static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
130{
131 return (regs->tstate &= ~TSTATE_SYSCALL);
132}
133
134#define arch_ptrace_stop_needed(exit_code, info) \
135({ flush_user_windows(); \
136 get_thread_wsaved() != 0; \
137})
138
139#define arch_ptrace_stop(exit_code, info) \
140 synchronize_user_stack()
141
142struct global_reg_snapshot {
143 unsigned long tstate;
144 unsigned long tpc;
145 unsigned long tnpc;
146 unsigned long o7;
147 unsigned long i7;
148 unsigned long rpc;
149 struct thread_info *thread;
150 unsigned long pad1;
151};
152extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
153
154#define force_successful_syscall_return() \
155do { current_thread_info()->syscall_noerror = 1; \
156} while (0)
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])
161#ifdef CONFIG_SMP
162extern unsigned long profile_pc(struct pt_regs *);
163#else
164#define profile_pc(regs) instruction_pointer(regs)
165#endif
166extern void show_regs(struct pt_regs *);
167#endif
168
169#else /* __ASSEMBLY__ */
170/* For assembly code. */
171#define TRACEREG_SZ 0xa0
172#define STACKFRAME_SZ 0xc0
173
174#define TRACEREG32_SZ 0x50
175#define STACKFRAME32_SZ 0x60
176#endif
177
178#ifdef __KERNEL__
179#define STACK_BIAS 2047
180#endif
181
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
203#define PT_V9_Y 0x98
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
208
209/* These for pt_regs32. */
210#define PT_PSR 0x0
211#define PT_PC 0x4
212#define PT_NPC 0x8
213#define PT_Y 0xc
214#define PT_G0 0x10
215#define PT_WIM PT_G0
216#define PT_G1 0x14
217#define PT_G2 0x18
218#define PT_G3 0x1c
219#define PT_G4 0x20
220#define PT_G5 0x24
221#define PT_G6 0x28
222#define PT_G7 0x2c
223#define PT_I0 0x30
224#define PT_I1 0x34
225#define PT_I2 0x38
226#define PT_I3 0x3c
227#define PT_I4 0x40
228#define PT_I5 0x44
229#define PT_I6 0x48
230#define PT_FP PT_I6
231#define PT_I7 0x4c
232
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
250
251#define RW_L0 0x00
252#define RW_L1 0x04
253#define RW_L2 0x08
254#define RW_L3 0x0c
255#define RW_L4 0x10
256#define RW_L5 0x14
257#define RW_L6 0x18
258#define RW_L7 0x1c
259#define RW_I0 0x20
260#define RW_I1 0x24
261#define RW_I2 0x28
262#define RW_I3 0x2c
263#define RW_I4 0x30
264#define RW_I5 0x34
265#define RW_I6 0x38
266#define RW_I7 0x3c
267
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
293
294#define SF_L0 0x00
295#define SF_L1 0x04
296#define SF_L2 0x08
297#define SF_L3 0x0c
298#define SF_L4 0x10
299#define SF_L5 0x14
300#define SF_L6 0x18
301#define SF_L7 0x1c
302#define SF_I0 0x20
303#define SF_I1 0x24
304#define SF_I2 0x28
305#define SF_I3 0x2c
306#define SF_I4 0x30
307#define SF_I5 0x34
308#define SF_FP 0x38
309#define SF_PC 0x3c
310#define SF_RETP 0x40
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
318
319#ifdef __KERNEL__
320
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
330
331#endif /* __KERNEL__ */
332
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
345
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.
348 */
349
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
355
356#endif /* !(_SPARC64_PTRACE_H) */