import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / include / asm-ia64 / ptrace.h
1 #ifndef _ASM_IA64_PTRACE_H
2 #define _ASM_IA64_PTRACE_H
3
4 /*
5  * Copyright (C) 1998-2001 Suresh Siddha <suresh.b.siddha@intel.com>  
6  * Copyright (C) 1998-2001 Hewlett-Packard Co
7  * Copyright (C) 1998-2001 David Mosberger-Tang <davidm@hpl.hp.com>
8  * Copyright (C) 1998, 1999 Stephane Eranian <eranian@hpl.hp.com>
9  *
10  * 12/07/98     S. Eranian      added pt_regs & switch_stack
11  * 12/21/98     D. Mosberger    updated to match latest code
12  *  6/17/99     D. Mosberger    added second unat member to "struct switch_stack"
13  *
14  */
15 /*
16  * When a user process is blocked, its state looks as follows:
17  *
18  *            +----------------------+  ------- IA64_STK_OFFSET
19  *            |                      |   ^
20  *            | struct pt_regs       |   |
21  *            |                      |   |
22  *            +----------------------+   |
23  *            |                      |   |
24  *            |    memory stack      |   |
25  *            | (growing downwards)  |   |
26  *            //.....................//  |
27  *                                       |
28  *            //.....................//  |
29  *            |                      |   |
30  *            +----------------------+   |
31  *            | struct switch_stack  |   |
32  *            |                      |   |
33  *            +----------------------+   |
34  *            |                      |   |
35  *            //.....................//  |
36  *                                       |
37  *            //.....................//  |
38  *            |                      |   |
39  *            |  register stack      |   |
40  *            | (growing upwards)    |   |
41  *            |                      |   |
42  *            +----------------------+   |  --- IA64_RBS_OFFSET
43  *            |                      |   |  ^
44  *            |  struct task_struct  |   |  |
45  * current -> |                      |   |  |
46  *            +----------------------+ -------
47  *
48  * Note that ar.ec is not saved explicitly in pt_reg or switch_stack.
49  * This is because ar.ec is saved as part of ar.pfs.
50  */
51
52 #include <linux/config.h>
53
54 #include <asm/fpu.h>
55 #include <asm/offsets.h>
56
57 /*
58  * Base-2 logarithm of number of pages to allocate per task structure
59  * (including register backing store and memory stack):
60  */
61 #if defined(CONFIG_IA64_PAGE_SIZE_4KB)
62 # define IA64_TASK_STRUCT_LOG_NUM_PAGES         3
63 #elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
64 # define IA64_TASK_STRUCT_LOG_NUM_PAGES         2
65 #elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
66 # define IA64_TASK_STRUCT_LOG_NUM_PAGES         1
67 #else
68 # define IA64_TASK_STRUCT_LOG_NUM_PAGES         0
69 #endif
70
71 #define IA64_RBS_OFFSET                 ((IA64_TASK_SIZE + 15) & ~15)
72 #define IA64_STK_OFFSET                 ((1 << IA64_TASK_STRUCT_LOG_NUM_PAGES)*PAGE_SIZE)
73
74 #define INIT_TASK_SIZE                  IA64_STK_OFFSET
75
76 #ifndef __ASSEMBLY__
77
78 #include <asm/current.h>
79 #include <asm/page.h>
80
81 /*
82  * This struct defines the way the registers are saved on system
83  * calls.
84  *
85  * We don't save all floating point register because the kernel
86  * is compiled to use only a very small subset, so the other are
87  * untouched.
88  *
89  * THIS STRUCTURE MUST BE A MULTIPLE 16-BYTE IN SIZE
90  * (because the memory stack pointer MUST ALWAYS be aligned this way)
91  *
92  */
93 struct pt_regs {
94         /* In break_fault, only registers from cr_ipsr to r15 are saved. 
95          * In any other interruptions, the registers cr_ipsr~r15, r8~r11, and r14~r3 are saved by 
96          * SAVE_MIN and all other registers are saved by SAVE_REST.
97          */
98         unsigned long b6;               /* scratch */
99         unsigned long b7;               /* scratch */
100
101         unsigned long ar_csd;           /* used by cmp8xchg16 (scratch) */
102         unsigned long ar_ssd;           /* reserved for future use (scratch) */
103
104         unsigned long r8;               /* scratch (return value register 0) */
105         unsigned long r9;               /* scratch (return value register 1) */
106         unsigned long r10;              /* scratch (return value register 2) */
107         unsigned long r11;              /* scratch (return value register 3) */
108
109         unsigned long cr_ipsr;          /* interrupted task's psr */
110         unsigned long cr_iip;           /* interrupted task's instruction pointer */
111         unsigned long cr_ifs;           /* interrupted task's function state */
112
113         unsigned long ar_unat;          /* interrupted task's NaT register (preserved) */
114         unsigned long ar_pfs;           /* prev function state  */
115         unsigned long ar_rsc;           /* RSE configuration */
116         /* The following two are valid only if cr_ipsr.cpl > 0: */
117         unsigned long ar_rnat;          /* RSE NaT */
118         unsigned long ar_bspstore;      /* RSE bspstore */
119
120         unsigned long pr;               /* 64 predicate registers (1 bit each) */
121         unsigned long b0;               /* return pointer (bp) */
122         unsigned long loadrs;           /* size of dirty partition << 16 */
123
124         unsigned long r1;               /* the gp pointer */
125         unsigned long r12;              /* interrupted task's memory stack pointer */
126         unsigned long r13;              /* thread pointer */
127
128         unsigned long ar_fpsr;          /* floating point status (preserved) */
129         unsigned long r15;              /* scratch */
130
131         unsigned long r14;              /* scratch */
132         unsigned long r2;               /* scratch */
133         unsigned long r3;               /* scratch */
134
135         unsigned long r16;              /* scratch */
136         unsigned long r17;              /* scratch */
137         unsigned long r18;              /* scratch */
138         unsigned long r19;              /* scratch */
139         unsigned long r20;              /* scratch */
140         unsigned long r21;              /* scratch */
141         unsigned long r22;              /* scratch */
142         unsigned long r23;              /* scratch */
143         unsigned long r24;              /* scratch */
144         unsigned long r25;              /* scratch */
145         unsigned long r26;              /* scratch */
146         unsigned long r27;              /* scratch */
147         unsigned long r28;              /* scratch */
148         unsigned long r29;              /* scratch */
149         unsigned long r30;              /* scratch */
150         unsigned long r31;              /* scratch */
151
152         unsigned long ar_ccv;           /* compare/exchange value (scratch) */
153
154         /*
155          * Floating point registers that the kernel considers
156          * scratch:
157          */
158         struct ia64_fpreg f6;           /* scratch */
159         struct ia64_fpreg f7;           /* scratch */
160         struct ia64_fpreg f8;           /* scratch */
161         struct ia64_fpreg f9;           /* scratch */
162         struct ia64_fpreg f10;          /* scratch */
163         struct ia64_fpreg f11;          /* scratch */
164 };
165
166 /*
167  * This structure contains the addition registers that need to
168  * preserved across a context switch.  This generally consists of
169  * "preserved" registers.
170  */
171 struct switch_stack {
172         unsigned long caller_unat;      /* user NaT collection register (preserved) */
173         unsigned long ar_fpsr;          /* floating-point status register */
174
175         struct ia64_fpreg f2;           /* preserved */
176         struct ia64_fpreg f3;           /* preserved */
177         struct ia64_fpreg f4;           /* preserved */
178         struct ia64_fpreg f5;           /* preserved */
179
180         struct ia64_fpreg f12;          /* scratch, but untouched by kernel */
181         struct ia64_fpreg f13;          /* scratch, but untouched by kernel */
182         struct ia64_fpreg f14;          /* scratch, but untouched by kernel */
183         struct ia64_fpreg f15;          /* scratch, but untouched by kernel */
184         struct ia64_fpreg f16;          /* preserved */
185         struct ia64_fpreg f17;          /* preserved */
186         struct ia64_fpreg f18;          /* preserved */
187         struct ia64_fpreg f19;          /* preserved */
188         struct ia64_fpreg f20;          /* preserved */
189         struct ia64_fpreg f21;          /* preserved */
190         struct ia64_fpreg f22;          /* preserved */
191         struct ia64_fpreg f23;          /* preserved */
192         struct ia64_fpreg f24;          /* preserved */
193         struct ia64_fpreg f25;          /* preserved */
194         struct ia64_fpreg f26;          /* preserved */
195         struct ia64_fpreg f27;          /* preserved */
196         struct ia64_fpreg f28;          /* preserved */
197         struct ia64_fpreg f29;          /* preserved */
198         struct ia64_fpreg f30;          /* preserved */
199         struct ia64_fpreg f31;          /* preserved */
200
201         unsigned long r4;               /* preserved */
202         unsigned long r5;               /* preserved */
203         unsigned long r6;               /* preserved */
204         unsigned long r7;               /* preserved */
205
206         unsigned long b0;               /* so we can force a direct return in copy_thread */
207         unsigned long b1;
208         unsigned long b2;
209         unsigned long b3;
210         unsigned long b4;
211         unsigned long b5;
212
213         unsigned long ar_pfs;           /* previous function state */
214         unsigned long ar_lc;            /* loop counter (preserved) */
215         unsigned long ar_unat;          /* NaT bits for r4-r7 */
216         unsigned long ar_rnat;          /* RSE NaT collection register */
217         unsigned long ar_bspstore;      /* RSE dirty base (preserved) */
218         unsigned long pr;               /* 64 predicate registers (1 bit each) */
219 };
220
221 #ifdef __KERNEL__
222   /* given a pointer to a task_struct, return the user's pt_regs */
223 # define ia64_task_regs(t)              (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1)
224 # define ia64_psr(regs)                 ((struct ia64_psr *) &(regs)->cr_ipsr)
225 # define user_mode(regs)                (((struct ia64_psr *) &(regs)->cr_ipsr)->cpl != 0)
226
227   struct task_struct;                   /* forward decl */
228   struct unw_frame_info;                /* forward decl */
229
230   extern void show_regs (struct pt_regs *);
231   extern void ia64_do_show_stack (struct unw_frame_info *, void *);
232   extern unsigned long ia64_get_user_rbs_end (struct task_struct *, struct pt_regs *,
233                                               unsigned long *);
234   extern long ia64_peek (struct task_struct *, struct switch_stack *, unsigned long,
235                          unsigned long, long *);
236   extern long ia64_poke (struct task_struct *, struct switch_stack *, unsigned long,
237                          unsigned long, long);
238   extern void ia64_flush_fph (struct task_struct *);
239   extern void ia64_sync_fph (struct task_struct *);
240   extern long ia64_sync_user_rbs (struct task_struct *, struct switch_stack *,
241                                   unsigned long, unsigned long);
242
243   /* get nat bits for scratch registers such that bit N==1 iff scratch register rN is a NaT */
244   extern unsigned long ia64_get_scratch_nat_bits (struct pt_regs *pt, unsigned long scratch_unat);
245   /* put nat bits for scratch registers such that scratch register rN is a NaT iff bit N==1 */
246   extern unsigned long ia64_put_scratch_nat_bits (struct pt_regs *pt, unsigned long nat);
247
248   extern void ia64_increment_ip (struct pt_regs *pt);
249   extern void ia64_decrement_ip (struct pt_regs *pt);
250
251 #define force_successful_syscall_return()               \
252         do {                                            \
253                 ia64_task_regs(current)->r8 = 0;        \
254         } while (0)
255
256 #endif /* !__KERNEL__ */
257
258 /* pt_all_user_regs is used for PTRACE_GETREGS PTRACE_SETREGS */
259 struct pt_all_user_regs {
260         unsigned long nat;
261         unsigned long cr_iip;
262         unsigned long cfm;
263         unsigned long cr_ipsr;
264         unsigned long pr;
265
266         unsigned long gr[32];
267         unsigned long br[8];
268         unsigned long ar[128];
269         struct ia64_fpreg fr[128];
270 };
271
272 #endif /* !__ASSEMBLY__ */
273
274 /* indices to application-registers array in pt_all_user_regs */
275 #define PT_AUR_RSC      16
276 #define PT_AUR_BSP      17
277 #define PT_AUR_BSPSTORE 18
278 #define PT_AUR_RNAT     19
279 #define PT_AUR_CCV      32
280 #define PT_AUR_UNAT     36
281 #define PT_AUR_FPSR     40
282 #define PT_AUR_PFS      64
283 #define PT_AUR_LC       65
284 #define PT_AUR_EC       66
285
286 /*
287  * The numbers chosen here are somewhat arbitrary but absolutely MUST
288  * not overlap with any of the number assigned in <linux/ptrace.h>.
289  */
290 #define PTRACE_SINGLEBLOCK      12      /* resume execution until next branch */
291 #define PTRACE_GETSIGINFO       13      /* get child's siginfo structure */
292 #define PTRACE_SETSIGINFO       14      /* set child's siginfo structure */
293 #define PTRACE_GETREGS          18      /* get all registers (pt_all_user_regs) in one shot */
294 #define PTRACE_SETREGS          19      /* set all registers (pt_all_user_regs) in one shot */
295
296 #endif /* _ASM_IA64_PTRACE_H */