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