ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-sparc64 / ptrace.h
1 /* $Id: ptrace.h,v 1.14 2002/02/09 19:49:32 davem Exp $ */
2 #ifndef _SPARC64_PTRACE_H
3 #define _SPARC64_PTRACE_H
4
5 #include <asm/pstate.h>
6
7 /* This struct defines the way the registers are stored on the 
8  * stack during a system call and basically all traps.
9  */
10
11 #ifndef __ASSEMBLY__
12
13 struct pt_regs {
14         unsigned long u_regs[16]; /* globals and ins */
15         unsigned long tstate;
16         unsigned long tpc;
17         unsigned long tnpc;
18         unsigned int y;
19         unsigned int fprs;
20 };
21
22 struct pt_regs32 {
23         unsigned int psr;
24         unsigned int pc;
25         unsigned int npc;
26         unsigned int y;
27         unsigned int u_regs[16]; /* globals and ins */
28 };
29
30 #define UREG_G0        0
31 #define UREG_G1        1
32 #define UREG_G2        2
33 #define UREG_G3        3
34 #define UREG_G4        4
35 #define UREG_G5        5
36 #define UREG_G6        6
37 #define UREG_G7        7
38 #define UREG_I0        8
39 #define UREG_I1        9
40 #define UREG_I2        10
41 #define UREG_I3        11
42 #define UREG_I4        12
43 #define UREG_I5        13
44 #define UREG_I6        14
45 #define UREG_I7        15
46 #define UREG_FP        UREG_I6
47 #define UREG_RETPC     UREG_I7
48
49 /* A V9 register window */
50 struct reg_window {
51         unsigned long locals[8];
52         unsigned long ins[8];
53 };
54
55 /* A 32-bit register window. */
56 struct reg_window32 {
57         unsigned int locals[8];
58         unsigned int ins[8];
59 };
60
61 /* A V9 Sparc stack frame */
62 struct sparc_stackf {
63         unsigned long locals[8];
64         unsigned long ins[6];
65         struct sparc_stackf *fp;
66         unsigned long callers_pc;
67         char *structptr;
68         unsigned long xargs[6];
69         unsigned long xxargs[1];
70 };      
71
72 /* A 32-bit Sparc stack frame */
73 struct sparc_stackf32 {
74         unsigned int locals[8];
75         unsigned int ins[6];
76         unsigned int fp;
77         unsigned int callers_pc;
78         unsigned int structptr;
79         unsigned int xargs[6];
80         unsigned int xxargs[1];
81 };      
82
83 struct sparc_trapf {
84         unsigned long locals[8];
85         unsigned long ins[8];
86         unsigned long _unused;
87         struct pt_regs *regs;
88 };
89
90 #define TRACEREG_SZ     sizeof(struct pt_regs)
91 #define STACKFRAME_SZ   sizeof(struct sparc_stackf)
92
93 #define TRACEREG32_SZ   sizeof(struct pt_regs32)
94 #define STACKFRAME32_SZ sizeof(struct sparc_stackf32)
95
96 #ifdef __KERNEL__
97 #define force_successful_syscall_return()       \
98         set_thread_flag(TIF_SYSCALL_SUCCESS)
99 #define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
100 #define instruction_pointer(regs) ((regs)->tpc)
101 extern void show_regs(struct pt_regs *);
102 #endif
103
104 #else /* __ASSEMBLY__ */
105 /* For assembly code. */
106 #define TRACEREG_SZ             0xa0
107 #define STACKFRAME_SZ           0xc0
108
109 #define TRACEREG32_SZ           0x50
110 #define STACKFRAME32_SZ         0x60
111 #endif
112
113 #ifdef __KERNEL__
114 #define STACK_BIAS              2047
115 #endif
116
117 /* These are for pt_regs. */
118 #define PT_V9_G0     0x00
119 #define PT_V9_G1     0x08
120 #define PT_V9_G2     0x10
121 #define PT_V9_G3     0x18
122 #define PT_V9_G4     0x20
123 #define PT_V9_G5     0x28
124 #define PT_V9_G6     0x30
125 #define PT_V9_G7     0x38
126 #define PT_V9_I0     0x40
127 #define PT_V9_I1     0x48
128 #define PT_V9_I2     0x50
129 #define PT_V9_I3     0x58
130 #define PT_V9_I4     0x60
131 #define PT_V9_I5     0x68
132 #define PT_V9_I6     0x70
133 #define PT_V9_FP     PT_V9_I6
134 #define PT_V9_I7     0x78
135 #define PT_V9_TSTATE 0x80
136 #define PT_V9_TPC    0x88
137 #define PT_V9_TNPC   0x90
138 #define PT_V9_Y      0x98
139 #define PT_V9_FPRS   0x9c
140 #define PT_TSTATE       PT_V9_TSTATE
141 #define PT_TPC          PT_V9_TPC
142 #define PT_TNPC         PT_V9_TNPC
143
144 /* These for pt_regs32. */
145 #define PT_PSR    0x0
146 #define PT_PC     0x4
147 #define PT_NPC    0x8
148 #define PT_Y      0xc
149 #define PT_G0     0x10
150 #define PT_WIM    PT_G0
151 #define PT_G1     0x14
152 #define PT_G2     0x18
153 #define PT_G3     0x1c
154 #define PT_G4     0x20
155 #define PT_G5     0x24
156 #define PT_G6     0x28
157 #define PT_G7     0x2c
158 #define PT_I0     0x30
159 #define PT_I1     0x34
160 #define PT_I2     0x38
161 #define PT_I3     0x3c
162 #define PT_I4     0x40
163 #define PT_I5     0x44
164 #define PT_I6     0x48
165 #define PT_FP     PT_I6
166 #define PT_I7     0x4c
167
168 /* Reg_window offsets */
169 #define RW_V9_L0     0x00
170 #define RW_V9_L1     0x08
171 #define RW_V9_L2     0x10
172 #define RW_V9_L3     0x18
173 #define RW_V9_L4     0x20
174 #define RW_V9_L5     0x28
175 #define RW_V9_L6     0x30
176 #define RW_V9_L7     0x38
177 #define RW_V9_I0     0x40
178 #define RW_V9_I1     0x48
179 #define RW_V9_I2     0x50
180 #define RW_V9_I3     0x58
181 #define RW_V9_I4     0x60
182 #define RW_V9_I5     0x68
183 #define RW_V9_I6     0x70
184 #define RW_V9_I7     0x78
185
186 #define RW_L0     0x00
187 #define RW_L1     0x04
188 #define RW_L2     0x08
189 #define RW_L3     0x0c
190 #define RW_L4     0x10
191 #define RW_L5     0x14
192 #define RW_L6     0x18
193 #define RW_L7     0x1c
194 #define RW_I0     0x20
195 #define RW_I1     0x24
196 #define RW_I2     0x28
197 #define RW_I3     0x2c
198 #define RW_I4     0x30
199 #define RW_I5     0x34
200 #define RW_I6     0x38
201 #define RW_I7     0x3c
202
203 /* Stack_frame offsets */
204 #define SF_V9_L0     0x00
205 #define SF_V9_L1     0x08
206 #define SF_V9_L2     0x10
207 #define SF_V9_L3     0x18
208 #define SF_V9_L4     0x20
209 #define SF_V9_L5     0x28
210 #define SF_V9_L6     0x30
211 #define SF_V9_L7     0x38
212 #define SF_V9_I0     0x40
213 #define SF_V9_I1     0x48
214 #define SF_V9_I2     0x50
215 #define SF_V9_I3     0x58
216 #define SF_V9_I4     0x60
217 #define SF_V9_I5     0x68
218 #define SF_V9_FP     0x70
219 #define SF_V9_PC     0x78
220 #define SF_V9_RETP   0x80
221 #define SF_V9_XARG0  0x88
222 #define SF_V9_XARG1  0x90
223 #define SF_V9_XARG2  0x98
224 #define SF_V9_XARG3  0xa0
225 #define SF_V9_XARG4  0xa8
226 #define SF_V9_XARG5  0xb0
227 #define SF_V9_XXARG  0xb8
228
229 #define SF_L0     0x00
230 #define SF_L1     0x04
231 #define SF_L2     0x08
232 #define SF_L3     0x0c
233 #define SF_L4     0x10
234 #define SF_L5     0x14
235 #define SF_L6     0x18
236 #define SF_L7     0x1c
237 #define SF_I0     0x20
238 #define SF_I1     0x24
239 #define SF_I2     0x28
240 #define SF_I3     0x2c
241 #define SF_I4     0x30
242 #define SF_I5     0x34
243 #define SF_FP     0x38
244 #define SF_PC     0x3c
245 #define SF_RETP   0x40
246 #define SF_XARG0  0x44
247 #define SF_XARG1  0x48
248 #define SF_XARG2  0x4c
249 #define SF_XARG3  0x50
250 #define SF_XARG4  0x54
251 #define SF_XARG5  0x58
252 #define SF_XXARG  0x5c
253
254 /* Stuff for the ptrace system call */
255 #define PTRACE_SUNATTACH          10
256 #define PTRACE_SUNDETACH          11
257 #define PTRACE_GETREGS            12
258 #define PTRACE_SETREGS            13
259 #define PTRACE_GETFPREGS          14
260 #define PTRACE_SETFPREGS          15
261 #define PTRACE_READDATA           16
262 #define PTRACE_WRITEDATA          17
263 #define PTRACE_READTEXT           18
264 #define PTRACE_WRITETEXT          19
265 #define PTRACE_GETFPAREGS         20
266 #define PTRACE_SETFPAREGS         21
267
268 /* There are for debugging 64-bit processes, either from a 32 or 64 bit
269  * parent.  Thus their complements are for debugging 32-bit processes only.
270  */
271
272 #define PTRACE_GETREGS64          22
273 #define PTRACE_SETREGS64          23
274 /* PTRACE_SYSCALL is 24 */
275 #define PTRACE_GETFPREGS64        25
276 #define PTRACE_SETFPREGS64        26
277
278 #define PTRACE_GETUCODE           29  /* stupid bsd-ism */
279
280 /* These are for 32-bit processes debugging 64-bit ones.
281  * Here addr and addr2 are passed in %g2 and %g3 respectively.
282  */
283 #define PTRACE_PEEKTEXT64         (30 + PTRACE_PEEKTEXT)
284 #define PTRACE_POKETEXT64         (30 + PTRACE_POKETEXT)
285 #define PTRACE_PEEKDATA64         (30 + PTRACE_PEEKDATA)
286 #define PTRACE_POKEDATA64         (30 + PTRACE_POKEDATA)
287 #define PTRACE_READDATA64         (30 + PTRACE_READDATA)
288 #define PTRACE_WRITEDATA64        (30 + PTRACE_WRITEDATA)
289 #define PTRACE_READTEXT64         (30 + PTRACE_READTEXT)
290 #define PTRACE_WRITETEXT64        (30 + PTRACE_WRITETEXT)
291
292 #endif /* !(_SPARC64_PTRACE_H) */