vki-x86-linux.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. /*--------------------------------------------------------------------*/
  2. /*--- x86/Linux-specific kernel interface. vki-x86-linux.h ---*/
  3. /*--------------------------------------------------------------------*/
  4. /*
  5. This file is part of Valgrind, a dynamic binary instrumentation
  6. framework.
  7. Copyright (C) 2000-2017 Julian Seward
  8. jseward@acm.org
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License as
  11. published by the Free Software Foundation; either version 2 of the
  12. License, or (at your option) any later version.
  13. This program is distributed in the hope that it will be useful, but
  14. WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  20. 02111-1307, USA.
  21. The GNU General Public License is contained in the file COPYING.
  22. */
  23. #ifndef __VKI_X86_LINUX_H
  24. #define __VKI_X86_LINUX_H
  25. // x86 is little-endian.
  26. #define VKI_LITTLE_ENDIAN 1
  27. //----------------------------------------------------------------------
  28. // From linux-2.6.8.1/include/asm-i386/types.h
  29. //----------------------------------------------------------------------
  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 long __vki_s64;
  36. typedef unsigned long long __vki_u64;
  37. typedef unsigned short vki_u16;
  38. typedef unsigned int vki_u32;
  39. //----------------------------------------------------------------------
  40. // From linux-2.6.8.1/include/asm-i386/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. #define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
  46. #define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
  47. //----------------------------------------------------------------------
  48. // From linux-2.6.35.4/arch/x86/include/asm/shmparam.h
  49. //----------------------------------------------------------------------
  50. #define VKI_SHMLBA VKI_PAGE_SIZE
  51. //----------------------------------------------------------------------
  52. // From linux-2.6.8.1/include/asm-i386/signal.h
  53. //----------------------------------------------------------------------
  54. #define VKI_MINSIGSTKSZ 2048
  55. #define VKI_SIG_BLOCK 0 /* for blocking signals */
  56. #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */
  57. #define VKI_SIG_SETMASK 2 /* for setting the signal mask */
  58. /* Type of a signal handler. */
  59. typedef void __vki_signalfn_t(int);
  60. typedef __vki_signalfn_t __user *__vki_sighandler_t;
  61. typedef void __vki_restorefn_t(void);
  62. typedef __vki_restorefn_t __user *__vki_sigrestore_t;
  63. #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */
  64. #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */
  65. #define _VKI_NSIG 64
  66. #define _VKI_NSIG_BPW 32
  67. #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
  68. typedef unsigned long vki_old_sigset_t; /* at least 32 bits */
  69. typedef struct {
  70. unsigned long sig[_VKI_NSIG_WORDS];
  71. } vki_sigset_t;
  72. #define VKI_SIGHUP 1
  73. #define VKI_SIGINT 2
  74. #define VKI_SIGQUIT 3
  75. #define VKI_SIGILL 4
  76. #define VKI_SIGTRAP 5
  77. #define VKI_SIGABRT 6
  78. //#define VKI_SIGIOT 6
  79. #define VKI_SIGBUS 7
  80. #define VKI_SIGFPE 8
  81. #define VKI_SIGKILL 9
  82. #define VKI_SIGUSR1 10
  83. #define VKI_SIGSEGV 11
  84. #define VKI_SIGUSR2 12
  85. #define VKI_SIGPIPE 13
  86. #define VKI_SIGALRM 14
  87. #define VKI_SIGTERM 15
  88. #define VKI_SIGSTKFLT 16
  89. #define VKI_SIGCHLD 17
  90. #define VKI_SIGCONT 18
  91. #define VKI_SIGSTOP 19
  92. #define VKI_SIGTSTP 20
  93. #define VKI_SIGTTIN 21
  94. #define VKI_SIGTTOU 22
  95. #define VKI_SIGURG 23
  96. #define VKI_SIGXCPU 24
  97. #define VKI_SIGXFSZ 25
  98. #define VKI_SIGVTALRM 26
  99. #define VKI_SIGPROF 27
  100. #define VKI_SIGWINCH 28
  101. #define VKI_SIGIO 29
  102. #define VKI_SIGPWR 30
  103. #define VKI_SIGSYS 31
  104. #define VKI_SIGUNUSED 31
  105. /* These should not be considered constants from userland. */
  106. #define VKI_SIGRTMIN 32
  107. // [[This was (_NSIG-1) in 2.4.X... not sure if it matters.]]
  108. #define VKI_SIGRTMAX _VKI_NSIG
  109. #define VKI_SA_NOCLDSTOP 0x00000001u
  110. #define VKI_SA_NOCLDWAIT 0x00000002u
  111. #define VKI_SA_SIGINFO 0x00000004u
  112. #define VKI_SA_ONSTACK 0x08000000u
  113. #define VKI_SA_RESTART 0x10000000u
  114. #define VKI_SA_NODEFER 0x40000000u
  115. #define VKI_SA_RESETHAND 0x80000000u
  116. #define VKI_SA_NOMASK VKI_SA_NODEFER
  117. #define VKI_SA_ONESHOT VKI_SA_RESETHAND
  118. //#define VKI_SA_INTERRUPT 0x20000000 /* dummy -- ignored */
  119. #define VKI_SA_RESTORER 0x04000000
  120. #define VKI_SS_ONSTACK 1
  121. #define VKI_SS_DISABLE 2
  122. /* These are 'legacy' sigactions in which the size of sa_mask is fixed
  123. (cannot be expanded at any future point) because it is sandwiched
  124. between two other fields.
  125. (there is identical kludgery in vki-ppc32-linux.h) */
  126. struct vki_old_sigaction {
  127. // [[Nb: a 'k' prefix is added to "sa_handler" because
  128. // bits/sigaction.h (which gets dragged in somehow via signal.h)
  129. // #defines it as something else. Since that is done for glibc's
  130. // purposes, which we don't care about here, we use our own name.]]
  131. __vki_sighandler_t ksa_handler;
  132. vki_old_sigset_t sa_mask;
  133. unsigned long sa_flags;
  134. __vki_sigrestore_t sa_restorer;
  135. };
  136. struct vki_sigaction_base {
  137. // [[See comment about extra 'k' above]]
  138. __vki_sighandler_t ksa_handler;
  139. unsigned long sa_flags;
  140. __vki_sigrestore_t sa_restorer;
  141. vki_sigset_t sa_mask; /* mask last for extensibility */
  142. };
  143. /* On Linux we use the same type for passing sigactions to
  144. and from the kernel. Hence: */
  145. typedef struct vki_sigaction_base vki_sigaction_toK_t;
  146. typedef struct vki_sigaction_base vki_sigaction_fromK_t;
  147. typedef struct vki_sigaltstack {
  148. void __user *ss_sp;
  149. int ss_flags;
  150. vki_size_t ss_size;
  151. } vki_stack_t;
  152. //----------------------------------------------------------------------
  153. // From linux-2.6.8.1/include/asm-i386/sigcontext.h
  154. //----------------------------------------------------------------------
  155. struct _vki_fpreg {
  156. unsigned short significand[4];
  157. unsigned short exponent;
  158. };
  159. struct _vki_fpxreg {
  160. unsigned short significand[4];
  161. unsigned short exponent;
  162. unsigned short padding[3];
  163. };
  164. struct _vki_xmmreg {
  165. unsigned long element[4];
  166. };
  167. struct _vki_fpstate {
  168. /* Regular FPU environment */
  169. unsigned long cw;
  170. unsigned long sw;
  171. unsigned long tag;
  172. unsigned long ipoff;
  173. unsigned long cssel;
  174. unsigned long dataoff;
  175. unsigned long datasel;
  176. struct _vki_fpreg _st[8];
  177. unsigned short status;
  178. unsigned short magic; /* 0xffff = regular FPU data only */
  179. /* FXSR FPU environment */
  180. unsigned long _fxsr_env[6]; /* FXSR FPU env is ignored */
  181. unsigned long mxcsr;
  182. unsigned long reserved;
  183. struct _vki_fpxreg _fxsr_st[8]; /* FXSR FPU reg data is ignored */
  184. struct _vki_xmmreg _xmm[8];
  185. unsigned long padding[56];
  186. };
  187. struct vki_sigcontext {
  188. unsigned short gs, __gsh;
  189. unsigned short fs, __fsh;
  190. unsigned short es, __esh;
  191. unsigned short ds, __dsh;
  192. unsigned long edi;
  193. unsigned long esi;
  194. unsigned long ebp;
  195. unsigned long esp;
  196. unsigned long ebx;
  197. unsigned long edx;
  198. unsigned long ecx;
  199. unsigned long eax;
  200. unsigned long trapno;
  201. unsigned long err;
  202. unsigned long eip;
  203. unsigned short cs, __csh;
  204. unsigned long eflags;
  205. unsigned long esp_at_signal;
  206. unsigned short ss, __ssh;
  207. struct _vki_fpstate __user * fpstate;
  208. unsigned long oldmask;
  209. unsigned long cr2;
  210. };
  211. //----------------------------------------------------------------------
  212. // From linux-2.6.8.1/include/asm-i386/mman.h
  213. //----------------------------------------------------------------------
  214. #define VKI_PROT_NONE 0x0 /* No page permissions */
  215. #define VKI_PROT_READ 0x1 /* page can be read */
  216. #define VKI_PROT_WRITE 0x2 /* page can be written */
  217. #define VKI_PROT_EXEC 0x4 /* page can be executed */
  218. #define VKI_PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
  219. #define VKI_PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
  220. #define VKI_MAP_SHARED 0x01 /* Share changes */
  221. #define VKI_MAP_PRIVATE 0x02 /* Changes are private */
  222. //#define VKI_MAP_TYPE 0x0f /* Mask for type of mapping */
  223. #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
  224. #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */
  225. #define VKI_MAP_NORESERVE 0x4000 /* don't check for reservations */
  226. //----------------------------------------------------------------------
  227. // From linux-2.6.8.1/include/asm-i386/fcntl.h
  228. //----------------------------------------------------------------------
  229. #define VKI_O_ACCMODE 03
  230. #define VKI_O_RDONLY 00
  231. #define VKI_O_WRONLY 01
  232. #define VKI_O_RDWR 02
  233. #define VKI_O_CREAT 0100 /* not fcntl */
  234. #define VKI_O_EXCL 0200 /* not fcntl */
  235. #define VKI_O_TRUNC 01000 /* not fcntl */
  236. #define VKI_O_APPEND 02000
  237. #define VKI_O_NONBLOCK 04000
  238. #define VKI_O_LARGEFILE 0100000
  239. #define VKI_AT_FDCWD -100
  240. #define VKI_F_DUPFD 0 /* dup */
  241. #define VKI_F_GETFD 1 /* get close_on_exec */
  242. #define VKI_F_SETFD 2 /* set/clear close_on_exec */
  243. #define VKI_F_GETFL 3 /* get file->f_flags */
  244. #define VKI_F_SETFL 4 /* set file->f_flags */
  245. #define VKI_F_GETLK 5
  246. #define VKI_F_SETLK 6
  247. #define VKI_F_SETLKW 7
  248. #define VKI_F_SETOWN 8 /* for sockets. */
  249. #define VKI_F_GETOWN 9 /* for sockets. */
  250. #define VKI_F_SETSIG 10 /* for sockets. */
  251. #define VKI_F_GETSIG 11 /* for sockets. */
  252. #define VKI_F_GETLK64 12 /* using 'struct flock64' */
  253. #define VKI_F_SETLK64 13
  254. #define VKI_F_SETLKW64 14
  255. #define VKI_F_SETOWN_EX 15
  256. #define VKI_F_GETOWN_EX 16
  257. #define VKI_F_OFD_GETLK 36
  258. #define VKI_F_OFD_SETLK 37
  259. #define VKI_F_OFD_SETLKW 38
  260. #define VKI_F_OWNER_TID 0
  261. #define VKI_F_OWNER_PID 1
  262. #define VKI_F_OWNER_PGRP 2
  263. struct vki_f_owner_ex {
  264. int type;
  265. __vki_kernel_pid_t pid;
  266. };
  267. /* for F_[GET|SET]FL */
  268. #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */
  269. #define VKI_F_LINUX_SPECIFIC_BASE 1024
  270. //----------------------------------------------------------------------
  271. // From linux-2.6.8.1/include/asm-i386/resource.h
  272. //----------------------------------------------------------------------
  273. #define VKI_RLIMIT_DATA 2 /* max data size */
  274. #define VKI_RLIMIT_STACK 3 /* max stack size */
  275. #define VKI_RLIMIT_CORE 4 /* max core file size */
  276. #define VKI_RLIMIT_NOFILE 7 /* max number of open files */
  277. //----------------------------------------------------------------------
  278. // From linux-2.6.8.1/include/asm-i386/socket.h
  279. //----------------------------------------------------------------------
  280. #define VKI_SOL_SOCKET 1
  281. #define VKI_SO_TYPE 3
  282. #define VKI_SO_ATTACH_FILTER 26
  283. //----------------------------------------------------------------------
  284. // From linux-2.6.8.1/include/asm-i386/sockios.h
  285. //----------------------------------------------------------------------
  286. #define VKI_SIOCSPGRP 0x8902
  287. #define VKI_SIOCGPGRP 0x8904
  288. #define VKI_SIOCATMARK 0x8905
  289. #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
  290. #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
  291. //----------------------------------------------------------------------
  292. // From linux-2.6.8.1/include/asm-i386/stat.h
  293. //----------------------------------------------------------------------
  294. struct vki_stat {
  295. unsigned long st_dev;
  296. unsigned long st_ino;
  297. unsigned short st_mode;
  298. unsigned short st_nlink;
  299. unsigned short st_uid;
  300. unsigned short st_gid;
  301. unsigned long st_rdev;
  302. unsigned long st_size;
  303. unsigned long st_blksize;
  304. unsigned long st_blocks;
  305. unsigned long st_atime;
  306. unsigned long st_atime_nsec;
  307. unsigned long st_mtime;
  308. unsigned long st_mtime_nsec;
  309. unsigned long st_ctime;
  310. unsigned long st_ctime_nsec;
  311. unsigned long __unused4;
  312. unsigned long __unused5;
  313. };
  314. struct vki_stat64 {
  315. unsigned long long st_dev;
  316. unsigned char __pad0[4];
  317. #define STAT64_HAS_BROKEN_ST_INO 1
  318. unsigned long __st_ino;
  319. unsigned int st_mode;
  320. unsigned int st_nlink;
  321. unsigned long st_uid;
  322. unsigned long st_gid;
  323. unsigned long long st_rdev;
  324. unsigned char __pad3[4];
  325. long long st_size;
  326. unsigned long st_blksize;
  327. unsigned long st_blocks; /* Number 512-byte blocks allocated. */
  328. unsigned long __pad4; /* future possible st_blocks high bits */
  329. unsigned long st_atime;
  330. unsigned long st_atime_nsec;
  331. unsigned long st_mtime;
  332. unsigned int st_mtime_nsec;
  333. unsigned long st_ctime;
  334. unsigned long st_ctime_nsec;
  335. unsigned long long st_ino;
  336. };
  337. //----------------------------------------------------------------------
  338. // From linux-2.6.8.1/include/asm-i386/statfs.h
  339. //----------------------------------------------------------------------
  340. // [[Nb: asm-i386/statfs.h just #include asm-generic/statfs.h directly]]
  341. struct vki_statfs {
  342. __vki_u32 f_type;
  343. __vki_u32 f_bsize;
  344. __vki_u32 f_blocks;
  345. __vki_u32 f_bfree;
  346. __vki_u32 f_bavail;
  347. __vki_u32 f_files;
  348. __vki_u32 f_ffree;
  349. __vki_kernel_fsid_t f_fsid;
  350. __vki_u32 f_namelen;
  351. __vki_u32 f_frsize;
  352. __vki_u32 f_spare[5];
  353. };
  354. //----------------------------------------------------------------------
  355. // From linux-2.6.8.1/include/asm-i386/termios.h
  356. //----------------------------------------------------------------------
  357. struct vki_winsize {
  358. unsigned short ws_row;
  359. unsigned short ws_col;
  360. unsigned short ws_xpixel;
  361. unsigned short ws_ypixel;
  362. };
  363. #define VKI_NCC 8
  364. struct vki_termio {
  365. unsigned short c_iflag; /* input mode flags */
  366. unsigned short c_oflag; /* output mode flags */
  367. unsigned short c_cflag; /* control mode flags */
  368. unsigned short c_lflag; /* local mode flags */
  369. unsigned char c_line; /* line discipline */
  370. unsigned char c_cc[VKI_NCC]; /* control characters */
  371. };
  372. //----------------------------------------------------------------------
  373. // From linux-2.6.8.1/include/asm-i386/termbits.h
  374. //----------------------------------------------------------------------
  375. typedef unsigned char vki_cc_t;
  376. typedef unsigned int vki_tcflag_t;
  377. #define VKI_NCCS 19
  378. struct vki_termios {
  379. vki_tcflag_t c_iflag; /* input mode flags */
  380. vki_tcflag_t c_oflag; /* output mode flags */
  381. vki_tcflag_t c_cflag; /* control mode flags */
  382. vki_tcflag_t c_lflag; /* local mode flags */
  383. vki_cc_t c_line; /* line discipline */
  384. vki_cc_t c_cc[VKI_NCCS]; /* control characters */
  385. };
  386. //----------------------------------------------------------------------
  387. // From linux-2.6.8.1/include/asm-i386/ioctl.h
  388. //----------------------------------------------------------------------
  389. #define _VKI_IOC_NRBITS 8
  390. #define _VKI_IOC_TYPEBITS 8
  391. #define _VKI_IOC_SIZEBITS 14
  392. #define _VKI_IOC_DIRBITS 2
  393. #define _VKI_IOC_NRMASK ((1 << _VKI_IOC_NRBITS)-1)
  394. #define _VKI_IOC_TYPEMASK ((1 << _VKI_IOC_TYPEBITS)-1)
  395. #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1)
  396. #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1)
  397. #define _VKI_IOC_NRSHIFT 0
  398. #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
  399. #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
  400. #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
  401. #define _VKI_IOC_NONE 0U
  402. #define _VKI_IOC_WRITE 1U
  403. #define _VKI_IOC_READ 2U
  404. #define _VKI_IOC(dir,type,nr,size) \
  405. (((dir) << _VKI_IOC_DIRSHIFT) | \
  406. ((type) << _VKI_IOC_TYPESHIFT) | \
  407. ((nr) << _VKI_IOC_NRSHIFT) | \
  408. ((size) << _VKI_IOC_SIZESHIFT))
  409. /* used to create numbers */
  410. #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
  411. #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
  412. #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
  413. #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
  414. /* used to decode ioctl numbers.. */
  415. #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
  416. #define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
  417. #define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
  418. #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
  419. //----------------------------------------------------------------------
  420. // From linux-2.6.8.1/include/asm-i386/ioctls.h
  421. //----------------------------------------------------------------------
  422. #define VKI_TCGETS 0x5401
  423. #define VKI_TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
  424. #define VKI_TCSETSW 0x5403
  425. #define VKI_TCSETSF 0x5404
  426. #define VKI_TCGETA 0x5405
  427. #define VKI_TCSETA 0x5406
  428. #define VKI_TCSETAW 0x5407
  429. #define VKI_TCSETAF 0x5408
  430. #define VKI_TCSBRK 0x5409
  431. #define VKI_TCXONC 0x540A
  432. #define VKI_TCFLSH 0x540B
  433. #define VKI_TIOCSCTTY 0x540E
  434. #define VKI_TIOCGPGRP 0x540F
  435. #define VKI_TIOCSPGRP 0x5410
  436. #define VKI_TIOCOUTQ 0x5411
  437. #define VKI_TIOCGWINSZ 0x5413
  438. #define VKI_TIOCSWINSZ 0x5414
  439. #define VKI_TIOCMGET 0x5415
  440. #define VKI_TIOCMBIS 0x5416
  441. #define VKI_TIOCMBIC 0x5417
  442. #define VKI_TIOCMSET 0x5418
  443. #define VKI_FIONREAD 0x541B
  444. #define VKI_TIOCLINUX 0x541C
  445. #define VKI_FIONBIO 0x5421
  446. #define VKI_TIOCNOTTY 0x5422
  447. #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
  448. #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
  449. #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */
  450. #define VKI_FIONCLEX 0x5450
  451. #define VKI_FIOCLEX 0x5451
  452. #define VKI_FIOASYNC 0x5452
  453. #define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */
  454. #define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
  455. //----------------------------------------------------------------------
  456. // From linux-2.6.8.1/include/asm-i386/poll.h
  457. //----------------------------------------------------------------------
  458. /* These are specified by iBCS2 */
  459. #define VKI_POLLIN 0x0001
  460. struct vki_pollfd {
  461. int fd;
  462. short events;
  463. short revents;
  464. };
  465. //----------------------------------------------------------------------
  466. // From linux-2.6.8.1/include/asm-i386/user.h
  467. //----------------------------------------------------------------------
  468. struct vki_user_i387_struct {
  469. long cwd;
  470. long swd;
  471. long twd;
  472. long fip;
  473. long fcs;
  474. long foo;
  475. long fos;
  476. long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
  477. };
  478. struct vki_user_fxsr_struct {
  479. unsigned short cwd;
  480. unsigned short swd;
  481. unsigned short twd;
  482. unsigned short fop;
  483. long fip;
  484. long fcs;
  485. long foo;
  486. long fos;
  487. long mxcsr;
  488. long reserved;
  489. long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
  490. long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
  491. long padding[56];
  492. };
  493. /*
  494. * This is the old layout of "struct pt_regs", and
  495. * is still the layout used by user mode (the new
  496. * pt_regs doesn't have all registers as the kernel
  497. * doesn't use the extra segment registers)
  498. */
  499. struct vki_user_regs_struct {
  500. long ebx, ecx, edx, esi, edi, ebp, eax;
  501. unsigned short ds, __ds, es, __es;
  502. unsigned short fs, __fs, gs, __gs;
  503. long orig_eax, eip;
  504. unsigned short cs, __cs;
  505. long eflags, esp;
  506. unsigned short ss, __ss;
  507. };
  508. //----------------------------------------------------------------------
  509. // From linux-2.6.8.1/include/asm-i386/elf.h
  510. //----------------------------------------------------------------------
  511. typedef unsigned long vki_elf_greg_t;
  512. #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
  513. typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
  514. typedef struct vki_user_i387_struct vki_elf_fpregset_t;
  515. typedef struct vki_user_fxsr_struct vki_elf_fpxregset_t;
  516. #define VKI_AT_SYSINFO 32
  517. //----------------------------------------------------------------------
  518. // From linux-2.6.8.1/include/asm-i386/ucontext.h
  519. //----------------------------------------------------------------------
  520. struct vki_ucontext {
  521. unsigned long uc_flags;
  522. struct vki_ucontext *uc_link;
  523. vki_stack_t uc_stack;
  524. struct vki_sigcontext uc_mcontext;
  525. vki_sigset_t uc_sigmask; /* mask last for extensibility */
  526. };
  527. //----------------------------------------------------------------------
  528. // From linux-2.6.8.1/include/asm-i386/segment.h
  529. //----------------------------------------------------------------------
  530. #define VKI_GDT_ENTRY_TLS_ENTRIES 3
  531. #define VKI_GDT_ENTRY_TLS_MIN 6
  532. #define VKI_GDT_ENTRY_TLS_MAX (VKI_GDT_ENTRY_TLS_MIN + VKI_GDT_ENTRY_TLS_ENTRIES - 1)
  533. //----------------------------------------------------------------------
  534. // From linux-2.6.8.1/include/asm-i386/ldt.h
  535. //----------------------------------------------------------------------
  536. /* [[Nb: This is the structure passed to the modify_ldt syscall. Just so as
  537. to confuse and annoy everyone, this is _not_ the same as an
  538. VgLdtEntry and has to be translated into such. The logic for doing
  539. so, in vg_ldt.c, is copied from the kernel sources.]] */
  540. struct vki_user_desc {
  541. unsigned int entry_number;
  542. unsigned long base_addr;
  543. unsigned int limit;
  544. unsigned int seg_32bit:1;
  545. unsigned int contents:2;
  546. unsigned int read_exec_only:1;
  547. unsigned int limit_in_pages:1;
  548. unsigned int seg_not_present:1;
  549. unsigned int useable:1;
  550. // [[Nb: this field is not in the kernel sources, but it has always
  551. // been in the Valgrind sources so I will keep it there in case it's
  552. // important... this is an x86-defined data structure so who
  553. // knows; maybe it's important to set this field to zero at some
  554. // point. --njn]]
  555. unsigned int reserved:25;
  556. };
  557. // [[Nb: for our convenience within Valgrind, use a more specific name]]
  558. typedef struct vki_user_desc vki_modify_ldt_t;
  559. //----------------------------------------------------------------------
  560. // From linux-2.6.8.1/include/asm-i386/ipcbuf.h
  561. //----------------------------------------------------------------------
  562. struct vki_ipc64_perm
  563. {
  564. __vki_kernel_key_t key;
  565. __vki_kernel_uid32_t uid;
  566. __vki_kernel_gid32_t gid;
  567. __vki_kernel_uid32_t cuid;
  568. __vki_kernel_gid32_t cgid;
  569. __vki_kernel_mode_t mode;
  570. unsigned short __pad1;
  571. unsigned short seq;
  572. unsigned short __pad2;
  573. unsigned long __unused1;
  574. unsigned long __unused2;
  575. };
  576. //----------------------------------------------------------------------
  577. // From linux-2.6.8.1/include/asm-i386/sembuf.h
  578. //----------------------------------------------------------------------
  579. struct vki_semid64_ds {
  580. struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */
  581. __vki_kernel_time_t sem_otime; /* last semop time */
  582. unsigned long __unused1;
  583. __vki_kernel_time_t sem_ctime; /* last change time */
  584. unsigned long __unused2;
  585. unsigned long sem_nsems; /* no. of semaphores in array */
  586. unsigned long __unused3;
  587. unsigned long __unused4;
  588. };
  589. //----------------------------------------------------------------------
  590. // From linux-2.6.8.1/include/asm-i386/msgbuf.h
  591. //----------------------------------------------------------------------
  592. struct vki_msqid64_ds {
  593. struct vki_ipc64_perm msg_perm;
  594. __vki_kernel_time_t msg_stime; /* last msgsnd time */
  595. unsigned long __unused1;
  596. __vki_kernel_time_t msg_rtime; /* last msgrcv time */
  597. unsigned long __unused2;
  598. __vki_kernel_time_t msg_ctime; /* last change time */
  599. unsigned long __unused3;
  600. unsigned long msg_cbytes; /* current number of bytes on queue */
  601. unsigned long msg_qnum; /* number of messages in queue */
  602. unsigned long msg_qbytes; /* max number of bytes on queue */
  603. __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */
  604. __vki_kernel_pid_t msg_lrpid; /* last receive pid */
  605. unsigned long __unused4;
  606. unsigned long __unused5;
  607. };
  608. //----------------------------------------------------------------------
  609. // From linux-2.6.8.1/include/asm-i386/ipc.h
  610. //----------------------------------------------------------------------
  611. struct vki_ipc_kludge {
  612. struct vki_msgbuf __user *msgp;
  613. long msgtyp;
  614. };
  615. #define VKI_SEMOP 1
  616. #define VKI_SEMGET 2
  617. #define VKI_SEMCTL 3
  618. #define VKI_SEMTIMEDOP 4
  619. #define VKI_MSGSND 11
  620. #define VKI_MSGRCV 12
  621. #define VKI_MSGGET 13
  622. #define VKI_MSGCTL 14
  623. #define VKI_SHMAT 21
  624. #define VKI_SHMDT 22
  625. #define VKI_SHMGET 23
  626. #define VKI_SHMCTL 24
  627. //----------------------------------------------------------------------
  628. // From linux-2.6.8.1/include/asm-i386/shmbuf.h
  629. //----------------------------------------------------------------------
  630. struct vki_shmid64_ds {
  631. struct vki_ipc64_perm shm_perm; /* operation perms */
  632. vki_size_t shm_segsz; /* size of segment (bytes) */
  633. __vki_kernel_time_t shm_atime; /* last attach time */
  634. unsigned long __unused1;
  635. __vki_kernel_time_t shm_dtime; /* last detach time */
  636. unsigned long __unused2;
  637. __vki_kernel_time_t shm_ctime; /* last change time */
  638. unsigned long __unused3;
  639. __vki_kernel_pid_t shm_cpid; /* pid of creator */
  640. __vki_kernel_pid_t shm_lpid; /* pid of last operator */
  641. unsigned long shm_nattch; /* no. of current attaches */
  642. unsigned long __unused4;
  643. unsigned long __unused5;
  644. };
  645. struct vki_shminfo64 {
  646. unsigned long shmmax;
  647. unsigned long shmmin;
  648. unsigned long shmmni;
  649. unsigned long shmseg;
  650. unsigned long shmall;
  651. unsigned long __unused1;
  652. unsigned long __unused2;
  653. unsigned long __unused3;
  654. unsigned long __unused4;
  655. };
  656. //----------------------------------------------------------------------
  657. // DRM ioctls
  658. //----------------------------------------------------------------------
  659. // jrs 20050207: where did all this stuff come from? Is it really
  660. // i386 specific, or should it go into the linux-generic category?
  661. //struct vki_drm_buf_pub {
  662. // Int idx; /**< Index into the master buffer list */
  663. // Int total; /**< Buffer size */
  664. // Int used; /**< Amount of buffer in use (for DMA) */
  665. // void __user *address; /**< Address of buffer */
  666. //};
  667. //
  668. //struct vki_drm_buf_map {
  669. // Int count; /**< Length of the buffer list */
  670. // void __user *virtual; /**< Mmap'd area in user-virtual */
  671. // struct vki_drm_buf_pub __user *list; /**< Buffer information */
  672. //};
  673. //
  674. ///* We need to pay attention to this, because it mmaps memory */
  675. //#define VKI_DRM_IOCTL_MAP_BUFS _VKI_IOWR('d', 0x19, struct vki_drm_buf_map)
  676. //----------------------------------------------------------------------
  677. // From linux-2.6.9/include/asm-i386/ptrace.h
  678. //----------------------------------------------------------------------
  679. #define VKI_PTRACE_GETREGS 12
  680. #define VKI_PTRACE_SETREGS 13
  681. #define VKI_PTRACE_GETFPREGS 14
  682. #define VKI_PTRACE_SETFPREGS 15
  683. #define VKI_PTRACE_GETFPXREGS 18
  684. #define VKI_PTRACE_SETFPXREGS 19
  685. #define VKI_PTRACE_GET_THREAD_AREA 25
  686. #define VKI_PTRACE_SET_THREAD_AREA 26
  687. //----------------------------------------------------------------------
  688. // From linux-2.6.15.4/include/asm-i386/vm86.h
  689. //----------------------------------------------------------------------
  690. #define VKI_VM86_PLUS_INSTALL_CHECK 0
  691. #define VKI_VM86_ENTER 1
  692. #define VKI_VM86_ENTER_NO_BYPASS 2
  693. #define VKI_VM86_REQUEST_IRQ 3
  694. #define VKI_VM86_FREE_IRQ 4
  695. #define VKI_VM86_GET_IRQ_BITS 5
  696. #define VKI_VM86_GET_AND_RESET_IRQ 6
  697. struct vki_vm86_regs {
  698. /*
  699. * normal regs, with special meaning for the segment descriptors..
  700. */
  701. long ebx;
  702. long ecx;
  703. long edx;
  704. long esi;
  705. long edi;
  706. long ebp;
  707. long eax;
  708. long __null_ds;
  709. long __null_es;
  710. long __null_fs;
  711. long __null_gs;
  712. long orig_eax;
  713. long eip;
  714. unsigned short cs, __csh;
  715. long eflags;
  716. long esp;
  717. unsigned short ss, __ssh;
  718. /*
  719. * these are specific to v86 mode:
  720. */
  721. unsigned short es, __esh;
  722. unsigned short ds, __dsh;
  723. unsigned short fs, __fsh;
  724. unsigned short gs, __gsh;
  725. };
  726. struct vki_revectored_struct {
  727. unsigned long __map[8]; /* 256 bits */
  728. };
  729. struct vki_vm86_struct {
  730. struct vki_vm86_regs regs;
  731. unsigned long flags;
  732. unsigned long screen_bitmap;
  733. unsigned long cpu_type;
  734. struct vki_revectored_struct int_revectored;
  735. struct vki_revectored_struct int21_revectored;
  736. };
  737. struct vki_vm86plus_info_struct {
  738. unsigned long force_return_for_pic:1;
  739. unsigned long vm86dbg_active:1; /* for debugger */
  740. unsigned long vm86dbg_TFpendig:1; /* for debugger */
  741. unsigned long unused:28;
  742. unsigned long is_vm86pus:1; /* for vm86 internal use */
  743. unsigned char vm86dbg_intxxtab[32]; /* for debugger */
  744. };
  745. struct vki_vm86plus_struct {
  746. struct vki_vm86_regs regs;
  747. unsigned long flags;
  748. unsigned long screen_bitmap;
  749. unsigned long cpu_type;
  750. struct vki_revectored_struct int_revectored;
  751. struct vki_revectored_struct int21_revectored;
  752. struct vki_vm86plus_info_struct vm86plus;
  753. };
  754. //----------------------------------------------------------------------
  755. // From linux-2.6.8.1/include/asm-generic/errno.h
  756. //----------------------------------------------------------------------
  757. #define VKI_ENOSYS 38 /* Function not implemented */
  758. #define VKI_EOVERFLOW 75 /* Value too large for defined data type */
  759. //----------------------------------------------------------------------
  760. // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
  761. //----------------------------------------------------------------------
  762. #define VKI_TIOCGSERIAL 0x541E
  763. #define VKI_TIOCSSERIAL 0x541F
  764. //----------------------------------------------------------------------
  765. // And that's it!
  766. //----------------------------------------------------------------------
  767. #endif // __VKI_X86_LINUX_H
  768. /*--------------------------------------------------------------------*/
  769. /*--- end ---*/
  770. /*--------------------------------------------------------------------*/