]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/sparc/include/asm/ptrace_64.h
Merge branches 'topic/fix/misc' and 'topic/fix/asoc' into for-linus
[linux-2.6-omap-h63xx.git] / arch / sparc / include / asm / ptrace_64.h
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
19 struct 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
40 struct 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 */
68 struct reg_window {
69         unsigned long locals[8];
70         unsigned long ins[8];
71 };
72
73 /* A 32-bit register window. */
74 struct reg_window32 {
75         unsigned int locals[8];
76         unsigned int ins[8];
77 };
78
79 /* A V9 Sparc stack frame */
80 struct 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 */
91 struct 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
101 struct 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
118 static inline int pt_regs_trap_type(struct pt_regs *regs)
119 {
120         return regs->magic & 0x1ff;
121 }
122
123 static inline bool pt_regs_is_syscall(struct pt_regs *regs)
124 {
125         return (regs->tstate & TSTATE_SYSCALL);
126 }
127
128 static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
129 {
130         return (regs->tstate &= ~TSTATE_SYSCALL);
131 }
132
133 struct global_reg_snapshot {
134         unsigned long           tstate;
135         unsigned long           tpc;
136         unsigned long           tnpc;
137         unsigned long           o7;
138         unsigned long           i7;
139         unsigned long           rpc;
140         struct thread_info      *thread;
141         unsigned long           pad1;
142 };
143 extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
144
145 #define __ARCH_WANT_COMPAT_SYS_PTRACE
146
147 #define force_successful_syscall_return()           \
148 do {    current_thread_info()->syscall_noerror = 1; \
149 } while (0)
150 #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
151 #define instruction_pointer(regs) ((regs)->tpc)
152 #define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
153 #define regs_return_value(regs) ((regs)->u_regs[UREG_I0])
154 #ifdef CONFIG_SMP
155 extern unsigned long profile_pc(struct pt_regs *);
156 #else
157 #define profile_pc(regs) instruction_pointer(regs)
158 #endif
159 extern void show_regs(struct pt_regs *);
160 #endif
161
162 #else /* __ASSEMBLY__ */
163 /* For assembly code. */
164 #define TRACEREG_SZ             0xa0
165 #define STACKFRAME_SZ           0xc0
166
167 #define TRACEREG32_SZ           0x50
168 #define STACKFRAME32_SZ         0x60
169 #endif
170
171 #ifdef __KERNEL__
172 #define STACK_BIAS              2047
173 #endif
174
175 /* These are for pt_regs. */
176 #define PT_V9_G0     0x00
177 #define PT_V9_G1     0x08
178 #define PT_V9_G2     0x10
179 #define PT_V9_G3     0x18
180 #define PT_V9_G4     0x20
181 #define PT_V9_G5     0x28
182 #define PT_V9_G6     0x30
183 #define PT_V9_G7     0x38
184 #define PT_V9_I0     0x40
185 #define PT_V9_I1     0x48
186 #define PT_V9_I2     0x50
187 #define PT_V9_I3     0x58
188 #define PT_V9_I4     0x60
189 #define PT_V9_I5     0x68
190 #define PT_V9_I6     0x70
191 #define PT_V9_FP     PT_V9_I6
192 #define PT_V9_I7     0x78
193 #define PT_V9_TSTATE 0x80
194 #define PT_V9_TPC    0x88
195 #define PT_V9_TNPC   0x90
196 #define PT_V9_Y      0x98
197 #define PT_V9_MAGIC  0x9c
198 #define PT_TSTATE       PT_V9_TSTATE
199 #define PT_TPC          PT_V9_TPC
200 #define PT_TNPC         PT_V9_TNPC
201
202 /* These for pt_regs32. */
203 #define PT_PSR    0x0
204 #define PT_PC     0x4
205 #define PT_NPC    0x8
206 #define PT_Y      0xc
207 #define PT_G0     0x10
208 #define PT_WIM    PT_G0
209 #define PT_G1     0x14
210 #define PT_G2     0x18
211 #define PT_G3     0x1c
212 #define PT_G4     0x20
213 #define PT_G5     0x24
214 #define PT_G6     0x28
215 #define PT_G7     0x2c
216 #define PT_I0     0x30
217 #define PT_I1     0x34
218 #define PT_I2     0x38
219 #define PT_I3     0x3c
220 #define PT_I4     0x40
221 #define PT_I5     0x44
222 #define PT_I6     0x48
223 #define PT_FP     PT_I6
224 #define PT_I7     0x4c
225
226 /* Reg_window offsets */
227 #define RW_V9_L0     0x00
228 #define RW_V9_L1     0x08
229 #define RW_V9_L2     0x10
230 #define RW_V9_L3     0x18
231 #define RW_V9_L4     0x20
232 #define RW_V9_L5     0x28
233 #define RW_V9_L6     0x30
234 #define RW_V9_L7     0x38
235 #define RW_V9_I0     0x40
236 #define RW_V9_I1     0x48
237 #define RW_V9_I2     0x50
238 #define RW_V9_I3     0x58
239 #define RW_V9_I4     0x60
240 #define RW_V9_I5     0x68
241 #define RW_V9_I6     0x70
242 #define RW_V9_I7     0x78
243
244 #define RW_L0     0x00
245 #define RW_L1     0x04
246 #define RW_L2     0x08
247 #define RW_L3     0x0c
248 #define RW_L4     0x10
249 #define RW_L5     0x14
250 #define RW_L6     0x18
251 #define RW_L7     0x1c
252 #define RW_I0     0x20
253 #define RW_I1     0x24
254 #define RW_I2     0x28
255 #define RW_I3     0x2c
256 #define RW_I4     0x30
257 #define RW_I5     0x34
258 #define RW_I6     0x38
259 #define RW_I7     0x3c
260
261 /* Stack_frame offsets */
262 #define SF_V9_L0     0x00
263 #define SF_V9_L1     0x08
264 #define SF_V9_L2     0x10
265 #define SF_V9_L3     0x18
266 #define SF_V9_L4     0x20
267 #define SF_V9_L5     0x28
268 #define SF_V9_L6     0x30
269 #define SF_V9_L7     0x38
270 #define SF_V9_I0     0x40
271 #define SF_V9_I1     0x48
272 #define SF_V9_I2     0x50
273 #define SF_V9_I3     0x58
274 #define SF_V9_I4     0x60
275 #define SF_V9_I5     0x68
276 #define SF_V9_FP     0x70
277 #define SF_V9_PC     0x78
278 #define SF_V9_RETP   0x80
279 #define SF_V9_XARG0  0x88
280 #define SF_V9_XARG1  0x90
281 #define SF_V9_XARG2  0x98
282 #define SF_V9_XARG3  0xa0
283 #define SF_V9_XARG4  0xa8
284 #define SF_V9_XARG5  0xb0
285 #define SF_V9_XXARG  0xb8
286
287 #define SF_L0     0x00
288 #define SF_L1     0x04
289 #define SF_L2     0x08
290 #define SF_L3     0x0c
291 #define SF_L4     0x10
292 #define SF_L5     0x14
293 #define SF_L6     0x18
294 #define SF_L7     0x1c
295 #define SF_I0     0x20
296 #define SF_I1     0x24
297 #define SF_I2     0x28
298 #define SF_I3     0x2c
299 #define SF_I4     0x30
300 #define SF_I5     0x34
301 #define SF_FP     0x38
302 #define SF_PC     0x3c
303 #define SF_RETP   0x40
304 #define SF_XARG0  0x44
305 #define SF_XARG1  0x48
306 #define SF_XARG2  0x4c
307 #define SF_XARG3  0x50
308 #define SF_XARG4  0x54
309 #define SF_XARG5  0x58
310 #define SF_XXARG  0x5c
311
312 #ifdef __KERNEL__
313
314 /* global_reg_snapshot offsets */
315 #define GR_SNAP_TSTATE  0x00
316 #define GR_SNAP_TPC     0x08
317 #define GR_SNAP_TNPC    0x10
318 #define GR_SNAP_O7      0x18
319 #define GR_SNAP_I7      0x20
320 #define GR_SNAP_RPC     0x28
321 #define GR_SNAP_THREAD  0x30
322 #define GR_SNAP_PAD1    0x38
323
324 #endif  /*  __KERNEL__  */
325
326 /* Stuff for the ptrace system call */
327 #define PTRACE_SPARC_DETACH       11
328 #define PTRACE_GETREGS            12
329 #define PTRACE_SETREGS            13
330 #define PTRACE_GETFPREGS          14
331 #define PTRACE_SETFPREGS          15
332 #define PTRACE_READDATA           16
333 #define PTRACE_WRITEDATA          17
334 #define PTRACE_READTEXT           18
335 #define PTRACE_WRITETEXT          19
336 #define PTRACE_GETFPAREGS         20
337 #define PTRACE_SETFPAREGS         21
338
339 /* There are for debugging 64-bit processes, either from a 32 or 64 bit
340  * parent.  Thus their complements are for debugging 32-bit processes only.
341  */
342
343 #define PTRACE_GETREGS64          22
344 #define PTRACE_SETREGS64          23
345 /* PTRACE_SYSCALL is 24 */
346 #define PTRACE_GETFPREGS64        25
347 #define PTRACE_SETFPREGS64        26
348
349 #endif /* !(_SPARC64_PTRACE_H) */