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