vki-s390x-linux.h revision 8f943afc22a6a683b78271836c8ddc462b4824a9
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-2011
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
41typedef __signed__ char __vki_s8;
42typedef unsigned char __vki_u8;
43
44typedef __signed__ short __vki_s16;
45typedef unsigned short __vki_u16;
46
47typedef __signed__ int __vki_s32;
48typedef unsigned int __vki_u32;
49
50typedef __signed__ long __vki_s64;
51typedef unsigned long __vki_u64;
52
53typedef unsigned short vki_u16;
54
55typedef 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
104typedef struct
105{
106	unsigned long mask;
107	unsigned long addr;
108} __attribute__ ((aligned(8))) _vki_psw_t;
109
110typedef 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
117typedef struct
118{
119	unsigned int fpc;
120	double   fprs[__VKI_NUM_FPRS];
121} _vki_s390_fp_regs;
122
123typedef struct
124{
125	_vki_s390_regs_common regs;
126	_vki_s390_fp_regs     fpregs;
127} _vki_sigregs;
128
129
130struct 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
145typedef unsigned long vki_old_sigset_t;
146
147typedef 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
236typedef void __vki_signalfn_t(int);
237typedef __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
247struct 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
258struct vki_sigaction {
259        // [[See comment about extra 'k' above]]
260        __vki_sighandler_t ksa_handler;
261        unsigned long sa_flags;
262        void (*sa_restorer)(void);
263        vki_sigset_t sa_mask;               /* mask last for extensibility */
264};
265
266struct vki_k_sigaction {
267        struct vki_sigaction sa;
268};
269
270
271/* On Linux we use the same type for passing sigactions to
272   and from the kernel.  Hence: */
273typedef  struct vki_sigaction  vki_sigaction_toK_t;
274typedef  struct vki_sigaction  vki_sigaction_fromK_t;
275
276
277typedef struct vki_sigaltstack {
278	void __user *ss_sp;
279	int ss_flags;
280	vki_size_t ss_size;
281} vki_stack_t;
282
283
284//----------------------------------------------------------------------
285// From linux-2.6.16.60/include/asm-s390/mman.h
286//----------------------------------------------------------------------
287
288#define VKI_PROT_NONE   0x0             /* No page permissions */
289#define VKI_PROT_READ   0x1             /* page can be read */
290#define VKI_PROT_WRITE  0x2             /* page can be written */
291#define VKI_PROT_EXEC   0x4             /* page can be executed */
292#define VKI_PROT_GROWSDOWN 0x01000000   /* mprotect flag: extend
293					   change to start of
294					   growsdown vma */
295#define VKI_PROT_GROWSUP   0x02000000   /* mprotect flag:
296					   extend change to end
297					   of growsup vma */
298
299#define VKI_MAP_SHARED		0x0001  /* Share changes */
300#define VKI_MAP_PRIVATE 	0x0002	/*  */
301#define VKI_MAP_FIXED   	0x0010	/*  */
302#define VKI_MAP_ANONYMOUS	0x0020	/*  */
303
304
305//----------------------------------------------------------------------
306// From linux-2.6.16.60/include/asm-s390/fcntl.h
307//----------------------------------------------------------------------
308
309#define VKI_O_RDONLY        00000000
310#define VKI_O_WRONLY        00000001
311#define VKI_O_RDWR          00000002
312#define VKI_O_ACCMODE       00000003
313#define VKI_O_CREAT         00000100        /* not fcntl */
314#define VKI_O_EXCL          00000200        /* not fcntl */
315#define VKI_O_NOCTTY        00000400        /* not fcntl */
316#define VKI_O_TRUNC         00001000        /* not fcntl */
317#define VKI_O_APPEND        00002000
318#define VKI_O_NONBLOCK      00004000
319
320#define VKI_AT_FDCWD            -100
321
322#define VKI_F_DUPFD	0	/* dup */
323#define VKI_F_GETFD	1	/* get close_on_exec */
324#define VKI_F_SETFD	2	/* set/clear close_on_exec */
325#define VKI_F_GETFL	3	/* get file->f_flags */
326#define VKI_F_SETFL	4	/* set file->f_flags */
327#define VKI_F_GETLK	5
328#define VKI_F_SETLK	6
329#define VKI_F_SETLKW	7
330#define VKI_F_SETOWN	8	/* for sockets. */
331#define VKI_F_GETOWN	9	/* for sockets. */
332#define VKI_F_SETSIG	10	/* for sockets. */
333#define VKI_F_GETSIG	11	/* for sockets. */
334
335#define VKI_FD_CLOEXEC  1  /* actually anything with low bit set goes */
336
337#define VKI_F_LINUX_SPECIFIC_BASE   1024
338
339
340//----------------------------------------------------------------------
341// From linux-2.6.16.60/include/asm-s390x/resource.h
342//----------------------------------------------------------------------
343
344// which just does #include <asm-generic/resource.h>
345
346#define VKI_RLIMIT_DATA             2       /* max data size */
347#define VKI_RLIMIT_STACK            3       /* max stack size */
348#define VKI_RLIMIT_CORE             4       /* max core file size */
349#define VKI_RLIMIT_NOFILE           7       /* max number of open files */
350
351
352//----------------------------------------------------------------------
353// From linux-2.6.16.60/include/asm-s390/socket.h
354//----------------------------------------------------------------------
355
356#define VKI_SOL_SOCKET      1
357
358#define VKI_SO_TYPE         3
359
360
361//----------------------------------------------------------------------
362// From linux-2.6.16.60/include/asm-s390/sockios.h
363//----------------------------------------------------------------------
364
365#define VKI_SIOCSPGRP       0x8902
366#define VKI_SIOCGPGRP       0x8904
367#define VKI_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
368/* since 2.6.22 */
369#define VKI_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
370
371
372//----------------------------------------------------------------------
373// From linux-2.6.16.60/include/asm-s390/stat.h
374//----------------------------------------------------------------------
375
376#ifndef VGA_s390x
377struct vki_stat {
378        unsigned short st_dev;
379        unsigned short __pad1;
380        unsigned long  st_ino;
381        unsigned short st_mode;
382        unsigned short st_nlink;
383        unsigned short st_uid;
384        unsigned short st_gid;
385        unsigned short st_rdev;
386        unsigned short __pad2;
387        unsigned long  st_size;
388        unsigned long  st_blksize;
389        unsigned long  st_blocks;
390        unsigned long  st_atime;
391        unsigned long  st_atime_nsec;
392        unsigned long  st_mtime;
393        unsigned long  st_mtime_nsec;
394        unsigned long  st_ctime;
395        unsigned long  st_ctime_nsec;
396        unsigned long  __unused4;
397        unsigned long  __unused5;
398};
399
400/* This matches struct stat64 in glibc2.1, hence the absolutely
401 * insane amounts of padding around dev_t's.
402 */
403struct vki_stat64 {
404        unsigned long long	st_dev;
405        unsigned int    __pad1;
406        unsigned long   __st_ino;
407        unsigned int    st_mode;
408        unsigned int    st_nlink;
409        unsigned long   st_uid;
410        unsigned long   st_gid;
411        unsigned long long	st_rdev;
412        unsigned int    __pad3;
413        long long	st_size;
414        unsigned long   st_blksize;
415        unsigned char   __pad4[4];
416        unsigned long   __pad5;     /* future possible st_blocks high bits */
417        unsigned long   st_blocks;  /* Number 512-byte blocks allocated. */
418        unsigned long   st_atime;
419        unsigned long   st_atime_nsec;
420        unsigned long   st_mtime;
421        unsigned long   st_mtime_nsec;
422        unsigned long   st_ctime;
423        unsigned long   st_ctime_nsec;  /* will be high 32 bits of ctime someday */
424        unsigned long long	st_ino;
425};
426
427#else
428
429struct vki_stat {
430        unsigned long  st_dev;
431        unsigned long  st_ino;
432        unsigned long  st_nlink;
433        unsigned int   st_mode;
434        unsigned int   st_uid;
435        unsigned int   st_gid;
436        unsigned int   __pad1;
437        unsigned long  st_rdev;
438        unsigned long  st_size;
439        unsigned long  st_atime;
440	unsigned long  st_atime_nsec;
441        unsigned long  st_mtime;
442	unsigned long  st_mtime_nsec;
443        unsigned long  st_ctime;
444	unsigned long  st_ctime_nsec;
445        unsigned long  st_blksize;
446        long           st_blocks;
447        unsigned long  __unused[3];
448};
449
450#endif /* VGA_s390x */
451
452
453//----------------------------------------------------------------------
454// From linux-2.6.16.60/include/asm-s390/statfs.h
455//----------------------------------------------------------------------
456
457struct vki_statfs {
458        int  f_type;
459        int  f_bsize;
460        long f_blocks;
461        long f_bfree;
462        long f_bavail;
463        long f_files;
464        long f_ffree;
465        __vki_kernel_fsid_t f_fsid;
466        int  f_namelen;
467        int  f_frsize;
468        int  f_spare[5];
469};
470
471
472//----------------------------------------------------------------------
473// From linux-2.6.16.60/include/asm-s390/termios.h
474//----------------------------------------------------------------------
475
476struct vki_winsize {
477	unsigned short ws_row;
478	unsigned short ws_col;
479	unsigned short ws_xpixel;
480	unsigned short ws_ypixel;
481};
482
483#define VKI_NCC 8
484struct vki_termio {
485	unsigned short c_iflag;		/* input mode flags */
486	unsigned short c_oflag;		/* output mode flags */
487	unsigned short c_cflag;		/* control mode flags */
488	unsigned short c_lflag;		/* local mode flags */
489	unsigned char c_line;		/* line discipline */
490	unsigned char c_cc[VKI_NCC];	/* control characters */
491};
492
493
494//----------------------------------------------------------------------
495// From linux-2.6.16.60/include/asm-s390/termbits.h
496//----------------------------------------------------------------------
497
498typedef unsigned char   vki_cc_t;
499typedef unsigned int    vki_tcflag_t;
500
501#define VKI_NCCS 19
502struct vki_termios {
503	vki_tcflag_t c_iflag;		/* input mode flags */
504	vki_tcflag_t c_oflag;		/* output mode flags */
505	vki_tcflag_t c_cflag;		/* control mode flags */
506	vki_tcflag_t c_lflag;		/* local mode flags */
507	vki_cc_t c_line;		/* line discipline */
508	vki_cc_t c_cc[VKI_NCCS];	/* control characters */
509};
510
511
512//----------------------------------------------------------------------
513// From linux-2.6.16.60/include/asm-s390/ioctl.h
514//----------------------------------------------------------------------
515
516#define _VKI_IOC_NRBITS		8
517#define _VKI_IOC_TYPEBITS	8
518#define _VKI_IOC_SIZEBITS	14
519#define _VKI_IOC_DIRBITS	2
520
521#define _VKI_IOC_NRMASK		((1 << _VKI_IOC_NRBITS)-1)
522#define _VKI_IOC_TYPEMASK	((1 << _VKI_IOC_TYPEBITS)-1)
523#define _VKI_IOC_SIZEMASK	((1 << _VKI_IOC_SIZEBITS)-1)
524#define _VKI_IOC_DIRMASK	((1 << _VKI_IOC_DIRBITS)-1)
525
526#define _VKI_IOC_NRSHIFT	0
527#define _VKI_IOC_TYPESHIFT	(_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
528#define _VKI_IOC_SIZESHIFT	(_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
529#define _VKI_IOC_DIRSHIFT	(_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
530
531#define _VKI_IOC_NONE	0U
532#define _VKI_IOC_WRITE	1U
533#define _VKI_IOC_READ	2U
534
535#define _VKI_IOC(dir,type,nr,size) \
536	(((dir)  << _VKI_IOC_DIRSHIFT) | \
537	 ((type) << _VKI_IOC_TYPESHIFT) | \
538	 ((nr)   << _VKI_IOC_NRSHIFT) | \
539	 ((size) << _VKI_IOC_SIZESHIFT))
540
541/* used to create numbers */
542#define _VKI_IO(type,nr)	_VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
543#define _VKI_IOR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
544#define _VKI_IOW(type,nr,size)	_VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
545#define _VKI_IOWR(type,nr,size)	_VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
546
547/* used to decode ioctl numbers.. */
548#define _VKI_IOC_DIR(nr)	(((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
549#define _VKI_IOC_TYPE(nr)	(((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
550#define _VKI_IOC_NR(nr)		(((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
551#define _VKI_IOC_SIZE(nr)	(((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
552
553//----------------------------------------------------------------------
554// From linux-2.6.16.60/include/asm-s390/ioctls.h
555//----------------------------------------------------------------------
556
557/* 0x54 is just a magic number to make these relatively unique ('T') */
558
559#define VKI_TCGETS	0x5401
560#define VKI_TCSETS	0x5402
561#define VKI_TCSETSW	0x5403
562#define VKI_TCSETSF	0x5404
563#define VKI_TCGETA	0x5405
564#define VKI_TCSETA	0x5406
565#define VKI_TCSETAW	0x5407
566#define VKI_TCSETAF	0x5408
567#define VKI_TCSBRK	0x5409
568#define VKI_TCXONC	0x540A
569#define VKI_TCFLSH	0x540B
570
571#define VKI_TIOCSCTTY	0x540E
572#define VKI_TIOCGPGRP	0x540F
573#define VKI_TIOCSPGRP	0x5410
574#define VKI_TIOCOUTQ	0x5411
575
576#define VKI_TIOCGWINSZ	0x5413
577#define VKI_TIOCSWINSZ	0x5414
578#define VKI_TIOCMGET	0x5415
579#define VKI_TIOCMBIS	0x5416
580#define VKI_TIOCMBIC	0x5417
581#define VKI_TIOCMSET	0x5418
582
583#define VKI_FIONREAD	0x541B
584#define VKI_TIOCLINUX	0x541C
585
586#define VKI_FIONBIO	0x5421
587
588#define VKI_TCSBRKP	0x5425	/* Needed for POSIX tcsendbreak() */
589
590#define VKI_TIOCGPTN	_VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
591#define VKI_TIOCSPTLCK	_VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
592
593#define VKI_FIOASYNC	        0x5452
594
595#define VKI_TIOCSERGETLSR       0x5459 /* Get line status register */
596
597#define VKI_TIOCGICOUNT	0x545D	/* read serial port inline interrupt counts */
598
599//----------------------------------------------------------------------
600// From linux-2.6.39-rc2/arch/s390/include/asm/ioctls.h
601//----------------------------------------------------------------------
602
603#define VKI_FIOQSIZE 0x545E
604
605//----------------------------------------------------------------------
606// From linux-2.6.16.60/include/asm-s390/poll.h
607//----------------------------------------------------------------------
608
609struct vki_pollfd {
610	int fd;
611	short events;
612	short revents;
613};
614
615#define VKI_POLLIN          0x0001
616
617//----------------------------------------------------------------------
618// From linux-2.6.16.60/include/asm-s390/ptrace.h
619//----------------------------------------------------------------------
620#define VKI_NUM_GPRS	16
621#define VKI_NUM_FPRS	16
622#define VKI_NUM_CRS	16
623#define VKI_NUM_ACRS	16
624
625typedef union
626{
627	float   f;
628	double  d;
629        __vki_u64   ui;
630	struct
631	{
632		__vki_u32 hi;
633		__vki_u32 lo;
634	} fp;
635} vki_freg_t;
636
637typedef struct
638{
639	__vki_u32   fpc;
640	vki_freg_t  fprs[VKI_NUM_FPRS];
641} vki_s390_fp_regs;
642
643typedef struct
644{
645        unsigned long mask;
646        unsigned long addr;
647} __attribute__ ((aligned(8))) vki_psw_t;
648
649typedef struct
650{
651	vki_psw_t psw;
652	unsigned long gprs[VKI_NUM_GPRS];
653	unsigned int  acrs[VKI_NUM_ACRS];
654	unsigned long orig_gpr2;
655} vki_s390_regs;
656
657/*
658 * Now for the program event recording (trace) definitions.
659 */
660typedef struct
661{
662	unsigned long cr[3];
663} vki_per_cr_words;
664
665typedef	struct
666{
667#ifdef VGA_s390x
668	unsigned                       : 32;
669#endif /* VGA_s390x */
670	unsigned em_branching          : 1;
671	unsigned em_instruction_fetch  : 1;
672	/*
673	 * Switching on storage alteration automatically fixes
674	 * the storage alteration event bit in the users std.
675	 */
676	unsigned em_storage_alteration : 1;
677	unsigned em_gpr_alt_unused     : 1;
678	unsigned em_store_real_address : 1;
679	unsigned                       : 3;
680	unsigned branch_addr_ctl       : 1;
681	unsigned                       : 1;
682	unsigned storage_alt_space_ctl : 1;
683	unsigned                       : 21;
684	unsigned long starting_addr;
685	unsigned long ending_addr;
686} vki_per_cr_bits;
687
688typedef struct
689{
690	unsigned short perc_atmid;
691	unsigned long address;
692	unsigned char access_id;
693} vki_per_lowcore_words;
694
695typedef struct
696{
697	unsigned perc_branching          : 1;
698	unsigned perc_instruction_fetch  : 1;
699	unsigned perc_storage_alteration : 1;
700	unsigned perc_gpr_alt_unused     : 1;
701	unsigned perc_store_real_address : 1;
702	unsigned                         : 3;
703	unsigned atmid_psw_bit_31        : 1;
704	unsigned atmid_validity_bit      : 1;
705	unsigned atmid_psw_bit_32        : 1;
706	unsigned atmid_psw_bit_5         : 1;
707	unsigned atmid_psw_bit_16        : 1;
708	unsigned atmid_psw_bit_17        : 1;
709	unsigned si                      : 2;
710	unsigned long address;
711	unsigned                         : 4;
712	unsigned access_id               : 4;
713} vki_per_lowcore_bits;
714
715typedef struct
716{
717	union {
718		vki_per_cr_words   words;
719		vki_per_cr_bits    bits;
720	} control_regs;
721	/*
722	 * Use these flags instead of setting em_instruction_fetch
723	 * directly they are used so that single stepping can be
724	 * switched on & off while not affecting other tracing
725	 */
726	unsigned  single_step       : 1;
727	unsigned  instruction_fetch : 1;
728	unsigned                    : 30;
729	/*
730	 * These addresses are copied into cr10 & cr11 if single
731	 * stepping is switched off
732	 */
733	unsigned long starting_addr;
734	unsigned long ending_addr;
735	union {
736		vki_per_lowcore_words words;
737		vki_per_lowcore_bits  bits;
738	} lowcore;
739} vki_per_struct;
740
741/*
742 * The user_regs_struct defines the way the user registers are
743 * store on the stack for signal handling.
744 */
745struct vki_user_regs_struct
746{
747	vki_psw_t psw;
748	unsigned long gprs[VKI_NUM_GPRS];
749	unsigned int  acrs[VKI_NUM_ACRS];
750	unsigned long orig_gpr2;
751	vki_s390_fp_regs fp_regs;
752	/*
753	 * These per registers are in here so that gdb can modify them
754	 * itself as there is no "official" ptrace interface for hardware
755	 * watchpoints. This is the way intel does it.
756	 */
757	vki_per_struct per_info;
758	unsigned long ieee_instruction_pointer;
759	/* Used to give failing instruction back to user for ieee exceptions */
760};
761
762typedef struct
763{
764	unsigned int  vki_len;
765	unsigned long vki_kernel_addr;
766	unsigned long vki_process_addr;
767} vki_ptrace_area;
768
769/*
770 * S/390 specific non posix ptrace requests
771 */
772#define VKI_PTRACE_PEEKUSR_AREA       0x5000
773#define VKI_PTRACE_POKEUSR_AREA       0x5001
774
775//----------------------------------------------------------------------
776// From linux-2.6.16.60/include/asm-s390/elf.h
777//----------------------------------------------------------------------
778
779typedef vki_s390_fp_regs vki_elf_fpregset_t;
780typedef vki_s390_regs vki_elf_gregset_t;
781
782
783//----------------------------------------------------------------------
784// From linux-2.6.16.60/include/asm-s390/ucontext.h
785//----------------------------------------------------------------------
786
787struct vki_ucontext {
788	unsigned long	      uc_flags;
789	struct vki_ucontext  *uc_link;
790	vki_stack_t	      uc_stack;
791	_vki_sigregs          uc_mcontext;
792	vki_sigset_t	      uc_sigmask; /* mask last for extensibility */
793};
794
795//----------------------------------------------------------------------
796// From linux-2.6.16.60/include/asm-s390/ipcbuf.h
797//----------------------------------------------------------------------
798
799struct vki_ipc64_perm
800{
801	__vki_kernel_key_t	key;
802	__vki_kernel_uid32_t	uid;
803	__vki_kernel_gid32_t	gid;
804	__vki_kernel_uid32_t	cuid;
805	__vki_kernel_gid32_t	cgid;
806	__vki_kernel_mode_t	mode;
807	unsigned short		__pad1;
808	unsigned short		seq;
809#ifndef VGA_s390x
810	unsigned short		__pad2;
811#endif /* ! VGA_s390x */
812	unsigned long		__unused1;
813	unsigned long		__unused2;
814};
815
816
817//----------------------------------------------------------------------
818// From linux-2.6.16.60/include/asm-s390/sembuf.h
819//----------------------------------------------------------------------
820
821struct vki_semid64_ds {
822	struct vki_ipc64_perm sem_perm;		/* permissions .. see ipc.h */
823	__vki_kernel_time_t   sem_otime;	/* last semop time */
824#ifndef VGA_s390x
825	unsigned long	__unused1;
826#endif /* ! VGA_s390x */
827	__vki_kernel_time_t   sem_ctime;	/* last change time */
828#ifndef VGA_s390x
829	unsigned long	__unused2;
830#endif /* ! VGA_s390x */
831	unsigned long	sem_nsems;		/* no. of semaphores in array */
832	unsigned long	__unused3;
833	unsigned long	__unused4;
834};
835
836
837//----------------------------------------------------------------------
838// From linux-2.6.16.60/include/asm-s390/msgbuf.h
839//----------------------------------------------------------------------
840
841struct vki_msqid64_ds {
842	struct vki_ipc64_perm msg_perm;
843	__vki_kernel_time_t msg_stime;	/* last msgsnd time */
844#ifndef VGA_s390x
845	unsigned long	__unused1;
846#endif /* ! VGA_s390x */
847	__vki_kernel_time_t msg_rtime;	/* last msgrcv time */
848#ifndef VGA_s390x
849	unsigned long	__unused2;
850#endif /* ! VGA_s390x */
851	__vki_kernel_time_t msg_ctime;	/* last change time */
852#ifndef VGA_s390x
853	unsigned long	__unused3;
854#endif /* ! VGA_s390x */
855	unsigned long  msg_cbytes;	/* current number of bytes on queue */
856	unsigned long  msg_qnum;	/* number of messages in queue */
857	unsigned long  msg_qbytes;	/* max number of bytes on queue */
858	__vki_kernel_pid_t msg_lspid;	/* pid of last msgsnd */
859	__vki_kernel_pid_t msg_lrpid;	/* last receive pid */
860	unsigned long  __unused4;
861	unsigned long  __unused5;
862};
863
864
865//----------------------------------------------------------------------
866// From linux-2.6.16.60/include/asm-s390/ipc.h
867//----------------------------------------------------------------------
868
869struct vki_ipc_kludge {
870	struct vki_msgbuf __user *msgp;
871	long msgtyp;
872};
873
874#define VKI_SEMOP	 1
875#define VKI_SEMGET	 2
876#define VKI_SEMCTL	 3
877#define VKI_SEMTIMEDOP	 4
878#define VKI_MSGSND	11
879#define VKI_MSGRCV	12
880#define VKI_MSGGET	13
881#define VKI_MSGCTL	14
882#define VKI_SHMAT	21
883#define VKI_SHMDT	22
884#define VKI_SHMGET	23
885#define VKI_SHMCTL	24
886
887
888//----------------------------------------------------------------------
889// From linux-2.6.16.60/include/asm-s390/shmbuf.h
890//----------------------------------------------------------------------
891
892struct vki_shmid64_ds {
893	struct vki_ipc64_perm	shm_perm;	/* operation perms */
894	vki_size_t		shm_segsz;	/* size of segment (bytes) */
895	__vki_kernel_time_t	shm_atime;	/* last attach time */
896#ifndef VGA_s390x
897	unsigned long		__unused1;
898#endif /* ! VGA_s390x */
899	__vki_kernel_time_t	shm_dtime;	/* last detach time */
900#ifndef VGA_s390x
901	unsigned long		__unused2;
902#endif /* ! VGA_s390x */
903	__vki_kernel_time_t	shm_ctime;	/* last change time */
904#ifndef VGA_s390x
905	unsigned long		__unused3;
906#endif /* ! VGA_s390x */
907	__vki_kernel_pid_t	shm_cpid;	/* pid of creator */
908	__vki_kernel_pid_t	shm_lpid;	/* pid of last operator */
909	unsigned long		shm_nattch;	/* no. of current attaches */
910	unsigned long		__unused4;
911	unsigned long		__unused5;
912};
913
914struct vki_shminfo64 {
915	unsigned long	shmmax;
916	unsigned long	shmmin;
917	unsigned long	shmmni;
918	unsigned long	shmseg;
919	unsigned long	shmall;
920	unsigned long	__unused1;
921	unsigned long	__unused2;
922	unsigned long	__unused3;
923	unsigned long	__unused4;
924};
925
926
927//----------------------------------------------------------------------
928// The following are defined in the VKI namespace but are nowhere found
929// in the linux headers.
930//----------------------------------------------------------------------
931#define VKI_BIG_ENDIAN      1
932#define VKI_MAX_PAGE_SHIFT  VKI_PAGE_SHIFT
933#define VKI_MAX_PAGE_SIZE   VKI_PAGE_SIZE
934
935//----------------------------------------------------------------------
936// From linux-2.6.35.4/arch/s390x/include/asm/shmparam.h
937//----------------------------------------------------------------------
938
939#define VKI_SHMLBA  VKI_PAGE_SIZE
940
941/* If a system call returns a value >= VKI_MAX_ERRNO then that is considered
942   an error condition. I.e. the system call failed. */
943#define VKI_MAX_ERRNO       -125
944
945#endif // __VKI_S390X_LINUX_H
946
947/*--------------------------------------------------------------------*/
948/*--- end                                                          ---*/
949/*--------------------------------------------------------------------*/
950