- Kai Germaschewski: ymfpci cleanups and resource leak fixes
[davej-history.git] / include / asm-s390 / ptrace.h
blob60a698662dc6f2c2f7fc2cb706a4680937f00ab9
1 /*
2 * include/asm-s390/ptrace.h
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 */
9 #ifndef _S390_PTRACE_H
10 #define _S390_PTRACE_H
11 #include <linux/config.h>
12 #include <asm/s390-regs-common.h>
13 #include <asm/current.h>
14 #include <linux/types.h>
15 #include <asm/setup.h>
16 #include <linux/stddef.h>
19 #define S390_REGS \
20 S390_REGS_COMMON \
21 __u32 orig_gpr2;
23 typedef struct
25 S390_REGS
26 } s390_regs;
28 struct pt_regs
30 S390_REGS
31 __u32 trap;
34 #if CONFIG_REMOTE_DEBUG
35 typedef struct
37 S390_REGS
38 __u32 trap;
39 __u32 crs[16];
40 s390_fp_regs fp_regs;
41 } gdb_pt_regs;
42 #endif
45 typedef struct
47 __u32 cr[3];
48 } per_cr_words __attribute__((packed));
50 #define PER_EM_MASK 0xE8000000
51 typedef struct
53 unsigned em_branching:1;
54 unsigned em_instruction_fetch:1;
55 /* Switching on storage alteration automatically fixes
56 the storage alteration event bit in the users std. */
57 unsigned em_storage_alteration:1;
58 unsigned em_gpr_alt_unused:1;
59 unsigned em_store_real_address:1;
60 unsigned :3;
61 unsigned branch_addr_ctl:1;
62 unsigned :1;
63 unsigned storage_alt_space_ctl:1;
64 unsigned :5;
65 unsigned :16;
66 __u32 starting_addr;
67 __u32 ending_addr;
68 } per_cr_bits __attribute__((packed));
70 typedef struct
72 __u16 perc_atmid; /* 0x096 */
73 __u32 address; /* 0x098 */
74 __u8 access_id; /* 0x0a1 */
75 } per_lowcore_words __attribute__((packed));
77 typedef struct
79 unsigned perc_branching:1; /* 0x096 */
80 unsigned perc_instruction_fetch:1;
81 unsigned perc_storage_alteration:1;
82 unsigned perc_gpr_alt_unused:1;
83 unsigned perc_store_real_address:1;
84 unsigned :3;
85 unsigned :1;
86 unsigned atmid:5;
87 unsigned si:2;
88 __u32 address; /* 0x098 */
89 unsigned :4; /* 0x0a1 */
90 unsigned access_id:4;
91 } per_lowcore_bits __attribute__((packed));
93 typedef struct
95 union
97 per_cr_words words;
98 per_cr_bits bits;
99 } control_regs __attribute__((packed));
100 /* Use these flags instead of setting em_instruction_fetch */
101 /* directly they are used so that single stepping can be */
102 /* switched on & off while not affecting other tracing */
103 unsigned single_step:1;
104 unsigned instruction_fetch:1;
105 unsigned :30;
106 /* These addresses are copied into cr10 & cr11 if single stepping
107 is switched off */
108 __u32 starting_addr;
109 __u32 ending_addr;
110 union
112 per_lowcore_words words;
113 per_lowcore_bits bits;
114 } lowcore;
115 } per_struct __attribute__((packed));
119 /* this struct defines the way the registers are stored on the
120 stack during a system call. If you change the pt_regs structure,
121 you'll need to change user.h too.
123 N.B. if you modify the pt_regs struct the strace command also has to be
124 modified & recompiled ( just wait till we have gdb going ).
128 struct user_regs_struct
130 S390_REGS
131 s390_fp_regs fp_regs;
132 /* These per registers are in here so that gdb can modify them itself
133 * as there is no "official" ptrace interface for hardware watchpoints.
134 * this is the way intel does it
136 per_struct per_info;
139 typedef struct user_regs_struct user_regs_struct;
141 typedef struct pt_regs pt_regs;
143 #ifdef __KERNEL__
144 #define user_mode(regs) (((regs)->psw.mask & PSW_PROBLEM_STATE) != 0)
145 #define instruction_pointer(regs) ((regs)->psw.addr)
147 struct thread_struct;
148 extern int sprintf_regs(int line,char *buff,struct task_struct * task,
149 struct thread_struct *tss,struct pt_regs * regs);
150 extern void show_regs(struct task_struct * task,struct thread_struct *tss,
151 struct pt_regs * regs);
152 #endif
158 #define FIX_PSW(addr) ((unsigned long)(addr)|0x80000000UL)
160 #define MULT_PROCPTR_TYPES ((CONFIG_BINFMT_ELF)&&(CONFIG_BINFMT_TOC))
162 typedef struct
164 long addr;
165 long toc;
166 } routine_descriptor;
167 extern void fix_routine_descriptor_regs(routine_descriptor *rdes,pt_regs *regs);
168 extern __inline__ void
169 fix_routine_descriptor_regs(routine_descriptor *rdes,pt_regs *regs)
171 regs->psw.addr=FIX_PSW(rdes->addr);
172 regs->gprs[12]=rdes->toc;
176 * Compiler optimisation should save this stuff from being non optimal
177 * & remove uneccessary code ( isnt gcc great DJB. )
180 /*I'm just using this an indicator of what binformat we are using
181 * (DJB) N.B. this needs to stay a macro unfortunately as I am otherwise
182 * dereferencing incomplete pointer types in with load_toc_binary
184 #if MULT_PROCPTR_TYPES
185 #define uses_routine_descriptors() \
186 (current->binfmt->load_binary==load_toc_binary)
187 #else
188 #if CONFIG_BINFMT_TOC
189 #define uses_routine_descriptors() 1
190 #else
191 #define uses_routine_descriptors() 0
192 #endif
193 #endif
195 #define pt_off(ptreg) offsetof(user_regs_struct,ptreg)
196 enum
198 PT_PSWMASK=pt_off(psw.mask),
199 PT_PSWADDR=pt_off(psw.addr),
200 PT_GPR0=pt_off(gprs[0]),
201 PT_GPR1=pt_off(gprs[1]),
202 PT_GPR2=pt_off(gprs[2]),
203 PT_GPR3=pt_off(gprs[3]),
204 PT_GPR4=pt_off(gprs[4]),
205 PT_GPR5=pt_off(gprs[5]),
206 PT_GPR6=pt_off(gprs[6]),
207 PT_GPR7=pt_off(gprs[7]),
208 PT_GPR8=pt_off(gprs[8]),
209 PT_GPR9=pt_off(gprs[9]),
210 PT_GPR10=pt_off(gprs[10]),
211 PT_GPR11=pt_off(gprs[11]),
212 PT_GPR12=pt_off(gprs[12]),
213 PT_GPR13=pt_off(gprs[13]),
214 PT_GPR14=pt_off(gprs[14]),
215 PT_GPR15=pt_off(gprs[15]),
216 PT_ACR0=pt_off(acrs[0]),
217 PT_ACR1=pt_off(acrs[1]),
218 PT_ACR2=pt_off(acrs[2]),
219 PT_ACR3=pt_off(acrs[3]),
220 PT_ACR4=pt_off(acrs[4]),
221 PT_ACR5=pt_off(acrs[5]),
222 PT_ACR6=pt_off(acrs[6]),
223 PT_ACR7=pt_off(acrs[7]),
224 PT_ACR8=pt_off(acrs[8]),
225 PT_ACR9=pt_off(acrs[9]),
226 PT_ACR10=pt_off(acrs[10]),
227 PT_ACR11=pt_off(acrs[11]),
228 PT_ACR12=pt_off(acrs[12]),
229 PT_ACR13=pt_off(acrs[13]),
230 PT_ACR14=pt_off(acrs[14]),
231 PT_ACR15=pt_off(acrs[15]),
232 PT_ORIGGPR2=pt_off(orig_gpr2),
233 PT_FPC=pt_off(fp_regs.fpc),
235 * A nasty fact of life that the ptrace api
236 * only supports passing of longs.
238 PT_FPR0_HI=pt_off(fp_regs.fprs[0].fp.hi),
239 PT_FPR0_LO=pt_off(fp_regs.fprs[0].fp.lo),
240 PT_FPR1_HI=pt_off(fp_regs.fprs[1].fp.hi),
241 PT_FPR1_LO=pt_off(fp_regs.fprs[1].fp.lo),
242 PT_FPR2_HI=pt_off(fp_regs.fprs[2].fp.hi),
243 PT_FPR2_LO=pt_off(fp_regs.fprs[2].fp.lo),
244 PT_FPR3_HI=pt_off(fp_regs.fprs[3].fp.hi),
245 PT_FPR3_LO=pt_off(fp_regs.fprs[3].fp.lo),
246 PT_FPR4_HI=pt_off(fp_regs.fprs[4].fp.hi),
247 PT_FPR4_LO=pt_off(fp_regs.fprs[4].fp.lo),
248 PT_FPR5_HI=pt_off(fp_regs.fprs[5].fp.hi),
249 PT_FPR5_LO=pt_off(fp_regs.fprs[5].fp.lo),
250 PT_FPR6_HI=pt_off(fp_regs.fprs[6].fp.hi),
251 PT_FPR6_LO=pt_off(fp_regs.fprs[6].fp.lo),
252 PT_FPR7_HI=pt_off(fp_regs.fprs[7].fp.hi),
253 PT_FPR7_LO=pt_off(fp_regs.fprs[7].fp.lo),
254 PT_FPR8_HI=pt_off(fp_regs.fprs[8].fp.hi),
255 PT_FPR8_LO=pt_off(fp_regs.fprs[8].fp.lo),
256 PT_FPR9_HI=pt_off(fp_regs.fprs[9].fp.hi),
257 PT_FPR9_LO=pt_off(fp_regs.fprs[9].fp.lo),
258 PT_FPR10_HI=pt_off(fp_regs.fprs[10].fp.hi),
259 PT_FPR10_LO=pt_off(fp_regs.fprs[10].fp.lo),
260 PT_FPR11_HI=pt_off(fp_regs.fprs[11].fp.hi),
261 PT_FPR11_LO=pt_off(fp_regs.fprs[11].fp.lo),
262 PT_FPR12_HI=pt_off(fp_regs.fprs[12].fp.hi),
263 PT_FPR12_LO=pt_off(fp_regs.fprs[12].fp.lo),
264 PT_FPR13_HI=pt_off(fp_regs.fprs[13].fp.hi),
265 PT_FPR13_LO=pt_off(fp_regs.fprs[13].fp.lo),
266 PT_FPR14_HI=pt_off(fp_regs.fprs[14].fp.hi),
267 PT_FPR14_LO=pt_off(fp_regs.fprs[14].fp.lo),
268 PT_FPR15_HI=pt_off(fp_regs.fprs[15].fp.hi),
269 PT_FPR15_LO=pt_off(fp_regs.fprs[15].fp.lo),
270 PT_CR_9=pt_off(per_info.control_regs.words.cr[0]),
271 PT_CR_10=pt_off(per_info.control_regs.words.cr[1]),
272 PT_CR_11=pt_off(per_info.control_regs.words.cr[2]),
273 PT_LASTOFF=PT_CR_11,
274 PT_ENDREGS=offsetof(user_regs_struct,per_info.lowcore.words.perc_atmid)
277 #define PTRACE_AREA \
278 __u32 len; \
279 addr_t kernel_addr; \
280 addr_t process_addr;
282 typedef struct
284 PTRACE_AREA
285 } ptrace_area;
288 390 specific non posix ptrace requests
289 I chose unusual values so they are unlikely to clash with future ptrace definitions.
291 #define PTRACE_PEEKUSR_AREA 0x5000
292 #define PTRACE_POKEUSR_AREA 0x5001
293 #define PTRACE_PEEKTEXT_AREA 0x5002
294 #define PTRACE_PEEKDATA_AREA 0x5003
295 #define PTRACE_POKETEXT_AREA 0x5004
296 #define PTRACE_POKEDATA_AREA 0x5005
297 /* PT_PROT definition is loosely based on hppa bsd definition in gdb/hppab-nat.c */
298 #define PTRACE_PROT 21
300 typedef enum
302 ptprot_set_access_watchpoint,
303 ptprot_set_write_watchpoint,
304 ptprot_disable_watchpoint
305 } ptprot_flags;
307 typedef struct
309 addr_t lowaddr;
310 addr_t hiaddr;
311 ptprot_flags prot;
312 } ptprot_area;
313 #endif