vki-s390x-linux.h 30 KB

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