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