1 
2 /*--------------------------------------------------------------------*/
3 /*--- s390x/Linux-specific kernel interface.     vki-s390x-linux.h ---*/
4 /*--------------------------------------------------------------------*/
5 
6 /*
7    This file is part of Valgrind, a dynamic binary instrumentation
8    framework.
9 
10    Copyright IBM Corp. 2010-2013
11 
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License as
14    published by the Free Software Foundation; either version 2 of the
15    License, or (at your option) any later version.
16 
17    This program is distributed in the hope that it will be useful, but
18    WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20    General Public License for more details.
21 
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25    02111-1307, USA.
26 
27    The GNU General Public License is contained in the file COPYING.
28 */
29 
30 /* Contributed by Florian Krohm and Volker Sameske */
31 
32 #ifndef __VKI_S390X_LINUX_H
33 #define __VKI_S390X_LINUX_H
34 
35 #define __force
36 
37 //----------------------------------------------------------------------
38 // From linux-2.6.16.60/include/asm-s390/types.h
39 //----------------------------------------------------------------------
40 
41 typedef __signed__ char __vki_s8;
42 typedef unsigned char __vki_u8;
43 
44 typedef __signed__ short __vki_s16;
45 typedef unsigned short __vki_u16;
46 
47 typedef __signed__ int __vki_s32;
48 typedef unsigned int __vki_u32;
49 
50 typedef __signed__ long __vki_s64;
51 typedef unsigned long __vki_u64;
52 
53 typedef unsigned short vki_u16;
54 
55 typedef unsigned int vki_u32;
56 
57 //----------------------------------------------------------------------
58 // From linux-2.6.16.60/include/asm-s390/page.h
59 //----------------------------------------------------------------------
60 
61 /* PAGE_SHIFT determines the page size */
62 #define VKI_PAGE_SHIFT  12
63 #define VKI_PAGE_SIZE   (1UL << VKI_PAGE_SHIFT)
64 
65 //----------------------------------------------------------------------
66 // From linux-2.6.16.60/include/asm-s390/siginfo.h
67 //----------------------------------------------------------------------
68 
69 /* We need that to ensure that sizeof(siginfo) == 128. */
70 #ifdef __s390x__
71 #define __VKI_ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
72 #endif
73 
74 //----------------------------------------------------------------------
75 // From linux-2.6.16.60/include/asm-s390/sigcontext.h
76 //----------------------------------------------------------------------
77 
78 #define __VKI_NUM_GPRS 16
79 #define __VKI_NUM_FPRS 16
80 #define __VKI_NUM_ACRS 16
81 
82 #ifndef VGA_s390x
83 
84 /* Has to be at least _NSIG_WORDS from asm/signal.h */
85 #define _VKI_SIGCONTEXT_NSIG	64
86 #define _VKI_SIGCONTEXT_NSIG_BPW	32
87 /* Size of stack frame allocated when calling signal handler. */
88 #define __VKI_SIGNAL_FRAMESIZE	96
89 
90 #else /* VGA_s390x */
91 
92 /* Has to be at least _NSIG_WORDS from asm/signal.h */
93 #define _VKI_SIGCONTEXT_NSIG	64
94 #define _VKI_SIGCONTEXT_NSIG_BPW	64
95 /* Size of stack frame allocated when calling signal handler. */
96 #define __VKI_SIGNAL_FRAMESIZE	160
97 
98 #endif /* VGA_s390x */
99 
100 
101 #define _VKI_SIGCONTEXT_NSIG_WORDS	(_VKI_SIGCONTEXT_NSIG / _VKI_SIGCONTEXT_NSIG_BPW)
102 #define _VKI_SIGMASK_COPY_SIZE	(sizeof(unsigned long)*_VKI_SIGCONTEXT_NSIG_WORDS)
103 
104 typedef struct
105 {
106 	unsigned long mask;
107 	unsigned long addr;
108 } __attribute__ ((aligned(8))) _vki_psw_t;
109 
110 typedef struct
111 {
112 	_vki_psw_t psw;
113 	unsigned long gprs[__VKI_NUM_GPRS];
114 	unsigned int  acrs[__VKI_NUM_ACRS];
115 } _vki_s390_regs_common;
116 
117 typedef struct
118 {
119 	unsigned int fpc;
120 	double   fprs[__VKI_NUM_FPRS];
121 } _vki_s390_fp_regs;
122 
123 typedef struct
124 {
125 	_vki_s390_regs_common regs;
126 	_vki_s390_fp_regs     fpregs;
127 } _vki_sigregs;
128 
129 
130 struct vki_sigcontext
131 {
132 	unsigned long   oldmask[_VKI_SIGCONTEXT_NSIG_WORDS];
133 	_vki_sigregs    __user *sregs;
134 };
135 
136 
137 //----------------------------------------------------------------------
138 // From linux-2.6.16.60/include/asm-s390/signal.h
139 //----------------------------------------------------------------------
140 
141 #define _VKI_NSIG           _VKI_SIGCONTEXT_NSIG
142 #define _VKI_NSIG_BPW       _VKI_SIGCONTEXT_NSIG_BPW
143 #define _VKI_NSIG_WORDS     _VKI_SIGCONTEXT_NSIG_WORDS
144 
145 typedef unsigned long vki_old_sigset_t;
146 
147 typedef struct {
148 	unsigned long sig[_VKI_NSIG_WORDS];
149 } vki_sigset_t;
150 
151 #define VKI_SIGHUP           1
152 #define VKI_SIGINT           2
153 #define VKI_SIGQUIT          3
154 #define VKI_SIGILL           4
155 #define VKI_SIGTRAP          5
156 #define VKI_SIGABRT          6
157 #define VKI_SIGIOT           6
158 #define VKI_SIGBUS           7
159 #define VKI_SIGFPE           8
160 #define VKI_SIGKILL          9
161 #define VKI_SIGUSR1         10
162 #define VKI_SIGSEGV         11
163 #define VKI_SIGUSR2         12
164 #define VKI_SIGPIPE         13
165 #define VKI_SIGALRM         14
166 #define VKI_SIGTERM         15
167 #define VKI_SIGSTKFLT       16
168 #define VKI_SIGCHLD         17
169 #define VKI_SIGCONT         18
170 #define VKI_SIGSTOP         19
171 #define VKI_SIGTSTP         20
172 #define VKI_SIGTTIN         21
173 #define VKI_SIGTTOU         22
174 #define VKI_SIGURG          23
175 #define VKI_SIGXCPU         24
176 #define VKI_SIGXFSZ         25
177 #define VKI_SIGVTALRM       26
178 #define VKI_SIGPROF         27
179 #define VKI_SIGWINCH        28
180 #define VKI_SIGIO           29
181 #define VKI_SIGPOLL         VKI_SIGIO
182 /*
183 #define VKI_SIGLOST         29
184 */
185 #define VKI_SIGPWR          30
186 #define VKI_SIGSYS	    31
187 #define VKI_SIGUNUSED       31
188 
189 /* These should not be considered constants from userland.  */
190 #define VKI_SIGRTMIN        32
191 #define VKI_SIGRTMAX        _VKI_NSIG
192 
193 /*
194  * SA_FLAGS values:
195  *
196  * SA_ONSTACK indicates that a registered stack_t will be used.
197  * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
198  * SA_RESTART flag to get restarting signals (which were the default long ago)
199  * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
200  * SA_RESETHAND clears the handler when the signal is delivered.
201  * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
202  * SA_NODEFER prevents the current signal from being masked in the handler.
203  *
204  * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
205  * Unix names RESETHAND and NODEFER respectively.
206  */
207 #define VKI_SA_NOCLDSTOP    0x00000001
208 #define VKI_SA_NOCLDWAIT    0x00000002
209 #define VKI_SA_SIGINFO      0x00000004
210 #define VKI_SA_ONSTACK      0x08000000
211 #define VKI_SA_RESTART      0x10000000
212 #define VKI_SA_NODEFER      0x40000000
213 #define VKI_SA_RESETHAND    0x80000000
214 
215 #define VKI_SA_NOMASK       VKI_SA_NODEFER
216 #define VKI_SA_ONESHOT      VKI_SA_RESETHAND
217 #define VKI_SA_INTERRUPT    0x20000000 /* dummy -- ignored */
218 
219 #define VKI_SA_RESTORER     0x04000000
220 
221 /*
222  * sigaltstack controls
223  */
224 #define VKI_SS_ONSTACK      1
225 #define VKI_SS_DISABLE      2
226 
227 #define VKI_MINSIGSTKSZ     2048
228 #define VKI_SIGSTKSZ        8192
229 
230 
231 /* Next lines asm-generic/signal.h */
232 #define VKI_SIG_BLOCK          0 /* for blocking signals */
233 #define VKI_SIG_UNBLOCK        1 /* for unblocking signals */
234 #define VKI_SIG_SETMASK        2 /* for setting the signal mask */
235 
236 typedef void __vki_signalfn_t(int);
237 typedef __vki_signalfn_t __user *__vki_sighandler_t;
238 
239 /* default signal handling */
240 #define VKI_SIG_DFL ((__force __vki_sighandler_t)0)
241 /* ignore signal */
242 #define VKI_SIG_IGN ((__force __vki_sighandler_t)1)
243 /* error return from signal */
244 #define VKI_SIG_ERR ((__force __vki_sighandler_t)-1)
245 /* Back to asm-s390/signal.h */
246 
247 struct vki_old_sigaction {
248         // [[Nb: a 'k' prefix is added to "sa_handler" because
249         // bits/sigaction.h (which gets dragged in somehow via signal.h)
250         // #defines it as something else.  Since that is done for glibc's
251         // purposes, which we don't care about here, we use our own name.]]
252         __vki_sighandler_t ksa_handler;
253         vki_old_sigset_t sa_mask;
254         unsigned long sa_flags;
255         void (*sa_restorer)(void);
256 };
257 
258 struct vki_sigaction {
259         // [[See comment about extra 'k' above]]
260         __vki_sighandler_t ksa_handler;
261         // Yes, the reserved field is really glibc specific. The kernel
262         // doesn't have it and uses an unsigned long for sa_flags.
263         // The glibc and the kernel agreed this is fine and the
264         // __glibc_reserved0 field can be undefined.
265         // See https://sourceware.org/ml/libc-alpha/2014-09/msg00161.html
266         int __glibc_reserved0;
267         int sa_flags;
268         void (*sa_restorer)(void);
269         vki_sigset_t sa_mask;               /* mask last for extensibility */
270 };
271 
272 struct vki_k_sigaction {
273         struct vki_sigaction sa;
274 };
275 
276 
277 /* On Linux we use the same type for passing sigactions to
278    and from the kernel.  Hence: */
279 typedef  struct vki_sigaction  vki_sigaction_toK_t;
280 typedef  struct vki_sigaction  vki_sigaction_fromK_t;
281 
282 
283 typedef struct vki_sigaltstack {
284 	void __user *ss_sp;
285 	int ss_flags;
286 	vki_size_t ss_size;
287 } vki_stack_t;
288 
289 
290 //----------------------------------------------------------------------
291 // From linux-2.6.16.60/include/asm-s390/mman.h
292 //----------------------------------------------------------------------
293 
294 #define VKI_PROT_NONE   0x0             /* No page permissions */
295 #define VKI_PROT_READ   0x1             /* page can be read */
296 #define VKI_PROT_WRITE  0x2             /* page can be written */
297 #define VKI_PROT_EXEC   0x4             /* page can be executed */
298 #define VKI_PROT_GROWSDOWN 0x01000000   /* mprotect flag: extend
299 					   change to start of
300 					   growsdown vma */
301 #define VKI_PROT_GROWSUP   0x02000000   /* mprotect flag:
302 					   extend change to end
303 					   of growsup vma */
304 
305 #define VKI_MAP_SHARED		0x0001  /* Share changes */
306 #define VKI_MAP_PRIVATE 	0x0002	/*  */
307 #define VKI_MAP_FIXED   	0x0010	/*  */
308 #define VKI_MAP_ANONYMOUS	0x0020	/*  */
309 
310 
311 //----------------------------------------------------------------------
312 // From linux-2.6.16.60/include/asm-s390/fcntl.h
313 //----------------------------------------------------------------------
314 
315 #define VKI_O_RDONLY        00000000
316 #define VKI_O_WRONLY        00000001
317 #define VKI_O_RDWR          00000002
318 #define VKI_O_ACCMODE       00000003
319 #define VKI_O_CREAT         00000100        /* not fcntl */
320 #define VKI_O_EXCL          00000200        /* not fcntl */
321 #define VKI_O_NOCTTY        00000400        /* not fcntl */
322 #define VKI_O_TRUNC         00001000        /* not fcntl */
323 #define VKI_O_APPEND        00002000
324 #define VKI_O_NONBLOCK      00004000
325 
326 #define VKI_AT_FDCWD            -100
327 
328 #define VKI_F_DUPFD	0	/* dup */
329 #define VKI_F_GETFD	1	/* get close_on_exec */
330 #define VKI_F_SETFD	2	/* set/clear close_on_exec */
331 #define VKI_F_GETFL	3	/* get file->f_flags */
332 #define VKI_F_SETFL	4	/* set file->f_flags */
333 #define VKI_F_GETLK	5
334 #define VKI_F_SETLK	6
335 #define VKI_F_SETLKW	7
336 #define VKI_F_SETOWN	8	/* for sockets. */
337 #define VKI_F_GETOWN	9	/* for sockets. */
338 #define VKI_F_SETSIG	10	/* for sockets. */
339 #define VKI_F_GETSIG	11	/* for sockets. */
340 
341 #define VKI_F_SETOWN_EX		15
342 #define VKI_F_GETOWN_EX		16
343 
344 #define VKI_F_OFD_GETLK		36
345 #define VKI_F_OFD_SETLK		37
346 #define VKI_F_OFD_SETLKW	38
347 
348 #define VKI_F_OWNER_TID		0
349 #define VKI_F_OWNER_PID		1
350 #define VKI_F_OWNER_PGRP	2
351 
352 struct vki_f_owner_ex {
353 	int	type;
354 	__vki_kernel_pid_t	pid;
355 };
356 
357 #define VKI_FD_CLOEXEC  1  /* actually anything with low bit set goes */
358 
359 #define VKI_F_LINUX_SPECIFIC_BASE   1024
360 
361 
362 //----------------------------------------------------------------------
363 // From linux-2.6.16.60/include/asm-s390x/resource.h
364 //----------------------------------------------------------------------
365 
366 // which just does #include <asm-generic/resource.h>
367 
368 #define VKI_RLIMIT_DATA             2       /* max data size */
369 #define VKI_RLIMIT_STACK            3       /* max stack size */
370 #define VKI_RLIMIT_CORE             4       /* max core file size */
371 #define VKI_RLIMIT_NOFILE           7       /* max number of open files */
372 
373 
374 //----------------------------------------------------------------------
375 // From linux-2.6.16.60/include/asm-s390/socket.h
376 //----------------------------------------------------------------------
377 
378 #define VKI_SOL_SOCKET      1
379 
380 #define VKI_SO_TYPE         3
381 
382 #define VKI_SO_ATTACH_FILTER        26
383 
384 //----------------------------------------------------------------------
385 // From linux-2.6.16.60/include/asm-s390/sockios.h
386 //----------------------------------------------------------------------
387 
388 #define VKI_SIOCSPGRP       0x8902
389 #define VKI_SIOCGPGRP       0x8904
390 #define VKI_SIOCATMARK      0x8905
391 #define VKI_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
392 /* since 2.6.22 */
393 #define VKI_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
394 
395 
396 //----------------------------------------------------------------------
397 // From linux-2.6.16.60/include/asm-s390/stat.h
398 //----------------------------------------------------------------------
399 
400 #ifndef VGA_s390x
401 struct vki_stat {
402         unsigned short st_dev;
403         unsigned short __pad1;
404         unsigned long  st_ino;
405         unsigned short st_mode;
406         unsigned short st_nlink;
407         unsigned short st_uid;
408         unsigned short st_gid;
409         unsigned short st_rdev;
410         unsigned short __pad2;
411         unsigned long  st_size;
412         unsigned long  st_blksize;
413         unsigned long  st_blocks;
414         unsigned long  st_atime;
415         unsigned long  st_atime_nsec;
416         unsigned long  st_mtime;
417         unsigned long  st_mtime_nsec;
418         unsigned long  st_ctime;
419         unsigned long  st_ctime_nsec;
420         unsigned long  __unused4;
421         unsigned long  __unused5;
422 };
423 
424 /* This matches struct stat64 in glibc2.1, hence the absolutely
425  * insane amounts of padding around dev_t's.
426  */
427 struct vki_stat64 {
428         unsigned long long	st_dev;
429         unsigned int    __pad1;
430         unsigned long   __st_ino;
431         unsigned int    st_mode;
432         unsigned int    st_nlink;
433         unsigned long   st_uid;
434         unsigned long   st_gid;
435         unsigned long long	st_rdev;
436         unsigned int    __pad3;
437         long long	st_size;
438         unsigned long   st_blksize;
439         unsigned char   __pad4[4];
440         unsigned long   __pad5;     /* future possible st_blocks high bits */
441         unsigned long   st_blocks;  /* Number 512-byte blocks allocated. */
442         unsigned long   st_atime;
443         unsigned long   st_atime_nsec;
444         unsigned long   st_mtime;
445         unsigned long   st_mtime_nsec;
446         unsigned long   st_ctime;
447         unsigned long   st_ctime_nsec;  /* will be high 32 bits of ctime someday */
448         unsigned long long	st_ino;
449 };
450 
451 #else
452 
453 struct vki_stat {
454         unsigned long  st_dev;
455         unsigned long  st_ino;
456         unsigned long  st_nlink;
457         unsigned int   st_mode;
458         unsigned int   st_uid;
459         unsigned int   st_gid;
460         unsigned int   __pad1;
461         unsigned long  st_rdev;
462         unsigned long  st_size;
463         unsigned long  st_atime;
464 	unsigned long  st_atime_nsec;
465         unsigned long  st_mtime;
466 	unsigned long  st_mtime_nsec;
467         unsigned long  st_ctime;
468 	unsigned long  st_ctime_nsec;
469         unsigned long  st_blksize;
470         long           st_blocks;
471         unsigned long  __unused0[3];
472 };
473 
474 #endif /* VGA_s390x */
475 
476 
477 //----------------------------------------------------------------------
478 // From linux-2.6.16.60/include/asm-s390/statfs.h
479 //----------------------------------------------------------------------
480 
481 struct vki_statfs {
482         int  f_type;
483         int  f_bsize;
484         long f_blocks;
485         long f_bfree;
486         long f_bavail;
487         long f_files;
488         long f_ffree;
489         __vki_kernel_fsid_t f_fsid;
490         int  f_namelen;
491         int  f_frsize;
492         int  f_spare[5];
493 };
494 
495 
496 //----------------------------------------------------------------------
497 // From linux-2.6.16.60/include/asm-s390/termios.h
498 //----------------------------------------------------------------------
499 
500 struct vki_winsize {
501 	unsigned short ws_row;
502 	unsigned short ws_col;
503 	unsigned short ws_xpixel;
504 	unsigned short ws_ypixel;
505 };
506 
507 #define VKI_NCC 8
508 struct vki_termio {
509 	unsigned short c_iflag;		/* input mode flags */
510 	unsigned short c_oflag;		/* output mode flags */
511 	unsigned short c_cflag;		/* control mode flags */
512 	unsigned short c_lflag;		/* local mode flags */
513 	unsigned char c_line;		/* line discipline */
514 	unsigned char c_cc[VKI_NCC];	/* control characters */
515 };
516 
517 
518 //----------------------------------------------------------------------
519 // From linux-2.6.16.60/include/asm-s390/termbits.h
520 //----------------------------------------------------------------------
521 
522 typedef unsigned char   vki_cc_t;
523 typedef unsigned int    vki_tcflag_t;
524 
525 #define VKI_NCCS 19
526 struct vki_termios {
527 	vki_tcflag_t c_iflag;		/* input mode flags */
528 	vki_tcflag_t c_oflag;		/* output mode flags */
529 	vki_tcflag_t c_cflag;		/* control mode flags */
530 	vki_tcflag_t c_lflag;		/* local mode flags */
531 	vki_cc_t c_line;		/* line discipline */
532 	vki_cc_t c_cc[VKI_NCCS];	/* control characters */
533 };
534 
535 
536 //----------------------------------------------------------------------
537 // From linux-2.6.16.60/include/asm-s390/ioctl.h
538 //----------------------------------------------------------------------
539 
540 #define _VKI_IOC_NRBITS		8
541 #define _VKI_IOC_TYPEBITS	8
542 #define _VKI_IOC_SIZEBITS	14
543 #define _VKI_IOC_DIRBITS	2
544 
545 #define _VKI_IOC_NRMASK		((1 << _VKI_IOC_NRBITS)-1)
546 #define _VKI_IOC_TYPEMASK	((1 << _VKI_IOC_TYPEBITS)-1)
547 #define _VKI_IOC_SIZEMASK	((1 << _VKI_IOC_SIZEBITS)-1)
548 #define _VKI_IOC_DIRMASK	((1 << _VKI_IOC_DIRBITS)-1)
549 
550 #define _VKI_IOC_NRSHIFT	0
551 #define _VKI_IOC_TYPESHIFT	(_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
552 #define _VKI_IOC_SIZESHIFT	(_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
553 #define _VKI_IOC_DIRSHIFT	(_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
554 
555 #define _VKI_IOC_NONE	0U
556 #define _VKI_IOC_WRITE	1U
557 #define _VKI_IOC_READ	2U
558 
559 #define _VKI_IOC(dir,type,nr,size) \
560 	(((dir)  << _VKI_IOC_DIRSHIFT) | \
561 	 ((type) << _VKI_IOC_TYPESHIFT) | \
562 	 ((nr)   << _VKI_IOC_NRSHIFT) | \
563 	 ((size) << _VKI_IOC_SIZESHIFT))
564 
565 /* used to create numbers */
566 #define _VKI_IO(type,nr)	_VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
567 #define _VKI_IOR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
568 #define _VKI_IOW(type,nr,size)	_VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
569 #define _VKI_IOWR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
570 
571 /* used to decode ioctl numbers.. */
572 #define _VKI_IOC_DIR(nr)	(((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
573 #define _VKI_IOC_TYPE(nr)	(((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
574 #define _VKI_IOC_NR(nr)		(((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
575 #define _VKI_IOC_SIZE(nr)	(((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
576 
577 //----------------------------------------------------------------------
578 // From linux-2.6.16.60/include/asm-s390/ioctls.h
579 //----------------------------------------------------------------------
580 
581 /* 0x54 is just a magic number to make these relatively unique ('T') */
582 
583 #define VKI_TCGETS	0x5401
584 #define VKI_TCSETS	0x5402
585 #define VKI_TCSETSW	0x5403
586 #define VKI_TCSETSF	0x5404
587 #define VKI_TCGETA	0x5405
588 #define VKI_TCSETA	0x5406
589 #define VKI_TCSETAW	0x5407
590 #define VKI_TCSETAF	0x5408
591 #define VKI_TCSBRK	0x5409
592 #define VKI_TCXONC	0x540A
593 #define VKI_TCFLSH	0x540B
594 
595 #define VKI_TIOCSCTTY	0x540E
596 #define VKI_TIOCGPGRP	0x540F
597 #define VKI_TIOCSPGRP	0x5410
598 #define VKI_TIOCOUTQ	0x5411
599 
600 #define VKI_TIOCGWINSZ	0x5413
601 #define VKI_TIOCSWINSZ	0x5414
602 #define VKI_TIOCMGET	0x5415
603 #define VKI_TIOCMBIS	0x5416
604 #define VKI_TIOCMBIC	0x5417
605 #define VKI_TIOCMSET	0x5418
606 
607 #define VKI_FIONREAD	0x541B
608 #define VKI_TIOCLINUX	0x541C
609 
610 #define VKI_FIONBIO	0x5421
611 #define VKI_TIOCNOTTY	0x5422
612 
613 #define VKI_TCSBRKP	0x5425	/* Needed for POSIX tcsendbreak() */
614 
615 #define VKI_TIOCGPTN	_VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
616 #define VKI_TIOCSPTLCK	_VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
617 
618 #define VKI_FIONCLEX	0x5450
619 #define VKI_FIOCLEX	0x5451
620 #define VKI_FIOASYNC	0x5452
621 
622 #define VKI_TIOCSERGETLSR       0x5459 /* Get line status register */
623 
624 #define VKI_TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
625 
626 //----------------------------------------------------------------------
627 // From linux-2.6.39-rc2/arch/s390/include/asm/ioctls.h
628 //----------------------------------------------------------------------
629 
630 #define VKI_FIOQSIZE 0x545E
631 
632 //----------------------------------------------------------------------
633 // From linux-2.6.16.60/include/asm-s390/poll.h
634 //----------------------------------------------------------------------
635 
636 struct vki_pollfd {
637 	int fd;
638 	short events;
639 	short revents;
640 };
641 
642 #define VKI_POLLIN          0x0001
643 
644 //----------------------------------------------------------------------
645 // From linux-2.6.16.60/include/asm-s390/ptrace.h
646 //----------------------------------------------------------------------
647 #define VKI_NUM_GPRS	16
648 #define VKI_NUM_FPRS	16
649 #define VKI_NUM_CRS	16
650 #define VKI_NUM_ACRS	16
651 
652 typedef union
653 {
654 	float   f;
655 	double  d;
656         __vki_u64   ui;
657 	struct
658 	{
659 		__vki_u32 hi;
660 		__vki_u32 lo;
661 	} fp;
662 } vki_freg_t;
663 
664 typedef struct
665 {
666 	__vki_u32   fpc;
667 	vki_freg_t  fprs[VKI_NUM_FPRS];
668 } vki_s390_fp_regs;
669 
670 typedef struct
671 {
672         unsigned long mask;
673         unsigned long addr;
674 } __attribute__ ((aligned(8))) vki_psw_t;
675 
676 typedef struct
677 {
678 	vki_psw_t psw;
679 	unsigned long gprs[VKI_NUM_GPRS];
680 	unsigned int  acrs[VKI_NUM_ACRS];
681 	unsigned long orig_gpr2;
682 } vki_s390_regs;
683 
684 /*
685  * Now for the program event recording (trace) definitions.
686  */
687 typedef struct
688 {
689 	unsigned long cr[3];
690 } vki_per_cr_words;
691 
692 typedef	struct
693 {
694 #ifdef VGA_s390x
695 	unsigned                       : 32;
696 #endif /* VGA_s390x */
697 	unsigned em_branching          : 1;
698 	unsigned em_instruction_fetch  : 1;
699 	/*
700 	 * Switching on storage alteration automatically fixes
701 	 * the storage alteration event bit in the users std.
702 	 */
703 	unsigned em_storage_alteration : 1;
704 	unsigned em_gpr_alt_unused     : 1;
705 	unsigned em_store_real_address : 1;
706 	unsigned                       : 3;
707 	unsigned branch_addr_ctl       : 1;
708 	unsigned                       : 1;
709 	unsigned storage_alt_space_ctl : 1;
710 	unsigned                       : 21;
711 	unsigned long starting_addr;
712 	unsigned long ending_addr;
713 } vki_per_cr_bits;
714 
715 typedef struct
716 {
717 	unsigned short perc_atmid;
718 	unsigned long address;
719 	unsigned char access_id;
720 } vki_per_lowcore_words;
721 
722 typedef struct
723 {
724 	unsigned perc_branching          : 1;
725 	unsigned perc_instruction_fetch  : 1;
726 	unsigned perc_storage_alteration : 1;
727 	unsigned perc_gpr_alt_unused     : 1;
728 	unsigned perc_store_real_address : 1;
729 	unsigned                         : 3;
730 	unsigned atmid_psw_bit_31        : 1;
731 	unsigned atmid_validity_bit      : 1;
732 	unsigned atmid_psw_bit_32        : 1;
733 	unsigned atmid_psw_bit_5         : 1;
734 	unsigned atmid_psw_bit_16        : 1;
735 	unsigned atmid_psw_bit_17        : 1;
736 	unsigned si                      : 2;
737 	unsigned long address;
738 	unsigned                         : 4;
739 	unsigned access_id               : 4;
740 } vki_per_lowcore_bits;
741 
742 typedef struct
743 {
744 	union {
745 		vki_per_cr_words   words;
746 		vki_per_cr_bits    bits;
747 	} control_regs;
748 	/*
749 	 * Use these flags instead of setting em_instruction_fetch
750 	 * directly they are used so that single stepping can be
751 	 * switched on & off while not affecting other tracing
752 	 */
753 	unsigned  single_step       : 1;
754 	unsigned  instruction_fetch : 1;
755 	unsigned                    : 30;
756 	/*
757 	 * These addresses are copied into cr10 & cr11 if single
758 	 * stepping is switched off
759 	 */
760 	unsigned long starting_addr;
761 	unsigned long ending_addr;
762 	union {
763 		vki_per_lowcore_words words;
764 		vki_per_lowcore_bits  bits;
765 	} lowcore;
766 } vki_per_struct;
767 
768 /*
769  * The user_regs_struct defines the way the user registers are
770  * store on the stack for signal handling.
771  */
772 struct vki_user_regs_struct
773 {
774 	vki_psw_t psw;
775 	unsigned long gprs[VKI_NUM_GPRS];
776 	unsigned int  acrs[VKI_NUM_ACRS];
777 	unsigned long orig_gpr2;
778 	vki_s390_fp_regs fp_regs;
779 	/*
780 	 * These per registers are in here so that gdb can modify them
781 	 * itself as there is no "official" ptrace interface for hardware
782 	 * watchpoints. This is the way intel does it.
783 	 */
784 	vki_per_struct per_info;
785 	unsigned long ieee_instruction_pointer;
786 	/* Used to give failing instruction back to user for ieee exceptions */
787 };
788 
789 typedef struct
790 {
791 	unsigned int  vki_len;
792 	unsigned long vki_kernel_addr;
793 	unsigned long vki_process_addr;
794 } vki_ptrace_area;
795 
796 /*
797  * S/390 specific non posix ptrace requests
798  */
799 #define VKI_PTRACE_PEEKUSR_AREA       0x5000
800 #define VKI_PTRACE_POKEUSR_AREA       0x5001
801 
802 //----------------------------------------------------------------------
803 // From linux-2.6.16.60/include/asm-s390/elf.h
804 //----------------------------------------------------------------------
805 
806 typedef vki_s390_fp_regs vki_elf_fpregset_t;
807 typedef vki_s390_regs vki_elf_gregset_t;
808 
809 
810 //----------------------------------------------------------------------
811 // From linux-2.6.16.60/include/asm-s390/ucontext.h
812 //----------------------------------------------------------------------
813 
814 struct vki_ucontext {
815 	unsigned long	      uc_flags;
816 	struct vki_ucontext  *uc_link;
817 	vki_stack_t	      uc_stack;
818 	_vki_sigregs          uc_mcontext;
819 	vki_sigset_t	      uc_sigmask; /* mask last for extensibility */
820 };
821 
822 //----------------------------------------------------------------------
823 // From linux-2.6.16.60/include/asm-s390/ipcbuf.h
824 //----------------------------------------------------------------------
825 
826 struct vki_ipc64_perm
827 {
828 	__vki_kernel_key_t	key;
829 	__vki_kernel_uid32_t	uid;
830 	__vki_kernel_gid32_t	gid;
831 	__vki_kernel_uid32_t	cuid;
832 	__vki_kernel_gid32_t	cgid;
833 	__vki_kernel_mode_t	mode;
834 	unsigned short		__pad1;
835 	unsigned short		seq;
836 #ifndef VGA_s390x
837 	unsigned short		__pad2;
838 #endif /* ! VGA_s390x */
839 	unsigned long		__unused1;
840 	unsigned long		__unused2;
841 };
842 
843 
844 //----------------------------------------------------------------------
845 // From linux-2.6.16.60/include/asm-s390/sembuf.h
846 //----------------------------------------------------------------------
847 
848 struct vki_semid64_ds {
849 	struct vki_ipc64_perm sem_perm;		/* permissions .. see ipc.h */
850 	__vki_kernel_time_t   sem_otime;	/* last semop time */
851 #ifndef VGA_s390x
852 	unsigned long	__unused1;
853 #endif /* ! VGA_s390x */
854 	__vki_kernel_time_t   sem_ctime;	/* last change time */
855 #ifndef VGA_s390x
856 	unsigned long	__unused2;
857 #endif /* ! VGA_s390x */
858 	unsigned long	sem_nsems;		/* no. of semaphores in array */
859 	unsigned long	__unused3;
860 	unsigned long	__unused4;
861 };
862 
863 
864 //----------------------------------------------------------------------
865 // From linux-2.6.16.60/include/asm-s390/msgbuf.h
866 //----------------------------------------------------------------------
867 
868 struct vki_msqid64_ds {
869 	struct vki_ipc64_perm msg_perm;
870 	__vki_kernel_time_t msg_stime;	/* last msgsnd time */
871 #ifndef VGA_s390x
872 	unsigned long	__unused1;
873 #endif /* ! VGA_s390x */
874 	__vki_kernel_time_t msg_rtime;	/* last msgrcv time */
875 #ifndef VGA_s390x
876 	unsigned long	__unused2;
877 #endif /* ! VGA_s390x */
878 	__vki_kernel_time_t msg_ctime;	/* last change time */
879 #ifndef VGA_s390x
880 	unsigned long	__unused3;
881 #endif /* ! VGA_s390x */
882 	unsigned long  msg_cbytes;	/* current number of bytes on queue */
883 	unsigned long  msg_qnum;	/* number of messages in queue */
884 	unsigned long  msg_qbytes;	/* max number of bytes on queue */
885 	__vki_kernel_pid_t msg_lspid;	/* pid of last msgsnd */
886 	__vki_kernel_pid_t msg_lrpid;	/* last receive pid */
887 	unsigned long  __unused4;
888 	unsigned long  __unused5;
889 };
890 
891 
892 //----------------------------------------------------------------------
893 // From linux-2.6.16.60/include/asm-s390/ipc.h
894 //----------------------------------------------------------------------
895 
896 struct vki_ipc_kludge {
897 	struct vki_msgbuf __user *msgp;
898 	long msgtyp;
899 };
900 
901 #define VKI_SEMOP	 1
902 #define VKI_SEMGET	 2
903 #define VKI_SEMCTL	 3
904 #define VKI_SEMTIMEDOP	 4
905 #define VKI_MSGSND	11
906 #define VKI_MSGRCV	12
907 #define VKI_MSGGET	13
908 #define VKI_MSGCTL	14
909 #define VKI_SHMAT	21
910 #define VKI_SHMDT	22
911 #define VKI_SHMGET	23
912 #define VKI_SHMCTL	24
913 
914 
915 //----------------------------------------------------------------------
916 // From linux-2.6.16.60/include/asm-s390/shmbuf.h
917 //----------------------------------------------------------------------
918 
919 struct vki_shmid64_ds {
920 	struct vki_ipc64_perm	shm_perm;	/* operation perms */
921 	vki_size_t		shm_segsz;	/* size of segment (bytes) */
922 	__vki_kernel_time_t	shm_atime;	/* last attach time */
923 #ifndef VGA_s390x
924 	unsigned long		__unused1;
925 #endif /* ! VGA_s390x */
926 	__vki_kernel_time_t	shm_dtime;	/* last detach time */
927 #ifndef VGA_s390x
928 	unsigned long		__unused2;
929 #endif /* ! VGA_s390x */
930 	__vki_kernel_time_t	shm_ctime;	/* last change time */
931 #ifndef VGA_s390x
932 	unsigned long		__unused3;
933 #endif /* ! VGA_s390x */
934 	__vki_kernel_pid_t	shm_cpid;	/* pid of creator */
935 	__vki_kernel_pid_t	shm_lpid;	/* pid of last operator */
936 	unsigned long		shm_nattch;	/* no. of current attaches */
937 	unsigned long		__unused4;
938 	unsigned long		__unused5;
939 };
940 
941 struct vki_shminfo64 {
942 	unsigned long	shmmax;
943 	unsigned long	shmmin;
944 	unsigned long	shmmni;
945 	unsigned long	shmseg;
946 	unsigned long	shmall;
947 	unsigned long	__unused1;
948 	unsigned long	__unused2;
949 	unsigned long	__unused3;
950 	unsigned long	__unused4;
951 };
952 
953 
954 //----------------------------------------------------------------------
955 // The following are defined in the VKI namespace but are nowhere found
956 // in the linux headers.
957 //----------------------------------------------------------------------
958 #define VKI_BIG_ENDIAN      1
959 #define VKI_MAX_PAGE_SHIFT  VKI_PAGE_SHIFT
960 #define VKI_MAX_PAGE_SIZE   VKI_PAGE_SIZE
961 
962 //----------------------------------------------------------------------
963 // From linux-2.6.35.4/arch/s390x/include/asm/shmparam.h
964 //----------------------------------------------------------------------
965 
966 #define VKI_SHMLBA  VKI_PAGE_SIZE
967 
968 /* If a system call returns a value >= VKI_MAX_ERRNO then that is considered
969    an error condition. I.e. the system call failed. */
970 #define VKI_MAX_ERRNO       -125
971 
972 //----------------------------------------------------------------------
973 // From linux-2.6.8.1/include/asm-generic/errno.h
974 //----------------------------------------------------------------------
975 
976 #define	VKI_ENOSYS       38  /* Function not implemented */
977 #define	VKI_EOVERFLOW    75  /* Value too large for defined data type */
978 
979 #endif // __VKI_S390X_LINUX_H
980 
981 /*--------------------------------------------------------------------*/
982 /*--- end                                                          ---*/
983 /*--------------------------------------------------------------------*/
984