Home | History | Annotate | Download | only in vki
      1 
      2 /*--------------------------------------------------------------------*/
      3 /*--- Linux-specific kernel interface.                 vki-linux.h ---*/
      4 /*--------------------------------------------------------------------*/
      5 
      6 /*
      7    This file is part of Valgrind, a dynamic binary instrumentation
      8    framework.
      9 
     10    Copyright (C) 2000-2010 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 /* This file defines types and constants for the kernel interface, and to
     32    make that clear everything is prefixed VKI_/vki_.
     33 
     34    All code is copied verbatim from kernel source files, except that:
     35    - VKI_/vki_ prefixes are added
     36    - some extra explanatory comments are included;  they are all within
     37      "[[ ]]"
     38    - for some types, we only care about the size;  for a few of them (big
     39      ones that are painful to fully drag in here), a VKI_SIZEOF_* constant
     40      is used.
     41 
     42    The files the code is taken from is indicated.
     43 
     44    Note especially that the types are not the glibc versions, many of which
     45    are different to those in here.
     46 
     47    Also note that this file contains all the generic header info, ie. that
     48    from linux/include/linux/ *.h.  The arch-specific header info, eg. that
     49    from linux/include/asm-i386/ *.h, is in vki-$PLATFORM.h and
     50    vki_posixtypes-$PLATFORM.h.  (Two files are required to avoid
     51    circular dependencies between the generic VKI header and the
     52    arch-specific VKI header.  It's possible in the future, as more stuff
     53    gets pulled in, that we might have to split files up some more to avoid
     54    further circular dependencies.)
     55 
     56    Finally, note that it is assumed that __KERNEL__ is set for all these
     57    definitions, which affects some of them.
     58 */
     59 
     60 /* The structure is (aiui, jrs 20060504):
     61 
     62      #include plat-specific posix types (vki-posixtypes-ARCH-linux.h)
     63 
     64      Lots more types, structs, consts, in this file
     65 
     66      #include other plat-specific stuff (vki-ARCH-linux.h)
     67 
     68      Even more types, structs, consts, in this file
     69 
     70    The system call numbers are dealt with by
     71    pub_{core,tool}_vkiscnums.h, not via pub_{core,tool}_vki.h, which
     72    is what this file is part of.
     73 */
     74 
     75 #ifndef __VKI_LINUX_H
     76 #define __VKI_LINUX_H
     77 
     78 //----------------------------------------------------------------------
     79 // Arch-specific POSIX types
     80 //----------------------------------------------------------------------
     81 
     82 #if defined(VGA_x86)
     83 #  include "vki-posixtypes-x86-linux.h"
     84 #elif defined(VGA_amd64)
     85 #  include "vki-posixtypes-amd64-linux.h"
     86 #elif defined(VGA_ppc32)
     87 #  include "vki-posixtypes-ppc32-linux.h"
     88 #elif defined(VGA_ppc64)
     89 #  include "vki-posixtypes-ppc64-linux.h"
     90 #elif defined(VGA_arm)
     91 #  include "vki-posixtypes-arm-linux.h"
     92 #else
     93 #  error Unknown platform
     94 #endif
     95 
     96 //----------------------------------------------------------------------
     97 // VKI_STATIC_ASSERT(). Inspired by BUILD_BUG_ON() from
     98 // linux-2.6.34/include/linux/kernel.h
     99 //----------------------------------------------------------------------
    100 
    101 /*
    102  * Evaluates to zero if 'expr' is true and forces a compilation error if
    103  * 'expr' is false. Can be used in a context where no comma expressions
    104  * are allowed.
    105  */
    106 #define VKI_STATIC_ASSERT(expr) (sizeof(int [-!(expr)]))
    107 //----------------------------------------------------------------------
    108 // Based on _IOC_TYPECHECK() from linux-2.6.34/asm-generic/ioctl.h
    109 //----------------------------------------------------------------------
    110 
    111 /* provoke compile error for invalid uses of size argument */
    112 #define _VKI_IOC_TYPECHECK(t)                                           \
    113     (VKI_STATIC_ASSERT((sizeof(t) == sizeof(t[1])                       \
    114                         && sizeof(t) < (1 << _VKI_IOC_SIZEBITS)))       \
    115      + sizeof(t))
    116 
    117 //----------------------------------------------------------------------
    118 // From linux-2.6.8.1/include/linux/compiler.h
    119 //----------------------------------------------------------------------
    120 
    121 # define __user
    122 
    123 # define __attribute_const__    /* unimplemented */
    124 
    125 //----------------------------------------------------------------------
    126 // From linux-2.6.8.1/include/linux/posix_types.h
    127 //----------------------------------------------------------------------
    128 
    129 #undef __VKI_NFDBITS
    130 #define __VKI_NFDBITS	(8 * sizeof(unsigned long))
    131 
    132 #undef __VKI_FD_SETSIZE
    133 #define __VKI_FD_SETSIZE	1024
    134 
    135 #undef __VKI_FDSET_LONGS
    136 #define __VKI_FDSET_LONGS	(__VKI_FD_SETSIZE/__VKI_NFDBITS)
    137 
    138 #undef __VKI_FDELT
    139 #define	__VKI_FDELT(d)	((d) / __VKI_NFDBITS)
    140 
    141 #undef __VKI_FDMASK
    142 #define	__VKI_FDMASK(d)	(1UL << ((d) % __VKI_NFDBITS))
    143 
    144 typedef struct {
    145 	unsigned long fds_bits [__VKI_FDSET_LONGS];
    146 } __vki_kernel_fd_set;
    147 
    148 typedef int __vki_kernel_key_t;
    149 typedef int __vki_kernel_mqd_t;
    150 
    151 //----------------------------------------------------------------------
    152 // From linux-2.6.8.1/include/linux/types.h
    153 //----------------------------------------------------------------------
    154 
    155 typedef __vki_kernel_fd_set	vki_fd_set;
    156 typedef __vki_kernel_mode_t	vki_mode_t;
    157 typedef __vki_kernel_off_t	vki_off_t;
    158 typedef __vki_kernel_pid_t	vki_pid_t;
    159 typedef __vki_kernel_key_t	vki_key_t;
    160 typedef __vki_kernel_suseconds_t	vki_suseconds_t;
    161 typedef __vki_kernel_timer_t	vki_timer_t;
    162 typedef __vki_kernel_clockid_t	vki_clockid_t;
    163 typedef __vki_kernel_mqd_t	vki_mqd_t;
    164 
    165 // [[Nb: it's a bit unclear due to a #ifdef, but I think this is right. --njn]]
    166 typedef __vki_kernel_uid32_t	vki_uid_t;
    167 typedef __vki_kernel_gid32_t	vki_gid_t;
    168 
    169 typedef __vki_kernel_old_uid_t	vki_old_uid_t;
    170 typedef __vki_kernel_old_gid_t	vki_old_gid_t;
    171 
    172 typedef __vki_kernel_loff_t	vki_loff_t;
    173 
    174 typedef __vki_kernel_size_t	vki_size_t;
    175 typedef __vki_kernel_time_t	vki_time_t;
    176 typedef __vki_kernel_clock_t	vki_clock_t;
    177 typedef __vki_kernel_caddr_t	vki_caddr_t;
    178 
    179 typedef unsigned long           vki_u_long;
    180 
    181 typedef unsigned int	        vki_uint;
    182 
    183 //----------------------------------------------------------------------
    184 // Now the rest of the arch-specific stuff
    185 //----------------------------------------------------------------------
    186 
    187 #if defined(VGA_x86)
    188 #  include "vki-x86-linux.h"
    189 #elif defined(VGA_amd64)
    190 #  include "vki-amd64-linux.h"
    191 #elif defined(VGA_ppc32)
    192 #  include "vki-ppc32-linux.h"
    193 #elif defined(VGA_ppc64)
    194 #  include "vki-ppc64-linux.h"
    195 #elif defined(VGA_arm)
    196 #  include "vki-arm-linux.h"
    197 #else
    198 #  error Unknown platform
    199 #endif
    200 
    201 //----------------------------------------------------------------------
    202 // From linux-2.6.20.1/include/linux/types.h
    203 //----------------------------------------------------------------------
    204 
    205 typedef		__vki_s32	vki_int32_t;
    206 typedef		__vki_s64	vki_int64_t;
    207 
    208 typedef		__vki_u8	vki_uint8_t;
    209 typedef		__vki_u16	vki_uint16_t;
    210 typedef		__vki_u32	vki_uint32_t;
    211 
    212 //----------------------------------------------------------------------
    213 // From linux-2.6.8.1/include/linux/limits.h
    214 //----------------------------------------------------------------------
    215 
    216 #define VKI_PATH_MAX       4096	/* # chars in a path name including nul */
    217 
    218 //----------------------------------------------------------------------
    219 // From linux-2.6.8.1/include/linux/kernel.h
    220 //----------------------------------------------------------------------
    221 
    222 struct vki_sysinfo {
    223 	long uptime;			/* Seconds since boot */
    224 	unsigned long loads[3];		/* 1, 5, and 15 minute load averages */
    225 	unsigned long totalram;		/* Total usable main memory size */
    226 	unsigned long freeram;		/* Available memory size */
    227 	unsigned long sharedram;	/* Amount of shared memory */
    228 	unsigned long bufferram;	/* Memory used by buffers */
    229 	unsigned long totalswap;	/* Total swap space size */
    230 	unsigned long freeswap;		/* swap space still available */
    231 	unsigned short procs;		/* Number of current processes */
    232 	unsigned short pad;		/* explicit padding for m68k */
    233 	unsigned long totalhigh;	/* Total high memory size */
    234 	unsigned long freehigh;		/* Available high memory size */
    235 	unsigned int mem_unit;		/* Memory unit size in bytes */
    236 	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
    237 };
    238 
    239 //----------------------------------------------------------------------
    240 // From linux-2.6.8.1/include/linux/time.h
    241 //----------------------------------------------------------------------
    242 
    243 #define VKI_CLOCK_REALTIME            0
    244 #define VKI_CLOCK_MONOTONIC           1
    245 #define VKI_CLOCK_PROCESS_CPUTIME_ID  2
    246 #define VKI_CLOCK_THREAD_CPUTIME_ID   3
    247 
    248 struct vki_timespec {
    249 	vki_time_t	tv_sec;		/* seconds */
    250 	long		tv_nsec;	/* nanoseconds */
    251 };
    252 
    253 struct vki_timeval {
    254 	vki_time_t	tv_sec;		/* seconds */
    255 	vki_suseconds_t	tv_usec;	/* microseconds */
    256 };
    257 
    258 struct vki_timezone {
    259 	int	tz_minuteswest;	/* minutes west of Greenwich */
    260 	int	tz_dsttime;	/* type of dst correction */
    261 };
    262 
    263 struct  vki_itimerspec {
    264         struct  vki_timespec it_interval;    /* timer period */
    265         struct  vki_timespec it_value;       /* timer expiration */
    266 };
    267 
    268 struct	vki_itimerval {
    269 	struct	vki_timeval it_interval;	/* timer interval */
    270 	struct	vki_timeval it_value;	/* current value */
    271 };
    272 
    273 //----------------------------------------------------------------------
    274 // From linux-2.6.8.1/include/linux/timex.h
    275 //----------------------------------------------------------------------
    276 
    277 struct vki_timex {
    278 	unsigned int modes;	/* mode selector */
    279 	long offset;		/* time offset (usec) */
    280 	long freq;		/* frequency offset (scaled ppm) */
    281 	long maxerror;		/* maximum error (usec) */
    282 	long esterror;		/* estimated error (usec) */
    283 	int status;		/* clock command/status */
    284 	long constant;		/* pll time constant */
    285 	long precision;		/* clock precision (usec) (read only) */
    286 	long tolerance;		/* clock frequency tolerance (ppm)
    287 				 * (read only)
    288 				 */
    289 	struct vki_timeval time;	/* (read only) */
    290 	long tick;		/* (modified) usecs between clock ticks */
    291 
    292 	long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
    293 	long jitter;            /* pps jitter (us) (ro) */
    294 	int shift;              /* interval duration (s) (shift) (ro) */
    295 	long stabil;            /* pps stability (scaled ppm) (ro) */
    296 	long jitcnt;            /* jitter limit exceeded (ro) */
    297 	long calcnt;            /* calibration intervals (ro) */
    298 	long errcnt;            /* calibration errors (ro) */
    299 	long stbcnt;            /* stability limit exceeded (ro) */
    300 
    301 	int  :32; int  :32; int  :32; int  :32;
    302 	int  :32; int  :32; int  :32; int  :32;
    303 	int  :32; int  :32; int  :32; int  :32;
    304 };
    305 
    306 #define VKI_ADJ_OFFSET			0x0001	/* time offset */
    307 #define VKI_ADJ_FREQUENCY		0x0002	/* frequency offset */
    308 #define VKI_ADJ_MAXERROR		0x0004	/* maximum time error */
    309 #define VKI_ADJ_ESTERROR		0x0008	/* estimated time error */
    310 #define VKI_ADJ_STATUS			0x0010	/* clock status */
    311 #define VKI_ADJ_TIMECONST		0x0020	/* pll time constant */
    312 #define VKI_ADJ_TAI			0x0080	/* set TAI offset */
    313 #define VKI_ADJ_TICK			0x4000	/* tick value */
    314 #define VKI_ADJ_ADJTIME			0x8000	/* switch between adjtime/adjtimex modes */
    315 //#define VKI_ADJ_OFFSET_SINGLESHOT	0x8001	/* old-fashioned adjtime */
    316 #define VKI_ADJ_OFFSET_READONLY		0x2000	/* read-only adjtime */
    317 
    318 //----------------------------------------------------------------------
    319 // From linux-2.6.8.1/include/linux/times.h
    320 //----------------------------------------------------------------------
    321 
    322 struct vki_tms {
    323 	vki_clock_t tms_utime;
    324 	vki_clock_t tms_stime;
    325 	vki_clock_t tms_cutime;
    326 	vki_clock_t tms_cstime;
    327 };
    328 
    329 //----------------------------------------------------------------------
    330 // From linux-2.6.8.1/include/linux/utime.h
    331 //----------------------------------------------------------------------
    332 
    333 struct vki_utimbuf {
    334 	vki_time_t actime;
    335 	vki_time_t modtime;
    336 };
    337 
    338 //----------------------------------------------------------------------
    339 // From linux-2.6.8.1/include/linux/sched.h
    340 //----------------------------------------------------------------------
    341 
    342 #define VKI_CSIGNAL		0x000000ff	/* signal mask to be sent at exit */
    343 #define VKI_CLONE_VM		0x00000100	/* set if VM shared between processes */
    344 #define VKI_CLONE_FS		0x00000200	/* set if fs info shared between processes */
    345 #define VKI_CLONE_FILES		0x00000400	/* set if open files shared between processes */
    346 #define VKI_CLONE_SIGHAND	0x00000800	/* set if signal handlers and blocked signals shared */
    347 #define VKI_CLONE_VFORK		0x00004000	/* set if the parent wants the child to wake it up on mm_release */
    348 #define VKI_CLONE_PARENT	0x00008000	/* set if we want to have the same parent as the cloner */
    349 #define VKI_CLONE_THREAD	0x00010000	/* Same thread group? */
    350 #define VKI_CLONE_SYSVSEM	0x00040000	/* share system V SEM_UNDO semantics */
    351 #define VKI_CLONE_SETTLS	0x00080000	/* create a new TLS for the child */
    352 #define VKI_CLONE_PARENT_SETTID	0x00100000	/* set the TID in the parent */
    353 #define VKI_CLONE_CHILD_CLEARTID	0x00200000	/* clear the TID in the child */
    354 #define VKI_CLONE_DETACHED	0x00400000	/* Unused, ignored */
    355 #define VKI_CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
    356 
    357 struct vki_sched_param {
    358 	int sched_priority;
    359 };
    360 
    361 #define VKI_TASK_COMM_LEN 16
    362 
    363 //----------------------------------------------------------------------
    364 // From linux-2.6.8.1/include/asm-generic/siginfo.h
    365 //----------------------------------------------------------------------
    366 
    367 typedef union vki_sigval {
    368 	int sival_int;
    369 	void __user *sival_ptr;
    370 } vki_sigval_t;
    371 
    372 #ifndef __VKI_ARCH_SI_PREAMBLE_SIZE
    373 #define __VKI_ARCH_SI_PREAMBLE_SIZE	(3 * sizeof(int))
    374 #endif
    375 
    376 #define VKI_SI_MAX_SIZE	128
    377 
    378 #ifndef VKI_SI_PAD_SIZE
    379 #define VKI_SI_PAD_SIZE	((VKI_SI_MAX_SIZE - __VKI_ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
    380 #endif
    381 
    382 #ifndef __VKI_ARCH_SI_UID_T
    383 #define __VKI_ARCH_SI_UID_T	vki_uid_t
    384 #endif
    385 
    386 #ifndef __VKI_ARCH_SI_BAND_T
    387 #define __VKI_ARCH_SI_BAND_T long
    388 #endif
    389 
    390 // [[Nb: this type changed between 2.4 and 2.6, but not in a way that
    391 // affects Valgrind.]]
    392 typedef struct vki_siginfo {
    393 	int si_signo;
    394 	int si_errno;
    395 	int si_code;
    396 
    397 	union {
    398 		int _pad[VKI_SI_PAD_SIZE];
    399 
    400 		/* kill() */
    401 		struct {
    402 			vki_pid_t _pid;		/* sender's pid */
    403 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
    404 		} _kill;
    405 
    406 		/* POSIX.1b timers */
    407 		struct {
    408 			vki_timer_t _tid;		/* timer id */
    409 			int _overrun;		/* overrun count */
    410 			char _pad[sizeof( __VKI_ARCH_SI_UID_T) - sizeof(int)];
    411 			vki_sigval_t _sigval;	/* same as below */
    412 			int _sys_private;       /* not to be passed to user */
    413 		} _timer;
    414 
    415 		/* POSIX.1b signals */
    416 		struct {
    417 			vki_pid_t _pid;		/* sender's pid */
    418 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
    419 			vki_sigval_t _sigval;
    420 		} _rt;
    421 
    422 		/* SIGCHLD */
    423 		struct {
    424 			vki_pid_t _pid;		/* which child */
    425 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
    426 			int _status;		/* exit code */
    427 			vki_clock_t _utime;
    428 			vki_clock_t _stime;
    429 		} _sigchld;
    430 
    431 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
    432 		struct {
    433 			void __user *_addr; /* faulting insn/memory ref. */
    434 #ifdef __ARCH_SI_TRAPNO
    435 			int _trapno;	/* TRAP # which caused the signal */
    436 #endif
    437 		} _sigfault;
    438 
    439 		/* SIGPOLL */
    440 		struct {
    441 			__VKI_ARCH_SI_BAND_T _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
    442 			int _fd;
    443 		} _sigpoll;
    444 	} _sifields;
    445 } vki_siginfo_t;
    446 
    447 #define __VKI_SI_FAULT	0
    448 
    449 /*
    450  * si_code values
    451  * Digital reserves positive values for kernel-generated signals.
    452  */
    453 #define VKI_SI_USER	0		/* sent by kill, sigsend, raise */
    454 #define VKI_SI_TKILL	-6		/* sent by tkill system call */
    455 
    456 /*
    457  * SIGILL si_codes
    458  */
    459 #define VKI_ILL_ILLOPC	(__VKI_SI_FAULT|1)	/* illegal opcode */
    460 #define VKI_ILL_ILLOPN	(__VKI_SI_FAULT|2)	/* illegal operand */
    461 #define VKI_ILL_ILLADR	(__VKI_SI_FAULT|3)	/* illegal addressing mode */
    462 #define VKI_ILL_ILLTRP	(__VKI_SI_FAULT|4)	/* illegal trap */
    463 #define VKI_ILL_PRVOPC	(__VKI_SI_FAULT|5)	/* privileged opcode */
    464 #define VKI_ILL_PRVREG	(__VKI_SI_FAULT|6)	/* privileged register */
    465 #define VKI_ILL_COPROC	(__VKI_SI_FAULT|7)	/* coprocessor error */
    466 #define VKI_ILL_BADSTK	(__VKI_SI_FAULT|8)	/* internal stack error */
    467 
    468 /*
    469  * SIGFPE si_codes
    470  */
    471 #define VKI_FPE_INTDIV	(__VKI_SI_FAULT|1)	/* integer divide by zero */
    472 #define VKI_FPE_INTOVF	(__VKI_SI_FAULT|2)	/* integer overflow */
    473 #define VKI_FPE_FLTDIV	(__VKI_SI_FAULT|3)	/* floating point divide by zero */
    474 #define VKI_FPE_FLTOVF	(__VKI_SI_FAULT|4)	/* floating point overflow */
    475 #define VKI_FPE_FLTUND	(__VKI_SI_FAULT|5)	/* floating point underflow */
    476 #define VKI_FPE_FLTRES	(__VKI_SI_FAULT|6)	/* floating point inexact result */
    477 #define VKI_FPE_FLTINV	(__VKI_SI_FAULT|7)	/* floating point invalid operation */
    478 #define VKI_FPE_FLTSUB	(__VKI_SI_FAULT|8)	/* subscript out of range */
    479 
    480 /*
    481  * SIGSEGV si_codes
    482  */
    483 #define VKI_SEGV_MAPERR	(__VKI_SI_FAULT|1)	/* address not mapped to object */
    484 #define VKI_SEGV_ACCERR	(__VKI_SI_FAULT|2)	/* invalid permissions for mapped object */
    485 
    486 /*
    487  * SIGBUS si_codes
    488  */
    489 #define VKI_BUS_ADRALN	(__VKI_SI_FAULT|1)	/* invalid address alignment */
    490 #define VKI_BUS_ADRERR	(__VKI_SI_FAULT|2)	/* non-existant physical address */
    491 #define VKI_BUS_OBJERR	(__VKI_SI_FAULT|3)	/* object specific hardware error */
    492 
    493 /*
    494  * SIGTRAP si_codes
    495  */
    496 #define VKI_TRAP_BRKPT      (__VKI_SI_FAULT|1)  /* process breakpoint */
    497 #define VKI_TRAP_TRACE      (__VKI_SI_FAULT|2)  /* process trace trap */
    498 
    499 /*
    500  * This works because the alignment is ok on all current architectures
    501  * but we leave open this being overridden in the future
    502  */
    503 #ifndef VKI___ARCH_SIGEV_PREAMBLE_SIZE
    504 #define VKI___ARCH_SIGEV_PREAMBLE_SIZE	(sizeof(int) * 2 + sizeof(vki_sigval_t))
    505 #endif
    506 
    507 #define VKI_SIGEV_MAX_SIZE	64
    508 #define VKI_SIGEV_PAD_SIZE	((VKI_SIGEV_MAX_SIZE - VKI___ARCH_SIGEV_PREAMBLE_SIZE) \
    509 		/ sizeof(int))
    510 
    511 typedef struct vki_sigevent {
    512 	vki_sigval_t sigev_value;
    513 	int sigev_signo;
    514 	int sigev_notify;
    515 	union {
    516 		int _pad[VKI_SIGEV_PAD_SIZE];
    517 		 int _tid;
    518 
    519 		struct {
    520 			void (*_function)(vki_sigval_t);
    521 			void *_attribute;	/* really pthread_attr_t */
    522 		} _sigev_thread;
    523 	} _sigev_un;
    524 } vki_sigevent_t;
    525 
    526 //----------------------------------------------------------------------
    527 // From elsewhere...
    528 //----------------------------------------------------------------------
    529 
    530 // [[The kernel actually uses the numbers 0,1,2 directly here, believe it or
    531 // not.  So we introduce our own constants, based on the glibc ones.]]
    532 #define VKI_SEEK_SET              0
    533 #define VKI_SEEK_CUR              1
    534 #define VKI_SEEK_END              2
    535 
    536 //----------------------------------------------------------------------
    537 // From linux-2.6.8.1/include/linux/net.h
    538 //----------------------------------------------------------------------
    539 
    540 #define VKI_SYS_SOCKET		1	/* sys_socket(2)		*/
    541 #define VKI_SYS_BIND		2	/* sys_bind(2)			*/
    542 #define VKI_SYS_CONNECT		3	/* sys_connect(2)		*/
    543 #define VKI_SYS_LISTEN		4	/* sys_listen(2)		*/
    544 #define VKI_SYS_ACCEPT		5	/* sys_accept(2)		*/
    545 #define VKI_SYS_GETSOCKNAME	6	/* sys_getsockname(2)		*/
    546 #define VKI_SYS_GETPEERNAME	7	/* sys_getpeername(2)		*/
    547 #define VKI_SYS_SOCKETPAIR	8	/* sys_socketpair(2)		*/
    548 #define VKI_SYS_SEND		9	/* sys_send(2)			*/
    549 #define VKI_SYS_RECV		10	/* sys_recv(2)			*/
    550 #define VKI_SYS_SENDTO		11	/* sys_sendto(2)		*/
    551 #define VKI_SYS_RECVFROM	12	/* sys_recvfrom(2)		*/
    552 #define VKI_SYS_SHUTDOWN	13	/* sys_shutdown(2)		*/
    553 #define VKI_SYS_SETSOCKOPT	14	/* sys_setsockopt(2)		*/
    554 #define VKI_SYS_GETSOCKOPT	15	/* sys_getsockopt(2)		*/
    555 #define VKI_SYS_SENDMSG		16	/* sys_sendmsg(2)		*/
    556 #define VKI_SYS_RECVMSG		17	/* sys_recvmsg(2)		*/
    557 #define VKI_SYS_ACCEPT4		18	/* sys_accept4(2)		*/
    558 
    559 enum vki_sock_type {
    560 	VKI_SOCK_STREAM	= 1,
    561 	// [[others omitted]]
    562 };
    563 
    564 //----------------------------------------------------------------------
    565 // From linux-2.6.8.1/include/linux/uio.h
    566 //----------------------------------------------------------------------
    567 
    568 struct vki_iovec
    569 {
    570 	void __user *iov_base;	/* BSD uses caddr_t (1003.1g requires void *) */
    571 	__vki_kernel_size_t iov_len; /* Must be size_t (1003.1g) */
    572 };
    573 
    574 //----------------------------------------------------------------------
    575 // From linux-2.6.8.1/include/linux/socket.h
    576 //----------------------------------------------------------------------
    577 
    578 // [[Resolved arbitrarily;  doesn't really matter whether it's '__inline__'
    579 //   or 'inline']]
    580 #define __KINLINE static __inline__
    581 
    582 typedef unsigned short	vki_sa_family_t;
    583 
    584 struct vki_sockaddr {
    585 	vki_sa_family_t	sa_family;	/* address family, AF_xxx	*/
    586 	char		sa_data[14];	/* 14 bytes of protocol address	*/
    587 };
    588 
    589 struct vki_msghdr {
    590 	void	*	msg_name;	/* Socket name			*/
    591 	int		msg_namelen;	/* Length of name		*/
    592 	struct vki_iovec *	msg_iov;	/* Data blocks			*/
    593 	__vki_kernel_size_t	msg_iovlen;	/* Number of blocks		*/
    594 	void 	*	msg_control;	/* Per protocol magic (eg BSD file descriptor passing) */
    595 	__vki_kernel_size_t	msg_controllen;	/* Length of cmsg list */
    596 	unsigned	msg_flags;
    597 };
    598 
    599 struct vki_cmsghdr {
    600 	__vki_kernel_size_t	cmsg_len;	/* data byte count, including hdr */
    601         int		cmsg_level;	/* originating protocol */
    602         int		cmsg_type;	/* protocol-specific type */
    603 };
    604 
    605 #define __VKI_CMSG_NXTHDR(ctl, len, cmsg) __vki_cmsg_nxthdr((ctl),(len),(cmsg))
    606 #define VKI_CMSG_NXTHDR(mhdr, cmsg) vki_cmsg_nxthdr((mhdr), (cmsg))
    607 
    608 #define VKI_CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
    609 
    610 #define VKI_CMSG_DATA(cmsg)	((void *)((char *)(cmsg) + VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr))))
    611 
    612 #define __VKI_CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct vki_cmsghdr) ? \
    613 				  (struct vki_cmsghdr *)(ctl) : \
    614 				  (struct vki_cmsghdr *)NULL)
    615 #define VKI_CMSG_FIRSTHDR(msg)	__VKI_CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
    616 
    617 // [[Urgh, this is revolting...]
    618 __KINLINE struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, __vki_kernel_size_t __size,
    619 					       struct vki_cmsghdr *__cmsg)
    620 {
    621 	struct vki_cmsghdr * __ptr;
    622 
    623 	__ptr = (struct vki_cmsghdr*)(((unsigned char *) __cmsg) +  VKI_CMSG_ALIGN(__cmsg->cmsg_len));
    624 	if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
    625 		return (struct vki_cmsghdr *)0;
    626 
    627 	return __ptr;
    628 }
    629 
    630 __KINLINE struct vki_cmsghdr * vki_cmsg_nxthdr (struct vki_msghdr *__msg, struct vki_cmsghdr *__cmsg)
    631 {
    632 	return __vki_cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
    633 }
    634 
    635 #define	VKI_SCM_RIGHTS	0x01		/* rw: access rights (array of int) */
    636 
    637 #define VKI_AF_UNIX	1	/* Unix domain sockets 		*/
    638 #define VKI_AF_INET	2	/* Internet IP Protocol		*/
    639 #define VKI_AF_INET6	10	/* IP version 6			*/
    640 
    641 #define VKI_MSG_NOSIGNAL	0x4000	/* Do not generate SIGPIPE */
    642 
    643 #define VKI_SOL_SCTP	132
    644 
    645 //----------------------------------------------------------------------
    646 // From linux-2.6.8.1/include/linux/in.h
    647 //----------------------------------------------------------------------
    648 
    649 struct vki_in_addr {
    650 	__vki_u32	s_addr;
    651 };
    652 
    653 /* Structure describing an Internet (IP) socket address. */
    654 #define __VKI_SOCK_SIZE__	16	/* sizeof(struct sockaddr)	*/
    655 struct vki_sockaddr_in {
    656   vki_sa_family_t	sin_family;	/* Address family		*/
    657   unsigned short int	sin_port;	/* Port number			*/
    658   struct vki_in_addr	sin_addr;	/* Internet address		*/
    659 
    660   /* Pad to size of `struct sockaddr'. */
    661   unsigned char		__pad[__VKI_SOCK_SIZE__ - sizeof(short int) -
    662 			sizeof(unsigned short int) - sizeof(struct vki_in_addr)];
    663 };
    664 
    665 //----------------------------------------------------------------------
    666 // From linux-2.6.8.1/include/linux/in6.h
    667 //----------------------------------------------------------------------
    668 
    669 struct vki_in6_addr
    670 {
    671 	union
    672 	{
    673 		__vki_u8	u6_addr8[16];
    674 		__vki_u16	u6_addr16[8];
    675 		__vki_u32	u6_addr32[4];
    676 	} vki_in6_u;
    677 #define vki_s6_addr		vki_in6_u.u6_addr8
    678 #define vki_s6_addr16		vki_in6_u.u6_addr16
    679 #define vki_s6_addr32		vki_in6_u.u6_addr32
    680 };
    681 
    682 struct vki_sockaddr_in6 {
    683 	unsigned short int	sin6_family;    /* AF_INET6 */
    684 	__vki_u16		sin6_port;      /* Transport layer port # */
    685 	__vki_u32		sin6_flowinfo;  /* IPv6 flow information */
    686 	struct vki_in6_addr	sin6_addr;      /* IPv6 address */
    687 	__vki_u32		sin6_scope_id;  /* scope id (new in RFC2553) */
    688 };
    689 
    690 //----------------------------------------------------------------------
    691 // From linux-2.6.8.1/include/linux/un.h
    692 //----------------------------------------------------------------------
    693 
    694 #define VKI_UNIX_PATH_MAX	108
    695 
    696 struct vki_sockaddr_un {
    697 	vki_sa_family_t sun_family;	/* AF_UNIX */
    698 	char sun_path[VKI_UNIX_PATH_MAX];	/* pathname */
    699 };
    700 
    701 //----------------------------------------------------------------------
    702 // From linux-2.6.8.1/include/linux/if.h
    703 //----------------------------------------------------------------------
    704 
    705 #define	VKI_IFNAMSIZ	16
    706 
    707 struct vki_ifmap
    708 {
    709 	unsigned long mem_start;
    710 	unsigned long mem_end;
    711 	unsigned short base_addr;
    712 	unsigned char irq;
    713 	unsigned char dma;
    714 	unsigned char port;
    715 	/* 3 bytes spare */
    716 };
    717 
    718 struct vki_if_settings
    719 {
    720 	unsigned int type;	/* Type of physical device or protocol */
    721 	unsigned int size;	/* Size of the data allocated by the caller */
    722 	union {
    723                 // [[Nb: converted these all to void* to avoid pulling in
    724                 //   unnecessary headers]]]
    725 		/* {atm/eth/dsl}_settings anyone ? */
    726 		void /*raw_hdlc_proto		*/__user *raw_hdlc;
    727 		void /*cisco_proto		*/__user *cisco;
    728 		void /*fr_proto			*/__user *fr;
    729 		void /*fr_proto_pvc		*/__user *fr_pvc;
    730 		void /*fr_proto_pvc_info	*/__user *fr_pvc_info;
    731 
    732 		/* interface settings */
    733 		void /*sync_serial_settings	*/__user *sync;
    734 		void /*te1_settings		*/__user *te1;
    735 	} ifs_ifsu;
    736 };
    737 
    738 struct vki_ifreq
    739 {
    740 #define VKI_IFHWADDRLEN	6
    741 	union
    742 	{
    743 		char	ifrn_name[VKI_IFNAMSIZ];		/* if name, e.g. "en0" */
    744 	} ifr_ifrn;
    745 
    746 	union {
    747 		struct	vki_sockaddr ifru_addr;
    748 		struct	vki_sockaddr ifru_dstaddr;
    749 		struct	vki_sockaddr ifru_broadaddr;
    750 		struct	vki_sockaddr ifru_netmask;
    751 		struct  vki_sockaddr ifru_hwaddr;
    752 		short	ifru_flags;
    753 		int	ifru_ivalue;
    754 		int	ifru_mtu;
    755 		struct  vki_ifmap ifru_map;
    756 		char	ifru_slave[VKI_IFNAMSIZ];	/* Just fits the size */
    757 		char	ifru_newname[VKI_IFNAMSIZ];
    758 		void __user *	ifru_data;
    759 		struct	vki_if_settings ifru_settings;
    760 	} ifr_ifru;
    761 };
    762 
    763 #define vki_ifr_name	ifr_ifrn.ifrn_name	/* interface name 	*/
    764 #define ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address 		*/
    765 #define	ifr_addr	ifr_ifru.ifru_addr	/* address		*/
    766 #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-p lnk	*/
    767 #define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address	*/
    768 #define	ifr_netmask	ifr_ifru.ifru_netmask	/* interface net mask	*/
    769 #define	vki_ifr_flags	ifr_ifru.ifru_flags	/* flags		*/
    770 #define	vki_ifr_metric	ifr_ifru.ifru_ivalue	/* metric		*/
    771 #define	vki_ifr_mtu		ifr_ifru.ifru_mtu	/* mtu			*/
    772 #define ifr_map		ifr_ifru.ifru_map	/* device map		*/
    773 #define ifr_slave	ifr_ifru.ifru_slave	/* slave device		*/
    774 #define	vki_ifr_data	ifr_ifru.ifru_data	/* for use by interface	*/
    775 #define vki_ifr_ifindex	ifr_ifru.ifru_ivalue	/* interface index	*/
    776 #define ifr_bandwidth	ifr_ifru.ifru_ivalue    /* link bandwidth	*/
    777 #define ifr_qlen	ifr_ifru.ifru_ivalue	/* Queue length 	*/
    778 #define ifr_newname	ifr_ifru.ifru_newname	/* New name		*/
    779 #define ifr_settings	ifr_ifru.ifru_settings	/* Device/proto settings*/
    780 
    781 struct vki_ifconf
    782 {
    783 	int	ifc_len;			/* size of buffer	*/
    784 	union
    785 	{
    786 		char __user *ifcu_buf;
    787 		struct vki_ifreq __user *ifcu_req;
    788 	} ifc_ifcu;
    789 };
    790 #define	vki_ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address	*/
    791 
    792 //----------------------------------------------------------------------
    793 // From linux-2.6.8.1/include/linux/if_arp.h
    794 //----------------------------------------------------------------------
    795 
    796 struct vki_arpreq {
    797   struct vki_sockaddr	arp_pa;		/* protocol address		*/
    798   struct vki_sockaddr	arp_ha;		/* hardware address		*/
    799   int			arp_flags;	/* flags			*/
    800   struct vki_sockaddr   arp_netmask;    /* netmask (only for proxy arps) */
    801   char			arp_dev[16];
    802 };
    803 
    804 //----------------------------------------------------------------------
    805 // From linux-2.6.8.1/include/linux/route.h
    806 //----------------------------------------------------------------------
    807 
    808 struct vki_rtentry
    809 {
    810 	unsigned long	rt_pad1;
    811 	struct vki_sockaddr	rt_dst;		/* target address		*/
    812 	struct vki_sockaddr	rt_gateway;	/* gateway addr (RTF_GATEWAY)	*/
    813 	struct vki_sockaddr	rt_genmask;	/* target network mask (IP)	*/
    814 	unsigned short	rt_flags;
    815 	short		rt_pad2;
    816 	unsigned long	rt_pad3;
    817 	void		*rt_pad4;
    818 	short		rt_metric;	/* +1 for binary compatibility!	*/
    819 	char __user	*rt_dev;	/* forcing the device at add	*/
    820 	unsigned long	rt_mtu;		/* per route MTU/Window 	*/
    821 // [[Not important for Valgrind]]
    822 //#ifndef __KERNEL__
    823 //#define rt_mss	rt_mtu		/* Compatibility :-(            */
    824 //#endif
    825 	unsigned long	rt_window;	/* Window clamping 		*/
    826 	unsigned short	rt_irtt;	/* Initial RTT			*/
    827 };
    828 
    829 //----------------------------------------------------------------------
    830 // From linux-2.6.13-rc5/include/net/sctp/user.h
    831 //----------------------------------------------------------------------
    832 
    833 typedef __vki_s32 vki_sctp_assoc_t;
    834 
    835 enum vki_sctp_optname {
    836 	VKI_SCTP_RTOINFO,
    837 #define VKI_SCTP_RTOINFO VKI_SCTP_RTOINFO
    838 	VKI_SCTP_ASSOCINFO,
    839 #define VKI_SCTP_ASSOCINFO VKI_SCTP_ASSOCINFO
    840 	VKI_SCTP_INITMSG,
    841 #define VKI_SCTP_INITMSG VKI_SCTP_INITMSG
    842 	VKI_SCTP_NODELAY, 	/* Get/set nodelay option. */
    843 #define VKI_SCTP_NODELAY	VKI_SCTP_NODELAY
    844 	VKI_SCTP_AUTOCLOSE,
    845 #define VKI_SCTP_AUTOCLOSE VKI_SCTP_AUTOCLOSE
    846 	VKI_SCTP_SET_PEER_PRIMARY_ADDR,
    847 #define VKI_SCTP_SET_PEER_PRIMARY_ADDR VKI_SCTP_SET_PEER_PRIMARY_ADDR
    848 	VKI_SCTP_PRIMARY_ADDR,
    849 #define VKI_SCTP_PRIMARY_ADDR VKI_SCTP_PRIMARY_ADDR
    850 	VKI_SCTP_ADAPTION_LAYER,
    851 #define VKI_SCTP_ADAPTION_LAYER VKI_SCTP_ADAPTION_LAYER
    852 	VKI_SCTP_DISABLE_FRAGMENTS,
    853 #define VKI_SCTP_DISABLE_FRAGMENTS VKI_SCTP_DISABLE_FRAGMENTS
    854 	VKI_SCTP_PEER_ADDR_PARAMS,
    855 #define VKI_SCTP_PEER_ADDR_PARAMS VKI_SCTP_PEER_ADDR_PARAMS
    856 	VKI_SCTP_DEFAULT_SEND_PARAM,
    857 #define VKI_SCTP_DEFAULT_SEND_PARAM VKI_SCTP_DEFAULT_SEND_PARAM
    858 	VKI_SCTP_EVENTS,
    859 #define VKI_SCTP_EVENTS VKI_SCTP_EVENTS
    860 	VKI_SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
    861 #define VKI_SCTP_I_WANT_MAPPED_V4_ADDR VKI_SCTP_I_WANT_MAPPED_V4_ADDR
    862 	VKI_SCTP_MAXSEG, 	/* Get/set maximum fragment. */
    863 #define VKI_SCTP_MAXSEG 	VKI_SCTP_MAXSEG
    864 	VKI_SCTP_STATUS,
    865 #define VKI_SCTP_STATUS VKI_SCTP_STATUS
    866 	VKI_SCTP_GET_PEER_ADDR_INFO,
    867 #define VKI_SCTP_GET_PEER_ADDR_INFO VKI_SCTP_GET_PEER_ADDR_INFO
    868 
    869 	/* Internal Socket Options. Some of the sctp library functions are
    870 	 * implemented using these socket options.
    871 	 */
    872 	VKI_SCTP_SOCKOPT_BINDX_ADD = 100,/* BINDX requests for adding addresses. */
    873 #define VKI_SCTP_SOCKOPT_BINDX_ADD	VKI_SCTP_SOCKOPT_BINDX_ADD
    874 	VKI_SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
    875 #define VKI_SCTP_SOCKOPT_BINDX_REM	VKI_SCTP_SOCKOPT_BINDX_REM
    876 	VKI_SCTP_SOCKOPT_PEELOFF, 	/* peel off association. */
    877 #define VKI_SCTP_SOCKOPT_PEELOFF	VKI_SCTP_SOCKOPT_PEELOFF
    878 	VKI_SCTP_GET_PEER_ADDRS_NUM, 	/* Get number of peer addresss. */
    879 #define VKI_SCTP_GET_PEER_ADDRS_NUM	VKI_SCTP_GET_PEER_ADDRS_NUM
    880 	VKI_SCTP_GET_PEER_ADDRS, 	/* Get all peer addresss. */
    881 #define VKI_SCTP_GET_PEER_ADDRS	VKI_SCTP_GET_PEER_ADDRS
    882 	VKI_SCTP_GET_LOCAL_ADDRS_NUM, 	/* Get number of local addresss. */
    883 #define VKI_SCTP_GET_LOCAL_ADDRS_NUM	VKI_SCTP_GET_LOCAL_ADDRS_NUM
    884 	VKI_SCTP_GET_LOCAL_ADDRS, 	/* Get all local addresss. */
    885 #define VKI_SCTP_GET_LOCAL_ADDRS	VKI_SCTP_GET_LOCAL_ADDRS
    886 	VKI_SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
    887 #define VKI_SCTP_SOCKOPT_CONNECTX	VKI_SCTP_SOCKOPT_CONNECTX
    888 };
    889 
    890 struct vki_sctp_getaddrs {
    891 	vki_sctp_assoc_t        assoc_id;
    892 	int			addr_num;
    893 	struct vki_sockaddr	*addrs;
    894 };
    895 
    896 //----------------------------------------------------------------------
    897 // From linux-2.6.8.1/include/linux/resource.h
    898 //----------------------------------------------------------------------
    899 
    900 struct	vki_rusage {
    901 	struct vki_timeval ru_utime;	/* user time used */
    902 	struct vki_timeval ru_stime;	/* system time used */
    903 	long	ru_maxrss;		/* maximum resident set size */
    904 	long	ru_ixrss;		/* integral shared memory size */
    905 	long	ru_idrss;		/* integral unshared data size */
    906 	long	ru_isrss;		/* integral unshared stack size */
    907 	long	ru_minflt;		/* page reclaims */
    908 	long	ru_majflt;		/* page faults */
    909 	long	ru_nswap;		/* swaps */
    910 	long	ru_inblock;		/* block input operations */
    911 	long	ru_oublock;		/* block output operations */
    912 	long	ru_msgsnd;		/* messages sent */
    913 	long	ru_msgrcv;		/* messages received */
    914 	long	ru_nsignals;		/* signals received */
    915 	long	ru_nvcsw;		/* voluntary context switches */
    916 	long	ru_nivcsw;		/* involuntary " */
    917 };
    918 
    919 struct vki_rlimit {
    920 	unsigned long	rlim_cur;
    921 	unsigned long	rlim_max;
    922 };
    923 
    924 //----------------------------------------------------------------------
    925 // From linux-2.6.8.1/include/linux/elfcore.h
    926 //----------------------------------------------------------------------
    927 
    928 struct vki_elf_siginfo
    929 {
    930 	int	si_signo;			/* signal number */
    931 	int	si_code;			/* extra code */
    932 	int	si_errno;			/* errno */
    933 };
    934 
    935 // [[Removed some commented out lines here]]
    936 struct vki_elf_prstatus
    937 {
    938 	struct vki_elf_siginfo pr_info;	/* Info associated with signal */
    939 	short	pr_cursig;		/* Current signal */
    940 	unsigned long pr_sigpend;	/* Set of pending signals */
    941 	unsigned long pr_sighold;	/* Set of held signals */
    942 	vki_pid_t	pr_pid;
    943 	vki_pid_t	pr_ppid;
    944 	vki_pid_t	pr_pgrp;
    945 	vki_pid_t	pr_sid;
    946 	struct vki_timeval pr_utime;	/* User time */
    947 	struct vki_timeval pr_stime;	/* System time */
    948 	struct vki_timeval pr_cutime;	/* Cumulative user time */
    949 	struct vki_timeval pr_cstime;	/* Cumulative system time */
    950 	vki_elf_gregset_t pr_reg;	/* GP registers */
    951 	int pr_fpvalid;		/* True if math co-processor being used.  */
    952 };
    953 
    954 #define VKI_ELF_PRARGSZ	(80)	/* Number of chars for args */
    955 
    956 struct vki_elf_prpsinfo
    957 {
    958 	char	pr_state;	/* numeric process state */
    959 	char	pr_sname;	/* char for pr_state */
    960 	char	pr_zomb;	/* zombie */
    961 	char	pr_nice;	/* nice val */
    962 	unsigned long pr_flag;	/* flags */
    963 	__vki_kernel_uid_t	pr_uid;
    964 	__vki_kernel_gid_t	pr_gid;
    965 	vki_pid_t	pr_pid, pr_ppid, pr_pgrp, pr_sid;
    966 	/* Lots missing */
    967 	char	pr_fname[16];	/* filename of executable */
    968 	char	pr_psargs[VKI_ELF_PRARGSZ];	/* initial part of arg list */
    969 };
    970 
    971 //----------------------------------------------------------------------
    972 // From linux-2.6.12.1/include/linux/eventpoll.h
    973 //----------------------------------------------------------------------
    974 
    975 /* Valid opcodes to issue to sys_epoll_ctl() */
    976 #define VKI_EPOLL_CTL_ADD 1
    977 #define VKI_EPOLL_CTL_DEL 2
    978 #define VKI_EPOLL_CTL_MOD 3
    979 
    980 #ifdef __x86_64__
    981 #define VKI_EPOLL_PACKED __attribute__((packed))
    982 #else
    983 #define VKI_EPOLL_PACKED
    984 #endif
    985 
    986 struct vki_epoll_event {
    987 	__vki_u32 events;
    988 	__vki_u64 data;
    989 } VKI_EPOLL_PACKED;
    990 
    991 
    992 //----------------------------------------------------------------------
    993 // From linux-2.6.8.1/include/linux/mqueue.h
    994 //----------------------------------------------------------------------
    995 
    996 struct vki_mq_attr {
    997 	long	mq_flags;	/* message queue flags			*/
    998 	long	mq_maxmsg;	/* maximum number of messages		*/
    999 	long	mq_msgsize;	/* maximum message size			*/
   1000 	long	mq_curmsgs;	/* number of messages currently queued	*/
   1001 	long	__reserved[4];	/* ignored for input, zeroed for output */
   1002 };
   1003 
   1004 //----------------------------------------------------------------------
   1005 // From linux-2.6.8.1/include/linux/utsname.h
   1006 //----------------------------------------------------------------------
   1007 
   1008 struct vki_new_utsname {
   1009 	char sysname[65];
   1010 	char nodename[65];
   1011 	char release[65];
   1012 	char version[65];
   1013 	char machine[65];
   1014 	char domainname[65];
   1015 };
   1016 
   1017 //----------------------------------------------------------------------
   1018 // From linux-2.6.8.1/include/linux/mii.h
   1019 //----------------------------------------------------------------------
   1020 
   1021 /* This structure is used in all SIOCxMIIxxx ioctl calls */
   1022 struct vki_mii_ioctl_data {
   1023 	vki_u16		phy_id;
   1024 	vki_u16		reg_num;
   1025 	vki_u16		val_in;
   1026 	vki_u16		val_out;
   1027 };
   1028 
   1029 //----------------------------------------------------------------------
   1030 // From linux-2.6.8.1/include/linux/capability.h
   1031 //----------------------------------------------------------------------
   1032 
   1033 // [[capget()/capset() man page says this, ominously:
   1034 //
   1035 //   The kernel API is likely to change and use of these functions  (in
   1036 //   particular the format of the cap_user_*_t types) is subject to
   1037 //   change with each kernel revision.
   1038 //
   1039 // However, the format hasn't changed since at least Linux 2.4.6.]]
   1040 
   1041 typedef struct __vki_user_cap_header_struct {
   1042 	__vki_u32 version;
   1043 	int pid;
   1044 } __user *vki_cap_user_header_t;
   1045 
   1046 typedef struct __vki_user_cap_data_struct {
   1047         __vki_u32 effective;
   1048         __vki_u32 permitted;
   1049         __vki_u32 inheritable;
   1050 } __user *vki_cap_user_data_t;
   1051 
   1052 
   1053 //----------------------------------------------------------------------
   1054 // From linux-2.6.8.1/include/linux/module.h
   1055 //----------------------------------------------------------------------
   1056 
   1057 // [[We do a VKI_SIZEOF_* here because this type is so big, and its size
   1058 //   depends on the word size, so see vki_arch.h]]
   1059 
   1060 //----------------------------------------------------------------------
   1061 // From linux-2.6.8.1/include/linux/ipc.h
   1062 //----------------------------------------------------------------------
   1063 
   1064 /* Obsolete, used only for backwards compatibility and libc5 compiles */
   1065 struct vki_ipc_perm
   1066 {
   1067 	__vki_kernel_key_t	key;
   1068 	__vki_kernel_uid_t	uid;
   1069 	__vki_kernel_gid_t	gid;
   1070 	__vki_kernel_uid_t	cuid;
   1071 	__vki_kernel_gid_t	cgid;
   1072 	__vki_kernel_mode_t	mode;
   1073 	unsigned short	seq;
   1074 };
   1075 
   1076 #define VKI_IPC_CREAT  00001000   /* create if key is nonexistent */
   1077 #define VKI_IPC_EXCL   00002000   /* fail if key exists */
   1078 #define VKI_IPC_NOWAIT 00004000   /* return error on wait */
   1079 
   1080 //#define VKI_IPC_RMID 0     /* remove resource */
   1081 #define VKI_IPC_SET  1     /* set ipc_perm options */
   1082 #define VKI_IPC_STAT 2     /* get ipc_perm options */
   1083 #define VKI_IPC_INFO 3     /* see ipcs */
   1084 
   1085 #define VKI_IPC_64  0x0100  /* New version (support 32-bit UIDs, bigger
   1086 			       message sizes, etc. */
   1087 
   1088 //----------------------------------------------------------------------
   1089 // From linux-2.6.8.1/include/linux/sem.h
   1090 //----------------------------------------------------------------------
   1091 
   1092 #define VKI_GETALL  13       /* get all semval's */
   1093 #define VKI_SETVAL  16       /* set semval */
   1094 #define VKI_SETALL  17       /* set all semval's */
   1095 
   1096 #define VKI_SEM_STAT 18
   1097 #define VKI_SEM_INFO 19
   1098 
   1099 /* Obsolete, used only for backwards compatibility and libc5 compiles */
   1100 struct vki_semid_ds {
   1101 	struct vki_ipc_perm	sem_perm;		/* permissions .. see ipc.h */
   1102 	__vki_kernel_time_t	sem_otime;		/* last semop time */
   1103 	__vki_kernel_time_t	sem_ctime;		/* last change time */
   1104         // [[Use void* to avoid excess header copying]]
   1105 	void/*struct sem	*/*sem_base;		/* ptr to first semaphore in array */
   1106 	void/*struct sem_queue */*sem_pending;		/* pending operations to be processed */
   1107 	void/*struct sem_queue */**sem_pending_last;	/* last pending operation */
   1108 	void/*struct sem_undo	*/*undo;			/* undo requests on this array */
   1109 	unsigned short	sem_nsems;		/* no. of semaphores in array */
   1110 };
   1111 
   1112 struct vki_sembuf {
   1113 	unsigned short  sem_num;	/* semaphore index in array */
   1114 	short		sem_op;		/* semaphore operation */
   1115 	short		sem_flg;	/* operation flags */
   1116 };
   1117 
   1118 union vki_semun {
   1119 	int val;			/* value for SETVAL */
   1120 	struct vki_semid_ds __user *buf;	/* buffer for IPC_STAT & IPC_SET */
   1121 	unsigned short __user *array;	/* array for GETALL & SETALL */
   1122 	struct vki_seminfo __user *__buf;	/* buffer for IPC_INFO */
   1123 	void __user *__pad;
   1124 };
   1125 
   1126 struct  vki_seminfo {
   1127 	int semmap;
   1128 	int semmni;
   1129 	int semmns;
   1130 	int semmnu;
   1131 	int semmsl;
   1132 	int semopm;
   1133 	int semume;
   1134 	int semusz;
   1135 	int semvmx;
   1136 	int semaem;
   1137 };
   1138 
   1139 //----------------------------------------------------------------------
   1140 // From linux-2.6.8.1/include/asm-generic/errno-base.h
   1141 //----------------------------------------------------------------------
   1142 
   1143 #define	VKI_EPERM		 1	/* Operation not permitted */
   1144 #define	VKI_ENOENT		 2	/* No such file or directory */
   1145 #define	VKI_ESRCH		 3	/* No such process */
   1146 #define	VKI_EINTR		 4	/* Interrupted system call */
   1147 #define VKI_ENOEXEC              8      /* Exec format error */
   1148 #define	VKI_EBADF		 9	/* Bad file number */
   1149 #define VKI_ECHILD              10      /* No child processes */
   1150 #define VKI_EAGAIN		11	/* Try again */
   1151 #define VKI_EWOULDBLOCK		VKI_EAGAIN
   1152 #define	VKI_ENOMEM		12	/* Out of memory */
   1153 #define	VKI_EACCES		13	/* Permission denied */
   1154 #define	VKI_EFAULT		14	/* Bad address */
   1155 #define	VKI_EEXIST		17	/* File exists */
   1156 #define	VKI_EINVAL		22	/* Invalid argument */
   1157 #define	VKI_EMFILE		24	/* Too many open files */
   1158 
   1159 //----------------------------------------------------------------------
   1160 // From linux-2.6.8.1/include/asm-generic/errno.h
   1161 //----------------------------------------------------------------------
   1162 
   1163 #define	VKI_ENOSYS		38	/* Function not implemented */
   1164 #define	VKI_EOVERFLOW		75	/* Value too large for defined data type */
   1165 
   1166 //----------------------------------------------------------------------
   1167 // From linux-2.6.8.1/include/linux/wait.h
   1168 //----------------------------------------------------------------------
   1169 
   1170 #define VKI_WNOHANG	0x00000001
   1171 
   1172 #define __VKI_WALL	0x40000000	/* Wait on all children, regardless of type */
   1173 #define __VKI_WCLONE	0x80000000	/* Wait only on non-SIGCHLD children */
   1174 
   1175 //----------------------------------------------------------------------
   1176 // From linux-2.6.8.1/include/linux/mman.h
   1177 //----------------------------------------------------------------------
   1178 
   1179 #define VKI_MREMAP_MAYMOVE	1
   1180 #define VKI_MREMAP_FIXED	2
   1181 
   1182 //----------------------------------------------------------------------
   1183 // From linux-2.6.31-rc4/include/linux/futex.h
   1184 //----------------------------------------------------------------------
   1185 
   1186 #define VKI_FUTEX_WAIT (0)
   1187 #define VKI_FUTEX_WAKE (1)
   1188 #define VKI_FUTEX_FD (2)
   1189 #define VKI_FUTEX_REQUEUE (3)
   1190 #define VKI_FUTEX_CMP_REQUEUE (4)
   1191 #define VKI_FUTEX_WAKE_OP (5)
   1192 #define VKI_FUTEX_LOCK_PI (6)
   1193 #define VKI_FUTEX_UNLOCK_PI (7)
   1194 #define VKI_FUTEX_TRYLOCK_PI (8)
   1195 #define VKI_FUTEX_WAIT_BITSET (9)
   1196 #define VKI_FUTEX_WAKE_BITSET (10)
   1197 #define VKI_FUTEX_WAIT_REQUEUE_PI (11)
   1198 #define VKI_FUTEX_CMP_REQUEUE_PI (12)
   1199 #define VKI_FUTEX_PRIVATE_FLAG (128)
   1200 #define VKI_FUTEX_CLOCK_REALTIME (256)
   1201 
   1202 struct vki_robust_list {
   1203 	struct vki_robust_list __user *next;
   1204 };
   1205 
   1206 struct vki_robust_list_head {
   1207 	/*
   1208 	 * The head of the list. Points back to itself if empty:
   1209 	 */
   1210 	struct vki_robust_list list;
   1211 
   1212 	/*
   1213 	 * This relative offset is set by user-space, it gives the kernel
   1214 	 * the relative position of the futex field to examine. This way
   1215 	 * we keep userspace flexible, to freely shape its data-structure,
   1216 	 * without hardcoding any particular offset into the kernel:
   1217 	 */
   1218 	long futex_offset;
   1219 
   1220 	/*
   1221 	 * The death of the thread may race with userspace setting
   1222 	 * up a lock's links. So to handle this race, userspace first
   1223 	 * sets this field to the address of the to-be-taken lock,
   1224 	 * then does the lock acquire, and then adds itself to the
   1225 	 * list, and then clears this field. Hence the kernel will
   1226 	 * always have full knowledge of all locks that the thread
   1227 	 * _might_ have taken. We check the owner TID in any case,
   1228 	 * so only truly owned locks will be handled.
   1229 	 */
   1230 	struct vki_robust_list __user *list_op_pending;
   1231 };
   1232 
   1233 //----------------------------------------------------------------------
   1234 // From linux-2.6.8.1/include/linux/errno.h
   1235 //----------------------------------------------------------------------
   1236 
   1237 #define VKI_ERESTARTSYS	512
   1238 
   1239 //----------------------------------------------------------------------
   1240 // From linux-2.6.8.1/include/linux/stat.h
   1241 //----------------------------------------------------------------------
   1242 
   1243 #define VKI_S_IFMT  00170000
   1244 #define VKI_S_IFSOCK 0140000
   1245 #define VKI_S_IFLNK  0120000
   1246 #define VKI_S_IFREG  0100000
   1247 #define VKI_S_IFBLK  0060000
   1248 #define VKI_S_IFDIR  0040000
   1249 #define VKI_S_IFCHR  0020000
   1250 #define VKI_S_IFIFO  0010000
   1251 #define VKI_S_ISUID  0004000
   1252 #define VKI_S_ISGID  0002000
   1253 #define VKI_S_ISVTX  0001000
   1254 
   1255 #define VKI_S_ISLNK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFLNK)
   1256 #define VKI_S_ISREG(m)	(((m) & VKI_S_IFMT) == VKI_S_IFREG)
   1257 #define VKI_S_ISDIR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFDIR)
   1258 #define VKI_S_ISCHR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFCHR)
   1259 #define VKI_S_ISBLK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFBLK)
   1260 #define VKI_S_ISFIFO(m)	(((m) & VKI_S_IFMT) == VKI_S_IFIFO)
   1261 #define VKI_S_ISSOCK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
   1262 
   1263 #define VKI_S_IRWXU 00700
   1264 #define VKI_S_IRUSR 00400
   1265 #define VKI_S_IWUSR 00200
   1266 #define VKI_S_IXUSR 00100
   1267 
   1268 #define VKI_S_IRWXG 00070
   1269 #define VKI_S_IRGRP 00040
   1270 #define VKI_S_IWGRP 00020
   1271 #define VKI_S_IXGRP 00010
   1272 
   1273 #define VKI_S_IRWXO 00007
   1274 #define VKI_S_IROTH 00004
   1275 #define VKI_S_IWOTH 00002
   1276 #define VKI_S_IXOTH 00001
   1277 
   1278 //----------------------------------------------------------------------
   1279 // From linux-2.6.8.1/include/linux/dirent.h
   1280 //----------------------------------------------------------------------
   1281 
   1282 struct vki_dirent {
   1283 	long		d_ino;
   1284 	__vki_kernel_off_t	d_off;
   1285 	unsigned short	d_reclen;
   1286 	char		d_name[256]; /* We must not include limits.h! */
   1287 };
   1288 
   1289 //----------------------------------------------------------------------
   1290 // From linux-2.6.8.1/include/linux/fcntl.h
   1291 //----------------------------------------------------------------------
   1292 
   1293 #define VKI_F_SETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 0)
   1294 #define VKI_F_GETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 1)
   1295 
   1296 #define VKI_F_CANCELLK      (VKI_F_LINUX_SPECIFIC_BASE + 5)
   1297 
   1298 #define VKI_F_DUPFD_CLOEXEC (VKI_F_LINUX_SPECIFIC_BASE + 6)
   1299 
   1300 #define VKI_F_NOTIFY        (VKI_F_LINUX_SPECIFIC_BASE + 2)
   1301 
   1302 #define VKI_F_SETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 7)
   1303 #define VKI_F_GETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 8)
   1304 
   1305 //----------------------------------------------------------------------
   1306 // From linux-2.6.8.1/include/linux/sysctl.h
   1307 //----------------------------------------------------------------------
   1308 
   1309 struct __vki_sysctl_args {
   1310 	int __user *name;
   1311 	int nlen;
   1312 	void __user *oldval;
   1313 	vki_size_t __user *oldlenp;
   1314 	void __user *newval;
   1315 	vki_size_t newlen;
   1316 	unsigned long __unused1[4];
   1317 };
   1318 
   1319 //----------------------------------------------------------------------
   1320 // From linux-2.6.8.1/include/linux/aio_abi.h
   1321 //----------------------------------------------------------------------
   1322 
   1323 typedef unsigned long	vki_aio_context_t;
   1324 
   1325 enum {
   1326 	VKI_IOCB_CMD_PREAD = 0,
   1327 	VKI_IOCB_CMD_PWRITE = 1,
   1328 	VKI_IOCB_CMD_FSYNC = 2,
   1329 	VKI_IOCB_CMD_FDSYNC = 3,
   1330 	VKI_IOCB_CMD_PREADV = 7,
   1331 	VKI_IOCB_CMD_PWRITEV = 8,
   1332 };
   1333 
   1334 /* read() from /dev/aio returns these structures. */
   1335 struct vki_io_event {
   1336 	__vki_u64	data;		/* the data field from the iocb */
   1337 	__vki_u64	obj;		/* what iocb this event came from */
   1338         // [[Nb: These fields renamed from 'res' and 'res2' because 'res' is
   1339         //   a macro in vg_syscalls.c!]]
   1340 	__vki_s64	result;		/* result code for this event */
   1341 	__vki_s64	result2;	/* secondary result */
   1342 };
   1343 
   1344 #if defined(VKI_LITTLE_ENDIAN)
   1345 #  define VKI_PADDED(x,y)	x, y
   1346 #elif defined(VKI_BIG_ENDIAN)
   1347 #  define VKI_PADDED(x,y)	y, x
   1348 #else
   1349 #error edit for your odd byteorder.
   1350 #endif
   1351 
   1352 struct vki_iocb {
   1353 	/* these are internal to the kernel/libc. */
   1354 	__vki_u64	aio_data;	/* data to be returned in event's data */
   1355 	__vki_u32	VKI_PADDED(aio_key, aio_reserved1);
   1356 				/* the kernel sets aio_key to the req # */
   1357 
   1358 	/* common fields */
   1359 	__vki_u16	aio_lio_opcode;	/* see IOCB_CMD_ above */
   1360 	__vki_s16	aio_reqprio;
   1361 	__vki_u32	aio_fildes;
   1362 
   1363 	__vki_u64	aio_buf;
   1364 	__vki_u64	aio_nbytes;
   1365 	__vki_s64	aio_offset;
   1366 
   1367 	/* extra parameters */
   1368 	__vki_u64	aio_reserved2;	/* TODO: use this for a (struct sigevent *) */
   1369 	__vki_u64	aio_reserved3;
   1370 }; /* 64 bytes */
   1371 
   1372 //----------------------------------------------------------------------
   1373 // From linux-2.6.8.1/include/linux/aio.h
   1374 //----------------------------------------------------------------------
   1375 
   1376 struct vki_aio_ring {
   1377 	unsigned	id;	/* kernel internal index number */
   1378 	unsigned	nr;	/* number of io_events */
   1379 	unsigned	head;
   1380 	unsigned	tail;
   1381 
   1382 	unsigned	magic;
   1383 	unsigned	compat_features;
   1384 	unsigned	incompat_features;
   1385 	unsigned	header_length;	/* size of aio_ring */
   1386 
   1387 	struct vki_io_event		io_events[0];
   1388 }; /* 128 bytes + ring size */
   1389 
   1390 //----------------------------------------------------------------------
   1391 // From linux-2.6.8.1/include/linux/msg.h
   1392 //----------------------------------------------------------------------
   1393 
   1394 #define VKI_MSG_STAT 11
   1395 #define VKI_MSG_INFO 12
   1396 
   1397 struct vki_msqid_ds {
   1398 	struct vki_ipc_perm msg_perm;
   1399 	struct vki_msg *msg_first;		/* first message on queue,unused  */
   1400 	struct vki_msg *msg_last;		/* last message in queue,unused */
   1401 	__vki_kernel_time_t msg_stime;	/* last msgsnd time */
   1402 	__vki_kernel_time_t msg_rtime;	/* last msgrcv time */
   1403 	__vki_kernel_time_t msg_ctime;	/* last change time */
   1404 	unsigned long  msg_lcbytes;	/* Reuse junk fields for 32 bit */
   1405 	unsigned long  msg_lqbytes;	/* ditto */
   1406 	unsigned short msg_cbytes;	/* current number of bytes on queue */
   1407 	unsigned short msg_qnum;	/* number of messages in queue */
   1408 	unsigned short msg_qbytes;	/* max number of bytes on queue */
   1409 	__vki_kernel_ipc_pid_t msg_lspid;	/* pid of last msgsnd */
   1410 	__vki_kernel_ipc_pid_t msg_lrpid;	/* last receive pid */
   1411 };
   1412 
   1413 struct vki_msgbuf {
   1414 	long mtype;         /* type of message */
   1415 	char mtext[1];      /* message text */
   1416 };
   1417 
   1418 struct vki_msginfo {
   1419 	int msgpool;
   1420 	int msgmap;
   1421 	int msgmax;
   1422 	int msgmnb;
   1423 	int msgmni;
   1424 	int msgssz;
   1425 	int msgtql;
   1426 	unsigned short  msgseg;
   1427 };
   1428 
   1429 //----------------------------------------------------------------------
   1430 // From linux-2.6.8.1/include/linux/shm.h
   1431 //----------------------------------------------------------------------
   1432 
   1433 struct vki_shmid_ds {
   1434 	struct vki_ipc_perm		shm_perm;	/* operation perms */
   1435 	int			shm_segsz;	/* size of segment (bytes) */
   1436 	__vki_kernel_time_t		shm_atime;	/* last attach time */
   1437 	__vki_kernel_time_t		shm_dtime;	/* last detach time */
   1438 	__vki_kernel_time_t		shm_ctime;	/* last change time */
   1439 	__vki_kernel_ipc_pid_t	shm_cpid;	/* pid of creator */
   1440 	__vki_kernel_ipc_pid_t	shm_lpid;	/* pid of last operator */
   1441 	unsigned short		shm_nattch;	/* no. of current attaches */
   1442 	unsigned short 		shm_unused;	/* compatibility */
   1443 	void 			*shm_unused2;	/* ditto - used by DIPC */
   1444 	void			*shm_unused3;	/* unused */
   1445 };
   1446 
   1447 #define VKI_SHM_RDONLY  010000  /* read-only access */
   1448 #define VKI_SHM_RND     020000  /* round attach address to SHMLBA boundary */
   1449 
   1450 #define VKI_SHM_STAT 	13
   1451 #define VKI_SHM_INFO 	14
   1452 
   1453 /* Obsolete, used only for backwards compatibility */
   1454 struct	vki_shminfo {
   1455 	int shmmax;
   1456 	int shmmin;
   1457 	int shmmni;
   1458 	int shmseg;
   1459 	int shmall;
   1460 };
   1461 
   1462 struct vki_shm_info {
   1463 	int used_ids;
   1464 	unsigned long shm_tot;	/* total allocated shm */
   1465 	unsigned long shm_rss;	/* total resident shm */
   1466 	unsigned long shm_swp;	/* total swapped shm */
   1467 	unsigned long swap_attempts;
   1468 	unsigned long swap_successes;
   1469 };
   1470 
   1471 //----------------------------------------------------------------------
   1472 // From linux-2.6.8.1/include/linux/rtc.h
   1473 //----------------------------------------------------------------------
   1474 
   1475 struct vki_rtc_time {
   1476 	int tm_sec;
   1477 	int tm_min;
   1478 	int tm_hour;
   1479 	int tm_mday;
   1480 	int tm_mon;
   1481 	int tm_year;
   1482 	int tm_wday;
   1483 	int tm_yday;
   1484 	int tm_isdst;
   1485 };
   1486 
   1487 #define VKI_RTC_AIE_ON	_VKI_IO('p', 0x01)	/* Alarm int. enable on	*/
   1488 #define VKI_RTC_AIE_OFF	_VKI_IO('p', 0x02)	/* ... off		*/
   1489 #define VKI_RTC_UIE_ON	_VKI_IO('p', 0x03)	/* Update int. enable on*/
   1490 #define VKI_RTC_UIE_OFF	_VKI_IO('p', 0x04)	/* ... off		*/
   1491 #define VKI_RTC_PIE_ON	_VKI_IO('p', 0x05)	/* Periodic int. enable on*/
   1492 #define VKI_RTC_PIE_OFF	_VKI_IO('p', 0x06)	/* ... off		*/
   1493 
   1494 #define VKI_RTC_ALM_SET		_VKI_IOW('p', 0x07, struct vki_rtc_time) /* Set alarm time  */
   1495 #define VKI_RTC_ALM_READ	_VKI_IOR('p', 0x08, struct vki_rtc_time) /* Read alarm time */
   1496 #define VKI_RTC_RD_TIME		_VKI_IOR('p', 0x09, struct vki_rtc_time) /* Read RTC time   */
   1497 //#define RTC_SET_TIME	_IOW('p', 0x0a, struct rtc_time) /* Set RTC time    */
   1498 #define VKI_RTC_IRQP_READ	_VKI_IOR('p', 0x0b, unsigned long)	 /* Read IRQ rate   */
   1499 #define VKI_RTC_IRQP_SET	_VKI_IOW('p', 0x0c, unsigned long)	 /* Set IRQ rate    */
   1500 
   1501 //----------------------------------------------------------------------
   1502 // From linux-2.6.8.1/include/linux/isdn.h
   1503 //----------------------------------------------------------------------
   1504 
   1505 // [[Nb: Resolved this for the common case where CONFIG_COBALT_MICRO_SERVER
   1506 //   is not defined]]
   1507 #define VKI_ISDN_MAX_CHANNELS   64
   1508 
   1509 #define VKI_IIOCGETCPS  _VKI_IO('I',21)
   1510 
   1511 #define VKI_IIOCNETGPN  _VKI_IO('I',34)
   1512 
   1513 #define VKI_ISDN_MSNLEN          32
   1514 
   1515 typedef struct {
   1516   char name[10];
   1517   char phone[VKI_ISDN_MSNLEN];
   1518   int  outgoing;
   1519 } vki_isdn_net_ioctl_phone;
   1520 
   1521 //----------------------------------------------------------------------
   1522 // From linux-2.6.8.1/include/linux/sockios.h
   1523 //----------------------------------------------------------------------
   1524 
   1525 #define VKI_SIOCOUTQ		VKI_TIOCOUTQ
   1526 
   1527 #define VKI_SIOCADDRT		0x890B	/* add routing table entry	*/
   1528 #define VKI_SIOCDELRT		0x890C	/* delete routing table entry	*/
   1529 
   1530 #define VKI_SIOCGIFNAME		0x8910	/* get iface name		*/
   1531 #define VKI_SIOCGIFCONF		0x8912	/* get iface list		*/
   1532 #define VKI_SIOCGIFFLAGS	0x8913	/* get flags			*/
   1533 #define VKI_SIOCSIFFLAGS	0x8914	/* set flags			*/
   1534 #define VKI_SIOCGIFADDR		0x8915	/* get PA address		*/
   1535 #define VKI_SIOCSIFADDR		0x8916	/* set PA address		*/
   1536 #define VKI_SIOCGIFDSTADDR	0x8917	/* get remote PA address	*/
   1537 #define VKI_SIOCSIFDSTADDR	0x8918	/* set remote PA address	*/
   1538 #define VKI_SIOCGIFBRDADDR	0x8919	/* get broadcast PA address	*/
   1539 #define VKI_SIOCSIFBRDADDR	0x891a	/* set broadcast PA address	*/
   1540 #define VKI_SIOCGIFNETMASK	0x891b	/* get network PA mask		*/
   1541 #define VKI_SIOCSIFNETMASK	0x891c	/* set network PA mask		*/
   1542 #define VKI_SIOCGIFMETRIC	0x891d	/* get metric			*/
   1543 #define VKI_SIOCSIFMETRIC	0x891e	/* set metric			*/
   1544 #define VKI_SIOCGIFMTU		0x8921	/* get MTU size			*/
   1545 #define VKI_SIOCSIFMTU		0x8922	/* set MTU size			*/
   1546 #define	VKI_SIOCSIFHWADDR	0x8924	/* set hardware address 	*/
   1547 #define VKI_SIOCGIFHWADDR	0x8927	/* Get hardware address		*/
   1548 #define VKI_SIOCGIFINDEX	0x8933	/* name -> if_index mapping	*/
   1549 
   1550 #define VKI_SIOCGIFTXQLEN	0x8942	/* Get the tx queue length	*/
   1551 #define VKI_SIOCSIFTXQLEN	0x8943	/* Set the tx queue length 	*/
   1552 
   1553 #define VKI_SIOCGMIIPHY		0x8947	/* Get address of MII PHY in use. */
   1554 #define VKI_SIOCGMIIREG		0x8948	/* Read MII PHY register.	*/
   1555 #define VKI_SIOCSMIIREG		0x8949	/* Write MII PHY register.	*/
   1556 
   1557 #define VKI_SIOCDARP		0x8953	/* delete ARP table entry	*/
   1558 #define VKI_SIOCGARP		0x8954	/* get ARP table entry		*/
   1559 #define VKI_SIOCSARP		0x8955	/* set ARP table entry		*/
   1560 
   1561 #define VKI_SIOCDRARP		0x8960	/* delete RARP table entry	*/
   1562 #define VKI_SIOCGRARP		0x8961	/* get RARP table entry		*/
   1563 #define VKI_SIOCSRARP		0x8962	/* set RARP table entry		*/
   1564 
   1565 #define VKI_SIOCGIFMAP		0x8970	/* Get device parameters	*/
   1566 #define VKI_SIOCSIFMAP		0x8971	/* Set device parameters	*/
   1567 
   1568 //----------------------------------------------------------------------
   1569 // From linux-2.6.8.1/include/linux/ppdev.h
   1570 //----------------------------------------------------------------------
   1571 
   1572 #define VKI_PP_MAJOR	99
   1573 
   1574 #define VKI_PP_IOCTL	'p'
   1575 
   1576 /* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */
   1577 #define VKI_PPSETMODE	_VKI_IOW(VKI_PP_IOCTL, 0x80, int)
   1578 
   1579 /* Read status */
   1580 #define VKI_PPRSTATUS	_VKI_IOR(VKI_PP_IOCTL, 0x81, unsigned char)
   1581 //#define PPWSTATUS	OBSOLETE__IOW(PP_IOCTL, 0x82, unsigned char)
   1582 
   1583 /* Read/write control */
   1584 #define VKI_PPRCONTROL	_VKI_IOR(VKI_PP_IOCTL, 0x83, unsigned char)
   1585 #define VKI_PPWCONTROL	_VKI_IOW(VKI_PP_IOCTL, 0x84, unsigned char)
   1586 
   1587 struct vki_ppdev_frob_struct {
   1588 	unsigned char mask;
   1589 	unsigned char val;
   1590 };
   1591 #define VKI_PPFCONTROL      _VKI_IOW(VKI_PP_IOCTL, 0x8e, struct vki_ppdev_frob_struct)
   1592 
   1593 /* Read/write data */
   1594 #define VKI_PPRDATA		_VKI_IOR(VKI_PP_IOCTL, 0x85, unsigned char)
   1595 #define VKI_PPWDATA		_VKI_IOW(VKI_PP_IOCTL, 0x86, unsigned char)
   1596 
   1597 /* Claim the port to start using it */
   1598 #define VKI_PPCLAIM		_VKI_IO(VKI_PP_IOCTL, 0x8b)
   1599 
   1600 /* Release the port when you aren't using it */
   1601 #define VKI_PPRELEASE	_VKI_IO(VKI_PP_IOCTL, 0x8c)
   1602 
   1603 /* Yield the port (release it if another driver is waiting,
   1604  * then reclaim) */
   1605 #define VKI_PPYIELD		_VKI_IO(VKI_PP_IOCTL, 0x8d)
   1606 
   1607 /* Register device exclusively (must be before PPCLAIM). */
   1608 #define VKI_PPEXCL		_VKI_IO(VKI_PP_IOCTL, 0x8f)
   1609 
   1610 /* Data line direction: non-zero for input mode. */
   1611 #define VKI_PPDATADIR	_VKI_IOW(VKI_PP_IOCTL, 0x90, int)
   1612 
   1613 /* Negotiate a particular IEEE 1284 mode. */
   1614 #define VKI_PPNEGOT	_VKI_IOW(VKI_PP_IOCTL, 0x91, int)
   1615 
   1616 /* Set control lines when an interrupt occurs. */
   1617 #define VKI_PPWCTLONIRQ	_VKI_IOW(VKI_PP_IOCTL, 0x92, unsigned char)
   1618 
   1619 /* Clear (and return) interrupt count. */
   1620 #define VKI_PPCLRIRQ	_VKI_IOR(VKI_PP_IOCTL, 0x93, int)
   1621 
   1622 /* Set the IEEE 1284 phase that we're in (e.g. IEEE1284_PH_FWD_IDLE) */
   1623 #define VKI_PPSETPHASE	_VKI_IOW(VKI_PP_IOCTL, 0x94, int)
   1624 
   1625 /* Set and get port timeout (struct timeval's) */
   1626 #define VKI_PPGETTIME	_VKI_IOR(VKI_PP_IOCTL, 0x95, struct vki_timeval)
   1627 #define VKI_PPSETTIME	_VKI_IOW(VKI_PP_IOCTL, 0x96, struct vki_timeval)
   1628 
   1629 #define VKI_PPGETMODES	_VKI_IOR(VKI_PP_IOCTL, 0x97, unsigned int)
   1630 
   1631 #define VKI_PPGETMODE	_VKI_IOR(VKI_PP_IOCTL, 0x98, int)
   1632 #define VKI_PPGETPHASE	_VKI_IOR(VKI_PP_IOCTL, 0x99, int)
   1633 
   1634 #define VKI_PPGETFLAGS	_VKI_IOR(VKI_PP_IOCTL, 0x9a, int)
   1635 #define VKI_PPSETFLAGS	_VKI_IOW(VKI_PP_IOCTL, 0x9b, int)
   1636 
   1637 //----------------------------------------------------------------------
   1638 // From linux-2.6.8.1/include/linux/fs.h
   1639 //----------------------------------------------------------------------
   1640 
   1641 #define VKI_BLKROSET   _VKI_IO(0x12,93)	/* set device read-only (0 = read-write) */
   1642 #define VKI_BLKROGET   _VKI_IO(0x12,94)	/* get read-only status (0 = read_write) */
   1643 #define VKI_BLKGETSIZE _VKI_IO(0x12,96) /* return device size /512 (long *arg) */
   1644 #define VKI_BLKRASET   _VKI_IO(0x12,98)	/* set read ahead for block device */
   1645 #define VKI_BLKRAGET   _VKI_IO(0x12,99)	/* get current read ahead setting */
   1646 #define VKI_BLKFRASET  _VKI_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
   1647 #define VKI_BLKFRAGET  _VKI_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
   1648 #define VKI_BLKSECTGET _VKI_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
   1649 #define VKI_BLKSSZGET  _VKI_IO(0x12,104)/* get block device sector size */
   1650 #define VKI_BLKBSZGET  _VKI_IOR(0x12,112,vki_size_t)
   1651 #define VKI_BLKBSZSET  _VKI_IOW(0x12,113,vki_size_t)
   1652 #define VKI_BLKGETSIZE64 _VKI_IOR(0x12,114,vki_size_t) /* return device size in bytes (u64 *arg) */
   1653 
   1654 #define VKI_FIBMAP	_VKI_IO(0x00,1)	/* bmap access */
   1655 #define VKI_FIGETBSZ    _VKI_IO(0x00,2)	/* get the block size used for bmap */
   1656 
   1657 //----------------------------------------------------------------------
   1658 // From linux-2.6.8.1/include/scsi/sg.h
   1659 //----------------------------------------------------------------------
   1660 
   1661 typedef struct vki_sg_io_hdr
   1662 {
   1663     int interface_id;           /* [i] 'S' for SCSI generic (required) */
   1664     int dxfer_direction;        /* [i] data transfer direction  */
   1665     unsigned char cmd_len;      /* [i] SCSI command length ( <= 16 bytes) */
   1666     unsigned char mx_sb_len;    /* [i] max length to write to sbp */
   1667     unsigned short iovec_count; /* [i] 0 implies no scatter gather */
   1668     unsigned int dxfer_len;     /* [i] byte count of data transfer */
   1669     void __user *dxferp;	/* [i], [*io] points to data transfer memory
   1670 					      or scatter gather list */
   1671     unsigned char __user *cmdp; /* [i], [*i] points to command to perform */
   1672     void __user *sbp;		/* [i], [*o] points to sense_buffer memory */
   1673     unsigned int timeout;       /* [i] MAX_UINT->no timeout (unit: millisec) */
   1674     unsigned int flags;         /* [i] 0 -> default, see SG_FLAG... */
   1675     int pack_id;                /* [i->o] unused internally (normally) */
   1676     void __user * usr_ptr;      /* [i->o] unused internally */
   1677     unsigned char status;       /* [o] scsi status */
   1678     unsigned char masked_status;/* [o] shifted, masked scsi status */
   1679     unsigned char msg_status;   /* [o] messaging level data (optional) */
   1680     unsigned char sb_len_wr;    /* [o] byte count actually written to sbp */
   1681     unsigned short host_status; /* [o] errors from host adapter */
   1682     unsigned short driver_status;/* [o] errors from software driver */
   1683     int resid;                  /* [o] dxfer_len - actual_transferred */
   1684     unsigned int duration;      /* [o] time taken by cmd (unit: millisec) */
   1685     unsigned int info;          /* [o] auxiliary information */
   1686 } vki_sg_io_hdr_t;  /* 64 bytes long (on i386) */
   1687 
   1688 typedef struct vki_sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */
   1689     int host_no;        /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */
   1690     int channel;
   1691     int scsi_id;        /* scsi id of target device */
   1692     int lun;
   1693     int scsi_type;      /* TYPE_... defined in scsi/scsi.h */
   1694     short h_cmd_per_lun;/* host (adapter) maximum commands per lun */
   1695     short d_queue_depth;/* device (or adapter) maximum queue length */
   1696     int unused[2];      /* probably find a good use, set 0 for now */
   1697 } vki_sg_scsi_id_t; /* 32 bytes long on i386 */
   1698 
   1699 #define VKI_SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */
   1700 
   1701 #define VKI_SG_SET_RESERVED_SIZE 0x2275  /* request a new reserved buffer size */
   1702 #define VKI_SG_GET_RESERVED_SIZE 0x2272  /* actual size of reserved buffer */
   1703 
   1704 #define VKI_SG_GET_SCSI_ID 0x2276   /* Yields fd's bus, chan, dev, lun + type */
   1705 
   1706 #define VKI_SG_GET_SG_TABLESIZE 0x227F  /* 0 implies can't do scatter gather */
   1707 
   1708 #define VKI_SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
   1709 
   1710 #define VKI_SG_IO 0x2285   /* similar effect as write() followed by read() */
   1711 
   1712 #define VKI_SG_SET_TIMEOUT 0x2201  /* unit: jiffies (10ms on i386) */
   1713 #define VKI_SG_GET_TIMEOUT 0x2202  /* yield timeout as _return_ value */
   1714 
   1715 //#define SG_GET_COMMAND_Q 0x2270   /* Yields 0 (queuing off) or 1 (on) */
   1716 #define VKI_SG_SET_COMMAND_Q 0x2271   /* Change queuing state with 0 or 1 */
   1717 
   1718 //----------------------------------------------------------------------
   1719 // From linux-2.6.8.1/include/linux/cdrom.h
   1720 //----------------------------------------------------------------------
   1721 
   1722 #define VKI_CDROMPLAYMSF	0x5303 /* Play Audio MSF (struct cdrom_msf) */
   1723 #define VKI_CDROMREADTOCHDR	0x5305 /* Read TOC header
   1724                                            (struct cdrom_tochdr) */
   1725 #define VKI_CDROMREADTOCENTRY	0x5306 /* Read TOC entry
   1726                                            (struct cdrom_tocentry) */
   1727 #define VKI_CDROMSUBCHNL	0x530b /* Read subchannel data
   1728                                            (struct cdrom_subchnl) */
   1729 #define VKI_CDROMREADMODE2	0x530c /* Read CDROM mode 2 data (2336 Bytes)
   1730                                            (struct cdrom_read) */
   1731 #define VKI_CDROMREADAUDIO	0x530e /* (struct cdrom_read_audio) */
   1732 #define VKI_CDROMMULTISESSION	0x5310 /* Obtain the start-of-last-session
   1733                                            address of multi session disks
   1734                                            (struct cdrom_multisession) */
   1735 #define VKI_CDROM_GET_MCN	0x5311 /* Obtain the "Universal Product Code"
   1736                                            if available (struct cdrom_mcn) */
   1737 #define VKI_CDROMVOLREAD	0x5313 /* Get the drive's volume setting
   1738                                           (struct cdrom_volctrl) */
   1739 #define VKI_CDROMREADRAW	0x5314	/* read data in raw mode (2352 Bytes)
   1740                                            (struct cdrom_read) */
   1741 #define VKI_CDROM_CLEAR_OPTIONS	0x5321  /* Clear behavior options */
   1742 #define VKI_CDROM_DRIVE_STATUS	0x5326  /* Get tray position, etc. */
   1743 
   1744 #define VKI_CDROM_SEND_PACKET	0x5393	/* send a packet to the drive */
   1745 
   1746 struct vki_cdrom_msf0
   1747 {
   1748 	__vki_u8	minute;
   1749 	__vki_u8	second;
   1750 	__vki_u8	frame;
   1751 };
   1752 
   1753 union vki_cdrom_addr
   1754 {
   1755 	struct vki_cdrom_msf0	msf;
   1756 	int			lba;
   1757 };
   1758 
   1759 struct vki_cdrom_msf
   1760 {
   1761 	__vki_u8	cdmsf_min0;	/* start minute */
   1762 	__vki_u8	cdmsf_sec0;	/* start second */
   1763 	__vki_u8	cdmsf_frame0;	/* start frame */
   1764 	__vki_u8	cdmsf_min1;	/* end minute */
   1765 	__vki_u8	cdmsf_sec1;	/* end second */
   1766 	__vki_u8	cdmsf_frame1;	/* end frame */
   1767 };
   1768 
   1769 struct vki_cdrom_tochdr
   1770 {
   1771 	__vki_u8	cdth_trk0;	/* start track */
   1772 	__vki_u8	cdth_trk1;	/* end track */
   1773 };
   1774 
   1775 struct vki_cdrom_volctrl
   1776 {
   1777 	__vki_u8	channel0;
   1778 	__vki_u8	channel1;
   1779 	__vki_u8	channel2;
   1780 	__vki_u8	channel3;
   1781 };
   1782 
   1783 struct vki_cdrom_subchnl
   1784 {
   1785 	__vki_u8	cdsc_format;
   1786 	__vki_u8	cdsc_audiostatus;
   1787 	__vki_u8	cdsc_adr:	4;
   1788 	__vki_u8	cdsc_ctrl:	4;
   1789 	__vki_u8	cdsc_trk;
   1790 	__vki_u8	cdsc_ind;
   1791 	union vki_cdrom_addr cdsc_absaddr;
   1792 	union vki_cdrom_addr cdsc_reladdr;
   1793 };
   1794 
   1795 struct vki_cdrom_tocentry
   1796 {
   1797 	__vki_u8	cdte_track;
   1798 	__vki_u8	cdte_adr	:4;
   1799 	__vki_u8	cdte_ctrl	:4;
   1800 	__vki_u8	cdte_format;
   1801 	union vki_cdrom_addr cdte_addr;
   1802 	__vki_u8	cdte_datamode;
   1803 };
   1804 
   1805 struct vki_cdrom_read
   1806 {
   1807 	int	cdread_lba;
   1808 	char 	*cdread_bufaddr;
   1809 	int	cdread_buflen;
   1810 };
   1811 
   1812 struct vki_cdrom_read_audio
   1813 {
   1814 	union vki_cdrom_addr addr; /* frame address */
   1815 	__vki_u8 addr_format;      /* CDROM_LBA or CDROM_MSF */
   1816 	int nframes;           /* number of 2352-byte-frames to read at once */
   1817 	__vki_u8 __user *buf;      /* frame buffer (size: nframes*2352 bytes) */
   1818 };
   1819 
   1820 struct vki_cdrom_multisession
   1821 {
   1822 	union vki_cdrom_addr addr; /* frame address: start-of-last-session
   1823 	                           (not the new "frame 16"!).  Only valid
   1824 	                           if the "xa_flag" is true. */
   1825 	__vki_u8 xa_flag;        /* 1: "is XA disk" */
   1826 	__vki_u8 addr_format;    /* CDROM_LBA or CDROM_MSF */
   1827 };
   1828 
   1829 struct vki_cdrom_mcn
   1830 {
   1831   __vki_u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
   1832 };
   1833 
   1834 #define VKI_CDROM_PACKET_SIZE	12
   1835 
   1836 struct vki_cdrom_generic_command
   1837 {
   1838 	unsigned char 		cmd[VKI_CDROM_PACKET_SIZE];
   1839 	unsigned char		__user *buffer;
   1840 	unsigned int 		buflen;
   1841 	int			stat;
   1842         // [[replace with void* to reduce inclusion amounts]]
   1843 	void/*struct vki_request_sense	*/__user *sense;
   1844 	unsigned char		data_direction;
   1845 	int			quiet;
   1846 	int			timeout;
   1847 	void			__user *reserved[1];	/* unused, actually */
   1848 };
   1849 
   1850 #define VKI_CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
   1851 #define VKI_CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
   1852 #define VKI_CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
   1853 #define VKI_CD_FRAMESIZE_RAW0 (VKI_CD_FRAMESIZE_RAW-VKI_CD_SYNC_SIZE-VKI_CD_HEAD_SIZE) /*2336*/
   1854 
   1855 //----------------------------------------------------------------------
   1856 // From linux-2.6.8.1/include/linux/soundcard.h
   1857 //----------------------------------------------------------------------
   1858 
   1859 #ifndef _VKI_SIOWR
   1860 #if defined(_VKI_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__)))
   1861 /* Use already defined ioctl defines if they exist (except with Sun or Sparc) */
   1862 #define	_VKI_SIO		_VKI_IO
   1863 #define	_VKI_SIOR		_VKI_IOR
   1864 #define	_VKI_SIOW		_VKI_IOW
   1865 #define	_VKI_SIOWR		_VKI_IOWR
   1866 #else
   1867 // [[Valgrind: Install this case if/when necessary]
   1868 #error Valgrind: Cannot handle sparc/sun case yet...
   1869 #  endif /* _IOWR */
   1870 #endif  /* !_VKI_SIOWR */
   1871 
   1872 #define VKI_SNDCTL_SEQ_CTRLRATE		_VKI_SIOWR('Q', 3, int)	/* Set/get timer resolution (HZ) */
   1873 #define VKI_SNDCTL_SEQ_GETOUTCOUNT	_VKI_SIOR ('Q', 4, int)
   1874 #define VKI_SNDCTL_SEQ_GETINCOUNT	_VKI_SIOR ('Q', 5, int)
   1875 #define VKI_SNDCTL_SEQ_PERCMODE		_VKI_SIOW ('Q', 6, int)
   1876 #define VKI_SNDCTL_SEQ_TESTMIDI		_VKI_SIOW ('Q', 8, int)
   1877 #define VKI_SNDCTL_SEQ_RESETSAMPLES	_VKI_SIOW ('Q', 9, int)
   1878 #define VKI_SNDCTL_SEQ_NRSYNTHS		_VKI_SIOR ('Q',10, int)
   1879 #define VKI_SNDCTL_SEQ_NRMIDIS		_VKI_SIOR ('Q',11, int)
   1880 #define VKI_SNDCTL_SEQ_GETTIME		_VKI_SIOR ('Q',19, int)
   1881 
   1882 #define VKI_SNDCTL_TMR_TIMEBASE		_VKI_SIOWR('T', 1, int)
   1883 #define VKI_SNDCTL_TMR_TEMPO		_VKI_SIOWR('T', 5, int)
   1884 #define VKI_SNDCTL_TMR_SOURCE		_VKI_SIOWR('T', 6, int)
   1885 
   1886 #define VKI_SNDCTL_MIDI_PRETIME		_VKI_SIOWR('m', 0, int)
   1887 #define VKI_SNDCTL_MIDI_MPUMODE		_VKI_SIOWR('m', 1, int)
   1888 
   1889 #define VKI_SNDCTL_DSP_RESET		_VKI_SIO  ('P', 0)
   1890 #define VKI_SNDCTL_DSP_SYNC		_VKI_SIO  ('P', 1)
   1891 #define VKI_SNDCTL_DSP_SPEED		_VKI_SIOWR('P', 2, int)
   1892 #define VKI_SNDCTL_DSP_STEREO		_VKI_SIOWR('P', 3, int)
   1893 #define VKI_SNDCTL_DSP_GETBLKSIZE	_VKI_SIOWR('P', 4, int)
   1894 #define VKI_SNDCTL_DSP_CHANNELS		_VKI_SIOWR('P', 6, int)
   1895 #define VKI_SOUND_PCM_WRITE_FILTER	_VKI_SIOWR('P', 7, int)
   1896 #define VKI_SNDCTL_DSP_POST		_VKI_SIO  ('P', 8)
   1897 #define VKI_SNDCTL_DSP_SUBDIVIDE	_VKI_SIOWR('P', 9, int)
   1898 #define VKI_SNDCTL_DSP_SETFRAGMENT	_VKI_SIOWR('P',10, int)
   1899 
   1900 #define VKI_SNDCTL_DSP_GETFMTS		_VKI_SIOR ('P',11, int) /* Returns a mask */
   1901 #define VKI_SNDCTL_DSP_SETFMT		_VKI_SIOWR('P', 5, int) /* Selects ONE fmt */
   1902 
   1903 typedef struct vki_audio_buf_info {
   1904 			int fragments;	/* # of available fragments (partially usend ones not counted) */
   1905 			int fragstotal;	/* Total # of fragments allocated */
   1906 			int fragsize;	/* Size of a fragment in bytes */
   1907 
   1908 			int bytes;	/* Available space in bytes (includes partially used fragments) */
   1909 			/* Note! 'bytes' could be more than fragments*fragsize */
   1910 		} vki_audio_buf_info;
   1911 
   1912 #define VKI_SNDCTL_DSP_GETOSPACE	_VKI_SIOR ('P',12, vki_audio_buf_info)
   1913 #define VKI_SNDCTL_DSP_GETISPACE	_VKI_SIOR ('P',13, vki_audio_buf_info)
   1914 #define VKI_SNDCTL_DSP_NONBLOCK		_VKI_SIO  ('P',14)
   1915 #define VKI_SNDCTL_DSP_GETCAPS		_VKI_SIOR ('P',15, int)
   1916 
   1917 #define VKI_SNDCTL_DSP_GETTRIGGER	_VKI_SIOR ('P',16, int)
   1918 #define VKI_SNDCTL_DSP_SETTRIGGER	_VKI_SIOW ('P',16, int)
   1919 
   1920 #define VKI_SNDCTL_DSP_SETSYNCRO	_VKI_SIO  ('P', 21)
   1921 #define VKI_SNDCTL_DSP_SETDUPLEX	_VKI_SIO  ('P', 22)
   1922 #define VKI_SNDCTL_DSP_GETODELAY	_VKI_SIOR ('P', 23, int)
   1923 
   1924 #define VKI_SNDCTL_DSP_GETCHANNELMASK	_VKI_SIOWR('P', 64, int)
   1925 #define VKI_SNDCTL_DSP_BIND_CHANNEL	_VKI_SIOWR('P', 65, int)
   1926 
   1927 #define VKI_SNDCTL_DSP_SETSPDIF		_VKI_SIOW ('P', 66, int)
   1928 #define VKI_SNDCTL_DSP_GETSPDIF		_VKI_SIOR ('P', 67, int)
   1929 
   1930 #define VKI_SOUND_PCM_READ_RATE		_VKI_SIOR ('P', 2, int)
   1931 #define VKI_SOUND_PCM_READ_CHANNELS	_VKI_SIOR ('P', 6, int)
   1932 #define VKI_SOUND_PCM_READ_BITS		_VKI_SIOR ('P', 5, int)
   1933 #define VKI_SOUND_PCM_READ_FILTER	_VKI_SIOR ('P', 7, int)
   1934 
   1935 
   1936 //----------------------------------------------------------------------
   1937 // From linux-2.6.8.1/include/linux/hdreg.h
   1938 //----------------------------------------------------------------------
   1939 
   1940 struct vki_hd_geometry {
   1941       unsigned char heads;
   1942       unsigned char sectors;
   1943       unsigned short cylinders;
   1944       unsigned long start;
   1945 };
   1946 
   1947 #define VKI_HDIO_GETGEO		0x0301	/* get device geometry */
   1948 #define VKI_HDIO_GET_DMA	0x030b	/* get use-dma flag */
   1949 #define VKI_HDIO_GET_IDENTITY	0x030d	/* get IDE identification info */
   1950 
   1951 // [[Nb: done like this because the original type is a huge struct that will
   1952 //   always be the same size.]]
   1953 #define VKI_SIZEOF_STRUCT_HD_DRIVEID   512
   1954 
   1955 //----------------------------------------------------------------------
   1956 // From linux-2.6.8.1/include/linux/fb.h
   1957 //----------------------------------------------------------------------
   1958 
   1959 #define VKI_FBIOGET_VSCREENINFO	0x4600
   1960 #define VKI_FBIOGET_FSCREENINFO	0x4602
   1961 
   1962 struct vki_fb_fix_screeninfo {
   1963 	char id[16];			/* identification string eg "TT Builtin" */
   1964 	unsigned long smem_start;	/* Start of frame buffer mem */
   1965 					/* (physical address) */
   1966 	__vki_u32 smem_len;			/* Length of frame buffer mem */
   1967 	__vki_u32 type;			/* see FB_TYPE_*		*/
   1968 	__vki_u32 type_aux;		/* Interleave for interleaved Planes */
   1969 	__vki_u32 visual;		/* see FB_VISUAL_*		*/
   1970 	__vki_u16 xpanstep;		/* zero if no hardware panning  */
   1971 	__vki_u16 ypanstep;		/* zero if no hardware panning  */
   1972 	__vki_u16 ywrapstep;		/* zero if no hardware ywrap    */
   1973 	__vki_u32 line_length;		/* length of a line in bytes    */
   1974 	unsigned long mmio_start;	/* Start of Memory Mapped I/O   */
   1975 					/* (physical address) */
   1976 	__vki_u32 mmio_len;		/* Length of Memory Mapped I/O  */
   1977 	__vki_u32 accel;		/* Indicate to driver which	*/
   1978 					/*  specific chip/card we have	*/
   1979 	__vki_u16 reserved[3];		/* Reserved for future compatibility */
   1980 };
   1981 
   1982 struct vki_fb_bitfield {
   1983 	__vki_u32 offset;		/* beginning of bitfield	*/
   1984 	__vki_u32 length;		/* length of bitfield		*/
   1985 	__vki_u32 msb_right;		/* != 0 : Most significant bit is */
   1986 					/* right */
   1987 };
   1988 
   1989 struct vki_fb_var_screeninfo {
   1990 	__vki_u32 xres;			/* visible resolution		*/
   1991 	__vki_u32 yres;
   1992 	__vki_u32 xres_virtual;		/* virtual resolution		*/
   1993 	__vki_u32 yres_virtual;
   1994 	__vki_u32 xoffset;		/* offset from virtual to visible */
   1995 	__vki_u32 yoffset;		/* resolution			*/
   1996 
   1997 	__vki_u32 bits_per_pixel;	/* guess what			*/
   1998 	__vki_u32 grayscale;		/* != 0 Graylevels instead of colors */
   1999 
   2000 	struct vki_fb_bitfield red;	/* bitfield in fb mem if true color, */
   2001 	struct vki_fb_bitfield green;	/* else only length is significant */
   2002 	struct vki_fb_bitfield blue;
   2003 	struct vki_fb_bitfield transp;	/* transparency			*/
   2004 
   2005 	__vki_u32 nonstd;		/* != 0 Non standard pixel format */
   2006 
   2007 	__vki_u32 activate;		/* see FB_ACTIVATE_*		*/
   2008 
   2009 	__vki_u32 height;		/* height of picture in mm    */
   2010 	__vki_u32 width;		/* width of picture in mm     */
   2011 
   2012 	__vki_u32 accel_flags;		/* (OBSOLETE) see fb_info.flags */
   2013 
   2014 	/* Timing: All values in pixclocks, except pixclock (of course) */
   2015 	__vki_u32 pixclock;		/* pixel clock in ps (pico seconds) */
   2016 	__vki_u32 left_margin;		/* time from sync to picture	*/
   2017 	__vki_u32 right_margin;		/* time from picture to sync	*/
   2018 	__vki_u32 upper_margin;		/* time from sync to picture	*/
   2019 	__vki_u32 lower_margin;
   2020 	__vki_u32 hsync_len;		/* length of horizontal sync	*/
   2021 	__vki_u32 vsync_len;		/* length of vertical sync	*/
   2022 	__vki_u32 sync;			/* see FB_SYNC_*		*/
   2023 	__vki_u32 vmode;		/* see FB_VMODE_*		*/
   2024 	__vki_u32 rotate;		/* angle we rotate counter clockwise */
   2025 	__vki_u32 reserved[5];		/* Reserved for future compatibility */
   2026 };
   2027 
   2028 //----------------------------------------------------------------------
   2029 // From linux-2.6.9/include/linux/kd.h
   2030 //----------------------------------------------------------------------
   2031 
   2032 #define VKI_GIO_FONT       0x4B60  /* gets font in expanded form */
   2033 #define VKI_PIO_FONT       0x4B61  /* use font in expanded form */
   2034 
   2035 #define VKI_GIO_FONTX      0x4B6B  /* get font using struct consolefontdesc */
   2036 #define VKI_PIO_FONTX      0x4B6C  /* set font using struct consolefontdesc */
   2037 struct vki_consolefontdesc {
   2038 	unsigned short charcount;	/* characters in font (256 or 512) */
   2039 	unsigned short charheight;	/* scan lines per character (1-32) */
   2040 	char __user *chardata;		/* font data in expanded form */
   2041 };
   2042 
   2043 #define VKI_PIO_FONTRESET  0x4B6D  /* reset to default font */
   2044 
   2045 #define VKI_GIO_CMAP       0x4B70  /* gets colour palette on VGA+ */
   2046 #define VKI_PIO_CMAP       0x4B71  /* sets colour palette on VGA+ */
   2047 
   2048 #define VKI_KIOCSOUND      0x4B2F  /* start sound generation (0 for off) */
   2049 #define VKI_KDMKTONE       0x4B30  /* generate tone */
   2050 
   2051 #define VKI_KDGETLED       0x4B31  /* return current led state */
   2052 #define VKI_KDSETLED       0x4B32  /* set led state [lights, not flags] */
   2053 
   2054 #define VKI_KDGKBTYPE      0x4B33  /* get keyboard type */
   2055 
   2056 #define VKI_KDADDIO        0x4B34  /* add i/o port as valid */
   2057 #define VKI_KDDELIO        0x4B35  /* del i/o port as valid */
   2058 #define VKI_KDENABIO       0x4B36  /* enable i/o to video board */
   2059 #define VKI_KDDISABIO      0x4B37  /* disable i/o to video board */
   2060 
   2061 #define VKI_KDSETMODE      0x4B3A  /* set text/graphics mode */
   2062 #define VKI_KDGETMODE      0x4B3B  /* get current mode */
   2063 
   2064 #define VKI_KDMAPDISP      0x4B3C  /* map display into address space */
   2065 #define VKI_KDUNMAPDISP    0x4B3D  /* unmap display from address space */
   2066 
   2067 #define		VKI_E_TABSZ		256
   2068 #define VKI_GIO_SCRNMAP    0x4B40  /* get screen mapping from kernel */
   2069 #define VKI_PIO_SCRNMAP	   0x4B41  /* put screen mapping table in kernel */
   2070 #define VKI_GIO_UNISCRNMAP 0x4B69  /* get full Unicode screen mapping */
   2071 #define VKI_PIO_UNISCRNMAP 0x4B6A  /* set full Unicode screen mapping */
   2072 
   2073 #define VKI_GIO_UNIMAP     0x4B66  /* get unicode-to-font mapping from kernel */
   2074 struct vki_unipair {
   2075 	unsigned short unicode;
   2076 	unsigned short fontpos;
   2077 };
   2078 struct vki_unimapdesc {
   2079 	unsigned short entry_ct;
   2080 	struct vki_unipair __user *entries;
   2081 };
   2082 #define VKI_PIO_UNIMAP     0x4B67  /* put unicode-to-font mapping in kernel */
   2083 #define VKI_PIO_UNIMAPCLR  0x4B68  /* clear table, possibly advise hash algorithm */
   2084 struct vki_unimapinit {
   2085 	unsigned short advised_hashsize;  /* 0 if no opinion */
   2086 	unsigned short advised_hashstep;  /* 0 if no opinion */
   2087 	unsigned short advised_hashlevel; /* 0 if no opinion */
   2088 };
   2089 
   2090 #define VKI_KDGKBMODE      0x4B44  /* gets current keyboard mode */
   2091 #define VKI_KDSKBMODE      0x4B45  /* sets current keyboard mode */
   2092 
   2093 #define VKI_KDGKBMETA      0x4B62  /* gets meta key handling mode */
   2094 #define VKI_KDSKBMETA      0x4B63  /* sets meta key handling mode */
   2095 
   2096 #define VKI_KDGKBLED       0x4B64  /* get led flags (not lights) */
   2097 #define VKI_KDSKBLED       0x4B65  /* set led flags (not lights) */
   2098 
   2099 struct vki_kbentry {
   2100 	unsigned char kb_table;
   2101 	unsigned char kb_index;
   2102 	unsigned short kb_value;
   2103 };
   2104 #define VKI_KDGKBENT       0x4B46  /* gets one entry in translation table */
   2105 #define VKI_KDSKBENT       0x4B47  /* sets one entry in translation table */
   2106 
   2107 struct vki_kbsentry {
   2108 	unsigned char kb_func;
   2109 	unsigned char kb_string[512];
   2110 };
   2111 #define VKI_KDGKBSENT      0x4B48  /* gets one function key string entry */
   2112 #define VKI_KDSKBSENT      0x4B49  /* sets one function key string entry */
   2113 
   2114 struct vki_kbdiacr {
   2115         unsigned char diacr, base, result;
   2116 };
   2117 struct vki_kbdiacrs {
   2118         unsigned int kb_cnt;    /* number of entries in following array */
   2119 	struct vki_kbdiacr kbdiacr[256];    /* MAX_DIACR from keyboard.h */
   2120 };
   2121 #define VKI_KDGKBDIACR     0x4B4A  /* read kernel accent table */
   2122 #define VKI_KDSKBDIACR     0x4B4B  /* write kernel accent table */
   2123 
   2124 struct vki_kbkeycode {
   2125 	unsigned int scancode, keycode;
   2126 };
   2127 #define VKI_KDGETKEYCODE   0x4B4C  /* read kernel keycode table entry */
   2128 #define VKI_KDSETKEYCODE   0x4B4D  /* write kernel keycode table entry */
   2129 
   2130 #define VKI_KDSIGACCEPT    0x4B4E  /* accept kbd generated signals */
   2131 
   2132 struct vki_kbd_repeat {
   2133 	int delay;	/* in msec; <= 0: don't change */
   2134 	int period;	/* in msec; <= 0: don't change */
   2135 			/* earlier this field was misnamed "rate" */
   2136 };
   2137 #define VKI_KDKBDREP       0x4B52  /* set keyboard delay/repeat rate;
   2138                                     * actually used values are returned */
   2139 
   2140 #define VKI_KDFONTOP       0x4B72  /* font operations */
   2141 
   2142 struct vki_console_font_op {
   2143 	unsigned int op;	/* operation code KD_FONT_OP_* */
   2144 	unsigned int flags;	/* KD_FONT_FLAG_* */
   2145 	unsigned int width, height;	/* font size */
   2146 	unsigned int charcount;
   2147 	unsigned char __user *data;	/* font data with height fixed to 32 */
   2148 };
   2149 
   2150 #define VKI_KD_FONT_OP_SET		0	/* Set font */
   2151 #define VKI_KD_FONT_OP_GET		1	/* Get font */
   2152 #define VKI_KD_FONT_OP_SET_DEFAULT	2	/* Set font to default, data points to name / NULL */
   2153 #define VKI_KD_FONT_OP_COPY		3	/* Copy from another console */
   2154 
   2155 //----------------------------------------------------------------------
   2156 // From linux-2.6.9/include/linux/kb.h
   2157 //----------------------------------------------------------------------
   2158 
   2159 typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory */
   2160 
   2161 //----------------------------------------------------------------------
   2162 // From linux-2.6.20.1/include/linux/ptrace.h
   2163 //----------------------------------------------------------------------
   2164 
   2165 #define VKI_PTRACE_TRACEME         0
   2166 #define VKI_PTRACE_PEEKTEXT	   1
   2167 #define VKI_PTRACE_PEEKDATA	   2
   2168 #define VKI_PTRACE_PEEKUSR	   3
   2169 #define VKI_PTRACE_POKEUSR	   6
   2170 
   2171 #define VKI_PTRACE_DETACH         17
   2172 
   2173 #define VKI_PTRACE_GETEVENTMSG	0x4201
   2174 #define VKI_PTRACE_GETSIGINFO	0x4202
   2175 #define VKI_PTRACE_SETSIGINFO	0x4203
   2176 
   2177 //----------------------------------------------------------------------
   2178 // From linux-2.6.14/include/sound/asound.h
   2179 //----------------------------------------------------------------------
   2180 
   2181 enum {
   2182 	VKI_SNDRV_PCM_IOCTL_HW_FREE = _VKI_IO('A', 0x12),
   2183 	VKI_SNDRV_PCM_IOCTL_HWSYNC = _VKI_IO('A', 0x22),
   2184 	VKI_SNDRV_PCM_IOCTL_PREPARE = _VKI_IO('A', 0x40),
   2185 	VKI_SNDRV_PCM_IOCTL_RESET = _VKI_IO('A', 0x41),
   2186 	VKI_SNDRV_PCM_IOCTL_START = _VKI_IO('A', 0x42),
   2187 	VKI_SNDRV_PCM_IOCTL_DROP = _VKI_IO('A', 0x43),
   2188 	VKI_SNDRV_PCM_IOCTL_DRAIN = _VKI_IO('A', 0x44),
   2189 	VKI_SNDRV_PCM_IOCTL_PAUSE = _VKI_IOW('A', 0x45, int),
   2190 	VKI_SNDRV_PCM_IOCTL_RESUME = _VKI_IO('A', 0x47),
   2191 	VKI_SNDRV_PCM_IOCTL_XRUN = _VKI_IO('A', 0x48),
   2192 	VKI_SNDRV_PCM_IOCTL_LINK = _VKI_IOW('A', 0x60, int),
   2193 	VKI_SNDRV_PCM_IOCTL_UNLINK = _VKI_IO('A', 0x61),
   2194 };
   2195 
   2196 enum {
   2197 	VKI_SNDRV_TIMER_IOCTL_START = _VKI_IO('T', 0xa0),
   2198 	VKI_SNDRV_TIMER_IOCTL_STOP = _VKI_IO('T', 0xa1),
   2199 	VKI_SNDRV_TIMER_IOCTL_CONTINUE = _VKI_IO('T', 0xa2),
   2200 	VKI_SNDRV_TIMER_IOCTL_PAUSE = _VKI_IO('T', 0xa3),
   2201 };
   2202 
   2203 //----------------------------------------------------------------------
   2204 // From linux-2.6.15.4/include/linux/serial.h
   2205 //----------------------------------------------------------------------
   2206 
   2207 struct vki_serial_icounter_struct {
   2208 	int cts, dsr, rng, dcd;
   2209 	int rx, tx;
   2210 	int frame, overrun, parity, brk;
   2211 	int buf_overrun;
   2212 	int reserved[9];
   2213 };
   2214 
   2215 //----------------------------------------------------------------------
   2216 // From linux-2.6.16/include/linux/vt.h
   2217 //----------------------------------------------------------------------
   2218 
   2219 #define VKI_VT_OPENQRY	0x5600	/* find available vt */
   2220 
   2221 struct vki_vt_mode {
   2222 	char mode;		/* vt mode */
   2223 	char waitv;		/* if set, hang on writes if not active */
   2224 	short relsig;		/* signal to raise on release req */
   2225 	short acqsig;		/* signal to raise on acquisition */
   2226 	short frsig;		/* unused (set to 0) */
   2227 };
   2228 #define VKI_VT_GETMODE	0x5601	/* get mode of active vt */
   2229 #define VKI_VT_SETMODE	0x5602	/* set mode of active vt */
   2230 
   2231 struct vki_vt_stat {
   2232 	unsigned short v_active;	/* active vt */
   2233 	unsigned short v_signal;	/* signal to send */
   2234 	unsigned short v_state;		/* vt bitmask */
   2235 };
   2236 #define VKI_VT_GETSTATE	0x5603	/* get global vt state info */
   2237 #define VKI_VT_SENDSIG	0x5604	/* signal to send to bitmask of vts */
   2238 
   2239 #define VKI_VT_RELDISP	0x5605	/* release display */
   2240 
   2241 #define VKI_VT_ACTIVATE	0x5606	/* make vt active */
   2242 #define VKI_VT_WAITACTIVE	0x5607	/* wait for vt active */
   2243 #define VKI_VT_DISALLOCATE	0x5608  /* free memory associated to vt */
   2244 
   2245 struct vki_vt_sizes {
   2246 	unsigned short v_rows;		/* number of rows */
   2247 	unsigned short v_cols;		/* number of columns */
   2248 	unsigned short v_scrollsize;	/* number of lines of scrollback */
   2249 };
   2250 #define VKI_VT_RESIZE	0x5609	/* set kernel's idea of screensize */
   2251 
   2252 struct vki_vt_consize {
   2253 	unsigned short v_rows;	/* number of rows */
   2254 	unsigned short v_cols;	/* number of columns */
   2255 	unsigned short v_vlin;	/* number of pixel rows on screen */
   2256 	unsigned short v_clin;	/* number of pixel rows per character */
   2257 	unsigned short v_vcol;	/* number of pixel columns on screen */
   2258 	unsigned short v_ccol;	/* number of pixel columns per character */
   2259 };
   2260 #define VKI_VT_RESIZEX      0x560A  /* set kernel's idea of screensize + more */
   2261 #define VKI_VT_LOCKSWITCH   0x560B  /* disallow vt switching */
   2262 #define VKI_VT_UNLOCKSWITCH 0x560C  /* allow vt switching */
   2263 
   2264 //----------------------------------------------------------------------
   2265 // From linux-2.6.19/include/linux/prctl.h
   2266 //----------------------------------------------------------------------
   2267 
   2268 #define VKI_PR_SET_PDEATHSIG  1  /* Second arg is a signal */
   2269 #define VKI_PR_GET_PDEATHSIG  2  /* Second arg is a ptr to return the signal */
   2270 
   2271 #define VKI_PR_GET_DUMPABLE   3
   2272 #define VKI_PR_SET_DUMPABLE   4
   2273 
   2274 #define VKI_PR_GET_UNALIGN	  5
   2275 #define VKI_PR_SET_UNALIGN	  6
   2276 # define VKI_PR_UNALIGN_NOPRINT	1	/* silently fix up unaligned user accesses */
   2277 # define VKI_PR_UNALIGN_SIGBUS	2	/* generate SIGBUS on unaligned user access */
   2278 
   2279 #define VKI_PR_GET_KEEPCAPS   7
   2280 #define VKI_PR_SET_KEEPCAPS   8
   2281 
   2282 #define VKI_PR_GET_FPEMU  9
   2283 #define VKI_PR_SET_FPEMU 10
   2284 # define VKI_PR_FPEMU_NOPRINT	1	/* silently emulate fp operations accesses */
   2285 # define VKI_PR_FPEMU_SIGFPE	2	/* don't emulate fp operations, send SIGFPE instead */
   2286 
   2287 #define VKI_PR_GET_FPEXC	11
   2288 #define VKI_PR_SET_FPEXC	12
   2289 # define VKI_PR_FP_EXC_SW_ENABLE	0x80	/* Use FPEXC for FP exception enables */
   2290 # define VKI_PR_FP_EXC_DIV		0x010000	/* floating point divide by zero */
   2291 # define VKI_PR_FP_EXC_OVF		0x020000	/* floating point overflow */
   2292 # define VKI_PR_FP_EXC_UND		0x040000	/* floating point underflow */
   2293 # define VKI_PR_FP_EXC_RES		0x080000	/* floating point inexact result */
   2294 # define VKI_PR_FP_EXC_INV		0x100000	/* floating point invalid operation */
   2295 # define VKI_PR_FP_EXC_DISABLED	0	/* FP exceptions disabled */
   2296 # define VKI_PR_FP_EXC_NONRECOV	1	/* async non-recoverable exc. mode */
   2297 # define VKI_PR_FP_EXC_ASYNC	2	/* async recoverable exception mode */
   2298 # define VKI_PR_FP_EXC_PRECISE	3	/* precise exception mode */
   2299 
   2300 #define VKI_PR_GET_TIMING   13
   2301 #define VKI_PR_SET_TIMING   14
   2302 # define VKI_PR_TIMING_STATISTICAL  0       /* Normal, traditional,
   2303                                                    statistical process timing */
   2304 # define VKI_PR_TIMING_TIMESTAMP    1       /* Accurate timestamp based
   2305                                                    process timing */
   2306 
   2307 #define VKI_PR_SET_NAME    15		/* Set process name */
   2308 #define VKI_PR_GET_NAME    16		/* Get process name */
   2309 
   2310 #define VKI_PR_GET_ENDIAN	19
   2311 #define VKI_PR_SET_ENDIAN	20
   2312 # define VKI_PR_ENDIAN_BIG		0
   2313 # define VKI_PR_ENDIAN_LITTLE	1	/* True little endian mode */
   2314 # define VKI_PR_ENDIAN_PPC_LITTLE	2	/* "PowerPC" pseudo little endian */
   2315 
   2316 //----------------------------------------------------------------------
   2317 // From linux-2.6.19/include/linux/usbdevice_fs.h
   2318 //----------------------------------------------------------------------
   2319 
   2320 struct vki_usbdevfs_ctrltransfer {
   2321 	__vki_u8 bRequestType;
   2322 	__vki_u8 bRequest;
   2323 	__vki_u16 wValue;
   2324 	__vki_u16 wIndex;
   2325 	__vki_u16 wLength;
   2326 	__vki_u32 timeout;  /* in milliseconds */
   2327  	void __user *data;
   2328 };
   2329 
   2330 struct vki_usbdevfs_bulktransfer {
   2331 	unsigned int ep;
   2332 	unsigned int len;
   2333 	unsigned int timeout; /* in milliseconds */
   2334 	void __user *data;
   2335 };
   2336 
   2337 #define VKI_USBDEVFS_MAXDRIVERNAME 255
   2338 
   2339 struct vki_usbdevfs_getdriver {
   2340 	unsigned int interface;
   2341 	char driver[VKI_USBDEVFS_MAXDRIVERNAME + 1];
   2342 };
   2343 
   2344 struct vki_usbdevfs_connectinfo {
   2345 	unsigned int devnum;
   2346 	unsigned char slow;
   2347 };
   2348 
   2349 struct vki_usbdevfs_iso_packet_desc {
   2350 	unsigned int length;
   2351 	unsigned int actual_length;
   2352 	unsigned int status;
   2353 };
   2354 
   2355 struct vki_usbdevfs_urb {
   2356 	unsigned char type;
   2357 	unsigned char endpoint;
   2358 	int status;
   2359 	unsigned int flags;
   2360 	void __user *buffer;
   2361 	int buffer_length;
   2362 	int actual_length;
   2363 	int start_frame;
   2364 	int number_of_packets;
   2365 	int error_count;
   2366 	unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
   2367 	void *usercontext;
   2368 	struct vki_usbdevfs_iso_packet_desc iso_frame_desc[0];
   2369 };
   2370 
   2371 struct vki_usbdevfs_ioctl {
   2372 	int	ifno;		/* interface 0..N ; negative numbers reserved */
   2373 	int	ioctl_code;	/* MUST encode size + direction of data so the
   2374 				 * macros in <asm/ioctl.h> give correct values */
   2375 	void __user *data;	/* param buffer (in, or out) */
   2376 };
   2377 
   2378 #define VKI_USBDEVFS_CONTROL           _VKI_IOWR('U', 0, struct vki_usbdevfs_ctrltransfer)
   2379 #define VKI_USBDEVFS_BULK              _VKI_IOWR('U', 2, struct vki_usbdevfs_bulktransfer)
   2380 #define VKI_USBDEVFS_GETDRIVER         _VKI_IOW('U', 8, struct vki_usbdevfs_getdriver)
   2381 #define VKI_USBDEVFS_SUBMITURB         _VKI_IOR('U', 10, struct vki_usbdevfs_urb)
   2382 #define VKI_USBDEVFS_DISCARDURB        _VKI_IO('U', 11)
   2383 #define VKI_USBDEVFS_REAPURB           _VKI_IOW('U', 12, void *)
   2384 #define VKI_USBDEVFS_REAPURBNDELAY     _VKI_IOW('U', 13, void *)
   2385 #define VKI_USBDEVFS_CONNECTINFO       _VKI_IOW('U', 17, struct vki_usbdevfs_connectinfo)
   2386 #define VKI_USBDEVFS_IOCTL             _VKI_IOWR('U', 18, struct vki_usbdevfs_ioctl)
   2387 
   2388 #define VKI_USBDEVFS_URB_TYPE_ISO              0
   2389 #define VKI_USBDEVFS_URB_TYPE_INTERRUPT        1
   2390 #define VKI_USBDEVFS_URB_TYPE_CONTROL          2
   2391 #define VKI_USBDEVFS_URB_TYPE_BULK             3
   2392 
   2393 // [[this is missing in usbdevice_fs.h]]
   2394 struct vki_usbdevfs_setuppacket {
   2395        __vki_u8 bRequestType;
   2396        __vki_u8 bRequest;
   2397        __vki_u16 wValue;
   2398        __vki_u16 wIndex;
   2399        __vki_u16 wLength;
   2400 };
   2401 
   2402 //----------------------------------------------------------------------
   2403 // From linux-2.6.20.1/include/linux/i2c.h
   2404 //----------------------------------------------------------------------
   2405 
   2406 #define VKI_I2C_SLAVE		0x0703	/* Change slave address			*/
   2407 					/* Attn.: Slave address is 7 or 10 bits */
   2408 #define VKI_I2C_SLAVE_FORCE	0x0706	/* Change slave address			*/
   2409 					/* Attn.: Slave address is 7 or 10 bits */
   2410 					/* This changes the address, even if it */
   2411 					/* is already taken!			*/
   2412 #define VKI_I2C_TENBIT		0x0704	/* 0 for 7 bit addrs, != 0 for 10 bit	*/
   2413 #define VKI_I2C_FUNCS		0x0705	/* Get the adapter functionality */
   2414 #define VKI_I2C_PEC		0x0708	/* != 0 for SMBus PEC                   */
   2415 
   2416 //----------------------------------------------------------------------
   2417 // From linux-2.6.20.1/include/linux/keyctl.h
   2418 //----------------------------------------------------------------------
   2419 
   2420 /* keyctl commands */
   2421 #define VKI_KEYCTL_GET_KEYRING_ID	0	/* ask for a keyring's ID */
   2422 #define VKI_KEYCTL_JOIN_SESSION_KEYRING	1	/* join or start named session keyring */
   2423 #define VKI_KEYCTL_UPDATE		2	/* update a key */
   2424 #define VKI_KEYCTL_REVOKE		3	/* revoke a key */
   2425 #define VKI_KEYCTL_CHOWN		4	/* set ownership of a key */
   2426 #define VKI_KEYCTL_SETPERM		5	/* set perms on a key */
   2427 #define VKI_KEYCTL_DESCRIBE		6	/* describe a key */
   2428 #define VKI_KEYCTL_CLEAR		7	/* clear contents of a keyring */
   2429 #define VKI_KEYCTL_LINK			8	/* link a key into a keyring */
   2430 #define VKI_KEYCTL_UNLINK		9	/* unlink a key from a keyring */
   2431 #define VKI_KEYCTL_SEARCH		10	/* search for a key in a keyring */
   2432 #define VKI_KEYCTL_READ			11	/* read a key or keyring's contents */
   2433 #define VKI_KEYCTL_INSTANTIATE		12	/* instantiate a partially constructed key */
   2434 #define VKI_KEYCTL_NEGATE		13	/* negate a partially constructed key */
   2435 #define VKI_KEYCTL_SET_REQKEY_KEYRING	14	/* set default request-key keyring */
   2436 #define VKI_KEYCTL_SET_TIMEOUT		15	/* set key timeout */
   2437 #define VKI_KEYCTL_ASSUME_AUTHORITY	16	/* assume request_key() authorisation */
   2438 
   2439 /*--------------------------------------------------------------------*/
   2440 // From linux-2.6.20.1/include/linux/key.h
   2441 /*--------------------------------------------------------------------*/
   2442 
   2443 /* key handle serial number */
   2444 typedef vki_int32_t vki_key_serial_t;
   2445 
   2446 /* key handle permissions mask */
   2447 typedef vki_uint32_t vki_key_perm_t;
   2448 
   2449 //----------------------------------------------------------------------
   2450 // From linux-2.6.24.7/include/linux/wireless.h
   2451 // (wireless extensions version 22, 2007-03-16)
   2452 //----------------------------------------------------------------------
   2453 
   2454 /*
   2455  * [[Wireless extensions ioctls.]]
   2456  */
   2457 
   2458 /* Wireless Identification */
   2459 #define VKI_SIOCSIWCOMMIT	0x8B00	/* Commit pending changes to driver */
   2460 #define VKI_SIOCGIWNAME		0x8B01	/* get name == wireless protocol */
   2461 
   2462 /* Basic operations */
   2463 #define VKI_SIOCSIWNWID		0x8B02	/* set network id (pre-802.11) */
   2464 #define VKI_SIOCGIWNWID		0x8B03	/* get network id (the cell) */
   2465 #define VKI_SIOCSIWFREQ		0x8B04	/* set channel/frequency (Hz) */
   2466 #define VKI_SIOCGIWFREQ		0x8B05	/* get channel/frequency (Hz) */
   2467 #define VKI_SIOCSIWMODE		0x8B06	/* set operation mode */
   2468 #define VKI_SIOCGIWMODE		0x8B07	/* get operation mode */
   2469 #define VKI_SIOCSIWSENS		0x8B08	/* set sensitivity (dBm) */
   2470 #define VKI_SIOCGIWSENS		0x8B09	/* get sensitivity (dBm) */
   2471 
   2472 /* Informative stuff */
   2473 #define VKI_SIOCSIWRANGE	0x8B0A	/* Unused */
   2474 #define VKI_SIOCGIWRANGE	0x8B0B	/* Get range of parameters */
   2475 #define VKI_SIOCSIWPRIV		0x8B0C	/* Unused */
   2476 #define VKI_SIOCGIWPRIV		0x8B0D	/* get private ioctl interface info */
   2477 #define VKI_SIOCSIWSTATS	0x8B0E	/* Unused */
   2478 #define VKI_SIOCGIWSTATS	0x8B0F	/* Get /proc/net/wireless stats */
   2479 
   2480 /* Spy support (statistics per MAC address - used for Mobile IP support) */
   2481 #define VKI_SIOCSIWSPY		0x8B10	/* set spy addresses */
   2482 #define VKI_SIOCGIWSPY		0x8B11	/* get spy info (quality of link) */
   2483 #define VKI_SIOCSIWTHRSPY	0x8B12	/* set spy threshold (spy event) */
   2484 #define VKI_SIOCGIWTHRSPY	0x8B13	/* get spy threshold */
   2485 
   2486 /* Access Point manipulation */
   2487 #define VKI_SIOCSIWAP		0x8B14	/* set access point MAC addresses */
   2488 #define VKI_SIOCGIWAP		0x8B15	/* get access point MAC addresses */
   2489 #define VKI_SIOCGIWAPLIST	0x8B17	/* Deprecated in favor of scanning */
   2490 #define VKI_SIOCSIWSCAN         0x8B18	/* trigger scanning (list cells) */
   2491 #define VKI_SIOCGIWSCAN         0x8B19	/* get scanning results */
   2492 
   2493 /* 802.11 specific support */
   2494 #define VKI_SIOCSIWESSID	0x8B1A	/* set ESSID (network name) */
   2495 #define VKI_SIOCGIWESSID	0x8B1B	/* get ESSID */
   2496 #define VKI_SIOCSIWNICKN	0x8B1C	/* set node name/nickname */
   2497 #define VKI_SIOCGIWNICKN	0x8B1D	/* get node name/nickname */
   2498 
   2499 /* Other parameters useful in 802.11 and some other devices */
   2500 #define VKI_SIOCSIWRATE		0x8B20	/* set default bit rate (bps) */
   2501 #define VKI_SIOCGIWRATE		0x8B21	/* get default bit rate (bps) */
   2502 #define VKI_SIOCSIWRTS		0x8B22	/* set RTS/CTS threshold (bytes) */
   2503 #define VKI_SIOCGIWRTS		0x8B23	/* get RTS/CTS threshold (bytes) */
   2504 #define VKI_SIOCSIWFRAG		0x8B24	/* set fragmentation thr (bytes) */
   2505 #define VKI_SIOCGIWFRAG		0x8B25	/* get fragmentation thr (bytes) */
   2506 #define VKI_SIOCSIWTXPOW	0x8B26	/* set transmit power (dBm) */
   2507 #define VKI_SIOCGIWTXPOW	0x8B27	/* get transmit power (dBm) */
   2508 #define VKI_SIOCSIWRETRY	0x8B28	/* set retry limits and lifetime */
   2509 #define VKI_SIOCGIWRETRY	0x8B29	/* get retry limits and lifetime */
   2510 
   2511 /* Encoding stuff (scrambling, hardware security, WEP...) */
   2512 #define VKI_SIOCSIWENCODE	0x8B2A	/* set encoding token & mode */
   2513 #define VKI_SIOCGIWENCODE	0x8B2B	/* get encoding token & mode */
   2514 
   2515 /* Power saving stuff (power management, unicast and multicast) */
   2516 #define VKI_SIOCSIWPOWER	0x8B2C	/* set Power Management settings */
   2517 #define VKI_SIOCGIWPOWER	0x8B2D	/* get Power Management settings */
   2518 
   2519 /* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). */
   2520 #define VKI_SIOCSIWGENIE	0x8B30		/* set generic IE */
   2521 #define VKI_SIOCGIWGENIE	0x8B31		/* get generic IE */
   2522 
   2523 /* WPA : IEEE 802.11 MLME requests */
   2524 #define VKI_SIOCSIWMLME		0x8B16	/* request MLME operation; uses
   2525 					 * struct iw_mlme */
   2526 /* WPA : Authentication mode parameters */
   2527 #define VKI_SIOCSIWAUTH		0x8B32	/* set authentication mode params */
   2528 #define VKI_SIOCGIWAUTH		0x8B33	/* get authentication mode params */
   2529 
   2530 /* WPA : Extended version of encoding configuration */
   2531 #define VKI_SIOCSIWENCODEEXT	0x8B34	/* set encoding token & mode */
   2532 #define VKI_SIOCGIWENCODEEXT	0x8B35	/* get encoding token & mode */
   2533 
   2534 /* WPA2 : PMKSA cache management */
   2535 #define VKI_SIOCSIWPMKSA	0x8B36	/* PMKSA cache operation */
   2536 
   2537 /*
   2538  * [[Payload for the wireless extensions ioctls.]]
   2539  */
   2540 
   2541 struct	vki_iw_param
   2542 {
   2543   __vki_s32	value;		/* The value of the parameter itself */
   2544   __vki_u8	fixed;		/* Hardware should not use auto select */
   2545   __vki_u8	disabled;	/* Disable the feature */
   2546   __vki_u16	flags;		/* Various specifc flags (if any) */
   2547 };
   2548 
   2549 struct	vki_iw_point
   2550 {
   2551   void __user	*pointer;	/* Pointer to the data  (in user space) */
   2552   __vki_u16	length;		/* number of fields or size in bytes */
   2553   __vki_u16	flags;		/* Optional params */
   2554 };
   2555 
   2556 struct	vki_iw_freq
   2557 {
   2558 	__vki_s32	m;		/* Mantissa */
   2559 	__vki_s16	e;		/* Exponent */
   2560 	__vki_u8	i;		/* List index (when in range struct) */
   2561 	__vki_u8	flags;		/* Flags (fixed/auto) */
   2562 };
   2563 
   2564 struct	vki_iw_quality
   2565 {
   2566 	__vki_u8	qual;		/* link quality (%retries, SNR,
   2567 					   %missed beacons or better...) */
   2568 	__vki_u8	level;		/* signal level (dBm) */
   2569 	__vki_u8	noise;		/* noise level (dBm) */
   2570 	__vki_u8	updated;	/* Flags to know if updated */
   2571 };
   2572 
   2573 union	vki_iwreq_data
   2574 {
   2575 	/* Config - generic */
   2576 	char		name[VKI_IFNAMSIZ];
   2577 	/* Name : used to verify the presence of  wireless extensions.
   2578 	 * Name of the protocol/provider... */
   2579 
   2580 	struct vki_iw_point	essid;	/* Extended network name */
   2581 	struct vki_iw_param	nwid;	/* network id (or domain - the cell) */
   2582 	struct vki_iw_freq	freq;	/* frequency or channel :
   2583 					 * 0-1000 = channel
   2584 					 * > 1000 = frequency in Hz */
   2585 
   2586 	struct vki_iw_param	sens;	/* signal level threshold */
   2587 	struct vki_iw_param	bitrate;/* default bit rate */
   2588 	struct vki_iw_param	txpower;/* default transmit power */
   2589 	struct vki_iw_param	rts;	/* RTS threshold threshold */
   2590 	struct vki_iw_param	frag;	/* Fragmentation threshold */
   2591 	__vki_u32		mode;	/* Operation mode */
   2592 	struct vki_iw_param	retry;	/* Retry limits & lifetime */
   2593 
   2594 	struct vki_iw_point	encoding; /* Encoding stuff : tokens */
   2595 	struct vki_iw_param	power;	/* PM duration/timeout */
   2596 	struct vki_iw_quality	qual;	/* Quality part of statistics */
   2597 
   2598 	struct vki_sockaddr ap_addr;	/* Access point address */
   2599 	struct vki_sockaddr addr;	/* Destination address (hw/mac) */
   2600 
   2601 	struct vki_iw_param	param;	/* Other small parameters */
   2602 	struct vki_iw_point	data;	/* Other large parameters */
   2603 };
   2604 
   2605 struct	vki_iwreq
   2606 {
   2607 	union
   2608 	{
   2609 		char ifrn_name[VKI_IFNAMSIZ];	/* if name, e.g. "eth0" */
   2610 	} ifr_ifrn;
   2611 
   2612 	/* Data part (defined just above) */
   2613 	union	vki_iwreq_data	u;
   2614 };
   2615 
   2616 /*--------------------------------------------------------------------*/
   2617 // From linux-2.6.31.5/include/linux/perf_counter.h
   2618 /*--------------------------------------------------------------------*/
   2619 
   2620 struct vki_perf_counter_attr {
   2621 
   2622 	/*
   2623 	 * Major type: hardware/software/tracepoint/etc.
   2624 	 */
   2625 	__vki_u32			type;
   2626 
   2627 	/*
   2628 	 * Size of the attr structure, for fwd/bwd compat.
   2629 	 */
   2630 	__vki_u32			size;
   2631 
   2632 	/*
   2633 	 * Type specific configuration information.
   2634 	 */
   2635 	__vki_u64			config;
   2636 
   2637 	union {
   2638 		__vki_u64		sample_period;
   2639 		__vki_u64		sample_freq;
   2640 	};
   2641 
   2642 	__vki_u64			sample_type;
   2643 	__vki_u64			read_format;
   2644 
   2645 	__vki_u64			disabled       :  1, /* off by default        */
   2646 					inherit	       :  1, /* children inherit it   */
   2647 					pinned	       :  1, /* must always be on PMU */
   2648 					exclusive      :  1, /* only group on PMU     */
   2649 					exclude_user   :  1, /* don't count user      */
   2650 					exclude_kernel :  1, /* ditto kernel          */
   2651 					exclude_hv     :  1, /* ditto hypervisor      */
   2652 					exclude_idle   :  1, /* don't count when idle */
   2653 					mmap           :  1, /* include mmap data     */
   2654 					comm	       :  1, /* include comm data     */
   2655 					freq           :  1, /* use freq, not period  */
   2656 					inherit_stat   :  1, /* per task counts       */
   2657 					enable_on_exec :  1, /* next exec enables     */
   2658 					task           :  1, /* trace fork/exit       */
   2659 
   2660 					__reserved_1   : 50;
   2661 
   2662 	__vki_u32			wakeup_events;	/* wakeup every n events */
   2663 	__vki_u32			__reserved_2;
   2664 
   2665 	__vki_u64			__reserved_3;
   2666 };
   2667 
   2668 /*--------------------------------------------------------------------*/
   2669 // From linux-2.6.32.4/include/linux/getcpu.h
   2670 /*--------------------------------------------------------------------*/
   2671 
   2672 struct vki_getcpu_cache {
   2673 	unsigned long blob[128 / sizeof(long)];
   2674 };
   2675 
   2676 //----------------------------------------------------------------------
   2677 // From linux-2.6.33.3/include/linux/input.h
   2678 //----------------------------------------------------------------------
   2679 
   2680 /*
   2681  * IOCTLs (0x00 - 0x7f)
   2682  */
   2683 
   2684 #define VKI_EVIOCGNAME(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x06, len)		/* get device name */
   2685 #define VKI_EVIOCGPHYS(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x07, len)		/* get physical location */
   2686 #define VKI_EVIOCGUNIQ(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x08, len)		/* get unique identifier */
   2687 
   2688 #define VKI_EVIOCGKEY(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x18, len)		/* get global keystate */
   2689 #define VKI_EVIOCGLED(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x19, len)		/* get all LEDs */
   2690 #define VKI_EVIOCGSND(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x1a, len)		/* get all sounds status */
   2691 #define VKI_EVIOCGSW(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x1b, len)		/* get all switch states */
   2692 
   2693 #define VKI_EVIOCGBIT(ev,len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x20 + ev, len)	/* get event bits */
   2694 
   2695 /*
   2696  * Event types
   2697  */
   2698 
   2699 #define VKI_EV_SYN		0x00
   2700 #define VKI_EV_KEY		0x01
   2701 #define VKI_EV_REL		0x02
   2702 #define VKI_EV_ABS		0x03
   2703 #define VKI_EV_MSC		0x04
   2704 #define VKI_EV_SW		0x05
   2705 #define VKI_EV_LED		0x11
   2706 #define VKI_EV_SND		0x12
   2707 #define VKI_EV_REP		0x14
   2708 #define VKI_EV_FF		0x15
   2709 #define VKI_EV_PWR		0x16
   2710 #define VKI_EV_FF_STATUS	0x17
   2711 #define VKI_EV_MAX		0x1f
   2712 #define VKI_EV_CNT		(VKI_EV_MAX+1)
   2713 
   2714 #ifdef ANDROID
   2715 //----------------------------------------------------------------------
   2716 // From kernel/common/include/linux/ashmem.h
   2717 //----------------------------------------------------------------------
   2718 
   2719 #define VKI_ASHMEM_NAME_LEN 256
   2720 
   2721 #define VKI_ASHMEM_NAME_DEF "dev/ashmem"
   2722 
   2723 #define VKI_ASHMEM_NOT_PURGED 0
   2724 #define VKI_ASHMEM_WAS_PURGED 1
   2725 
   2726 #define VKI_ASHMEM_IS_UNPINNED 0
   2727 #define VKI_ASHMEM_IS_PINNED 1
   2728 
   2729 struct vki_ashmem_pin {
   2730    vki_uint32_t offset;
   2731    vki_uint32_t len;
   2732 };
   2733 
   2734 #define __VKI_ASHMEMIOC 0x77
   2735 
   2736 #define VKI_ASHMEM_SET_NAME _VKI_IOW(__VKI_ASHMEMIOC, 1, char[VKI_ASHMEM_NAME_LEN])
   2737 #define VKI_ASHMEM_GET_NAME _VKI_IOR(__VKI_ASHMEMIOC, 2, char[VKI_ASHMEM_NAME_LEN])
   2738 #define VKI_ASHMEM_SET_SIZE _VKI_IOW(__VKI_ASHMEMIOC, 3, vki_size_t)
   2739 #define VKI_ASHMEM_GET_SIZE _VKI_IO(__VKI_ASHMEMIOC, 4)
   2740 #define VKI_ASHMEM_SET_PROT_MASK _VKI_IOW(__VKI_ASHMEMIOC, 5, unsigned long)
   2741 #define VKI_ASHMEM_GET_PROT_MASK _VKI_IO(__VKI_ASHMEMIOC, 6)
   2742 #define VKI_ASHMEM_PIN _VKI_IOW(__VKI_ASHMEMIOC, 7, struct vki_ashmem_pin)
   2743 #define VKI_ASHMEM_UNPIN _VKI_IOW(__VKI_ASHMEMIOC, 8, struct vki_ashmem_pin)
   2744 #define VKI_ASHMEM_GET_PIN_STATUS _VKI_IO(__VKI_ASHMEMIOC, 9)
   2745 #define VKI_ASHMEM_PURGE_ALL_CACHES _VKI_IO(__VKI_ASHMEMIOC, 10)
   2746 
   2747 //----------------------------------------------------------------------
   2748 // From kernel/common/include/linux/binder.h
   2749 //----------------------------------------------------------------------
   2750 
   2751 struct vki_binder_write_read {
   2752  signed long write_size;
   2753  signed long write_consumed;
   2754  unsigned long write_buffer;
   2755  signed long read_size;
   2756  signed long read_consumed;
   2757  unsigned long read_buffer;
   2758 };
   2759 
   2760 struct vki_binder_version {
   2761  signed long protocol_version;
   2762 };
   2763 
   2764 #define VKI_BINDER_WRITE_READ _VKI_IOWR('b', 1, struct vki_binder_write_read)
   2765 #define VKI_BINDER_SET_IDLE_TIMEOUT _VKI_IOW('b', 3, vki_int64_t)
   2766 #define VKI_BINDER_SET_MAX_THREADS _VKI_IOW('b', 5, vki_size_t)
   2767 #define VKI_BINDER_SET_IDLE_PRIORITY _VKI_IOW('b', 6, int)
   2768 #define VKI_BINDER_SET_CONTEXT_MGR _VKI_IOW('b', 7, int)
   2769 #define VKI_BINDER_THREAD_EXIT _VKI_IOW('b', 8, int)
   2770 #define VKI_BINDER_VERSION _VKI_IOWR('b', 9, struct vki_binder_version)
   2771 
   2772 #endif // ANDROID
   2773 
   2774 #endif // __VKI_LINUX_H
   2775 
   2776 /*--------------------------------------------------------------------*/
   2777 /*--- end                                                          ---*/
   2778 /*--------------------------------------------------------------------*/
   2779