Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:35:46

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 #define VKI_O_DIRECT        00040000
0324 
0325 #define VKI_AT_FDCWD            -100
0326 
0327 #define VKI_F_DUPFD 0   /* dup */
0328 #define VKI_F_GETFD 1   /* get close_on_exec */
0329 #define VKI_F_SETFD 2   /* set/clear close_on_exec */
0330 #define VKI_F_GETFL 3   /* get file->f_flags */
0331 #define VKI_F_SETFL 4   /* set file->f_flags */
0332 #define VKI_F_GETLK 5
0333 #define VKI_F_SETLK 6
0334 #define VKI_F_SETLKW    7
0335 #define VKI_F_SETOWN    8   /* for sockets. */
0336 #define VKI_F_GETOWN    9   /* for sockets. */
0337 #define VKI_F_SETSIG    10  /* for sockets. */
0338 #define VKI_F_GETSIG    11  /* for sockets. */
0339 
0340 #define VKI_F_SETOWN_EX     15
0341 #define VKI_F_GETOWN_EX     16
0342 
0343 #define VKI_F_OFD_GETLK     36
0344 #define VKI_F_OFD_SETLK     37
0345 #define VKI_F_OFD_SETLKW    38
0346 
0347 #define VKI_F_OWNER_TID     0
0348 #define VKI_F_OWNER_PID     1
0349 #define VKI_F_OWNER_PGRP    2
0350 
0351 struct vki_f_owner_ex {
0352     int type;
0353     __vki_kernel_pid_t  pid;
0354 };
0355 
0356 #define VKI_FD_CLOEXEC  1  /* actually anything with low bit set goes */
0357 
0358 #define VKI_F_LINUX_SPECIFIC_BASE   1024
0359 
0360 
0361 //----------------------------------------------------------------------
0362 // From linux-2.6.16.60/include/asm-s390x/resource.h
0363 //----------------------------------------------------------------------
0364 
0365 // which just does #include <asm-generic/resource.h>
0366 
0367 #define VKI_RLIMIT_DATA             2       /* max data size */
0368 #define VKI_RLIMIT_STACK            3       /* max stack size */
0369 #define VKI_RLIMIT_CORE             4       /* max core file size */
0370 #define VKI_RLIMIT_NOFILE           7       /* max number of open files */
0371 
0372 
0373 //----------------------------------------------------------------------
0374 // From linux-2.6.16.60/include/asm-s390/socket.h
0375 //----------------------------------------------------------------------
0376 
0377 #define VKI_SOL_SOCKET      1
0378 
0379 #define VKI_SO_TYPE         3
0380 
0381 #define VKI_SO_ATTACH_FILTER        26
0382 
0383 //----------------------------------------------------------------------
0384 // From linux-2.6.16.60/include/asm-s390/sockios.h
0385 //----------------------------------------------------------------------
0386 
0387 #define VKI_SIOCSPGRP       0x8902
0388 #define VKI_SIOCGPGRP       0x8904
0389 #define VKI_SIOCATMARK      0x8905
0390 #define VKI_SIOCGSTAMP      0x8906          /* Get stamp (timeval) */
0391 /* since 2.6.22 */
0392 #define VKI_SIOCGSTAMPNS    0x8907          /* Get stamp (timespec) */
0393 
0394 
0395 //----------------------------------------------------------------------
0396 // From linux-2.6.16.60/include/asm-s390/stat.h
0397 //----------------------------------------------------------------------
0398 
0399 #ifndef VGA_s390x
0400 struct vki_stat {
0401         unsigned short st_dev;
0402         unsigned short __pad1;
0403         unsigned long  st_ino;
0404         unsigned short st_mode;
0405         unsigned short st_nlink;
0406         unsigned short st_uid;
0407         unsigned short st_gid;
0408         unsigned short st_rdev;
0409         unsigned short __pad2;
0410         unsigned long  st_size;
0411         unsigned long  st_blksize;
0412         unsigned long  st_blocks;
0413         unsigned long  st_atime;
0414         unsigned long  st_atime_nsec;
0415         unsigned long  st_mtime;
0416         unsigned long  st_mtime_nsec;
0417         unsigned long  st_ctime;
0418         unsigned long  st_ctime_nsec;
0419         unsigned long  __unused4;
0420         unsigned long  __unused5;
0421 };
0422 
0423 /* This matches struct stat64 in glibc2.1, hence the absolutely
0424  * insane amounts of padding around dev_t's.
0425  */
0426 struct vki_stat64 {
0427         unsigned long long  st_dev;
0428         unsigned int    __pad1;
0429         unsigned long   __st_ino;
0430         unsigned int    st_mode;
0431         unsigned int    st_nlink;
0432         unsigned long   st_uid;
0433         unsigned long   st_gid;
0434         unsigned long long  st_rdev;
0435         unsigned int    __pad3;
0436         long long   st_size;
0437         unsigned long   st_blksize;
0438         unsigned char   __pad4[4];
0439         unsigned long   __pad5;     /* future possible st_blocks high bits */
0440         unsigned long   st_blocks;  /* Number 512-byte blocks allocated. */
0441         unsigned long   st_atime;
0442         unsigned long   st_atime_nsec;
0443         unsigned long   st_mtime;
0444         unsigned long   st_mtime_nsec;
0445         unsigned long   st_ctime;
0446         unsigned long   st_ctime_nsec;  /* will be high 32 bits of ctime someday */
0447         unsigned long long  st_ino;
0448 };
0449 
0450 #else
0451 
0452 struct vki_stat {
0453         unsigned long  st_dev;
0454         unsigned long  st_ino;
0455         unsigned long  st_nlink;
0456         unsigned int   st_mode;
0457         unsigned int   st_uid;
0458         unsigned int   st_gid;
0459         unsigned int   __pad1;
0460         unsigned long  st_rdev;
0461         unsigned long  st_size;
0462         unsigned long  st_atime;
0463     unsigned long  st_atime_nsec;
0464         unsigned long  st_mtime;
0465     unsigned long  st_mtime_nsec;
0466         unsigned long  st_ctime;
0467     unsigned long  st_ctime_nsec;
0468         unsigned long  st_blksize;
0469         long           st_blocks;
0470         unsigned long  __unused0[3];
0471 };
0472 
0473 #endif /* VGA_s390x */
0474 
0475 
0476 //----------------------------------------------------------------------
0477 // From linux-2.6.16.60/include/asm-s390/statfs.h
0478 //----------------------------------------------------------------------
0479 
0480 struct vki_statfs {
0481         int  f_type;
0482         int  f_bsize;
0483         long f_blocks;
0484         long f_bfree;
0485         long f_bavail;
0486         long f_files;
0487         long f_ffree;
0488         __vki_kernel_fsid_t f_fsid;
0489         int  f_namelen;
0490         int  f_frsize;
0491         int  f_spare[5];
0492 };
0493 
0494 
0495 //----------------------------------------------------------------------
0496 // From linux-2.6.16.60/include/asm-s390/termios.h
0497 //----------------------------------------------------------------------
0498 
0499 struct vki_winsize {
0500     unsigned short ws_row;
0501     unsigned short ws_col;
0502     unsigned short ws_xpixel;
0503     unsigned short ws_ypixel;
0504 };
0505 
0506 #define VKI_NCC 8
0507 struct vki_termio {
0508     unsigned short c_iflag;     /* input mode flags */
0509     unsigned short c_oflag;     /* output mode flags */
0510     unsigned short c_cflag;     /* control mode flags */
0511     unsigned short c_lflag;     /* local mode flags */
0512     unsigned char c_line;       /* line discipline */
0513     unsigned char c_cc[VKI_NCC];    /* control characters */
0514 };
0515 
0516 
0517 //----------------------------------------------------------------------
0518 // From linux-2.6.16.60/include/asm-s390/termbits.h
0519 //----------------------------------------------------------------------
0520 
0521 typedef unsigned char   vki_cc_t;
0522 typedef unsigned int    vki_tcflag_t;
0523 
0524 #define VKI_NCCS 19
0525 struct vki_termios {
0526     vki_tcflag_t c_iflag;       /* input mode flags */
0527     vki_tcflag_t c_oflag;       /* output mode flags */
0528     vki_tcflag_t c_cflag;       /* control mode flags */
0529     vki_tcflag_t c_lflag;       /* local mode flags */
0530     vki_cc_t c_line;        /* line discipline */
0531     vki_cc_t c_cc[VKI_NCCS];    /* control characters */
0532 };
0533 
0534 
0535 //----------------------------------------------------------------------
0536 // From linux-2.6.16.60/include/asm-s390/ioctl.h
0537 //----------------------------------------------------------------------
0538 
0539 #define _VKI_IOC_NRBITS     8
0540 #define _VKI_IOC_TYPEBITS   8
0541 #define _VKI_IOC_SIZEBITS   14
0542 #define _VKI_IOC_DIRBITS    2
0543 
0544 #define _VKI_IOC_NRMASK     ((1 << _VKI_IOC_NRBITS)-1)
0545 #define _VKI_IOC_TYPEMASK   ((1 << _VKI_IOC_TYPEBITS)-1)
0546 #define _VKI_IOC_SIZEMASK   ((1 << _VKI_IOC_SIZEBITS)-1)
0547 #define _VKI_IOC_DIRMASK    ((1 << _VKI_IOC_DIRBITS)-1)
0548 
0549 #define _VKI_IOC_NRSHIFT    0
0550 #define _VKI_IOC_TYPESHIFT  (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
0551 #define _VKI_IOC_SIZESHIFT  (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
0552 #define _VKI_IOC_DIRSHIFT   (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
0553 
0554 #define _VKI_IOC_NONE   0U
0555 #define _VKI_IOC_WRITE  1U
0556 #define _VKI_IOC_READ   2U
0557 
0558 #define _VKI_IOC(dir,type,nr,size) \
0559     (((dir)  << _VKI_IOC_DIRSHIFT) | \
0560      ((type) << _VKI_IOC_TYPESHIFT) | \
0561      ((nr)   << _VKI_IOC_NRSHIFT) | \
0562      ((size) << _VKI_IOC_SIZESHIFT))
0563 
0564 /* used to create numbers */
0565 #define _VKI_IO(type,nr)    _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
0566 #define _VKI_IOR(type,nr,size)  _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0567 #define _VKI_IOW(type,nr,size)  _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0568 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
0569 
0570 /* used to decode ioctl numbers.. */
0571 #define _VKI_IOC_DIR(nr)    (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
0572 #define _VKI_IOC_TYPE(nr)   (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
0573 #define _VKI_IOC_NR(nr)     (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
0574 #define _VKI_IOC_SIZE(nr)   (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
0575 
0576 //----------------------------------------------------------------------
0577 // From linux-2.6.16.60/include/asm-s390/ioctls.h
0578 //----------------------------------------------------------------------
0579 
0580 /* 0x54 is just a magic number to make these relatively unique ('T') */
0581 
0582 #define VKI_TCGETS  0x5401
0583 #define VKI_TCSETS  0x5402
0584 #define VKI_TCSETSW 0x5403
0585 #define VKI_TCSETSF 0x5404
0586 #define VKI_TCGETA  0x5405
0587 #define VKI_TCSETA  0x5406
0588 #define VKI_TCSETAW 0x5407
0589 #define VKI_TCSETAF 0x5408
0590 #define VKI_TCSBRK  0x5409
0591 #define VKI_TCXONC  0x540A
0592 #define VKI_TCFLSH  0x540B
0593 
0594 #define VKI_TIOCSCTTY   0x540E
0595 #define VKI_TIOCGPGRP   0x540F
0596 #define VKI_TIOCSPGRP   0x5410
0597 #define VKI_TIOCOUTQ    0x5411
0598 
0599 #define VKI_TIOCGWINSZ  0x5413
0600 #define VKI_TIOCSWINSZ  0x5414
0601 #define VKI_TIOCMGET    0x5415
0602 #define VKI_TIOCMBIS    0x5416
0603 #define VKI_TIOCMBIC    0x5417
0604 #define VKI_TIOCMSET    0x5418
0605 
0606 #define VKI_FIONREAD    0x541B
0607 #define VKI_TIOCLINUX   0x541C
0608 
0609 #define VKI_FIONBIO 0x5421
0610 #define VKI_TIOCNOTTY   0x5422
0611 
0612 #define VKI_TCSBRKP 0x5425  /* Needed for POSIX tcsendbreak() */
0613 
0614 #define VKI_TIOCGPTN    _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
0615 #define VKI_TIOCSPTLCK  _VKI_IOW('T',0x31, int)  /* Lock/unlock Pty */
0616 
0617 #define VKI_FIONCLEX    0x5450
0618 #define VKI_FIOCLEX 0x5451
0619 #define VKI_FIOASYNC    0x5452
0620 
0621 #define VKI_TIOCSERGETLSR       0x5459 /* Get line status register */
0622 
0623 #define VKI_TIOCGICOUNT 0x545D  /* read serial port inline interrupt counts */
0624 
0625 //----------------------------------------------------------------------
0626 // From linux-2.6.39-rc2/arch/s390/include/asm/ioctls.h
0627 //----------------------------------------------------------------------
0628 
0629 #define VKI_FIOQSIZE 0x545E
0630 
0631 //----------------------------------------------------------------------
0632 // From linux-2.6.16.60/include/asm-s390/poll.h
0633 //----------------------------------------------------------------------
0634 
0635 struct vki_pollfd {
0636     int fd;
0637     short events;
0638     short revents;
0639 };
0640 
0641 #define VKI_POLLIN          0x0001
0642 
0643 //----------------------------------------------------------------------
0644 // From linux-2.6.16.60/include/asm-s390/ptrace.h
0645 //----------------------------------------------------------------------
0646 #define VKI_NUM_GPRS    16
0647 #define VKI_NUM_FPRS    16
0648 #define VKI_NUM_CRS 16
0649 #define VKI_NUM_ACRS    16
0650 
0651 typedef union
0652 {
0653     float   f;
0654     double  d;
0655         __vki_u64   ui;
0656     struct
0657     {
0658         __vki_u32 hi;
0659         __vki_u32 lo;
0660     } fp;
0661 } vki_freg_t;
0662 
0663 typedef struct
0664 {
0665     __vki_u32   fpc;
0666     vki_freg_t  fprs[VKI_NUM_FPRS];
0667 } vki_s390_fp_regs;
0668 
0669 typedef struct
0670 {
0671         unsigned long mask;
0672         unsigned long addr;
0673 } __attribute__ ((aligned(8))) vki_psw_t;
0674 
0675 typedef struct
0676 {
0677     vki_psw_t psw;
0678     unsigned long gprs[VKI_NUM_GPRS];
0679     unsigned int  acrs[VKI_NUM_ACRS];
0680     unsigned long orig_gpr2;
0681 } vki_s390_regs;
0682 
0683 /*
0684  * Now for the program event recording (trace) definitions.
0685  */
0686 typedef struct
0687 {
0688     unsigned long cr[3];
0689 } vki_per_cr_words;
0690 
0691 typedef struct
0692 {
0693 #ifdef VGA_s390x
0694     unsigned                       : 32;
0695 #endif /* VGA_s390x */
0696     unsigned em_branching          : 1;
0697     unsigned em_instruction_fetch  : 1;
0698     /*
0699      * Switching on storage alteration automatically fixes
0700      * the storage alteration event bit in the users std.
0701      */
0702     unsigned em_storage_alteration : 1;
0703     unsigned em_gpr_alt_unused     : 1;
0704     unsigned em_store_real_address : 1;
0705     unsigned                       : 3;
0706     unsigned branch_addr_ctl       : 1;
0707     unsigned                       : 1;
0708     unsigned storage_alt_space_ctl : 1;
0709     unsigned                       : 21;
0710     unsigned long starting_addr;
0711     unsigned long ending_addr;
0712 } vki_per_cr_bits;
0713 
0714 typedef struct
0715 {
0716     unsigned short perc_atmid;
0717     unsigned long address;
0718     unsigned char access_id;
0719 } vki_per_lowcore_words;
0720 
0721 typedef struct
0722 {
0723     unsigned perc_branching          : 1;
0724     unsigned perc_instruction_fetch  : 1;
0725     unsigned perc_storage_alteration : 1;
0726     unsigned perc_gpr_alt_unused     : 1;
0727     unsigned perc_store_real_address : 1;
0728     unsigned                         : 3;
0729     unsigned atmid_psw_bit_31        : 1;
0730     unsigned atmid_validity_bit      : 1;
0731     unsigned atmid_psw_bit_32        : 1;
0732     unsigned atmid_psw_bit_5         : 1;
0733     unsigned atmid_psw_bit_16        : 1;
0734     unsigned atmid_psw_bit_17        : 1;
0735     unsigned si                      : 2;
0736     unsigned long address;
0737     unsigned                         : 4;
0738     unsigned access_id               : 4;
0739 } vki_per_lowcore_bits;
0740 
0741 typedef struct
0742 {
0743     union {
0744         vki_per_cr_words   words;
0745         vki_per_cr_bits    bits;
0746     } control_regs;
0747     /*
0748      * Use these flags instead of setting em_instruction_fetch
0749      * directly they are used so that single stepping can be
0750      * switched on & off while not affecting other tracing
0751      */
0752     unsigned  single_step       : 1;
0753     unsigned  instruction_fetch : 1;
0754     unsigned                    : 30;
0755     /*
0756      * These addresses are copied into cr10 & cr11 if single
0757      * stepping is switched off
0758      */
0759     unsigned long starting_addr;
0760     unsigned long ending_addr;
0761     union {
0762         vki_per_lowcore_words words;
0763         vki_per_lowcore_bits  bits;
0764     } lowcore;
0765 } vki_per_struct;
0766 
0767 /*
0768  * The user_regs_struct defines the way the user registers are
0769  * store on the stack for signal handling.
0770  */
0771 struct vki_user_regs_struct
0772 {
0773     vki_psw_t psw;
0774     unsigned long gprs[VKI_NUM_GPRS];
0775     unsigned int  acrs[VKI_NUM_ACRS];
0776     unsigned long orig_gpr2;
0777     vki_s390_fp_regs fp_regs;
0778     /*
0779      * These per registers are in here so that gdb can modify them
0780      * itself as there is no "official" ptrace interface for hardware
0781      * watchpoints. This is the way intel does it.
0782      */
0783     vki_per_struct per_info;
0784     unsigned long ieee_instruction_pointer;
0785     /* Used to give failing instruction back to user for ieee exceptions */
0786 };
0787 
0788 typedef struct
0789 {
0790     unsigned int  vki_len;
0791     unsigned long vki_kernel_addr;
0792     unsigned long vki_process_addr;
0793 } vki_ptrace_area;
0794 
0795 /*
0796  * S/390 specific non posix ptrace requests
0797  */
0798 #define VKI_PTRACE_PEEKUSR_AREA       0x5000
0799 #define VKI_PTRACE_POKEUSR_AREA       0x5001
0800 
0801 //----------------------------------------------------------------------
0802 // From linux-3.18/include/asm-s390/elf.h
0803 //----------------------------------------------------------------------
0804 
0805 typedef vki_s390_fp_regs vki_elf_fpregset_t;
0806 typedef vki_s390_regs vki_elf_gregset_t;
0807 
0808 #define VKI_HWCAP_S390_TE           1024
0809 #define VKI_HWCAP_S390_VXRS         2048
0810 #define VKI_HWCAP_S390_VXRS_EXT     8192
0811 #define VKI_HWCAP_S390_VXRS_EXT2   32768
0812 #define VKI_HWCAP_S390_DFLT       (1<<18)
0813 #define VKI_HWCAP_S390_NNPA       (1<<20)
0814 
0815 
0816 //----------------------------------------------------------------------
0817 // From linux-2.6.16.60/include/asm-s390/ucontext.h
0818 //----------------------------------------------------------------------
0819 
0820 struct vki_ucontext {
0821     unsigned long         uc_flags;
0822     struct vki_ucontext  *uc_link;
0823     vki_stack_t       uc_stack;
0824     _vki_sigregs          uc_mcontext;
0825     vki_sigset_t          uc_sigmask; /* mask last for extensibility */
0826 };
0827 
0828 typedef char vki_modify_ldt_t;
0829 
0830 //----------------------------------------------------------------------
0831 // From linux-2.6.16.60/include/asm-s390/ipcbuf.h
0832 //----------------------------------------------------------------------
0833 
0834 struct vki_ipc64_perm
0835 {
0836     __vki_kernel_key_t  key;
0837     __vki_kernel_uid32_t    uid;
0838     __vki_kernel_gid32_t    gid;
0839     __vki_kernel_uid32_t    cuid;
0840     __vki_kernel_gid32_t    cgid;
0841     __vki_kernel_mode_t mode;
0842     unsigned short      __pad1;
0843     unsigned short      seq;
0844 #ifndef VGA_s390x
0845     unsigned short      __pad2;
0846 #endif /* ! VGA_s390x */
0847     unsigned long       __unused1;
0848     unsigned long       __unused2;
0849 };
0850 
0851 
0852 //----------------------------------------------------------------------
0853 // From linux-2.6.16.60/include/asm-s390/sembuf.h
0854 //----------------------------------------------------------------------
0855 
0856 struct vki_semid64_ds {
0857     struct vki_ipc64_perm sem_perm;     /* permissions .. see ipc.h */
0858     __vki_kernel_time_t   sem_otime;    /* last semop time */
0859 #ifndef VGA_s390x
0860     unsigned long   __unused1;
0861 #endif /* ! VGA_s390x */
0862     __vki_kernel_time_t   sem_ctime;    /* last change time */
0863 #ifndef VGA_s390x
0864     unsigned long   __unused2;
0865 #endif /* ! VGA_s390x */
0866     unsigned long   sem_nsems;      /* no. of semaphores in array */
0867     unsigned long   __unused3;
0868     unsigned long   __unused4;
0869 };
0870 
0871 
0872 //----------------------------------------------------------------------
0873 // From linux-2.6.16.60/include/asm-s390/msgbuf.h
0874 //----------------------------------------------------------------------
0875 
0876 struct vki_msqid64_ds {
0877     struct vki_ipc64_perm msg_perm;
0878     __vki_kernel_time_t msg_stime;  /* last msgsnd time */
0879 #ifndef VGA_s390x
0880     unsigned long   __unused1;
0881 #endif /* ! VGA_s390x */
0882     __vki_kernel_time_t msg_rtime;  /* last msgrcv time */
0883 #ifndef VGA_s390x
0884     unsigned long   __unused2;
0885 #endif /* ! VGA_s390x */
0886     __vki_kernel_time_t msg_ctime;  /* last change time */
0887 #ifndef VGA_s390x
0888     unsigned long   __unused3;
0889 #endif /* ! VGA_s390x */
0890     unsigned long  msg_cbytes;  /* current number of bytes on queue */
0891     unsigned long  msg_qnum;    /* number of messages in queue */
0892     unsigned long  msg_qbytes;  /* max number of bytes on queue */
0893     __vki_kernel_pid_t msg_lspid;   /* pid of last msgsnd */
0894     __vki_kernel_pid_t msg_lrpid;   /* last receive pid */
0895     unsigned long  __unused4;
0896     unsigned long  __unused5;
0897 };
0898 
0899 
0900 //----------------------------------------------------------------------
0901 // From linux-2.6.16.60/include/asm-s390/ipc.h
0902 //----------------------------------------------------------------------
0903 
0904 struct vki_ipc_kludge {
0905     struct vki_msgbuf __user *msgp;
0906     long msgtyp;
0907 };
0908 
0909 #define VKI_SEMOP    1
0910 #define VKI_SEMGET   2
0911 #define VKI_SEMCTL   3
0912 #define VKI_SEMTIMEDOP   4
0913 #define VKI_MSGSND  11
0914 #define VKI_MSGRCV  12
0915 #define VKI_MSGGET  13
0916 #define VKI_MSGCTL  14
0917 #define VKI_SHMAT   21
0918 #define VKI_SHMDT   22
0919 #define VKI_SHMGET  23
0920 #define VKI_SHMCTL  24
0921 
0922 
0923 //----------------------------------------------------------------------
0924 // From linux-2.6.16.60/include/asm-s390/shmbuf.h
0925 //----------------------------------------------------------------------
0926 
0927 struct vki_shmid64_ds {
0928     struct vki_ipc64_perm   shm_perm;   /* operation perms */
0929     vki_size_t      shm_segsz;  /* size of segment (bytes) */
0930     __vki_kernel_time_t shm_atime;  /* last attach time */
0931 #ifndef VGA_s390x
0932     unsigned long       __unused1;
0933 #endif /* ! VGA_s390x */
0934     __vki_kernel_time_t shm_dtime;  /* last detach time */
0935 #ifndef VGA_s390x
0936     unsigned long       __unused2;
0937 #endif /* ! VGA_s390x */
0938     __vki_kernel_time_t shm_ctime;  /* last change time */
0939 #ifndef VGA_s390x
0940     unsigned long       __unused3;
0941 #endif /* ! VGA_s390x */
0942     __vki_kernel_pid_t  shm_cpid;   /* pid of creator */
0943     __vki_kernel_pid_t  shm_lpid;   /* pid of last operator */
0944     unsigned long       shm_nattch; /* no. of current attaches */
0945     unsigned long       __unused4;
0946     unsigned long       __unused5;
0947 };
0948 
0949 struct vki_shminfo64 {
0950     unsigned long   shmmax;
0951     unsigned long   shmmin;
0952     unsigned long   shmmni;
0953     unsigned long   shmseg;
0954     unsigned long   shmall;
0955     unsigned long   __unused1;
0956     unsigned long   __unused2;
0957     unsigned long   __unused3;
0958     unsigned long   __unused4;
0959 };
0960 
0961 
0962 //----------------------------------------------------------------------
0963 // The following are defined in the VKI namespace but are nowhere found
0964 // in the linux headers.
0965 //----------------------------------------------------------------------
0966 #define VKI_BIG_ENDIAN      1
0967 #define VKI_MAX_PAGE_SHIFT  VKI_PAGE_SHIFT
0968 #define VKI_MAX_PAGE_SIZE   VKI_PAGE_SIZE
0969 
0970 //----------------------------------------------------------------------
0971 // From linux-2.6.35.4/arch/s390x/include/asm/shmparam.h
0972 //----------------------------------------------------------------------
0973 
0974 #define VKI_SHMLBA  VKI_PAGE_SIZE
0975 
0976 /* If a system call returns a value >= VKI_MAX_ERRNO then that is considered
0977    an error condition. I.e. the system call failed. */
0978 #define VKI_MAX_ERRNO       -125
0979 
0980 //----------------------------------------------------------------------
0981 // From linux-2.6.8.1/include/asm-generic/errno.h
0982 //----------------------------------------------------------------------
0983 
0984 #define VKI_ENOSYS       38  /* Function not implemented */
0985 #define VKI_EOVERFLOW    75  /* Value too large for defined data type */
0986 
0987 //----------------------------------------------------------------------
0988 // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
0989 //----------------------------------------------------------------------
0990 
0991 #define VKI_TIOCGSERIAL     0x541E
0992 #define VKI_TIOCSSERIAL     0x541F
0993 
0994 #endif // __VKI_S390X_LINUX_H
0995 
0996 /*--------------------------------------------------------------------*/
0997 /*--- end                                                          ---*/
0998 /*--------------------------------------------------------------------*/