Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:25:31

0001 
0002 /*--------------------------------------------------------------------*/
0003 /*--- s390x/Linux-specific kernel interface.     vki-s390x-linux.h ---*/
0004 /*--------------------------------------------------------------------*/
0005 
0006 /*
0007    This file is part of Valgrind, a dynamic binary instrumentation
0008    framework.
0009 
0010    Copyright IBM Corp. 2010-2017
0011 
0012    This program is free software; you can redistribute it and/or
0013    modify it under the terms of the GNU General Public License as
0014    published by the Free Software Foundation; either version 2 of the
0015    License, or (at your option) any later version.
0016 
0017    This program is distributed in the hope that it will be useful, but
0018    WITHOUT ANY WARRANTY; without even the implied warranty of
0019    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0020    General Public License for more details.
0021 
0022    You should have received a copy of the GNU General Public License
0023    along with this program; if not, see <http://www.gnu.org/licenses/>.
0024 
0025    The GNU General Public License is contained in the file COPYING.
0026 */
0027 
0028 /* Contributed by Florian Krohm and Volker Sameske */
0029 
0030 #ifndef __VKI_S390X_LINUX_H
0031 #define __VKI_S390X_LINUX_H
0032 
0033 #define __force
0034 
0035 //----------------------------------------------------------------------
0036 // From linux-2.6.16.60/include/asm-s390/types.h
0037 //----------------------------------------------------------------------
0038 
0039 typedef __signed__ char __vki_s8;
0040 typedef unsigned char __vki_u8;
0041 
0042 typedef __signed__ short __vki_s16;
0043 typedef unsigned short __vki_u16;
0044 
0045 typedef __signed__ int __vki_s32;
0046 typedef unsigned int __vki_u32;
0047 
0048 typedef __signed__ long __vki_s64;
0049 typedef unsigned long __vki_u64;
0050 
0051 typedef unsigned short vki_u16;
0052 
0053 typedef unsigned int vki_u32;
0054 
0055 //----------------------------------------------------------------------
0056 // From linux-2.6.16.60/include/asm-s390/page.h
0057 //----------------------------------------------------------------------
0058 
0059 /* PAGE_SHIFT determines the page size */
0060 #define VKI_PAGE_SHIFT  12
0061 #define VKI_PAGE_SIZE   (1UL << VKI_PAGE_SHIFT)
0062 
0063 //----------------------------------------------------------------------
0064 // From linux-2.6.16.60/include/asm-s390/siginfo.h
0065 //----------------------------------------------------------------------
0066 
0067 /* We need that to ensure that sizeof(siginfo) == 128. */
0068 #ifdef __s390x__
0069 #define __VKI_ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
0070 #endif
0071 
0072 //----------------------------------------------------------------------
0073 // From linux-2.6.16.60/include/asm-s390/sigcontext.h
0074 //----------------------------------------------------------------------
0075 
0076 #define __VKI_NUM_GPRS 16
0077 #define __VKI_NUM_FPRS 16
0078 #define __VKI_NUM_ACRS 16
0079 
0080 #ifndef VGA_s390x
0081 
0082 /* Has to be at least _NSIG_WORDS from asm/signal.h */
0083 #define _VKI_SIGCONTEXT_NSIG    64
0084 #define _VKI_SIGCONTEXT_NSIG_BPW    32
0085 /* Size of stack frame allocated when calling signal handler. */
0086 #define __VKI_SIGNAL_FRAMESIZE  96
0087 
0088 #else /* VGA_s390x */
0089 
0090 /* Has to be at least _NSIG_WORDS from asm/signal.h */
0091 #define _VKI_SIGCONTEXT_NSIG    64
0092 #define _VKI_SIGCONTEXT_NSIG_BPW    64
0093 /* Size of stack frame allocated when calling signal handler. */
0094 #define __VKI_SIGNAL_FRAMESIZE  160
0095 
0096 #endif /* VGA_s390x */
0097 
0098 
0099 #define _VKI_SIGCONTEXT_NSIG_WORDS  (_VKI_SIGCONTEXT_NSIG / _VKI_SIGCONTEXT_NSIG_BPW)
0100 #define _VKI_SIGMASK_COPY_SIZE  (sizeof(unsigned long)*_VKI_SIGCONTEXT_NSIG_WORDS)
0101 
0102 typedef struct
0103 {
0104     unsigned long mask;
0105     unsigned long addr;
0106 } __attribute__ ((aligned(8))) _vki_psw_t;
0107 
0108 typedef struct
0109 {
0110     _vki_psw_t psw;
0111     unsigned long gprs[__VKI_NUM_GPRS];
0112     unsigned int  acrs[__VKI_NUM_ACRS];
0113 } _vki_s390_regs_common;
0114 
0115 typedef struct
0116 {
0117     unsigned int fpc;
0118     double   fprs[__VKI_NUM_FPRS];
0119 } _vki_s390_fp_regs;
0120 
0121 typedef struct
0122 {
0123     _vki_s390_regs_common regs;
0124     _vki_s390_fp_regs     fpregs;
0125 } _vki_sigregs;
0126 
0127 
0128 struct vki_sigcontext
0129 {
0130     unsigned long   oldmask[_VKI_SIGCONTEXT_NSIG_WORDS];
0131     _vki_sigregs    __user *sregs;
0132 };
0133 
0134 
0135 //----------------------------------------------------------------------
0136 // From linux-2.6.16.60/include/asm-s390/signal.h
0137 //----------------------------------------------------------------------
0138 
0139 #define _VKI_NSIG           _VKI_SIGCONTEXT_NSIG
0140 #define _VKI_NSIG_BPW       _VKI_SIGCONTEXT_NSIG_BPW
0141 #define _VKI_NSIG_WORDS     _VKI_SIGCONTEXT_NSIG_WORDS
0142 
0143 typedef unsigned long vki_old_sigset_t;
0144 
0145 typedef struct {
0146     unsigned long sig[_VKI_NSIG_WORDS];
0147 } vki_sigset_t;
0148 
0149 #define VKI_SIGHUP           1
0150 #define VKI_SIGINT           2
0151 #define VKI_SIGQUIT          3
0152 #define VKI_SIGILL           4
0153 #define VKI_SIGTRAP          5
0154 #define VKI_SIGABRT          6
0155 #define VKI_SIGIOT           6
0156 #define VKI_SIGBUS           7
0157 #define VKI_SIGFPE           8
0158 #define VKI_SIGKILL          9
0159 #define VKI_SIGUSR1         10
0160 #define VKI_SIGSEGV         11
0161 #define VKI_SIGUSR2         12
0162 #define VKI_SIGPIPE         13
0163 #define VKI_SIGALRM         14
0164 #define VKI_SIGTERM         15
0165 #define VKI_SIGSTKFLT       16
0166 #define VKI_SIGCHLD         17
0167 #define VKI_SIGCONT         18
0168 #define VKI_SIGSTOP         19
0169 #define VKI_SIGTSTP         20
0170 #define VKI_SIGTTIN         21
0171 #define VKI_SIGTTOU         22
0172 #define VKI_SIGURG          23
0173 #define VKI_SIGXCPU         24
0174 #define VKI_SIGXFSZ         25
0175 #define VKI_SIGVTALRM       26
0176 #define VKI_SIGPROF         27
0177 #define VKI_SIGWINCH        28
0178 #define VKI_SIGIO           29
0179 #define VKI_SIGPOLL         VKI_SIGIO
0180 /*
0181 #define VKI_SIGLOST         29
0182 */
0183 #define VKI_SIGPWR          30
0184 #define VKI_SIGSYS      31
0185 #define VKI_SIGUNUSED       31
0186 
0187 /* These should not be considered constants from userland.  */
0188 #define VKI_SIGRTMIN        32
0189 #define VKI_SIGRTMAX        _VKI_NSIG
0190 
0191 /*
0192  * SA_FLAGS values:
0193  *
0194  * SA_ONSTACK indicates that a registered stack_t will be used.
0195  * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
0196  * SA_RESTART flag to get restarting signals (which were the default long ago)
0197  * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
0198  * SA_RESETHAND clears the handler when the signal is delivered.
0199  * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
0200  * SA_NODEFER prevents the current signal from being masked in the handler.
0201  *
0202  * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
0203  * Unix names RESETHAND and NODEFER respectively.
0204  */
0205 #define VKI_SA_NOCLDSTOP    0x00000001
0206 #define VKI_SA_NOCLDWAIT    0x00000002
0207 #define VKI_SA_SIGINFO      0x00000004
0208 #define VKI_SA_ONSTACK      0x08000000
0209 #define VKI_SA_RESTART      0x10000000
0210 #define VKI_SA_NODEFER      0x40000000
0211 #define VKI_SA_RESETHAND    0x80000000
0212 
0213 #define VKI_SA_NOMASK       VKI_SA_NODEFER
0214 #define VKI_SA_ONESHOT      VKI_SA_RESETHAND
0215 #define VKI_SA_INTERRUPT    0x20000000 /* dummy -- ignored */
0216 
0217 #define VKI_SA_RESTORER     0x04000000
0218 
0219 /*
0220  * sigaltstack controls
0221  */
0222 #define VKI_SS_ONSTACK      1
0223 #define VKI_SS_DISABLE      2
0224 
0225 #define VKI_MINSIGSTKSZ     2048
0226 #define VKI_SIGSTKSZ        8192
0227 
0228 
0229 /* Next lines asm-generic/signal.h */
0230 #define VKI_SIG_BLOCK          0 /* for blocking signals */
0231 #define VKI_SIG_UNBLOCK        1 /* for unblocking signals */
0232 #define VKI_SIG_SETMASK        2 /* for setting the signal mask */
0233 
0234 typedef void __vki_signalfn_t(int);
0235 typedef __vki_signalfn_t __user *__vki_sighandler_t;
0236 
0237 /* default signal handling */
0238 #define VKI_SIG_DFL ((__force __vki_sighandler_t)0)
0239 /* ignore signal */
0240 #define VKI_SIG_IGN ((__force __vki_sighandler_t)1)
0241 /* error return from signal */
0242 #define VKI_SIG_ERR ((__force __vki_sighandler_t)-1)
0243 /* Back to asm-s390/signal.h */
0244 
0245 struct vki_old_sigaction {
0246         // [[Nb: a 'k' prefix is added to "sa_handler" because
0247         // bits/sigaction.h (which gets dragged in somehow via signal.h)
0248         // #defines it as something else.  Since that is done for glibc's
0249         // purposes, which we don't care about here, we use our own name.]]
0250         __vki_sighandler_t ksa_handler;
0251         vki_old_sigset_t sa_mask;
0252         unsigned long sa_flags;
0253         void (*sa_restorer)(void);
0254 };
0255 
0256 struct vki_sigaction {
0257         // [[See comment about extra 'k' above]]
0258         __vki_sighandler_t ksa_handler;
0259         // Yes, the reserved field is really glibc specific. The kernel
0260         // doesn't have it and uses an unsigned long for sa_flags.
0261         // The glibc and the kernel agreed this is fine and the
0262         // __glibc_reserved0 field can be undefined.
0263         // See https://sourceware.org/ml/libc-alpha/2014-09/msg00161.html
0264         int __glibc_reserved0;
0265         int sa_flags;
0266         void (*sa_restorer)(void);
0267         vki_sigset_t sa_mask;               /* mask last for extensibility */
0268 };
0269 
0270 struct vki_k_sigaction {
0271         struct vki_sigaction sa;
0272 };
0273 
0274 
0275 /* On Linux we use the same type for passing sigactions to
0276    and from the kernel.  Hence: */
0277 typedef  struct vki_sigaction  vki_sigaction_toK_t;
0278 typedef  struct vki_sigaction  vki_sigaction_fromK_t;
0279 
0280 
0281 typedef struct vki_sigaltstack {
0282     void __user *ss_sp;
0283     int ss_flags;
0284     vki_size_t ss_size;
0285 } vki_stack_t;
0286 
0287 
0288 //----------------------------------------------------------------------
0289 // From linux-2.6.16.60/include/asm-s390/mman.h
0290 //----------------------------------------------------------------------
0291 
0292 #define VKI_PROT_NONE   0x0             /* No page permissions */
0293 #define VKI_PROT_READ   0x1             /* page can be read */
0294 #define VKI_PROT_WRITE  0x2             /* page can be written */
0295 #define VKI_PROT_EXEC   0x4             /* page can be executed */
0296 #define VKI_PROT_GROWSDOWN 0x01000000   /* mprotect flag: extend
0297                        change to start of
0298                        growsdown vma */
0299 #define VKI_PROT_GROWSUP   0x02000000   /* mprotect flag:
0300                        extend change to end
0301                        of growsup vma */
0302 
0303 #define VKI_MAP_SHARED      0x0001  /* Share changes */
0304 #define VKI_MAP_PRIVATE     0x0002  /*  */
0305 #define VKI_MAP_FIXED       0x0010  /*  */
0306 #define VKI_MAP_ANONYMOUS   0x0020  /*  */
0307 
0308 
0309 //----------------------------------------------------------------------
0310 // From linux-2.6.16.60/include/asm-s390/fcntl.h
0311 //----------------------------------------------------------------------
0312 
0313 #define VKI_O_RDONLY        00000000
0314 #define VKI_O_WRONLY        00000001
0315 #define VKI_O_RDWR          00000002
0316 #define VKI_O_ACCMODE       00000003
0317 #define VKI_O_CREAT         00000100        /* not fcntl */
0318 #define VKI_O_EXCL          00000200        /* not fcntl */
0319 #define VKI_O_NOCTTY        00000400        /* not fcntl */
0320 #define VKI_O_TRUNC         00001000        /* not fcntl */
0321 #define VKI_O_APPEND        00002000
0322 #define VKI_O_NONBLOCK      00004000
0323 
0324 #define VKI_AT_FDCWD            -100
0325 
0326 #define VKI_F_DUPFD 0   /* dup */
0327 #define VKI_F_GETFD 1   /* get close_on_exec */
0328 #define VKI_F_SETFD 2   /* set/clear close_on_exec */
0329 #define VKI_F_GETFL 3   /* get file->f_flags */
0330 #define VKI_F_SETFL 4   /* set file->f_flags */
0331 #define VKI_F_GETLK 5
0332 #define VKI_F_SETLK 6
0333 #define VKI_F_SETLKW    7
0334 #define VKI_F_SETOWN    8   /* for sockets. */
0335 #define VKI_F_GETOWN    9   /* for sockets. */
0336 #define VKI_F_SETSIG    10  /* for sockets. */
0337 #define VKI_F_GETSIG    11  /* for sockets. */
0338 
0339 #define VKI_F_SETOWN_EX     15
0340 #define VKI_F_GETOWN_EX     16
0341 
0342 #define VKI_F_OFD_GETLK     36
0343 #define VKI_F_OFD_SETLK     37
0344 #define VKI_F_OFD_SETLKW    38
0345 
0346 #define VKI_F_OWNER_TID     0
0347 #define VKI_F_OWNER_PID     1
0348 #define VKI_F_OWNER_PGRP    2
0349 
0350 struct vki_f_owner_ex {
0351     int type;
0352     __vki_kernel_pid_t  pid;
0353 };
0354 
0355 #define VKI_FD_CLOEXEC  1  /* actually anything with low bit set goes */
0356 
0357 #define VKI_F_LINUX_SPECIFIC_BASE   1024
0358 
0359 
0360 //----------------------------------------------------------------------
0361 // From linux-2.6.16.60/include/asm-s390x/resource.h
0362 //----------------------------------------------------------------------
0363 
0364 // which just does #include <asm-generic/resource.h>
0365 
0366 #define VKI_RLIMIT_DATA             2       /* max data size */
0367 #define VKI_RLIMIT_STACK            3       /* max stack size */
0368 #define VKI_RLIMIT_CORE             4       /* max core file size */
0369 #define VKI_RLIMIT_NOFILE           7       /* max number of open files */
0370 
0371 
0372 //----------------------------------------------------------------------
0373 // From linux-2.6.16.60/include/asm-s390/socket.h
0374 //----------------------------------------------------------------------
0375 
0376 #define VKI_SOL_SOCKET      1
0377 
0378 #define VKI_SO_TYPE         3
0379 
0380 #define VKI_SO_ATTACH_FILTER        26
0381 
0382 //----------------------------------------------------------------------
0383 // From linux-2.6.16.60/include/asm-s390/sockios.h
0384 //----------------------------------------------------------------------
0385 
0386 #define VKI_SIOCSPGRP       0x8902
0387 #define VKI_SIOCGPGRP       0x8904
0388 #define VKI_SIOCATMARK      0x8905
0389 #define VKI_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
0390 /* since 2.6.22 */
0391 #define VKI_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
0392 
0393 
0394 //----------------------------------------------------------------------
0395 // From linux-2.6.16.60/include/asm-s390/stat.h
0396 //----------------------------------------------------------------------
0397 
0398 #ifndef VGA_s390x
0399 struct vki_stat {
0400         unsigned short st_dev;
0401         unsigned short __pad1;
0402         unsigned long  st_ino;
0403         unsigned short st_mode;
0404         unsigned short st_nlink;
0405         unsigned short st_uid;
0406         unsigned short st_gid;
0407         unsigned short st_rdev;
0408         unsigned short __pad2;
0409         unsigned long  st_size;
0410         unsigned long  st_blksize;
0411         unsigned long  st_blocks;
0412         unsigned long  st_atime;
0413         unsigned long  st_atime_nsec;
0414         unsigned long  st_mtime;
0415         unsigned long  st_mtime_nsec;
0416         unsigned long  st_ctime;
0417         unsigned long  st_ctime_nsec;
0418         unsigned long  __unused4;
0419         unsigned long  __unused5;
0420 };
0421 
0422 /* This matches struct stat64 in glibc2.1, hence the absolutely
0423  * insane amounts of padding around dev_t's.
0424  */
0425 struct vki_stat64 {
0426         unsigned long long  st_dev;
0427         unsigned int    __pad1;
0428         unsigned long   __st_ino;
0429         unsigned int    st_mode;
0430         unsigned int    st_nlink;
0431         unsigned long   st_uid;
0432         unsigned long   st_gid;
0433         unsigned long long  st_rdev;
0434         unsigned int    __pad3;
0435         long long   st_size;
0436         unsigned long   st_blksize;
0437         unsigned char   __pad4[4];
0438         unsigned long   __pad5;     /* future possible st_blocks high bits */
0439         unsigned long   st_blocks;  /* Number 512-byte blocks allocated. */
0440         unsigned long   st_atime;
0441         unsigned long   st_atime_nsec;
0442         unsigned long   st_mtime;
0443         unsigned long   st_mtime_nsec;
0444         unsigned long   st_ctime;
0445         unsigned long   st_ctime_nsec;  /* will be high 32 bits of ctime someday */
0446         unsigned long long  st_ino;
0447 };
0448 
0449 #else
0450 
0451 struct vki_stat {
0452         unsigned long  st_dev;
0453         unsigned long  st_ino;
0454         unsigned long  st_nlink;
0455         unsigned int   st_mode;
0456         unsigned int   st_uid;
0457         unsigned int   st_gid;
0458         unsigned int   __pad1;
0459         unsigned long  st_rdev;
0460         unsigned long  st_size;
0461         unsigned long  st_atime;
0462     unsigned long  st_atime_nsec;
0463         unsigned long  st_mtime;
0464     unsigned long  st_mtime_nsec;
0465         unsigned long  st_ctime;
0466     unsigned long  st_ctime_nsec;
0467         unsigned long  st_blksize;
0468         long           st_blocks;
0469         unsigned long  __unused0[3];
0470 };
0471 
0472 #endif /* VGA_s390x */
0473 
0474 
0475 //----------------------------------------------------------------------
0476 // From linux-2.6.16.60/include/asm-s390/statfs.h
0477 //----------------------------------------------------------------------
0478 
0479 struct vki_statfs {
0480         int  f_type;
0481         int  f_bsize;
0482         long f_blocks;
0483         long f_bfree;
0484         long f_bavail;
0485         long f_files;
0486         long f_ffree;
0487         __vki_kernel_fsid_t f_fsid;
0488         int  f_namelen;
0489         int  f_frsize;
0490         int  f_spare[5];
0491 };
0492 
0493 
0494 //----------------------------------------------------------------------
0495 // From linux-2.6.16.60/include/asm-s390/termios.h
0496 //----------------------------------------------------------------------
0497 
0498 struct vki_winsize {
0499     unsigned short ws_row;
0500     unsigned short ws_col;
0501     unsigned short ws_xpixel;
0502     unsigned short ws_ypixel;
0503 };
0504 
0505 #define VKI_NCC 8
0506 struct vki_termio {
0507     unsigned short c_iflag;     /* input mode flags */
0508     unsigned short c_oflag;     /* output mode flags */
0509     unsigned short c_cflag;     /* control mode flags */
0510     unsigned short c_lflag;     /* local mode flags */
0511     unsigned char c_line;       /* line discipline */
0512     unsigned char c_cc[VKI_NCC];    /* control characters */
0513 };
0514 
0515 
0516 //----------------------------------------------------------------------
0517 // From linux-2.6.16.60/include/asm-s390/termbits.h
0518 //----------------------------------------------------------------------
0519 
0520 typedef unsigned char   vki_cc_t;
0521 typedef unsigned int    vki_tcflag_t;
0522 
0523 #define VKI_NCCS 19
0524 struct vki_termios {
0525     vki_tcflag_t c_iflag;       /* input mode flags */
0526     vki_tcflag_t c_oflag;       /* output mode flags */
0527     vki_tcflag_t c_cflag;       /* control mode flags */
0528     vki_tcflag_t c_lflag;       /* local mode flags */
0529     vki_cc_t c_line;        /* line discipline */
0530     vki_cc_t c_cc[VKI_NCCS];    /* control characters */
0531 };
0532 
0533 
0534 //----------------------------------------------------------------------
0535 // From linux-2.6.16.60/include/asm-s390/ioctl.h
0536 //----------------------------------------------------------------------
0537 
0538 #define _VKI_IOC_NRBITS     8
0539 #define _VKI_IOC_TYPEBITS   8
0540 #define _VKI_IOC_SIZEBITS   14
0541 #define _VKI_IOC_DIRBITS    2
0542 
0543 #define _VKI_IOC_NRMASK     ((1 << _VKI_IOC_NRBITS)-1)
0544 #define _VKI_IOC_TYPEMASK   ((1 << _VKI_IOC_TYPEBITS)-1)
0545 #define _VKI_IOC_SIZEMASK   ((1 << _VKI_IOC_SIZEBITS)-1)
0546 #define _VKI_IOC_DIRMASK    ((1 << _VKI_IOC_DIRBITS)-1)
0547 
0548 #define _VKI_IOC_NRSHIFT    0
0549 #define _VKI_IOC_TYPESHIFT  (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
0550 #define _VKI_IOC_SIZESHIFT  (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
0551 #define _VKI_IOC_DIRSHIFT   (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
0552 
0553 #define _VKI_IOC_NONE   0U
0554 #define _VKI_IOC_WRITE  1U
0555 #define _VKI_IOC_READ   2U
0556 
0557 #define _VKI_IOC(dir,type,nr,size) \
0558     (((dir)  << _VKI_IOC_DIRSHIFT) | \
0559      ((type) << _VKI_IOC_TYPESHIFT) | \
0560      ((nr)   << _VKI_IOC_NRSHIFT) | \
0561      ((size) << _VKI_IOC_SIZESHIFT))
0562 
0563 /* used to create numbers */
0564 #define _VKI_IO(type,nr)    _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
0565 #define _VKI_IOR(type,nr,size)  _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0566 #define _VKI_IOW(type,nr,size)  _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0567 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0568 
0569 /* used to decode ioctl numbers.. */
0570 #define _VKI_IOC_DIR(nr)    (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
0571 #define _VKI_IOC_TYPE(nr)   (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
0572 #define _VKI_IOC_NR(nr)     (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
0573 #define _VKI_IOC_SIZE(nr)   (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
0574 
0575 //----------------------------------------------------------------------
0576 // From linux-2.6.16.60/include/asm-s390/ioctls.h
0577 //----------------------------------------------------------------------
0578 
0579 /* 0x54 is just a magic number to make these relatively unique ('T') */
0580 
0581 #define VKI_TCGETS  0x5401
0582 #define VKI_TCSETS  0x5402
0583 #define VKI_TCSETSW 0x5403
0584 #define VKI_TCSETSF 0x5404
0585 #define VKI_TCGETA  0x5405
0586 #define VKI_TCSETA  0x5406
0587 #define VKI_TCSETAW 0x5407
0588 #define VKI_TCSETAF 0x5408
0589 #define VKI_TCSBRK  0x5409
0590 #define VKI_TCXONC  0x540A
0591 #define VKI_TCFLSH  0x540B
0592 
0593 #define VKI_TIOCSCTTY   0x540E
0594 #define VKI_TIOCGPGRP   0x540F
0595 #define VKI_TIOCSPGRP   0x5410
0596 #define VKI_TIOCOUTQ    0x5411
0597 
0598 #define VKI_TIOCGWINSZ  0x5413
0599 #define VKI_TIOCSWINSZ  0x5414
0600 #define VKI_TIOCMGET    0x5415
0601 #define VKI_TIOCMBIS    0x5416
0602 #define VKI_TIOCMBIC    0x5417
0603 #define VKI_TIOCMSET    0x5418
0604 
0605 #define VKI_FIONREAD    0x541B
0606 #define VKI_TIOCLINUX   0x541C
0607 
0608 #define VKI_FIONBIO 0x5421
0609 #define VKI_TIOCNOTTY   0x5422
0610 
0611 #define VKI_TCSBRKP 0x5425  /* Needed for POSIX tcsendbreak() */
0612 
0613 #define VKI_TIOCGPTN    _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
0614 #define VKI_TIOCSPTLCK  _VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
0615 
0616 #define VKI_FIONCLEX    0x5450
0617 #define VKI_FIOCLEX 0x5451
0618 #define VKI_FIOASYNC    0x5452
0619 
0620 #define VKI_TIOCSERGETLSR       0x5459 /* Get line status register */
0621 
0622 #define VKI_TIOCGICOUNT 0x545D  /* read serial port inline interrupt counts */
0623 
0624 //----------------------------------------------------------------------
0625 // From linux-2.6.39-rc2/arch/s390/include/asm/ioctls.h
0626 //----------------------------------------------------------------------
0627 
0628 #define VKI_FIOQSIZE 0x545E
0629 
0630 //----------------------------------------------------------------------
0631 // From linux-2.6.16.60/include/asm-s390/poll.h
0632 //----------------------------------------------------------------------
0633 
0634 struct vki_pollfd {
0635     int fd;
0636     short events;
0637     short revents;
0638 };
0639 
0640 #define VKI_POLLIN          0x0001
0641 
0642 //----------------------------------------------------------------------
0643 // From linux-2.6.16.60/include/asm-s390/ptrace.h
0644 //----------------------------------------------------------------------
0645 #define VKI_NUM_GPRS    16
0646 #define VKI_NUM_FPRS    16
0647 #define VKI_NUM_CRS 16
0648 #define VKI_NUM_ACRS    16
0649 
0650 typedef union
0651 {
0652     float   f;
0653     double  d;
0654         __vki_u64   ui;
0655     struct
0656     {
0657         __vki_u32 hi;
0658         __vki_u32 lo;
0659     } fp;
0660 } vki_freg_t;
0661 
0662 typedef struct
0663 {
0664     __vki_u32   fpc;
0665     vki_freg_t  fprs[VKI_NUM_FPRS];
0666 } vki_s390_fp_regs;
0667 
0668 typedef struct
0669 {
0670         unsigned long mask;
0671         unsigned long addr;
0672 } __attribute__ ((aligned(8))) vki_psw_t;
0673 
0674 typedef struct
0675 {
0676     vki_psw_t psw;
0677     unsigned long gprs[VKI_NUM_GPRS];
0678     unsigned int  acrs[VKI_NUM_ACRS];
0679     unsigned long orig_gpr2;
0680 } vki_s390_regs;
0681 
0682 /*
0683  * Now for the program event recording (trace) definitions.
0684  */
0685 typedef struct
0686 {
0687     unsigned long cr[3];
0688 } vki_per_cr_words;
0689 
0690 typedef struct
0691 {
0692 #ifdef VGA_s390x
0693     unsigned                       : 32;
0694 #endif /* VGA_s390x */
0695     unsigned em_branching          : 1;
0696     unsigned em_instruction_fetch  : 1;
0697     /*
0698      * Switching on storage alteration automatically fixes
0699      * the storage alteration event bit in the users std.
0700      */
0701     unsigned em_storage_alteration : 1;
0702     unsigned em_gpr_alt_unused     : 1;
0703     unsigned em_store_real_address : 1;
0704     unsigned                       : 3;
0705     unsigned branch_addr_ctl       : 1;
0706     unsigned                       : 1;
0707     unsigned storage_alt_space_ctl : 1;
0708     unsigned                       : 21;
0709     unsigned long starting_addr;
0710     unsigned long ending_addr;
0711 } vki_per_cr_bits;
0712 
0713 typedef struct
0714 {
0715     unsigned short perc_atmid;
0716     unsigned long address;
0717     unsigned char access_id;
0718 } vki_per_lowcore_words;
0719 
0720 typedef struct
0721 {
0722     unsigned perc_branching          : 1;
0723     unsigned perc_instruction_fetch  : 1;
0724     unsigned perc_storage_alteration : 1;
0725     unsigned perc_gpr_alt_unused     : 1;
0726     unsigned perc_store_real_address : 1;
0727     unsigned                         : 3;
0728     unsigned atmid_psw_bit_31        : 1;
0729     unsigned atmid_validity_bit      : 1;
0730     unsigned atmid_psw_bit_32        : 1;
0731     unsigned atmid_psw_bit_5         : 1;
0732     unsigned atmid_psw_bit_16        : 1;
0733     unsigned atmid_psw_bit_17        : 1;
0734     unsigned si                      : 2;
0735     unsigned long address;
0736     unsigned                         : 4;
0737     unsigned access_id               : 4;
0738 } vki_per_lowcore_bits;
0739 
0740 typedef struct
0741 {
0742     union {
0743         vki_per_cr_words   words;
0744         vki_per_cr_bits    bits;
0745     } control_regs;
0746     /*
0747      * Use these flags instead of setting em_instruction_fetch
0748      * directly they are used so that single stepping can be
0749      * switched on & off while not affecting other tracing
0750      */
0751     unsigned  single_step       : 1;
0752     unsigned  instruction_fetch : 1;
0753     unsigned                    : 30;
0754     /*
0755      * These addresses are copied into cr10 & cr11 if single
0756      * stepping is switched off
0757      */
0758     unsigned long starting_addr;
0759     unsigned long ending_addr;
0760     union {
0761         vki_per_lowcore_words words;
0762         vki_per_lowcore_bits  bits;
0763     } lowcore;
0764 } vki_per_struct;
0765 
0766 /*
0767  * The user_regs_struct defines the way the user registers are
0768  * store on the stack for signal handling.
0769  */
0770 struct vki_user_regs_struct
0771 {
0772     vki_psw_t psw;
0773     unsigned long gprs[VKI_NUM_GPRS];
0774     unsigned int  acrs[VKI_NUM_ACRS];
0775     unsigned long orig_gpr2;
0776     vki_s390_fp_regs fp_regs;
0777     /*
0778      * These per registers are in here so that gdb can modify them
0779      * itself as there is no "official" ptrace interface for hardware
0780      * watchpoints. This is the way intel does it.
0781      */
0782     vki_per_struct per_info;
0783     unsigned long ieee_instruction_pointer;
0784     /* Used to give failing instruction back to user for ieee exceptions */
0785 };
0786 
0787 typedef struct
0788 {
0789     unsigned int  vki_len;
0790     unsigned long vki_kernel_addr;
0791     unsigned long vki_process_addr;
0792 } vki_ptrace_area;
0793 
0794 /*
0795  * S/390 specific non posix ptrace requests
0796  */
0797 #define VKI_PTRACE_PEEKUSR_AREA       0x5000
0798 #define VKI_PTRACE_POKEUSR_AREA       0x5001
0799 
0800 //----------------------------------------------------------------------
0801 // From linux-3.18/include/asm-s390/elf.h
0802 //----------------------------------------------------------------------
0803 
0804 typedef vki_s390_fp_regs vki_elf_fpregset_t;
0805 typedef vki_s390_regs vki_elf_gregset_t;
0806 
0807 #define VKI_HWCAP_S390_TE           1024
0808 #define VKI_HWCAP_S390_VXRS         2048
0809 #define VKI_HWCAP_S390_VXRS_EXT     8192
0810 #define VKI_HWCAP_S390_VXRS_EXT2   32768
0811 
0812 
0813 //----------------------------------------------------------------------
0814 // From linux-2.6.16.60/include/asm-s390/ucontext.h
0815 //----------------------------------------------------------------------
0816 
0817 struct vki_ucontext {
0818     unsigned long         uc_flags;
0819     struct vki_ucontext  *uc_link;
0820     vki_stack_t       uc_stack;
0821     _vki_sigregs          uc_mcontext;
0822     vki_sigset_t          uc_sigmask; /* mask last for extensibility */
0823 };
0824 
0825 typedef char vki_modify_ldt_t;
0826 
0827 //----------------------------------------------------------------------
0828 // From linux-2.6.16.60/include/asm-s390/ipcbuf.h
0829 //----------------------------------------------------------------------
0830 
0831 struct vki_ipc64_perm
0832 {
0833     __vki_kernel_key_t  key;
0834     __vki_kernel_uid32_t    uid;
0835     __vki_kernel_gid32_t    gid;
0836     __vki_kernel_uid32_t    cuid;
0837     __vki_kernel_gid32_t    cgid;
0838     __vki_kernel_mode_t mode;
0839     unsigned short      __pad1;
0840     unsigned short      seq;
0841 #ifndef VGA_s390x
0842     unsigned short      __pad2;
0843 #endif /* ! VGA_s390x */
0844     unsigned long       __unused1;
0845     unsigned long       __unused2;
0846 };
0847 
0848 
0849 //----------------------------------------------------------------------
0850 // From linux-2.6.16.60/include/asm-s390/sembuf.h
0851 //----------------------------------------------------------------------
0852 
0853 struct vki_semid64_ds {
0854     struct vki_ipc64_perm sem_perm;     /* permissions .. see ipc.h */
0855     __vki_kernel_time_t   sem_otime;    /* last semop time */
0856 #ifndef VGA_s390x
0857     unsigned long   __unused1;
0858 #endif /* ! VGA_s390x */
0859     __vki_kernel_time_t   sem_ctime;    /* last change time */
0860 #ifndef VGA_s390x
0861     unsigned long   __unused2;
0862 #endif /* ! VGA_s390x */
0863     unsigned long   sem_nsems;      /* no. of semaphores in array */
0864     unsigned long   __unused3;
0865     unsigned long   __unused4;
0866 };
0867 
0868 
0869 //----------------------------------------------------------------------
0870 // From linux-2.6.16.60/include/asm-s390/msgbuf.h
0871 //----------------------------------------------------------------------
0872 
0873 struct vki_msqid64_ds {
0874     struct vki_ipc64_perm msg_perm;
0875     __vki_kernel_time_t msg_stime;  /* last msgsnd time */
0876 #ifndef VGA_s390x
0877     unsigned long   __unused1;
0878 #endif /* ! VGA_s390x */
0879     __vki_kernel_time_t msg_rtime;  /* last msgrcv time */
0880 #ifndef VGA_s390x
0881     unsigned long   __unused2;
0882 #endif /* ! VGA_s390x */
0883     __vki_kernel_time_t msg_ctime;  /* last change time */
0884 #ifndef VGA_s390x
0885     unsigned long   __unused3;
0886 #endif /* ! VGA_s390x */
0887     unsigned long  msg_cbytes;  /* current number of bytes on queue */
0888     unsigned long  msg_qnum;    /* number of messages in queue */
0889     unsigned long  msg_qbytes;  /* max number of bytes on queue */
0890     __vki_kernel_pid_t msg_lspid;   /* pid of last msgsnd */
0891     __vki_kernel_pid_t msg_lrpid;   /* last receive pid */
0892     unsigned long  __unused4;
0893     unsigned long  __unused5;
0894 };
0895 
0896 
0897 //----------------------------------------------------------------------
0898 // From linux-2.6.16.60/include/asm-s390/ipc.h
0899 //----------------------------------------------------------------------
0900 
0901 struct vki_ipc_kludge {
0902     struct vki_msgbuf __user *msgp;
0903     long msgtyp;
0904 };
0905 
0906 #define VKI_SEMOP    1
0907 #define VKI_SEMGET   2
0908 #define VKI_SEMCTL   3
0909 #define VKI_SEMTIMEDOP   4
0910 #define VKI_MSGSND  11
0911 #define VKI_MSGRCV  12
0912 #define VKI_MSGGET  13
0913 #define VKI_MSGCTL  14
0914 #define VKI_SHMAT   21
0915 #define VKI_SHMDT   22
0916 #define VKI_SHMGET  23
0917 #define VKI_SHMCTL  24
0918 
0919 
0920 //----------------------------------------------------------------------
0921 // From linux-2.6.16.60/include/asm-s390/shmbuf.h
0922 //----------------------------------------------------------------------
0923 
0924 struct vki_shmid64_ds {
0925     struct vki_ipc64_perm   shm_perm;   /* operation perms */
0926     vki_size_t      shm_segsz;  /* size of segment (bytes) */
0927     __vki_kernel_time_t shm_atime;  /* last attach time */
0928 #ifndef VGA_s390x
0929     unsigned long       __unused1;
0930 #endif /* ! VGA_s390x */
0931     __vki_kernel_time_t shm_dtime;  /* last detach time */
0932 #ifndef VGA_s390x
0933     unsigned long       __unused2;
0934 #endif /* ! VGA_s390x */
0935     __vki_kernel_time_t shm_ctime;  /* last change time */
0936 #ifndef VGA_s390x
0937     unsigned long       __unused3;
0938 #endif /* ! VGA_s390x */
0939     __vki_kernel_pid_t  shm_cpid;   /* pid of creator */
0940     __vki_kernel_pid_t  shm_lpid;   /* pid of last operator */
0941     unsigned long       shm_nattch; /* no. of current attaches */
0942     unsigned long       __unused4;
0943     unsigned long       __unused5;
0944 };
0945 
0946 struct vki_shminfo64 {
0947     unsigned long   shmmax;
0948     unsigned long   shmmin;
0949     unsigned long   shmmni;
0950     unsigned long   shmseg;
0951     unsigned long   shmall;
0952     unsigned long   __unused1;
0953     unsigned long   __unused2;
0954     unsigned long   __unused3;
0955     unsigned long   __unused4;
0956 };
0957 
0958 
0959 //----------------------------------------------------------------------
0960 // The following are defined in the VKI namespace but are nowhere found
0961 // in the linux headers.
0962 //----------------------------------------------------------------------
0963 #define VKI_BIG_ENDIAN      1
0964 #define VKI_MAX_PAGE_SHIFT  VKI_PAGE_SHIFT
0965 #define VKI_MAX_PAGE_SIZE   VKI_PAGE_SIZE
0966 
0967 //----------------------------------------------------------------------
0968 // From linux-2.6.35.4/arch/s390x/include/asm/shmparam.h
0969 //----------------------------------------------------------------------
0970 
0971 #define VKI_SHMLBA  VKI_PAGE_SIZE
0972 
0973 /* If a system call returns a value >= VKI_MAX_ERRNO then that is considered
0974    an error condition. I.e. the system call failed. */
0975 #define VKI_MAX_ERRNO       -125
0976 
0977 //----------------------------------------------------------------------
0978 // From linux-2.6.8.1/include/asm-generic/errno.h
0979 //----------------------------------------------------------------------
0980 
0981 #define VKI_ENOSYS       38  /* Function not implemented */
0982 #define VKI_EOVERFLOW    75  /* Value too large for defined data type */
0983 
0984 //----------------------------------------------------------------------
0985 // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
0986 //----------------------------------------------------------------------
0987 
0988 #define VKI_TIOCGSERIAL     0x541E
0989 #define VKI_TIOCSSERIAL     0x541F
0990 
0991 #endif // __VKI_S390X_LINUX_H
0992 
0993 /*--------------------------------------------------------------------*/
0994 /*--- end                                                          ---*/
0995 /*--------------------------------------------------------------------*/