xref: /openbmc/linux/arch/sparc/include/uapi/asm/ptrace.h (revision a8fe58ce)
1 #ifndef _UAPI__SPARC_PTRACE_H
2 #define _UAPI__SPARC_PTRACE_H
3 
4 #if defined(__sparc__) && defined(__arch64__)
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 
21 struct 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 chosen such that it can be
37 	 * loaded completely using just a sethi instruction.
38 	 */
39 	unsigned int magic;
40 };
41 
42 struct 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 */
51 struct reg_window {
52 	unsigned long locals[8];
53 	unsigned long ins[8];
54 };
55 
56 /* A 32-bit register window. */
57 struct reg_window32 {
58 	unsigned int locals[8];
59 	unsigned int ins[8];
60 };
61 
62 /* A V9 Sparc stack frame */
63 struct 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 */
74 struct 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 
84 struct 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__) */
91 #else
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 
101 #include <linux/types.h>
102 
103 struct pt_regs {
104 	unsigned long psr;
105 	unsigned long pc;
106 	unsigned long npc;
107 	unsigned long y;
108 	unsigned long u_regs[16]; /* globals and ins */
109 };
110 
111 /* A 32-bit register window. */
112 struct reg_window32 {
113 	unsigned long locals[8];
114 	unsigned long ins[8];
115 };
116 
117 /* A Sparc stack frame */
118 struct sparc_stackf {
119 	unsigned long locals[8];
120         unsigned long ins[6];
121 	struct sparc_stackf *fp;
122 	unsigned long callers_pc;
123 	char *structptr;
124 	unsigned long xargs[6];
125 	unsigned long xxargs[1];
126 };
127 #endif /* (!__ASSEMBLY__) */
128 
129 #endif /* (defined(__sparc__) && defined(__arch64__))*/
130 
131 #ifndef __ASSEMBLY__
132 
133 #define TRACEREG_SZ	sizeof(struct pt_regs)
134 #define STACKFRAME_SZ	sizeof(struct sparc_stackf)
135 
136 #define TRACEREG32_SZ	sizeof(struct pt_regs32)
137 #define STACKFRAME32_SZ	sizeof(struct sparc_stackf32)
138 
139 #endif /* (!__ASSEMBLY__) */
140 
141 #define UREG_G0        0
142 #define UREG_G1        1
143 #define UREG_G2        2
144 #define UREG_G3        3
145 #define UREG_G4        4
146 #define UREG_G5        5
147 #define UREG_G6        6
148 #define UREG_G7        7
149 #define UREG_I0        8
150 #define UREG_I1        9
151 #define UREG_I2        10
152 #define UREG_I3        11
153 #define UREG_I4        12
154 #define UREG_I5        13
155 #define UREG_I6        14
156 #define UREG_I7        15
157 #define UREG_FP        UREG_I6
158 #define UREG_RETPC     UREG_I7
159 
160 #if defined(__sparc__) && defined(__arch64__)
161 /* 64 bit sparc */
162 
163 #ifndef __ASSEMBLY__
164 
165 
166 #else /* __ASSEMBLY__ */
167 /* For assembly code. */
168 #define TRACEREG_SZ		0xa0
169 #define STACKFRAME_SZ		0xc0
170 
171 #define TRACEREG32_SZ		0x50
172 #define STACKFRAME32_SZ		0x60
173 #endif /* __ASSEMBLY__ */
174 
175 #else /* (defined(__sparc__) && defined(__arch64__)) */
176 
177 /* 32 bit sparc */
178 
179 #ifndef __ASSEMBLY__
180 
181 
182 #else /* (!__ASSEMBLY__) */
183 /* For assembly code. */
184 #define TRACEREG_SZ       0x50
185 #define STACKFRAME_SZ     0x60
186 #endif /* (!__ASSEMBLY__) */
187 
188 #endif /* (defined(__sparc__) && defined(__arch64__)) */
189 
190 
191 /* These are for pt_regs. */
192 #define PT_V9_G0     0x00
193 #define PT_V9_G1     0x08
194 #define PT_V9_G2     0x10
195 #define PT_V9_G3     0x18
196 #define PT_V9_G4     0x20
197 #define PT_V9_G5     0x28
198 #define PT_V9_G6     0x30
199 #define PT_V9_G7     0x38
200 #define PT_V9_I0     0x40
201 #define PT_V9_I1     0x48
202 #define PT_V9_I2     0x50
203 #define PT_V9_I3     0x58
204 #define PT_V9_I4     0x60
205 #define PT_V9_I5     0x68
206 #define PT_V9_I6     0x70
207 #define PT_V9_FP     PT_V9_I6
208 #define PT_V9_I7     0x78
209 #define PT_V9_TSTATE 0x80
210 #define PT_V9_TPC    0x88
211 #define PT_V9_TNPC   0x90
212 #define PT_V9_Y      0x98
213 #define PT_V9_MAGIC  0x9c
214 #define PT_TSTATE	PT_V9_TSTATE
215 #define PT_TPC		PT_V9_TPC
216 #define PT_TNPC		PT_V9_TNPC
217 
218 /* These for pt_regs32. */
219 #define PT_PSR    0x0
220 #define PT_PC     0x4
221 #define PT_NPC    0x8
222 #define PT_Y      0xc
223 #define PT_G0     0x10
224 #define PT_WIM    PT_G0
225 #define PT_G1     0x14
226 #define PT_G2     0x18
227 #define PT_G3     0x1c
228 #define PT_G4     0x20
229 #define PT_G5     0x24
230 #define PT_G6     0x28
231 #define PT_G7     0x2c
232 #define PT_I0     0x30
233 #define PT_I1     0x34
234 #define PT_I2     0x38
235 #define PT_I3     0x3c
236 #define PT_I4     0x40
237 #define PT_I5     0x44
238 #define PT_I6     0x48
239 #define PT_FP     PT_I6
240 #define PT_I7     0x4c
241 
242 /* Reg_window offsets */
243 #define RW_V9_L0     0x00
244 #define RW_V9_L1     0x08
245 #define RW_V9_L2     0x10
246 #define RW_V9_L3     0x18
247 #define RW_V9_L4     0x20
248 #define RW_V9_L5     0x28
249 #define RW_V9_L6     0x30
250 #define RW_V9_L7     0x38
251 #define RW_V9_I0     0x40
252 #define RW_V9_I1     0x48
253 #define RW_V9_I2     0x50
254 #define RW_V9_I3     0x58
255 #define RW_V9_I4     0x60
256 #define RW_V9_I5     0x68
257 #define RW_V9_I6     0x70
258 #define RW_V9_I7     0x78
259 
260 #define RW_L0     0x00
261 #define RW_L1     0x04
262 #define RW_L2     0x08
263 #define RW_L3     0x0c
264 #define RW_L4     0x10
265 #define RW_L5     0x14
266 #define RW_L6     0x18
267 #define RW_L7     0x1c
268 #define RW_I0     0x20
269 #define RW_I1     0x24
270 #define RW_I2     0x28
271 #define RW_I3     0x2c
272 #define RW_I4     0x30
273 #define RW_I5     0x34
274 #define RW_I6     0x38
275 #define RW_I7     0x3c
276 
277 /* Stack_frame offsets */
278 #define SF_V9_L0     0x00
279 #define SF_V9_L1     0x08
280 #define SF_V9_L2     0x10
281 #define SF_V9_L3     0x18
282 #define SF_V9_L4     0x20
283 #define SF_V9_L5     0x28
284 #define SF_V9_L6     0x30
285 #define SF_V9_L7     0x38
286 #define SF_V9_I0     0x40
287 #define SF_V9_I1     0x48
288 #define SF_V9_I2     0x50
289 #define SF_V9_I3     0x58
290 #define SF_V9_I4     0x60
291 #define SF_V9_I5     0x68
292 #define SF_V9_FP     0x70
293 #define SF_V9_PC     0x78
294 #define SF_V9_RETP   0x80
295 #define SF_V9_XARG0  0x88
296 #define SF_V9_XARG1  0x90
297 #define SF_V9_XARG2  0x98
298 #define SF_V9_XARG3  0xa0
299 #define SF_V9_XARG4  0xa8
300 #define SF_V9_XARG5  0xb0
301 #define SF_V9_XXARG  0xb8
302 
303 #define SF_L0     0x00
304 #define SF_L1     0x04
305 #define SF_L2     0x08
306 #define SF_L3     0x0c
307 #define SF_L4     0x10
308 #define SF_L5     0x14
309 #define SF_L6     0x18
310 #define SF_L7     0x1c
311 #define SF_I0     0x20
312 #define SF_I1     0x24
313 #define SF_I2     0x28
314 #define SF_I3     0x2c
315 #define SF_I4     0x30
316 #define SF_I5     0x34
317 #define SF_FP     0x38
318 #define SF_PC     0x3c
319 #define SF_RETP   0x40
320 #define SF_XARG0  0x44
321 #define SF_XARG1  0x48
322 #define SF_XARG2  0x4c
323 #define SF_XARG3  0x50
324 #define SF_XARG4  0x54
325 #define SF_XARG5  0x58
326 #define SF_XXARG  0x5c
327 
328 
329 /* Stuff for the ptrace system call */
330 #define PTRACE_SPARC_DETACH       11
331 #define PTRACE_GETREGS            12
332 #define PTRACE_SETREGS            13
333 #define PTRACE_GETFPREGS          14
334 #define PTRACE_SETFPREGS          15
335 #define PTRACE_READDATA           16
336 #define PTRACE_WRITEDATA          17
337 #define PTRACE_READTEXT           18
338 #define PTRACE_WRITETEXT          19
339 #define PTRACE_GETFPAREGS         20
340 #define PTRACE_SETFPAREGS         21
341 
342 /* There are for debugging 64-bit processes, either from a 32 or 64 bit
343  * parent.  Thus their complements are for debugging 32-bit processes only.
344  */
345 
346 #define PTRACE_GETREGS64	  22
347 #define PTRACE_SETREGS64	  23
348 /* PTRACE_SYSCALL is 24 */
349 #define PTRACE_GETFPREGS64	  25
350 #define PTRACE_SETFPREGS64	  26
351 
352 #endif /* _UAPI__SPARC_PTRACE_H */
353