special usb hub handling, IDE disks, and retries all over the place
[linux-2.4.git] / include / asm-s390 / ptrace.h
1 /*
2  *  include/asm-s390/ptrace.h
3  *
4  *  S390 version
5  *    Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6  *    Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
7  */
8
9 #ifndef _S390_PTRACE_H
10 #define _S390_PTRACE_H
11
12 /*
13  * Offsets in the user_regs_struct. They are used for the ptrace
14  * system call and in entry.S
15  */
16 #define PT_PSWMASK  0x00
17 #define PT_PSWADDR  0x04
18 #define PT_GPR0     0x08
19 #define PT_GPR1     0x0C
20 #define PT_GPR2     0x10
21 #define PT_GPR3     0x14
22 #define PT_GPR4     0x18
23 #define PT_GPR5     0x1C
24 #define PT_GPR6     0x20
25 #define PT_GPR7     0x24
26 #define PT_GPR8     0x28
27 #define PT_GPR9     0x2C
28 #define PT_GPR10    0x30
29 #define PT_GPR11    0x34
30 #define PT_GPR12    0x38
31 #define PT_GPR13    0x3C
32 #define PT_GPR14    0x40
33 #define PT_GPR15    0x44
34 #define PT_ACR0     0x48
35 #define PT_ACR1     0x4C
36 #define PT_ACR2     0x50
37 #define PT_ACR3     0x54
38 #define PT_ACR4     0x58
39 #define PT_ACR5     0x5C
40 #define PT_ACR6     0x60
41 #define PT_ACR7     0x64
42 #define PT_ACR8     0x68
43 #define PT_ACR9     0x6C
44 #define PT_ACR10    0x70
45 #define PT_ACR11    0x74
46 #define PT_ACR12    0x78
47 #define PT_ACR13    0x7C
48 #define PT_ACR14    0x80
49 #define PT_ACR15    0x84
50 #define PT_ORIGGPR2 0x88
51 #define PT_FPC      0x90
52 /*
53  * A nasty fact of life that the ptrace api
54  * only supports passing of longs.
55  */
56 #define PT_FPR0_HI  0x98
57 #define PT_FPR0_LO  0x9C
58 #define PT_FPR1_HI  0xA0
59 #define PT_FPR1_LO  0xA4
60 #define PT_FPR2_HI  0xA8
61 #define PT_FPR2_LO  0xAC
62 #define PT_FPR3_HI  0xB0
63 #define PT_FPR3_LO  0xB4
64 #define PT_FPR4_HI  0xB8
65 #define PT_FPR4_LO  0xBC
66 #define PT_FPR5_HI  0xC0
67 #define PT_FPR5_LO  0xC4
68 #define PT_FPR6_HI  0xC8
69 #define PT_FPR6_LO  0xCC
70 #define PT_FPR7_HI  0xD0
71 #define PT_FPR7_LO  0xD4
72 #define PT_FPR8_HI  0xD8
73 #define PT_FPR8_LO  0XDC
74 #define PT_FPR9_HI  0xE0
75 #define PT_FPR9_LO  0xE4
76 #define PT_FPR10_HI 0xE8
77 #define PT_FPR10_LO 0xEC
78 #define PT_FPR11_HI 0xF0
79 #define PT_FPR11_LO 0xF4
80 #define PT_FPR12_HI 0xF8
81 #define PT_FPR12_LO 0xFC
82 #define PT_FPR13_HI 0x100
83 #define PT_FPR13_LO 0x104
84 #define PT_FPR14_HI 0x108
85 #define PT_FPR14_LO 0x10C
86 #define PT_FPR15_HI 0x110
87 #define PT_FPR15_LO 0x114
88 #define PT_CR_9     0x118
89 #define PT_CR_10    0x11C
90 #define PT_CR_11    0x120
91 #define PT_IEEE_IP  0x13C
92 #define PT_LASTOFF  PT_IEEE_IP
93 #define PT_ENDREGS  0x140-1
94
95 #define NUM_GPRS        16
96 #define NUM_FPRS        16
97 #define NUM_CRS         16
98 #define NUM_ACRS        16
99 #define GPR_SIZE        4
100 #define FPR_SIZE        8
101 #define FPC_SIZE        4
102 #define FPC_PAD_SIZE    4 /* gcc insists on aligning the fpregs */
103 #define CR_SIZE         4
104 #define ACR_SIZE        4
105
106 #define STACK_FRAME_OVERHEAD    96      /* size of minimum stack frame */
107
108 #ifndef __ASSEMBLY__
109 #include <linux/config.h>
110 #include <linux/stddef.h>
111 #include <linux/types.h>
112
113 #include <asm/current.h>
114 #include <asm/setup.h>
115
116 /* this typedef defines how a Program Status Word looks like */
117 typedef struct 
118 {
119         __u32   mask;
120         __u32   addr;
121 } __attribute__ ((aligned(8))) psw_t;
122
123 #ifdef __KERNEL__
124 #define FIX_PSW(addr) ((unsigned long)(addr)|0x80000000UL)
125 #define ADDR_BITS_REMOVE(addr) ((addr)&0x7fffffff)
126 #endif
127
128 typedef union
129 {
130         float   f;
131         double  d;
132         __u64   ui;
133         struct
134         {
135                 __u32 hi;
136                 __u32 lo;
137         } fp;
138 } freg_t;
139
140 typedef struct
141 {
142         __u32   fpc;
143         freg_t  fprs[NUM_FPRS];              
144 } s390_fp_regs;
145
146 #define FPC_EXCEPTION_MASK      0xF8000000
147 #define FPC_FLAGS_MASK          0x00F80000
148 #define FPC_DXC_MASK            0x0000FF00
149 #define FPC_RM_MASK             0x00000003
150 #define FPC_VALID_MASK          0xF8F8FF03
151
152 /*
153  * The first entries in pt_regs and user_regs_struct
154  * are common for the two structures. The s390_regs structure
155  * covers the common parts. It simplifies copying the common part
156  * between the three structures.
157  */
158 typedef struct
159 {
160         psw_t psw;
161         __u32 gprs[NUM_GPRS];
162         __u32 acrs[NUM_ACRS];
163         __u32 orig_gpr2;
164 } s390_regs;
165
166 /*
167  * The pt_regs struct defines the way the registers are stored on
168  * the stack during a system call.
169  */
170 struct pt_regs 
171 {
172         psw_t psw;
173         __u32 gprs[NUM_GPRS];
174         __u32 acrs[NUM_ACRS];
175         __u32 orig_gpr2;
176         __u32 trap;
177 };
178
179 /*
180  * Now for the program event recording (trace) definitions.
181  */
182 typedef struct
183 {
184         __u32 cr[3];
185 } per_cr_words;
186
187 #define PER_EM_MASK 0xE8000000
188
189 typedef struct
190 {
191         unsigned em_branching          : 1;
192         unsigned em_instruction_fetch  : 1;
193         /*
194          * Switching on storage alteration automatically fixes
195          * the storage alteration event bit in the users std.
196          */
197         unsigned em_storage_alteration : 1;
198         unsigned em_gpr_alt_unused     : 1;
199         unsigned em_store_real_address : 1;
200         unsigned                       : 3;
201         unsigned branch_addr_ctl       : 1;
202         unsigned                       : 1;
203         unsigned storage_alt_space_ctl : 1;
204         unsigned                       : 21;
205         addr_t   starting_addr;
206         addr_t   ending_addr;
207 } per_cr_bits;
208
209 typedef struct
210 {
211         __u16          perc_atmid;          /* 0x096 */
212         __u32          address;             /* 0x098 */
213         __u8           access_id;           /* 0x0a1 */
214 } per_lowcore_words;
215
216 typedef struct
217 {
218         unsigned perc_branching          : 1; /* 0x096 */
219         unsigned perc_instruction_fetch  : 1;
220         unsigned perc_storage_alteration : 1;
221         unsigned perc_gpr_alt_unused     : 1;
222         unsigned perc_store_real_address : 1;
223         unsigned                         : 4;
224         unsigned atmid_validity_bit      : 1;
225         unsigned atmid_psw_bit_32        : 1;
226         unsigned atmid_psw_bit_5         : 1;
227         unsigned atmid_psw_bit_16        : 1;
228         unsigned atmid_psw_bit_17        : 1;
229         unsigned si                      : 2;
230         addr_t   address;                     /* 0x098 */
231         unsigned                         : 4; /* 0x0a1 */
232         unsigned access_id               : 4;
233 } per_lowcore_bits;
234
235 typedef struct
236 {
237         union {
238                 per_cr_words   words;
239                 per_cr_bits    bits;
240         } control_regs;
241         /*
242          * Use these flags instead of setting em_instruction_fetch
243          * directly they are used so that single stepping can be
244          * switched on & off while not affecting other tracing
245          */
246         unsigned  single_step       : 1;
247         unsigned  instruction_fetch : 1;
248         unsigned                    : 30;
249         /*
250          * These addresses are copied into cr10 & cr11 if single
251          * stepping is switched off
252          */
253         __u32     starting_addr;
254         __u32     ending_addr;
255         union {
256                 per_lowcore_words words;
257                 per_lowcore_bits  bits;
258         } lowcore; 
259 } per_struct;
260
261 typedef struct
262 {
263         __u32  len;
264         addr_t kernel_addr;
265         addr_t process_addr;
266 } ptrace_area;
267
268 /*
269  * S/390 specific non posix ptrace requests. I chose unusual values so
270  * they are unlikely to clash with future ptrace definitions.
271  */
272 #define PTRACE_PEEKUSR_AREA           0x5000
273 #define PTRACE_POKEUSR_AREA           0x5001
274 #define PTRACE_PEEKTEXT_AREA          0x5002
275 #define PTRACE_PEEKDATA_AREA          0x5003
276 #define PTRACE_POKETEXT_AREA          0x5004
277 #define PTRACE_POKEDATA_AREA          0x5005
278 /*
279  * PT_PROT definition is loosely based on hppa bsd definition in
280  * gdb/hppab-nat.c
281  */
282 #define PTRACE_PROT                       21
283
284 typedef enum
285 {
286         ptprot_set_access_watchpoint,
287         ptprot_set_write_watchpoint,
288         ptprot_disable_watchpoint
289 } ptprot_flags;
290
291 typedef struct
292 {
293         addr_t           lowaddr;
294         addr_t           hiaddr;
295         ptprot_flags     prot;
296 } ptprot_area;                     
297
298 /* Sequence of bytes for breakpoint illegal instruction.  */
299 #define S390_BREAKPOINT     {0x0,0x1}
300 #define S390_BREAKPOINT_U16 ((__u16)0x0001)
301 #define S390_SYSCALL_OPCODE ((__u16)0x0a00)
302 #define S390_SYSCALL_SIZE   2
303
304 /*
305  * The user_regs_struct defines the way the user registers are
306  * store on the stack for signal handling.
307  */
308 struct user_regs_struct
309 {
310         psw_t psw;
311         __u32 gprs[NUM_GPRS];
312         __u32 acrs[NUM_ACRS];
313         __u32 orig_gpr2;
314         s390_fp_regs fp_regs;
315         /*
316          * These per registers are in here so that gdb can modify them
317          * itself as there is no "official" ptrace interface for hardware
318          * watchpoints. This is the way intel does it.
319          */
320         per_struct per_info;
321         addr_t  ieee_instruction_pointer; 
322         /* Used to give failing instruction back to user for ieee exceptions */
323 };
324
325 #ifdef __KERNEL__
326 #define user_mode(regs) (((regs)->psw.mask & PSW_PROBLEM_STATE) != 0)
327 #define instruction_pointer(regs) ((regs)->psw.addr)
328 extern void show_regs(struct pt_regs * regs);
329 extern char *task_show_regs(struct task_struct *task, char *buffer);
330 #endif
331
332 #endif /* __ASSEMBLY__ */
333
334 #endif /* _S390_PTRACE_H */