• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-2017 Julian Seward
11       jseward@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_ppc64be) || defined(VGA_ppc64le)
89 #  include "vki-posixtypes-ppc64-linux.h"
90 #elif defined(VGA_arm)
91 #  include "vki-posixtypes-arm-linux.h"
92 #elif defined(VGA_arm64)
93 #  include "vki-posixtypes-arm64-linux.h"
94 #elif defined(VGA_s390x)
95 #  include "vki-posixtypes-s390x-linux.h"
96 #elif defined(VGA_mips32)
97 #  include "vki-posixtypes-mips32-linux.h"
98 #elif defined(VGA_mips64)
99 #  include "vki-posixtypes-mips64-linux.h"
100 #else
101 #  error Unknown platform
102 #endif
103 
104 //----------------------------------------------------------------------
105 // VKI_STATIC_ASSERT(). Inspired by BUILD_BUG_ON() from
106 // linux-2.6.34/include/linux/kernel.h
107 //----------------------------------------------------------------------
108 
109 /*
110  * Evaluates to zero if 'expr' is true and forces a compilation error if
111  * 'expr' is false. Can be used in a context where no comma expressions
112  * are allowed.
113  */
114 #ifdef __cplusplus
115 template <bool b> struct vki_static_assert { int m_bitfield:(2*b-1); };
116 #define VKI_STATIC_ASSERT(expr)                         \
117     (sizeof(vki_static_assert<(expr)>) - sizeof(int))
118 #else
119 #define VKI_STATIC_ASSERT(expr) (sizeof(struct { int:-!(expr); }))
120 #endif
121 
122 //----------------------------------------------------------------------
123 // Based on _IOC_TYPECHECK() from linux-2.6.34/asm-generic/ioctl.h
124 //----------------------------------------------------------------------
125 
126 /* provoke compile error for invalid uses of size argument */
127 #define _VKI_IOC_TYPECHECK(t)                                           \
128     (VKI_STATIC_ASSERT((sizeof(t) == sizeof(t[1])                       \
129                         && sizeof(t) < (1 << _VKI_IOC_SIZEBITS)))       \
130      + sizeof(t))
131 
132 //----------------------------------------------------------------------
133 // From linux-2.6.8.1/include/linux/compiler.h
134 //----------------------------------------------------------------------
135 
136 # define __user
137 
138 //----------------------------------------------------------------------
139 // From linux/include/linux/compiler-gcc.h
140 //----------------------------------------------------------------------
141 
142 #ifdef __GNUC__
143 #define __vki_packed			__attribute__((packed))
144 #endif
145 
146 //----------------------------------------------------------------------
147 // From linux-2.6.8.1/include/linux/posix_types.h
148 //----------------------------------------------------------------------
149 
150 #undef __VKI_NFDBITS
151 #define __VKI_NFDBITS	(8 * sizeof(unsigned long))
152 
153 #undef __VKI_FD_SETSIZE
154 #define __VKI_FD_SETSIZE	1024
155 
156 #undef __VKI_FDSET_LONGS
157 #define __VKI_FDSET_LONGS	(__VKI_FD_SETSIZE/__VKI_NFDBITS)
158 
159 #undef __VKI_FDELT
160 #define	__VKI_FDELT(d)	((d) / __VKI_NFDBITS)
161 
162 #undef __VKI_FDMASK
163 #define	__VKI_FDMASK(d)	(1UL << ((d) % __VKI_NFDBITS))
164 
165 typedef struct {
166 	unsigned long fds_bits [__VKI_FDSET_LONGS];
167 } __vki_kernel_fd_set;
168 
169 typedef int __vki_kernel_key_t;
170 typedef int __vki_kernel_mqd_t;
171 
172 //----------------------------------------------------------------------
173 // From linux-2.6.8.1/include/linux/types.h
174 //----------------------------------------------------------------------
175 
176 typedef __vki_kernel_fd_set	vki_fd_set;
177 typedef __vki_kernel_mode_t	vki_mode_t;
178 typedef __vki_kernel_off_t	vki_off_t;
179 typedef __vki_kernel_pid_t	vki_pid_t;
180 typedef __vki_kernel_key_t	vki_key_t;
181 typedef __vki_kernel_suseconds_t	vki_suseconds_t;
182 typedef __vki_kernel_timer_t	vki_timer_t;
183 typedef __vki_kernel_clockid_t	vki_clockid_t;
184 typedef __vki_kernel_mqd_t	vki_mqd_t;
185 
186 // [[Nb: it's a bit unclear due to a #ifdef, but I think this is right. --njn]]
187 typedef __vki_kernel_uid32_t	vki_uid_t;
188 typedef __vki_kernel_gid32_t	vki_gid_t;
189 
190 typedef __vki_kernel_old_uid_t	vki_old_uid_t;
191 typedef __vki_kernel_old_gid_t	vki_old_gid_t;
192 
193 typedef __vki_kernel_loff_t	vki_loff_t;
194 
195 typedef __vki_kernel_size_t	vki_size_t;
196 typedef __vki_kernel_time_t	vki_time_t;
197 typedef __vki_kernel_clock_t	vki_clock_t;
198 typedef __vki_kernel_caddr_t	vki_caddr_t;
199 
200 typedef unsigned long           vki_u_long;
201 
202 typedef unsigned int	        vki_uint;
203 
204 //----------------------------------------------------------------------
205 // Now the rest of the arch-specific stuff
206 //----------------------------------------------------------------------
207 
208 #if defined(VGA_x86)
209 #  include "vki-x86-linux.h"
210 #elif defined(VGA_amd64)
211 #  include "vki-amd64-linux.h"
212 #elif defined(VGA_ppc32)
213 #  include "vki-ppc32-linux.h"
214 #elif defined(VGA_ppc64be) || defined(VGA_ppc64le)
215 #  include "vki-ppc64-linux.h"
216 #elif defined(VGA_arm)
217 #  include "vki-arm-linux.h"
218 #elif defined(VGA_arm64)
219 #  include "vki-arm64-linux.h"
220 #elif defined(VGA_s390x)
221 #  include "vki-s390x-linux.h"
222 #elif defined(VGA_mips32)
223 #  include "vki-mips32-linux.h"
224 #elif defined(VGA_mips64)
225 #  include "vki-mips64-linux.h"
226 #else
227 #  error Unknown platform
228 #endif
229 
230 //----------------------------------------------------------------------
231 // From linux-2.6.20.1/include/linux/types.h
232 //----------------------------------------------------------------------
233 
234 typedef		__vki_s32	vki_int32_t;
235 typedef		__vki_s16	vki_int16_t;
236 typedef		__vki_s64	vki_int64_t;
237 
238 typedef		__vki_u8	vki_uint8_t;
239 typedef		__vki_u16	vki_uint16_t;
240 typedef		__vki_u32	vki_uint32_t;
241 typedef		__vki_u64	vki_uint64_t;
242 
243 typedef		__vki_u16	__vki_le16;
244 
245 //----------------------------------------------------------------------
246 // From linux-2.6.8.1/include/linux/limits.h
247 //----------------------------------------------------------------------
248 
249 #define VKI_PATH_MAX       4096	/* # chars in a path name including nul */
250 
251 //----------------------------------------------------------------------
252 // From linux-2.6.8.1/include/linux/kernel.h
253 //----------------------------------------------------------------------
254 
255 struct vki_sysinfo {
256 	long uptime;			/* Seconds since boot */
257 	unsigned long loads[3];		/* 1, 5, and 15 minute load averages */
258 	unsigned long totalram;		/* Total usable main memory size */
259 	unsigned long freeram;		/* Available memory size */
260 	unsigned long sharedram;	/* Amount of shared memory */
261 	unsigned long bufferram;	/* Memory used by buffers */
262 	unsigned long totalswap;	/* Total swap space size */
263 	unsigned long freeswap;		/* swap space still available */
264 	unsigned short procs;		/* Number of current processes */
265 	unsigned short pad;		/* explicit padding for m68k */
266 	unsigned long totalhigh;	/* Total high memory size */
267 	unsigned long freehigh;		/* Available high memory size */
268 	unsigned int mem_unit;		/* Memory unit size in bytes */
269 	char _f[20-2*sizeof(long)-sizeof(int)];	/* Padding: libc5 uses this.. */
270 };
271 
272 //----------------------------------------------------------------------
273 // From linux-2.6.8.1/include/linux/time.h
274 //----------------------------------------------------------------------
275 
276 #define VKI_CLOCK_REALTIME            0
277 #define VKI_CLOCK_MONOTONIC           1
278 #define VKI_CLOCK_PROCESS_CPUTIME_ID  2
279 #define VKI_CLOCK_THREAD_CPUTIME_ID   3
280 
281 struct vki_timespec {
282 	vki_time_t	tv_sec;		/* seconds */
283 	long		tv_nsec;	/* nanoseconds */
284 };
285 
286 struct vki_timeval {
287 	vki_time_t	tv_sec;		/* seconds */
288 	vki_suseconds_t	tv_usec;	/* microseconds */
289 };
290 
291 struct vki_timezone {
292 	int	tz_minuteswest;	/* minutes west of Greenwich */
293 	int	tz_dsttime;	/* type of dst correction */
294 };
295 
296 struct  vki_itimerspec {
297         struct  vki_timespec it_interval;    /* timer period */
298         struct  vki_timespec it_value;       /* timer expiration */
299 };
300 
301 struct	vki_itimerval {
302 	struct	vki_timeval it_interval;	/* timer interval */
303 	struct	vki_timeval it_value;	/* current value */
304 };
305 
306 //----------------------------------------------------------------------
307 // From linux-2.6.8.1/include/linux/timex.h
308 //----------------------------------------------------------------------
309 
310 struct vki_timex {
311 	unsigned int modes;	/* mode selector */
312 	long offset;		/* time offset (usec) */
313 	long freq;		/* frequency offset (scaled ppm) */
314 	long maxerror;		/* maximum error (usec) */
315 	long esterror;		/* estimated error (usec) */
316 	int status;		/* clock command/status */
317 	long constant;		/* pll time constant */
318 	long precision;		/* clock precision (usec) (read only) */
319 	long tolerance;		/* clock frequency tolerance (ppm)
320 				 * (read only)
321 				 */
322 	struct vki_timeval time;	/* (read only) */
323 	long tick;		/* (modified) usecs between clock ticks */
324 
325 	long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
326 	long jitter;            /* pps jitter (us) (ro) */
327 	int shift;              /* interval duration (s) (shift) (ro) */
328 	long stabil;            /* pps stability (scaled ppm) (ro) */
329 	long jitcnt;            /* jitter limit exceeded (ro) */
330 	long calcnt;            /* calibration intervals (ro) */
331 	long errcnt;            /* calibration errors (ro) */
332 	long stbcnt;            /* stability limit exceeded (ro) */
333 
334 	int  :32; int  :32; int  :32; int  :32;
335 	int  :32; int  :32; int  :32; int  :32;
336 	int  :32; int  :32; int  :32; int  :32;
337 };
338 
339 #define VKI_ADJ_OFFSET			0x0001	/* time offset */
340 #define VKI_ADJ_FREQUENCY		0x0002	/* frequency offset */
341 #define VKI_ADJ_MAXERROR		0x0004	/* maximum time error */
342 #define VKI_ADJ_ESTERROR		0x0008	/* estimated time error */
343 #define VKI_ADJ_STATUS			0x0010	/* clock status */
344 #define VKI_ADJ_TIMECONST		0x0020	/* pll time constant */
345 #define VKI_ADJ_TAI			0x0080	/* set TAI offset */
346 #define VKI_ADJ_TICK			0x4000	/* tick value */
347 #define VKI_ADJ_ADJTIME			0x8000	/* switch between adjtime/adjtimex modes */
348 //#define VKI_ADJ_OFFSET_SINGLESHOT	0x8001	/* old-fashioned adjtime */
349 #define VKI_ADJ_OFFSET_READONLY		0x2000	/* read-only adjtime */
350 
351 //----------------------------------------------------------------------
352 // From linux-2.6.8.1/include/linux/times.h
353 //----------------------------------------------------------------------
354 
355 struct vki_tms {
356 	vki_clock_t tms_utime;
357 	vki_clock_t tms_stime;
358 	vki_clock_t tms_cutime;
359 	vki_clock_t tms_cstime;
360 };
361 
362 //----------------------------------------------------------------------
363 // From linux-2.6.8.1/include/linux/utime.h
364 //----------------------------------------------------------------------
365 
366 struct vki_utimbuf {
367 	vki_time_t actime;
368 	vki_time_t modtime;
369 };
370 
371 //----------------------------------------------------------------------
372 // From linux-2.6.8.1/include/linux/sched.h
373 //----------------------------------------------------------------------
374 
375 #define VKI_CSIGNAL		0x000000ff	/* signal mask to be sent at exit */
376 #define VKI_CLONE_VM		0x00000100	/* set if VM shared between processes */
377 #define VKI_CLONE_FS		0x00000200	/* set if fs info shared between processes */
378 #define VKI_CLONE_FILES		0x00000400	/* set if open files shared between processes */
379 #define VKI_CLONE_SIGHAND	0x00000800	/* set if signal handlers and blocked signals shared */
380 #define VKI_CLONE_VFORK		0x00004000	/* set if the parent wants the child to wake it up on mm_release */
381 #define VKI_CLONE_PARENT	0x00008000	/* set if we want to have the same parent as the cloner */
382 #define VKI_CLONE_THREAD	0x00010000	/* Same thread group? */
383 #define VKI_CLONE_SYSVSEM	0x00040000	/* share system V SEM_UNDO semantics */
384 #define VKI_CLONE_SETTLS	0x00080000	/* create a new TLS for the child */
385 #define VKI_CLONE_PARENT_SETTID	0x00100000	/* set the TID in the parent */
386 #define VKI_CLONE_CHILD_CLEARTID	0x00200000	/* clear the TID in the child */
387 #define VKI_CLONE_DETACHED	0x00400000	/* Unused, ignored */
388 #define VKI_CLONE_CHILD_SETTID	0x01000000	/* set the TID in the child */
389 
390 struct vki_sched_param {
391 	int sched_priority;
392 };
393 
394 #define VKI_TASK_COMM_LEN 16
395 
396 //----------------------------------------------------------------------
397 // From linux-2.6.8.1/include/asm-generic/siginfo.h
398 //----------------------------------------------------------------------
399 
400 // Some archs, such as MIPS, have non-standard vki_siginfo.
401 #ifndef HAVE_ARCH_SIGINFO_T
402 typedef union vki_sigval {
403 	int sival_int;
404 	void __user *sival_ptr;
405 } vki_sigval_t;
406 
407 #ifndef __VKI_ARCH_SI_PREAMBLE_SIZE
408 #define __VKI_ARCH_SI_PREAMBLE_SIZE	(3 * sizeof(int))
409 #endif
410 
411 #define VKI_SI_MAX_SIZE	128
412 
413 #ifndef VKI_SI_PAD_SIZE
414 #define VKI_SI_PAD_SIZE	((VKI_SI_MAX_SIZE - __VKI_ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
415 #endif
416 
417 #ifndef __VKI_ARCH_SI_UID_T
418 #define __VKI_ARCH_SI_UID_T	vki_uid_t
419 #endif
420 
421 #ifndef __VKI_ARCH_SI_BAND_T
422 #define __VKI_ARCH_SI_BAND_T long
423 #endif
424 
425 // [[Nb: this type changed between 2.4 and 2.6, but not in a way that
426 // affects Valgrind.]]
427 typedef struct vki_siginfo {
428 	int si_signo;
429 	int si_errno;
430 	int si_code;
431 
432 	union {
433 		int _pad[VKI_SI_PAD_SIZE];
434 
435 		/* kill() */
436 		struct {
437 			vki_pid_t _pid;		/* sender's pid */
438 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
439 		} _kill;
440 
441 		/* POSIX.1b timers */
442 		struct {
443 			vki_timer_t _tid;		/* timer id */
444 			int _overrun;		/* overrun count */
445 			char _pad[sizeof( __VKI_ARCH_SI_UID_T) - sizeof(int)];
446 			vki_sigval_t _sigval;	/* same as below */
447 			int _sys_private;       /* not to be passed to user */
448 		} _timer;
449 
450 		/* POSIX.1b signals */
451 		struct {
452 			vki_pid_t _pid;		/* sender's pid */
453 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
454 			vki_sigval_t _sigval;
455 		} _rt;
456 
457 		/* SIGCHLD */
458 		struct {
459 			vki_pid_t _pid;		/* which child */
460 			__VKI_ARCH_SI_UID_T _uid;	/* sender's uid */
461 			int _status;		/* exit code */
462 			vki_clock_t _utime;
463 			vki_clock_t _stime;
464 		} _sigchld;
465 
466 		/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
467 		struct {
468 			void __user *_addr; /* faulting insn/memory ref. */
469 #ifdef __ARCH_SI_TRAPNO
470 			int _trapno;	/* TRAP # which caused the signal */
471 #endif
472 		} _sigfault;
473 
474 		/* SIGPOLL */
475 		struct {
476 			__VKI_ARCH_SI_BAND_T _band;	/* POLL_IN, POLL_OUT, POLL_MSG */
477 			int _fd;
478 		} _sigpoll;
479 	} _sifields;
480 } vki_siginfo_t;
481 #endif
482 
483 #define __VKI_SI_FAULT	0
484 
485 /*
486  * si_code values
487  * Digital reserves positive values for kernel-generated signals.
488  */
489 #define VKI_SI_USER	0		/* sent by kill, sigsend, raise */
490 #define VKI_SI_TKILL	-6		/* sent by tkill system call */
491 
492 /*
493  * SIGILL si_codes
494  */
495 #define VKI_ILL_ILLOPC	(__VKI_SI_FAULT|1)	/* illegal opcode */
496 #define VKI_ILL_ILLOPN	(__VKI_SI_FAULT|2)	/* illegal operand */
497 #define VKI_ILL_ILLADR	(__VKI_SI_FAULT|3)	/* illegal addressing mode */
498 #define VKI_ILL_ILLTRP	(__VKI_SI_FAULT|4)	/* illegal trap */
499 #define VKI_ILL_PRVOPC	(__VKI_SI_FAULT|5)	/* privileged opcode */
500 #define VKI_ILL_PRVREG	(__VKI_SI_FAULT|6)	/* privileged register */
501 #define VKI_ILL_COPROC	(__VKI_SI_FAULT|7)	/* coprocessor error */
502 #define VKI_ILL_BADSTK	(__VKI_SI_FAULT|8)	/* internal stack error */
503 
504 /*
505  * SIGFPE si_codes
506  */
507 #define VKI_FPE_INTDIV	(__VKI_SI_FAULT|1)	/* integer divide by zero */
508 #define VKI_FPE_INTOVF	(__VKI_SI_FAULT|2)	/* integer overflow */
509 #define VKI_FPE_FLTDIV	(__VKI_SI_FAULT|3)	/* floating point divide by zero */
510 #define VKI_FPE_FLTOVF	(__VKI_SI_FAULT|4)	/* floating point overflow */
511 #define VKI_FPE_FLTUND	(__VKI_SI_FAULT|5)	/* floating point underflow */
512 #define VKI_FPE_FLTRES	(__VKI_SI_FAULT|6)	/* floating point inexact result */
513 #define VKI_FPE_FLTINV	(__VKI_SI_FAULT|7)	/* floating point invalid operation */
514 #define VKI_FPE_FLTSUB	(__VKI_SI_FAULT|8)	/* subscript out of range */
515 
516 /*
517  * SIGSEGV si_codes
518  */
519 #define VKI_SEGV_MAPERR	(__VKI_SI_FAULT|1)	/* address not mapped to object */
520 #define VKI_SEGV_ACCERR	(__VKI_SI_FAULT|2)	/* invalid permissions for mapped object */
521 
522 /*
523  * SIGBUS si_codes
524  */
525 #define VKI_BUS_ADRALN	(__VKI_SI_FAULT|1)	/* invalid address alignment */
526 #define VKI_BUS_ADRERR	(__VKI_SI_FAULT|2)	/* non-existent physical address */
527 #define VKI_BUS_OBJERR	(__VKI_SI_FAULT|3)	/* object specific hardware error */
528 
529 /*
530  * SIGTRAP si_codes
531  */
532 #define VKI_TRAP_BRKPT      (__VKI_SI_FAULT|1)  /* process breakpoint */
533 #define VKI_TRAP_TRACE      (__VKI_SI_FAULT|2)  /* process trace trap */
534 
535 /*
536  * This works because the alignment is ok on all current architectures
537  * but we leave open this being overridden in the future
538  */
539 #ifndef VKI___ARCH_SIGEV_PREAMBLE_SIZE
540 #define VKI___ARCH_SIGEV_PREAMBLE_SIZE	(sizeof(int) * 2 + sizeof(vki_sigval_t))
541 #endif
542 
543 #define VKI_SIGEV_MAX_SIZE	64
544 #define VKI_SIGEV_PAD_SIZE	((VKI_SIGEV_MAX_SIZE - VKI___ARCH_SIGEV_PREAMBLE_SIZE) \
545 		/ sizeof(int))
546 
547 /* This is the flag the kernel handles, userspace/glibc handles SEGEV_THEAD. */
548 #define VKI_SIGEV_THREAD_ID	4
549 
550 typedef struct vki_sigevent {
551 	vki_sigval_t sigev_value;
552 	int sigev_signo;
553 	int sigev_notify;
554 	union {
555 		int _pad[VKI_SIGEV_PAD_SIZE];
556 		 int _tid;
557 
558 		struct {
559 			void (*_function)(vki_sigval_t);
560 			void *_attribute;	/* really pthread_attr_t */
561 		} _sigev_thread;
562 	} _sigev_un;
563 } vki_sigevent_t;
564 
565 #define vki_sigev_notify_thread_id	_sigev_un._tid
566 
567 //----------------------------------------------------------------------
568 // From elsewhere...
569 //----------------------------------------------------------------------
570 
571 // [[The kernel actually uses the numbers 0,1,2 directly here, believe it or
572 // not.  So we introduce our own constants, based on the glibc ones.]]
573 #define VKI_SEEK_SET              0
574 #define VKI_SEEK_CUR              1
575 #define VKI_SEEK_END              2
576 
577 //----------------------------------------------------------------------
578 // From linux-2.6.8.1/include/linux/net.h
579 //----------------------------------------------------------------------
580 
581 #define VKI_SYS_SOCKET		1	/* sys_socket(2)		*/
582 #define VKI_SYS_BIND		2	/* sys_bind(2)			*/
583 #define VKI_SYS_CONNECT		3	/* sys_connect(2)		*/
584 #define VKI_SYS_LISTEN		4	/* sys_listen(2)		*/
585 #define VKI_SYS_ACCEPT		5	/* sys_accept(2)		*/
586 #define VKI_SYS_GETSOCKNAME	6	/* sys_getsockname(2)		*/
587 #define VKI_SYS_GETPEERNAME	7	/* sys_getpeername(2)		*/
588 #define VKI_SYS_SOCKETPAIR	8	/* sys_socketpair(2)		*/
589 #define VKI_SYS_SEND		9	/* sys_send(2)			*/
590 #define VKI_SYS_RECV		10	/* sys_recv(2)			*/
591 #define VKI_SYS_SENDTO		11	/* sys_sendto(2)		*/
592 #define VKI_SYS_RECVFROM	12	/* sys_recvfrom(2)		*/
593 #define VKI_SYS_SHUTDOWN	13	/* sys_shutdown(2)		*/
594 #define VKI_SYS_SETSOCKOPT	14	/* sys_setsockopt(2)		*/
595 #define VKI_SYS_GETSOCKOPT	15	/* sys_getsockopt(2)		*/
596 #define VKI_SYS_SENDMSG		16	/* sys_sendmsg(2)		*/
597 #define VKI_SYS_RECVMSG		17	/* sys_recvmsg(2)		*/
598 #define VKI_SYS_ACCEPT4		18	/* sys_accept4(2)		*/
599 #define VKI_SYS_RECVMMSG	19	/* sys_recvmmsg(2)              */
600 #define VKI_SYS_SENDMMSG	20	/* sys_sendmmsg(2)              */
601 
602 #ifndef ARCH_HAS_SOCKET_TYPES
603 enum vki_sock_type {
604 	VKI_SOCK_STREAM	= 1,
605 	// [[others omitted]]
606 };
607 #endif /* ARCH_HAS_SOCKET_TYPES */
608 
609 //----------------------------------------------------------------------
610 // From linux-2.6.8.1/include/linux/uio.h
611 //----------------------------------------------------------------------
612 
613 struct vki_iovec
614 {
615 	void __user *iov_base;	/* BSD uses caddr_t (1003.1g requires void *) */
616 	__vki_kernel_size_t iov_len; /* Must be size_t (1003.1g) */
617 };
618 
619 //----------------------------------------------------------------------
620 // From linux-2.6.8.1/include/linux/socket.h
621 //----------------------------------------------------------------------
622 
623 // [[Resolved arbitrarily;  doesn't really matter whether it's '__inline__'
624 //   or 'inline']]
625 #define __KINLINE static __inline__
626 
627 typedef unsigned short	vki_sa_family_t;
628 
629 struct vki_sockaddr {
630 	vki_sa_family_t	sa_family;	/* address family, AF_xxx	*/
631 	char		sa_data[14];	/* 14 bytes of protocol address	*/
632 };
633 
634 struct vki_msghdr {
635 	void	*	msg_name;	/* Socket name			*/
636 	int		msg_namelen;	/* Length of name		*/
637 	struct vki_iovec *	msg_iov;	/* Data blocks			*/
638 	__vki_kernel_size_t	msg_iovlen;	/* Number of blocks		*/
639 	void 	*	msg_control;	/* Per protocol magic (eg BSD file descriptor passing) */
640 	__vki_kernel_size_t	msg_controllen;	/* Length of cmsg list */
641 	unsigned	msg_flags;
642 };
643 
644 struct vki_mmsghdr {
645 	struct vki_msghdr   msg_hdr;
646 	unsigned        msg_len;
647 };
648 
649 struct vki_cmsghdr {
650 	__vki_kernel_size_t	cmsg_len;	/* data byte count, including hdr */
651         int		cmsg_level;	/* originating protocol */
652         int		cmsg_type;	/* protocol-specific type */
653 };
654 
655 #define __VKI_CMSG_NXTHDR(ctl, len, cmsg) __vki_cmsg_nxthdr((ctl),(len),(cmsg))
656 #define VKI_CMSG_NXTHDR(mhdr, cmsg) vki_cmsg_nxthdr((mhdr), (cmsg))
657 
658 #define VKI_CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
659 
660 #define VKI_CMSG_DATA(cmsg)	((void *)((char *)(cmsg) + VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr))))
661 
662 #define __VKI_CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct vki_cmsghdr) ? \
663 				  (struct vki_cmsghdr *)(ctl) : \
664 				  (struct vki_cmsghdr *)NULL)
665 #define VKI_CMSG_FIRSTHDR(msg)	__VKI_CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
666 
667 // [[Urgh, this is revolting...]
__vki_cmsg_nxthdr(void * __ctl,__vki_kernel_size_t __size,struct vki_cmsghdr * __cmsg)668 __KINLINE struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, __vki_kernel_size_t __size,
669 					       struct vki_cmsghdr *__cmsg)
670 {
671 	struct vki_cmsghdr * __ptr;
672 
673 	__ptr = ASSUME_ALIGNED(struct vki_cmsghdr *,
674         	((unsigned char *) __cmsg) +  VKI_CMSG_ALIGN(__cmsg->cmsg_len));
675 	if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
676 		return (struct vki_cmsghdr *)0;
677 
678 	return __ptr;
679 }
680 
vki_cmsg_nxthdr(struct vki_msghdr * __msg,struct vki_cmsghdr * __cmsg)681 __KINLINE struct vki_cmsghdr * vki_cmsg_nxthdr (struct vki_msghdr *__msg, struct vki_cmsghdr *__cmsg)
682 {
683 	return __vki_cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
684 }
685 
686 #define	VKI_SCM_RIGHTS	0x01		/* rw: access rights (array of int) */
687 
688 #define VKI_AF_UNSPEC   0
689 #define VKI_AF_UNIX	1	/* Unix domain sockets 		*/
690 #define VKI_AF_INET	2	/* Internet IP Protocol		*/
691 #define VKI_AF_INET6	10	/* IP version 6			*/
692 #define VKI_AF_NETLINK  16
693 #define VKI_AF_BLUETOOTH 31	/* Bluetooth sockets		*/
694 
695 #define VKI_MSG_NOSIGNAL	0x4000	/* Do not generate SIGPIPE */
696 
697 #define VKI_SOL_SCTP	132
698 
699 //----------------------------------------------------------------------
700 // From linux-2.6.8.1/include/linux/in.h
701 //----------------------------------------------------------------------
702 
703 struct vki_in_addr {
704 	__vki_u32	s_addr;
705 };
706 
707 /* Structure describing an Internet (IP) socket address. */
708 #define __VKI_SOCK_SIZE__	16	/* sizeof(struct sockaddr)	*/
709 struct vki_sockaddr_in {
710   vki_sa_family_t	sin_family;	/* Address family		*/
711   unsigned short int	sin_port;	/* Port number			*/
712   struct vki_in_addr	sin_addr;	/* Internet address		*/
713 
714   /* Pad to size of `struct sockaddr'. */
715   unsigned char		__pad[__VKI_SOCK_SIZE__ - sizeof(short int) -
716 			sizeof(unsigned short int) - sizeof(struct vki_in_addr)];
717 };
718 
719 #define VKI_IPPROTO_TCP 6       /* Transmission Control Protocol        */
720 
721 //----------------------------------------------------------------------
722 // From linux-2.6.8.1/include/linux/in6.h
723 //----------------------------------------------------------------------
724 
725 struct vki_in6_addr
726 {
727 	union
728 	{
729 		__vki_u8	u6_addr8[16];
730 		__vki_u16	u6_addr16[8];
731 		__vki_u32	u6_addr32[4];
732 	} vki_in6_u;
733 #define vki_s6_addr		vki_in6_u.u6_addr8
734 #define vki_s6_addr16		vki_in6_u.u6_addr16
735 #define vki_s6_addr32		vki_in6_u.u6_addr32
736 };
737 
738 struct vki_sockaddr_in6 {
739 	unsigned short int	sin6_family;    /* AF_INET6 */
740 	__vki_u16		sin6_port;      /* Transport layer port # */
741 	__vki_u32		sin6_flowinfo;  /* IPv6 flow information */
742 	struct vki_in6_addr	sin6_addr;      /* IPv6 address */
743 	__vki_u32		sin6_scope_id;  /* scope id (new in RFC2553) */
744 };
745 
746 //----------------------------------------------------------------------
747 // From linux-2.6.8.1/include/linux/tcp.h
748 //----------------------------------------------------------------------
749 
750 #define VKI_TCP_NODELAY    1       /* Turn off Nagle's algorithm. */
751 
752 
753 //----------------------------------------------------------------------
754 // From linux-2.6.8.1/include/linux/un.h
755 //----------------------------------------------------------------------
756 
757 #define VKI_UNIX_PATH_MAX	108
758 
759 struct vki_sockaddr_un {
760 	vki_sa_family_t sun_family;	/* AF_UNIX */
761 	char sun_path[VKI_UNIX_PATH_MAX];	/* pathname */
762 };
763 
764 //----------------------------------------------------------------------
765 // From linux-3.15.8/include/uapi/linux/netlink.h
766 //----------------------------------------------------------------------
767 
768 struct vki_sockaddr_nl {
769         vki_sa_family_t    nl_family;      /* AF_NETLINK   */
770         unsigned short     nl_pad;         /* zero         */
771         __vki_u32          nl_pid;         /* port ID      */
772         __vki_u32          nl_groups;      /* multicast groups mask */
773 };
774 
775 //----------------------------------------------------------------------
776 // From linux-2.6.8.1/include/linux/if.h
777 //----------------------------------------------------------------------
778 
779 #define	VKI_IFNAMSIZ	16
780 
781 struct vki_ifmap
782 {
783 	unsigned long mem_start;
784 	unsigned long mem_end;
785 	unsigned short base_addr;
786 	unsigned char irq;
787 	unsigned char dma;
788 	unsigned char port;
789 	/* 3 bytes spare */
790 };
791 
792 struct vki_if_settings
793 {
794 	unsigned int type;	/* Type of physical device or protocol */
795 	unsigned int size;	/* Size of the data allocated by the caller */
796 	union {
797                 // [[Nb: converted these all to void* to avoid pulling in
798                 //   unnecessary headers]]]
799 		/* {atm/eth/dsl}_settings anyone ? */
800 		void /*raw_hdlc_proto		*/__user *raw_hdlc;
801 		void /*cisco_proto		*/__user *cisco;
802 		void /*fr_proto			*/__user *fr;
803 		void /*fr_proto_pvc		*/__user *fr_pvc;
804 		void /*fr_proto_pvc_info	*/__user *fr_pvc_info;
805 
806 		/* interface settings */
807 		void /*sync_serial_settings	*/__user *sync;
808 		void /*te1_settings		*/__user *te1;
809 	} ifs_ifsu;
810 };
811 
812 struct vki_ifreq
813 {
814 #define VKI_IFHWADDRLEN	6
815 	union
816 	{
817 		char	ifrn_name[VKI_IFNAMSIZ];		/* if name, e.g. "en0" */
818 	} ifr_ifrn;
819 
820 	union {
821 		struct	vki_sockaddr ifru_addr;
822 		struct	vki_sockaddr ifru_dstaddr;
823 		struct	vki_sockaddr ifru_broadaddr;
824 		struct	vki_sockaddr ifru_netmask;
825 		struct  vki_sockaddr ifru_hwaddr;
826 		short	ifru_flags;
827 		int	ifru_ivalue;
828 		int	ifru_mtu;
829 		struct  vki_ifmap ifru_map;
830 		char	ifru_slave[VKI_IFNAMSIZ];	/* Just fits the size */
831 		char	ifru_newname[VKI_IFNAMSIZ];
832 		void __user *	ifru_data;
833 		struct	vki_if_settings ifru_settings;
834 	} ifr_ifru;
835 };
836 
837 #define vki_ifr_name	ifr_ifrn.ifrn_name	/* interface name 	*/
838 #define vki_ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address 		*/
839 #define	vki_ifr_addr	ifr_ifru.ifru_addr	/* address		*/
840 #define	vki_ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-p lnk	*/
841 #define	vki_ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address	*/
842 #define	vki_ifr_netmask	ifr_ifru.ifru_netmask	/* interface net mask	*/
843 #define	vki_ifr_flags	ifr_ifru.ifru_flags	/* flags		*/
844 #define	vki_ifr_metric	ifr_ifru.ifru_ivalue	/* metric		*/
845 #define	vki_ifr_mtu	ifr_ifru.ifru_mtu	/* mtu			*/
846 #define vki_ifr_map	ifr_ifru.ifru_map	/* device map		*/
847 #define vki_ifr_slave	ifr_ifru.ifru_slave	/* slave device		*/
848 #define	vki_ifr_data	ifr_ifru.ifru_data	/* for use by interface	*/
849 #define vki_ifr_ifindex	ifr_ifru.ifru_ivalue	/* interface index	*/
850 #define vki_ifr_bandwidth ifr_ifru.ifru_ivalue  /* link bandwidth	*/
851 #define vki_ifr_qlen	ifr_ifru.ifru_ivalue	/* Queue length 	*/
852 #define vki_ifr_newname	ifr_ifru.ifru_newname	/* New name		*/
853 #define vki_ifr_settings ifr_ifru.ifru_settings	/* Device/proto settings*/
854 
855 struct vki_ifconf
856 {
857 	int	ifc_len;			/* size of buffer	*/
858 	union
859 	{
860 		char __user *ifcu_buf;
861 		struct vki_ifreq __user *ifcu_req;
862 	} ifc_ifcu;
863 };
864 #define	vki_ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address	*/
865 
866 //----------------------------------------------------------------------
867 // From linux-2.6.8.1/include/linux/if_arp.h
868 //----------------------------------------------------------------------
869 
870 struct vki_arpreq {
871   struct vki_sockaddr	arp_pa;		/* protocol address		*/
872   struct vki_sockaddr	arp_ha;		/* hardware address		*/
873   int			arp_flags;	/* flags			*/
874   struct vki_sockaddr   arp_netmask;    /* netmask (only for proxy arps) */
875   char			arp_dev[16];
876 };
877 
878 //----------------------------------------------------------------------
879 // From linux-2.6.8.1/include/linux/route.h
880 //----------------------------------------------------------------------
881 
882 struct vki_rtentry
883 {
884 	unsigned long	rt_pad1;
885 	struct vki_sockaddr	rt_dst;		/* target address		*/
886 	struct vki_sockaddr	rt_gateway;	/* gateway addr (RTF_GATEWAY)	*/
887 	struct vki_sockaddr	rt_genmask;	/* target network mask (IP)	*/
888 	unsigned short	rt_flags;
889 	short		rt_pad2;
890 	unsigned long	rt_pad3;
891 	void		*rt_pad4;
892 	short		rt_metric;	/* +1 for binary compatibility!	*/
893 	char __user	*rt_dev;	/* forcing the device at add	*/
894 	unsigned long	rt_mtu;		/* per route MTU/Window 	*/
895 // [[Not important for Valgrind]]
896 //#ifndef __KERNEL__
897 //#define rt_mss	rt_mtu		/* Compatibility :-(            */
898 //#endif
899 	unsigned long	rt_window;	/* Window clamping 		*/
900 	unsigned short	rt_irtt;	/* Initial RTT			*/
901 };
902 
903 //----------------------------------------------------------------------
904 // From linux-2.6.13-rc5/include/net/sctp/user.h
905 //----------------------------------------------------------------------
906 
907 typedef __vki_s32 vki_sctp_assoc_t;
908 
909 enum vki_sctp_optname {
910 	VKI_SCTP_RTOINFO,
911 #define VKI_SCTP_RTOINFO VKI_SCTP_RTOINFO
912 	VKI_SCTP_ASSOCINFO,
913 #define VKI_SCTP_ASSOCINFO VKI_SCTP_ASSOCINFO
914 	VKI_SCTP_INITMSG,
915 #define VKI_SCTP_INITMSG VKI_SCTP_INITMSG
916 	VKI_SCTP_NODELAY, 	/* Get/set nodelay option. */
917 #define VKI_SCTP_NODELAY	VKI_SCTP_NODELAY
918 	VKI_SCTP_AUTOCLOSE,
919 #define VKI_SCTP_AUTOCLOSE VKI_SCTP_AUTOCLOSE
920 	VKI_SCTP_SET_PEER_PRIMARY_ADDR,
921 #define VKI_SCTP_SET_PEER_PRIMARY_ADDR VKI_SCTP_SET_PEER_PRIMARY_ADDR
922 	VKI_SCTP_PRIMARY_ADDR,
923 #define VKI_SCTP_PRIMARY_ADDR VKI_SCTP_PRIMARY_ADDR
924 	VKI_SCTP_ADAPTION_LAYER,
925 #define VKI_SCTP_ADAPTION_LAYER VKI_SCTP_ADAPTION_LAYER
926 	VKI_SCTP_DISABLE_FRAGMENTS,
927 #define VKI_SCTP_DISABLE_FRAGMENTS VKI_SCTP_DISABLE_FRAGMENTS
928 	VKI_SCTP_PEER_ADDR_PARAMS,
929 #define VKI_SCTP_PEER_ADDR_PARAMS VKI_SCTP_PEER_ADDR_PARAMS
930 	VKI_SCTP_DEFAULT_SEND_PARAM,
931 #define VKI_SCTP_DEFAULT_SEND_PARAM VKI_SCTP_DEFAULT_SEND_PARAM
932 	VKI_SCTP_EVENTS,
933 #define VKI_SCTP_EVENTS VKI_SCTP_EVENTS
934 	VKI_SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
935 #define VKI_SCTP_I_WANT_MAPPED_V4_ADDR VKI_SCTP_I_WANT_MAPPED_V4_ADDR
936 	VKI_SCTP_MAXSEG, 	/* Get/set maximum fragment. */
937 #define VKI_SCTP_MAXSEG 	VKI_SCTP_MAXSEG
938 	VKI_SCTP_STATUS,
939 #define VKI_SCTP_STATUS VKI_SCTP_STATUS
940 	VKI_SCTP_GET_PEER_ADDR_INFO,
941 #define VKI_SCTP_GET_PEER_ADDR_INFO VKI_SCTP_GET_PEER_ADDR_INFO
942 
943 	/* Internal Socket Options. Some of the sctp library functions are
944 	 * implemented using these socket options.
945 	 */
946 	VKI_SCTP_SOCKOPT_BINDX_ADD = 100,/* BINDX requests for adding addresses. */
947 #define VKI_SCTP_SOCKOPT_BINDX_ADD	VKI_SCTP_SOCKOPT_BINDX_ADD
948 	VKI_SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
949 #define VKI_SCTP_SOCKOPT_BINDX_REM	VKI_SCTP_SOCKOPT_BINDX_REM
950 	VKI_SCTP_SOCKOPT_PEELOFF, 	/* peel off association. */
951 #define VKI_SCTP_SOCKOPT_PEELOFF	VKI_SCTP_SOCKOPT_PEELOFF
952 	VKI_SCTP_GET_PEER_ADDRS_NUM, 	/* Get number of peer addresss. */
953 #define VKI_SCTP_GET_PEER_ADDRS_NUM	VKI_SCTP_GET_PEER_ADDRS_NUM
954 	VKI_SCTP_GET_PEER_ADDRS, 	/* Get all peer addresss. */
955 #define VKI_SCTP_GET_PEER_ADDRS	VKI_SCTP_GET_PEER_ADDRS
956 	VKI_SCTP_GET_LOCAL_ADDRS_NUM, 	/* Get number of local addresss. */
957 #define VKI_SCTP_GET_LOCAL_ADDRS_NUM	VKI_SCTP_GET_LOCAL_ADDRS_NUM
958 	VKI_SCTP_GET_LOCAL_ADDRS, 	/* Get all local addresss. */
959 #define VKI_SCTP_GET_LOCAL_ADDRS	VKI_SCTP_GET_LOCAL_ADDRS
960 	VKI_SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
961 #define VKI_SCTP_SOCKOPT_CONNECTX	VKI_SCTP_SOCKOPT_CONNECTX
962 };
963 
964 struct vki_sctp_getaddrs {
965 	vki_sctp_assoc_t        assoc_id;
966 	int			addr_num;
967 	struct vki_sockaddr	*addrs;
968 };
969 
970 //----------------------------------------------------------------------
971 // From linux-2.6.8.1/include/linux/resource.h
972 //----------------------------------------------------------------------
973 
974 struct	vki_rusage {
975 	struct vki_timeval ru_utime;	/* user time used */
976 	struct vki_timeval ru_stime;	/* system time used */
977 	long	ru_maxrss;		/* maximum resident set size */
978 	long	ru_ixrss;		/* integral shared memory size */
979 	long	ru_idrss;		/* integral unshared data size */
980 	long	ru_isrss;		/* integral unshared stack size */
981 	long	ru_minflt;		/* page reclaims */
982 	long	ru_majflt;		/* page faults */
983 	long	ru_nswap;		/* swaps */
984 	long	ru_inblock;		/* block input operations */
985 	long	ru_oublock;		/* block output operations */
986 	long	ru_msgsnd;		/* messages sent */
987 	long	ru_msgrcv;		/* messages received */
988 	long	ru_nsignals;		/* signals received */
989 	long	ru_nvcsw;		/* voluntary context switches */
990 	long	ru_nivcsw;		/* involuntary " */
991 };
992 
993 struct vki_rlimit {
994 	unsigned long	rlim_cur;
995 	unsigned long	rlim_max;
996 };
997 
998 struct vki_rlimit64 {
999 	__vki_u64 rlim_cur;
1000 	__vki_u64 rlim_max;
1001 };
1002 
1003 //----------------------------------------------------------------------
1004 // From linux-2.6.8.1/include/linux/elfcore.h
1005 //----------------------------------------------------------------------
1006 
1007 struct vki_elf_siginfo
1008 {
1009 	int	si_signo;			/* signal number */
1010 	int	si_code;			/* extra code */
1011 	int	si_errno;			/* errno */
1012 };
1013 
1014 // [[Removed some commented out lines here]]
1015 struct vki_elf_prstatus
1016 {
1017 	struct vki_elf_siginfo pr_info;	/* Info associated with signal */
1018 	short	pr_cursig;		/* Current signal */
1019 	unsigned long pr_sigpend;	/* Set of pending signals */
1020 	unsigned long pr_sighold;	/* Set of held signals */
1021 	vki_pid_t	pr_pid;
1022 	vki_pid_t	pr_ppid;
1023 	vki_pid_t	pr_pgrp;
1024 	vki_pid_t	pr_sid;
1025 	struct vki_timeval pr_utime;	/* User time */
1026 	struct vki_timeval pr_stime;	/* System time */
1027 	struct vki_timeval pr_cutime;	/* Cumulative user time */
1028 	struct vki_timeval pr_cstime;	/* Cumulative system time */
1029 	vki_elf_gregset_t pr_reg;	/* GP registers */
1030 	int pr_fpvalid;		/* True if math co-processor being used.  */
1031 };
1032 
1033 #define VKI_ELF_PRARGSZ	(80)	/* Number of chars for args */
1034 
1035 struct vki_elf_prpsinfo
1036 {
1037 	char	pr_state;	/* numeric process state */
1038 	char	pr_sname;	/* char for pr_state */
1039 	char	pr_zomb;	/* zombie */
1040 	char	pr_nice;	/* nice val */
1041 	unsigned long pr_flag;	/* flags */
1042 	__vki_kernel_uid_t	pr_uid;
1043 	__vki_kernel_gid_t	pr_gid;
1044 	vki_pid_t	pr_pid, pr_ppid, pr_pgrp, pr_sid;
1045 	/* Lots missing */
1046 	char	pr_fname[16];	/* filename of executable */
1047 	char	pr_psargs[VKI_ELF_PRARGSZ];	/* initial part of arg list */
1048 };
1049 
1050 //----------------------------------------------------------------------
1051 // From linux-2.6.12.1/include/linux/eventpoll.h
1052 //----------------------------------------------------------------------
1053 
1054 /* Valid opcodes to issue to sys_epoll_ctl() */
1055 #define VKI_EPOLL_CTL_ADD 1
1056 #define VKI_EPOLL_CTL_DEL 2
1057 #define VKI_EPOLL_CTL_MOD 3
1058 
1059 #ifdef __x86_64__
1060 #define VKI_EPOLL_PACKED __attribute__((packed))
1061 #else
1062 #define VKI_EPOLL_PACKED
1063 #endif
1064 
1065 struct vki_epoll_event {
1066 	__vki_u32 events;
1067 	__vki_u64 data;
1068 } VKI_EPOLL_PACKED;
1069 
1070 
1071 //----------------------------------------------------------------------
1072 // From linux-2.6.8.1/include/linux/mqueue.h
1073 //----------------------------------------------------------------------
1074 
1075 struct vki_mq_attr {
1076 	long	mq_flags;	/* message queue flags			*/
1077 	long	mq_maxmsg;	/* maximum number of messages		*/
1078 	long	mq_msgsize;	/* maximum message size			*/
1079 	long	mq_curmsgs;	/* number of messages currently queued	*/
1080 	long	__reserved[4];	/* ignored for input, zeroed for output */
1081 };
1082 
1083 //----------------------------------------------------------------------
1084 // From linux-2.6.8.1/include/linux/utsname.h
1085 //----------------------------------------------------------------------
1086 
1087 struct vki_new_utsname {
1088 	char sysname[65];
1089 	char nodename[65];
1090 	char release[65];
1091 	char version[65];
1092 	char machine[65];
1093 	char domainname[65];
1094 };
1095 
1096 //----------------------------------------------------------------------
1097 // From linux-2.6.8.1/include/linux/mii.h
1098 //----------------------------------------------------------------------
1099 
1100 /* This structure is used in all SIOCxMIIxxx ioctl calls */
1101 struct vki_mii_ioctl_data {
1102 	vki_u16		phy_id;
1103 	vki_u16		reg_num;
1104 	vki_u16		val_in;
1105 	vki_u16		val_out;
1106 };
1107 
1108 //----------------------------------------------------------------------
1109 // From linux-2.6.8.1/include/linux/capability.h
1110 //----------------------------------------------------------------------
1111 
1112 // [[capget()/capset() man page says this, ominously:
1113 //
1114 //   The kernel API is likely to change and use of these functions  (in
1115 //   particular the format of the cap_user_*_t types) is subject to
1116 //   change with each kernel revision.
1117 //
1118 // However, the format hasn't changed since at least Linux 2.4.6.]]
1119 
1120 typedef struct __vki_user_cap_header_struct {
1121 	__vki_u32 version;
1122 	int pid;
1123 } __user *vki_cap_user_header_t;
1124 
1125 typedef struct __vki_user_cap_data_struct {
1126         __vki_u32 effective;
1127         __vki_u32 permitted;
1128         __vki_u32 inheritable;
1129 } __user *vki_cap_user_data_t;
1130 
1131 
1132 //----------------------------------------------------------------------
1133 // From linux-2.6.8.1/include/linux/module.h
1134 //----------------------------------------------------------------------
1135 
1136 // [[We do a VKI_SIZEOF_* here because this type is so big, and its size
1137 //   depends on the word size, so see vki_arch.h]]
1138 
1139 //----------------------------------------------------------------------
1140 // From linux-2.6.8.1/include/linux/ipc.h
1141 //----------------------------------------------------------------------
1142 
1143 /* Obsolete, used only for backwards compatibility and libc5 compiles */
1144 struct vki_ipc_perm
1145 {
1146 	__vki_kernel_key_t	key;
1147 	__vki_kernel_uid_t	uid;
1148 	__vki_kernel_gid_t	gid;
1149 	__vki_kernel_uid_t	cuid;
1150 	__vki_kernel_gid_t	cgid;
1151 	__vki_kernel_mode_t	mode;
1152 	unsigned short	seq;
1153 };
1154 
1155 #define VKI_IPC_CREAT  00001000   /* create if key is nonexistent */
1156 #define VKI_IPC_EXCL   00002000   /* fail if key exists */
1157 #define VKI_IPC_NOWAIT 00004000   /* return error on wait */
1158 
1159 //#define VKI_IPC_RMID 0     /* remove resource */
1160 #define VKI_IPC_SET  1     /* set ipc_perm options */
1161 #define VKI_IPC_STAT 2     /* get ipc_perm options */
1162 #define VKI_IPC_INFO 3     /* see ipcs */
1163 
1164 #define VKI_IPC_64  0x0100  /* New version (support 32-bit UIDs, bigger
1165 			       message sizes, etc. */
1166 // From /usr/include/bits/shm.h
1167 # define VKI_SHM_HUGETLB   04000
1168 
1169 
1170 //----------------------------------------------------------------------
1171 // From linux-2.6.8.1/include/linux/sem.h
1172 //----------------------------------------------------------------------
1173 
1174 #define VKI_GETALL  13       /* get all semval's */
1175 #define VKI_SETVAL  16       /* set semval */
1176 #define VKI_SETALL  17       /* set all semval's */
1177 
1178 #define VKI_SEM_STAT 18
1179 #define VKI_SEM_INFO 19
1180 
1181 /* Obsolete, used only for backwards compatibility and libc5 compiles */
1182 struct vki_semid_ds {
1183 	struct vki_ipc_perm	sem_perm;		/* permissions .. see ipc.h */
1184 	__vki_kernel_time_t	sem_otime;		/* last semop time */
1185 	__vki_kernel_time_t	sem_ctime;		/* last change time */
1186         // [[Use void* to avoid excess header copying]]
1187 	void/*struct sem	*/*sem_base;		/* ptr to first semaphore in array */
1188 	void/*struct sem_queue */*sem_pending;		/* pending operations to be processed */
1189 	void/*struct sem_queue */**sem_pending_last;	/* last pending operation */
1190 	void/*struct sem_undo	*/*undo;			/* undo requests on this array */
1191 	unsigned short	sem_nsems;		/* no. of semaphores in array */
1192 };
1193 
1194 struct vki_sembuf {
1195 	unsigned short  sem_num;	/* semaphore index in array */
1196 	short		sem_op;		/* semaphore operation */
1197 	short		sem_flg;	/* operation flags */
1198 };
1199 
1200 union vki_semun {
1201 	int val;			/* value for SETVAL */
1202 	struct vki_semid_ds __user *buf;	/* buffer for IPC_STAT & IPC_SET */
1203 	unsigned short __user *array;	/* array for GETALL & SETALL */
1204 	struct vki_seminfo __user *__buf;	/* buffer for IPC_INFO */
1205 	void __user *__pad;
1206 };
1207 
1208 struct  vki_seminfo {
1209 	int semmap;
1210 	int semmni;
1211 	int semmns;
1212 	int semmnu;
1213 	int semmsl;
1214 	int semopm;
1215 	int semume;
1216 	int semusz;
1217 	int semvmx;
1218 	int semaem;
1219 };
1220 
1221 //----------------------------------------------------------------------
1222 // From linux-2.6.8.1/include/asm-generic/errno-base.h
1223 //----------------------------------------------------------------------
1224 
1225 #define	VKI_EPERM		 1	/* Operation not permitted */
1226 #define	VKI_ENOENT		 2	/* No such file or directory */
1227 #define	VKI_ESRCH		 3	/* No such process */
1228 #define	VKI_EINTR		 4	/* Interrupted system call */
1229 #define	VKI_EIO			 5	/* I/O error */
1230 #define	VKI_ENXIO		 6	/* No such device or address */
1231 #define	VKI_E2BIG		 7	/* Argument list too long */
1232 #define	VKI_ENOEXEC		 8	/* Exec format error */
1233 #define	VKI_EBADF		 9	/* Bad file number */
1234 #define	VKI_ECHILD		10	/* No child processes */
1235 #define	VKI_EAGAIN		11	/* Try again */
1236 #define	VKI_ENOMEM		12	/* Out of memory */
1237 #define	VKI_EACCES		13	/* Permission denied */
1238 #define	VKI_EFAULT		14	/* Bad address */
1239 #define	VKI_ENOTBLK		15	/* Block device required */
1240 #define	VKI_EBUSY		16	/* Device or resource busy */
1241 #define	VKI_EEXIST		17	/* File exists */
1242 #define	VKI_EXDEV		18	/* Cross-device link */
1243 #define	VKI_ENODEV		19	/* No such device */
1244 #define	VKI_ENOTDIR		20	/* Not a directory */
1245 #define	VKI_EISDIR		21	/* Is a directory */
1246 #define	VKI_EINVAL		22	/* Invalid argument */
1247 #define	VKI_ENFILE		23	/* File table overflow */
1248 #define	VKI_EMFILE		24	/* Too many open files */
1249 #define	VKI_ENOTTY		25	/* Not a typewriter */
1250 #define	VKI_ETXTBSY		26	/* Text file busy */
1251 #define	VKI_EFBIG		27	/* File too large */
1252 #define	VKI_ENOSPC		28	/* No space left on device */
1253 #define	VKI_ESPIPE		29	/* Illegal seek */
1254 #define	VKI_EROFS		30	/* Read-only file system */
1255 #define	VKI_EMLINK		31	/* Too many links */
1256 #define	VKI_EPIPE		32	/* Broken pipe */
1257 #define	VKI_EDOM		33	/* Math argument out of domain of func */
1258 #define	VKI_ERANGE		34	/* Math result not representable */
1259 
1260 //----------------------------------------------------------------------
1261 // From linux-2.6.8.1/include/asm-generic/errno.h
1262 //----------------------------------------------------------------------
1263 
1264 #define VKI_EWOULDBLOCK		VKI_EAGAIN
1265 
1266 //----------------------------------------------------------------------
1267 // From linux-2.6.8.1/include/linux/wait.h
1268 //----------------------------------------------------------------------
1269 
1270 #define VKI_WNOHANG	0x00000001
1271 
1272 #define __VKI_WALL	0x40000000	/* Wait on all children, regardless of type */
1273 #define __VKI_WCLONE	0x80000000	/* Wait only on non-SIGCHLD children */
1274 
1275 //----------------------------------------------------------------------
1276 // From linux-2.6.8.1/include/linux/mman.h
1277 //----------------------------------------------------------------------
1278 
1279 #define VKI_MREMAP_MAYMOVE	1
1280 #define VKI_MREMAP_FIXED	2
1281 
1282 //----------------------------------------------------------------------
1283 // From linux-2.6.31-rc4/include/linux/futex.h
1284 //----------------------------------------------------------------------
1285 
1286 #define VKI_FUTEX_WAIT (0)
1287 #define VKI_FUTEX_WAKE (1)
1288 #define VKI_FUTEX_FD (2)
1289 #define VKI_FUTEX_REQUEUE (3)
1290 #define VKI_FUTEX_CMP_REQUEUE (4)
1291 #define VKI_FUTEX_WAKE_OP (5)
1292 #define VKI_FUTEX_LOCK_PI (6)
1293 #define VKI_FUTEX_UNLOCK_PI (7)
1294 #define VKI_FUTEX_TRYLOCK_PI (8)
1295 #define VKI_FUTEX_WAIT_BITSET (9)
1296 #define VKI_FUTEX_WAKE_BITSET (10)
1297 #define VKI_FUTEX_WAIT_REQUEUE_PI (11)
1298 #define VKI_FUTEX_CMP_REQUEUE_PI (12)
1299 #define VKI_FUTEX_PRIVATE_FLAG (128)
1300 #define VKI_FUTEX_CLOCK_REALTIME (256)
1301 
1302 struct vki_robust_list {
1303 	struct vki_robust_list __user *next;
1304 };
1305 
1306 struct vki_robust_list_head {
1307 	/*
1308 	 * The head of the list. Points back to itself if empty:
1309 	 */
1310 	struct vki_robust_list list;
1311 
1312 	/*
1313 	 * This relative offset is set by user-space, it gives the kernel
1314 	 * the relative position of the futex field to examine. This way
1315 	 * we keep userspace flexible, to freely shape its data-structure,
1316 	 * without hardcoding any particular offset into the kernel:
1317 	 */
1318 	long futex_offset;
1319 
1320 	/*
1321 	 * The death of the thread may race with userspace setting
1322 	 * up a lock's links. So to handle this race, userspace first
1323 	 * sets this field to the address of the to-be-taken lock,
1324 	 * then does the lock acquire, and then adds itself to the
1325 	 * list, and then clears this field. Hence the kernel will
1326 	 * always have full knowledge of all locks that the thread
1327 	 * _might_ have taken. We check the owner TID in any case,
1328 	 * so only truly owned locks will be handled.
1329 	 */
1330 	struct vki_robust_list __user *list_op_pending;
1331 };
1332 
1333 //----------------------------------------------------------------------
1334 // From linux-2.6.8.1/include/linux/errno.h
1335 //----------------------------------------------------------------------
1336 
1337 #define VKI_ERESTARTSYS	512
1338 
1339 //----------------------------------------------------------------------
1340 // From linux-2.6.8.1/include/linux/stat.h
1341 //----------------------------------------------------------------------
1342 
1343 #define VKI_S_IFMT  00170000
1344 #define VKI_S_IFSOCK 0140000
1345 #define VKI_S_IFLNK  0120000
1346 #define VKI_S_IFREG  0100000
1347 #define VKI_S_IFBLK  0060000
1348 #define VKI_S_IFDIR  0040000
1349 #define VKI_S_IFCHR  0020000
1350 #define VKI_S_IFIFO  0010000
1351 #define VKI_S_ISUID  0004000
1352 #define VKI_S_ISGID  0002000
1353 #define VKI_S_ISVTX  0001000
1354 
1355 #define VKI_S_ISLNK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFLNK)
1356 #define VKI_S_ISREG(m)	(((m) & VKI_S_IFMT) == VKI_S_IFREG)
1357 #define VKI_S_ISDIR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFDIR)
1358 #define VKI_S_ISCHR(m)	(((m) & VKI_S_IFMT) == VKI_S_IFCHR)
1359 #define VKI_S_ISBLK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFBLK)
1360 #define VKI_S_ISFIFO(m)	(((m) & VKI_S_IFMT) == VKI_S_IFIFO)
1361 #define VKI_S_ISSOCK(m)	(((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
1362 
1363 #define VKI_S_IRWXU 00700
1364 #define VKI_S_IRUSR 00400
1365 #define VKI_S_IWUSR 00200
1366 #define VKI_S_IXUSR 00100
1367 
1368 #define VKI_S_IRWXG 00070
1369 #define VKI_S_IRGRP 00040
1370 #define VKI_S_IWGRP 00020
1371 #define VKI_S_IXGRP 00010
1372 
1373 #define VKI_S_IRWXO 00007
1374 #define VKI_S_IROTH 00004
1375 #define VKI_S_IWOTH 00002
1376 #define VKI_S_IXOTH 00001
1377 
1378 //----------------------------------------------------------------------
1379 // From linux-2.6.8.1/include/linux/dirent.h
1380 //----------------------------------------------------------------------
1381 
1382 /* This is the old compat structure to use with the old dirent syscall. */
1383 struct vki_dirent {
1384 	long		d_ino;
1385 	__vki_kernel_off_t	d_off;
1386 	unsigned short	d_reclen;
1387 	char		d_name[256]; /* We must not include limits.h! */
1388 };
1389 
1390 /* This is the new structure to use with the dirent64 syscall. */
1391 struct vki_dirent64 {
1392 	__vki_u64 d_ino;
1393 	__vki_s64 d_off;
1394 	unsigned short d_reclen;
1395 	unsigned char d_type;
1396 	char d_name[256]; /* Note we hard code a max file length here. */
1397 };
1398 
1399 //----------------------------------------------------------------------
1400 // From linux-2.6.8.1/include/linux/fcntl.h
1401 //----------------------------------------------------------------------
1402 
1403 #define VKI_F_SETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 0)
1404 #define VKI_F_GETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 1)
1405 
1406 #define VKI_F_CANCELLK      (VKI_F_LINUX_SPECIFIC_BASE + 5)
1407 
1408 #define VKI_F_DUPFD_CLOEXEC (VKI_F_LINUX_SPECIFIC_BASE + 6)
1409 
1410 #define VKI_F_NOTIFY        (VKI_F_LINUX_SPECIFIC_BASE + 2)
1411 
1412 #define VKI_F_SETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 7)
1413 #define VKI_F_GETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 8)
1414 
1415 struct vki_flock {
1416 	short			l_type;
1417 	short			l_whence;
1418 	__vki_kernel_off_t	l_start;
1419 	__vki_kernel_off_t	l_len;
1420 	__vki_kernel_pid_t	l_pid;
1421 };
1422 
1423 struct vki_flock64 {
1424 	short			l_type;
1425 	short			l_whence;
1426 	__vki_kernel_loff_t	l_start;
1427 	__vki_kernel_loff_t	l_len;
1428 	__vki_kernel_pid_t	l_pid;
1429 };
1430 
1431 //----------------------------------------------------------------------
1432 // From linux-2.6.8.1/include/linux/sysctl.h
1433 //----------------------------------------------------------------------
1434 
1435 struct __vki_sysctl_args {
1436 	int __user *name;
1437 	int nlen;
1438 	void __user *oldval;
1439 	vki_size_t __user *oldlenp;
1440 	void __user *newval;
1441 	vki_size_t newlen;
1442 	unsigned long __unused0[4];
1443 };
1444 
1445 //----------------------------------------------------------------------
1446 // From linux-2.6.8.1/include/linux/aio_abi.h
1447 //----------------------------------------------------------------------
1448 
1449 typedef unsigned long	vki_aio_context_t;
1450 
1451 enum {
1452 	VKI_IOCB_CMD_PREAD = 0,
1453 	VKI_IOCB_CMD_PWRITE = 1,
1454 	VKI_IOCB_CMD_FSYNC = 2,
1455 	VKI_IOCB_CMD_FDSYNC = 3,
1456 	VKI_IOCB_CMD_PREADV = 7,
1457 	VKI_IOCB_CMD_PWRITEV = 8,
1458 };
1459 
1460 /* read() from /dev/aio returns these structures. */
1461 struct vki_io_event {
1462 	__vki_u64	data;		/* the data field from the iocb */
1463 	__vki_u64	obj;		/* what iocb this event came from */
1464         // [[Nb: These fields renamed from 'res' and 'res2' because 'res' is
1465         //   a macro in vg_syscalls.c!]]
1466 	__vki_s64	result;		/* result code for this event */
1467 	__vki_s64	result2;	/* secondary result */
1468 };
1469 
1470 #if defined(VKI_LITTLE_ENDIAN)
1471 #  define VKI_PADDED(x,y)	x, y
1472 #elif defined(VKI_BIG_ENDIAN)
1473 #  define VKI_PADDED(x,y)	y, x
1474 #else
1475 #error edit for your odd byteorder.
1476 #endif
1477 
1478 struct vki_iocb {
1479 	/* these are internal to the kernel/libc. */
1480 	__vki_u64	aio_data;	/* data to be returned in event's data */
1481 	__vki_u32	VKI_PADDED(aio_key, aio_reserved1);
1482 				/* the kernel sets aio_key to the req # */
1483 
1484 	/* common fields */
1485 	__vki_u16	aio_lio_opcode;	/* see IOCB_CMD_ above */
1486 	__vki_s16	aio_reqprio;
1487 	__vki_u32	aio_fildes;
1488 
1489 	__vki_u64	aio_buf;
1490 	__vki_u64	aio_nbytes;
1491 	__vki_s64	aio_offset;
1492 
1493 	/* extra parameters */
1494 	__vki_u64	aio_reserved2;	/* TODO: use this for a (struct sigevent *) */
1495 	__vki_u64	aio_reserved3;
1496 }; /* 64 bytes */
1497 
1498 //----------------------------------------------------------------------
1499 // From linux-2.6.8.1/include/linux/aio.h
1500 //----------------------------------------------------------------------
1501 
1502 struct vki_aio_ring {
1503 	unsigned	id;	/* kernel internal index number */
1504 	unsigned	nr;	/* number of io_events */
1505 	unsigned	head;
1506 	unsigned	tail;
1507 
1508 	unsigned	magic;
1509 	unsigned	compat_features;
1510 	unsigned	incompat_features;
1511 	unsigned	header_length;	/* size of aio_ring */
1512 
1513 	struct vki_io_event		io_events[0];
1514 }; /* 128 bytes + ring size */
1515 
1516 //----------------------------------------------------------------------
1517 // From linux-2.6.8.1/include/linux/msg.h
1518 //----------------------------------------------------------------------
1519 
1520 #define VKI_MSG_STAT 11
1521 #define VKI_MSG_INFO 12
1522 
1523 struct vki_msqid_ds {
1524 	struct vki_ipc_perm msg_perm;
1525 	struct vki_msg *msg_first;		/* first message on queue,unused  */
1526 	struct vki_msg *msg_last;		/* last message in queue,unused */
1527 	__vki_kernel_time_t msg_stime;	/* last msgsnd time */
1528 	__vki_kernel_time_t msg_rtime;	/* last msgrcv time */
1529 	__vki_kernel_time_t msg_ctime;	/* last change time */
1530 	unsigned long  msg_lcbytes;	/* Reuse junk fields for 32 bit */
1531 	unsigned long  msg_lqbytes;	/* ditto */
1532 	unsigned short msg_cbytes;	/* current number of bytes on queue */
1533 	unsigned short msg_qnum;	/* number of messages in queue */
1534 	unsigned short msg_qbytes;	/* max number of bytes on queue */
1535 	__vki_kernel_ipc_pid_t msg_lspid;	/* pid of last msgsnd */
1536 	__vki_kernel_ipc_pid_t msg_lrpid;	/* last receive pid */
1537 };
1538 
1539 struct vki_msgbuf {
1540 	long mtype;         /* type of message */
1541 	char mtext[1];      /* message text */
1542 };
1543 
1544 struct vki_msginfo {
1545 	int msgpool;
1546 	int msgmap;
1547 	int msgmax;
1548 	int msgmnb;
1549 	int msgmni;
1550 	int msgssz;
1551 	int msgtql;
1552 	unsigned short  msgseg;
1553 };
1554 
1555 //----------------------------------------------------------------------
1556 // From linux-2.6.8.1/include/linux/shm.h
1557 //----------------------------------------------------------------------
1558 
1559 struct vki_shmid_ds {
1560 	struct vki_ipc_perm		shm_perm;	/* operation perms */
1561 	int			shm_segsz;	/* size of segment (bytes) */
1562 	__vki_kernel_time_t		shm_atime;	/* last attach time */
1563 	__vki_kernel_time_t		shm_dtime;	/* last detach time */
1564 	__vki_kernel_time_t		shm_ctime;	/* last change time */
1565 	__vki_kernel_ipc_pid_t	shm_cpid;	/* pid of creator */
1566 	__vki_kernel_ipc_pid_t	shm_lpid;	/* pid of last operator */
1567 	unsigned short		shm_nattch;	/* no. of current attaches */
1568 	unsigned short 		shm_unused;	/* compatibility */
1569 	void 			*shm_unused2;	/* ditto - used by DIPC */
1570 	void			*shm_unused3;	/* unused */
1571 };
1572 
1573 #define VKI_SHM_RDONLY  010000  /* read-only access */
1574 #define VKI_SHM_RND     020000  /* round attach address to SHMLBA boundary */
1575 
1576 #define VKI_SHM_STAT 	13
1577 #define VKI_SHM_INFO 	14
1578 
1579 /* Obsolete, used only for backwards compatibility */
1580 struct	vki_shminfo {
1581 	int shmmax;
1582 	int shmmin;
1583 	int shmmni;
1584 	int shmseg;
1585 	int shmall;
1586 };
1587 
1588 struct vki_shm_info {
1589 	int used_ids;
1590 	unsigned long shm_tot;	/* total allocated shm */
1591 	unsigned long shm_rss;	/* total resident shm */
1592 	unsigned long shm_swp;	/* total swapped shm */
1593 	unsigned long swap_attempts;
1594 	unsigned long swap_successes;
1595 };
1596 
1597 //----------------------------------------------------------------------
1598 // From linux-2.6.8.1/include/linux/rtc.h
1599 //----------------------------------------------------------------------
1600 
1601 struct vki_rtc_time {
1602 	int tm_sec;
1603 	int tm_min;
1604 	int tm_hour;
1605 	int tm_mday;
1606 	int tm_mon;
1607 	int tm_year;
1608 	int tm_wday;
1609 	int tm_yday;
1610 	int tm_isdst;
1611 };
1612 
1613 #define VKI_RTC_AIE_ON	_VKI_IO('p', 0x01)	/* Alarm int. enable on	*/
1614 #define VKI_RTC_AIE_OFF	_VKI_IO('p', 0x02)	/* ... off		*/
1615 #define VKI_RTC_UIE_ON	_VKI_IO('p', 0x03)	/* Update int. enable on*/
1616 #define VKI_RTC_UIE_OFF	_VKI_IO('p', 0x04)	/* ... off		*/
1617 #define VKI_RTC_PIE_ON	_VKI_IO('p', 0x05)	/* Periodic int. enable on*/
1618 #define VKI_RTC_PIE_OFF	_VKI_IO('p', 0x06)	/* ... off		*/
1619 
1620 #define VKI_RTC_ALM_SET		_VKI_IOW('p', 0x07, struct vki_rtc_time) /* Set alarm time  */
1621 #define VKI_RTC_ALM_READ	_VKI_IOR('p', 0x08, struct vki_rtc_time) /* Read alarm time */
1622 #define VKI_RTC_RD_TIME		_VKI_IOR('p', 0x09, struct vki_rtc_time) /* Read RTC time   */
1623 //#define RTC_SET_TIME	_IOW('p', 0x0a, struct rtc_time) /* Set RTC time    */
1624 #define VKI_RTC_IRQP_READ	_VKI_IOR('p', 0x0b, unsigned long)	 /* Read IRQ rate   */
1625 #define VKI_RTC_IRQP_SET	_VKI_IOW('p', 0x0c, unsigned long)	 /* Set IRQ rate    */
1626 
1627 //----------------------------------------------------------------------
1628 // From linux-2.6.8.1/include/linux/isdn.h
1629 //----------------------------------------------------------------------
1630 
1631 // [[Nb: Resolved this for the common case where CONFIG_COBALT_MICRO_SERVER
1632 //   is not defined]]
1633 #define VKI_ISDN_MAX_CHANNELS   64
1634 
1635 #define VKI_IIOCGETCPS  _VKI_IO('I',21)
1636 
1637 #define VKI_IIOCNETGPN  _VKI_IO('I',34)
1638 
1639 #define VKI_ISDN_MSNLEN          32
1640 
1641 typedef struct {
1642   char name[10];
1643   char phone[VKI_ISDN_MSNLEN];
1644   int  outgoing;
1645 } vki_isdn_net_ioctl_phone;
1646 
1647 //----------------------------------------------------------------------
1648 // From linux-2.6.8.1/include/linux/sockios.h
1649 //----------------------------------------------------------------------
1650 
1651 #define VKI_SIOCOUTQ		VKI_TIOCOUTQ
1652 
1653 #define VKI_SIOCADDRT		0x890B	/* add routing table entry	*/
1654 #define VKI_SIOCDELRT		0x890C	/* delete routing table entry	*/
1655 
1656 #define VKI_SIOCGIFNAME		0x8910	/* get iface name		*/
1657 #define VKI_SIOCGIFCONF		0x8912	/* get iface list		*/
1658 #define VKI_SIOCGIFFLAGS	0x8913	/* get flags			*/
1659 #define VKI_SIOCSIFFLAGS	0x8914	/* set flags			*/
1660 #define VKI_SIOCGIFADDR		0x8915	/* get PA address		*/
1661 #define VKI_SIOCSIFADDR		0x8916	/* set PA address		*/
1662 #define VKI_SIOCGIFDSTADDR	0x8917	/* get remote PA address	*/
1663 #define VKI_SIOCSIFDSTADDR	0x8918	/* set remote PA address	*/
1664 #define VKI_SIOCGIFBRDADDR	0x8919	/* get broadcast PA address	*/
1665 #define VKI_SIOCSIFBRDADDR	0x891a	/* set broadcast PA address	*/
1666 #define VKI_SIOCGIFNETMASK	0x891b	/* get network PA mask		*/
1667 #define VKI_SIOCSIFNETMASK	0x891c	/* set network PA mask		*/
1668 #define VKI_SIOCGIFMETRIC	0x891d	/* get metric			*/
1669 #define VKI_SIOCSIFMETRIC	0x891e	/* set metric			*/
1670 #define VKI_SIOCGIFMTU		0x8921	/* get MTU size			*/
1671 #define VKI_SIOCSIFMTU		0x8922	/* set MTU size			*/
1672 #define	VKI_SIOCSIFHWADDR	0x8924	/* set hardware address 	*/
1673 #define VKI_SIOCGIFHWADDR	0x8927	/* Get hardware address		*/
1674 #define VKI_SIOCGIFINDEX	0x8933	/* name -> if_index mapping	*/
1675 
1676 #define VKI_SIOCGIFTXQLEN	0x8942	/* Get the tx queue length	*/
1677 #define VKI_SIOCSIFTXQLEN	0x8943	/* Set the tx queue length 	*/
1678 
1679 #define VKI_SIOCETHTOOL		0x8946	/* Ethtool interface		*/
1680 
1681 #define VKI_SIOCGMIIPHY		0x8947	/* Get address of MII PHY in use. */
1682 #define VKI_SIOCGMIIREG		0x8948	/* Read MII PHY register.	*/
1683 #define VKI_SIOCSMIIREG		0x8949	/* Write MII PHY register.	*/
1684 
1685 #define VKI_SIOCDARP		0x8953	/* delete ARP table entry	*/
1686 #define VKI_SIOCGARP		0x8954	/* get ARP table entry		*/
1687 #define VKI_SIOCSARP		0x8955	/* set ARP table entry		*/
1688 
1689 #define VKI_SIOCDRARP		0x8960	/* delete RARP table entry	*/
1690 #define VKI_SIOCGRARP		0x8961	/* get RARP table entry		*/
1691 #define VKI_SIOCSRARP		0x8962	/* set RARP table entry		*/
1692 
1693 #define VKI_SIOCGIFMAP		0x8970	/* Get device parameters	*/
1694 #define VKI_SIOCSIFMAP		0x8971	/* Set device parameters	*/
1695 
1696 #define VKI_SIOCSHWTSTAMP	0x89B0	/* Set hardware time stamping */
1697 
1698 //----------------------------------------------------------------------
1699 // From linux-2.6.8.1/include/linux/ppdev.h
1700 //----------------------------------------------------------------------
1701 
1702 #define VKI_PP_MAJOR	99
1703 
1704 #define VKI_PP_IOCTL	'p'
1705 
1706 /* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */
1707 #define VKI_PPSETMODE	_VKI_IOW(VKI_PP_IOCTL, 0x80, int)
1708 
1709 /* Read status */
1710 #define VKI_PPRSTATUS	_VKI_IOR(VKI_PP_IOCTL, 0x81, unsigned char)
1711 //#define PPWSTATUS	OBSOLETE__IOW(PP_IOCTL, 0x82, unsigned char)
1712 
1713 /* Read/write control */
1714 #define VKI_PPRCONTROL	_VKI_IOR(VKI_PP_IOCTL, 0x83, unsigned char)
1715 #define VKI_PPWCONTROL	_VKI_IOW(VKI_PP_IOCTL, 0x84, unsigned char)
1716 
1717 struct vki_ppdev_frob_struct {
1718 	unsigned char mask;
1719 	unsigned char val;
1720 };
1721 #define VKI_PPFCONTROL      _VKI_IOW(VKI_PP_IOCTL, 0x8e, struct vki_ppdev_frob_struct)
1722 
1723 /* Read/write data */
1724 #define VKI_PPRDATA		_VKI_IOR(VKI_PP_IOCTL, 0x85, unsigned char)
1725 #define VKI_PPWDATA		_VKI_IOW(VKI_PP_IOCTL, 0x86, unsigned char)
1726 
1727 /* Claim the port to start using it */
1728 #define VKI_PPCLAIM		_VKI_IO(VKI_PP_IOCTL, 0x8b)
1729 
1730 /* Release the port when you aren't using it */
1731 #define VKI_PPRELEASE	_VKI_IO(VKI_PP_IOCTL, 0x8c)
1732 
1733 /* Yield the port (release it if another driver is waiting,
1734  * then reclaim) */
1735 #define VKI_PPYIELD		_VKI_IO(VKI_PP_IOCTL, 0x8d)
1736 
1737 /* Register device exclusively (must be before PPCLAIM). */
1738 #define VKI_PPEXCL		_VKI_IO(VKI_PP_IOCTL, 0x8f)
1739 
1740 /* Data line direction: non-zero for input mode. */
1741 #define VKI_PPDATADIR	_VKI_IOW(VKI_PP_IOCTL, 0x90, int)
1742 
1743 /* Negotiate a particular IEEE 1284 mode. */
1744 #define VKI_PPNEGOT	_VKI_IOW(VKI_PP_IOCTL, 0x91, int)
1745 
1746 /* Set control lines when an interrupt occurs. */
1747 #define VKI_PPWCTLONIRQ	_VKI_IOW(VKI_PP_IOCTL, 0x92, unsigned char)
1748 
1749 /* Clear (and return) interrupt count. */
1750 #define VKI_PPCLRIRQ	_VKI_IOR(VKI_PP_IOCTL, 0x93, int)
1751 
1752 /* Set the IEEE 1284 phase that we're in (e.g. IEEE1284_PH_FWD_IDLE) */
1753 #define VKI_PPSETPHASE	_VKI_IOW(VKI_PP_IOCTL, 0x94, int)
1754 
1755 /* Set and get port timeout (struct timeval's) */
1756 #define VKI_PPGETTIME	_VKI_IOR(VKI_PP_IOCTL, 0x95, struct vki_timeval)
1757 #define VKI_PPSETTIME	_VKI_IOW(VKI_PP_IOCTL, 0x96, struct vki_timeval)
1758 
1759 #define VKI_PPGETMODES	_VKI_IOR(VKI_PP_IOCTL, 0x97, unsigned int)
1760 
1761 #define VKI_PPGETMODE	_VKI_IOR(VKI_PP_IOCTL, 0x98, int)
1762 #define VKI_PPGETPHASE	_VKI_IOR(VKI_PP_IOCTL, 0x99, int)
1763 
1764 #define VKI_PPGETFLAGS	_VKI_IOR(VKI_PP_IOCTL, 0x9a, int)
1765 #define VKI_PPSETFLAGS	_VKI_IOW(VKI_PP_IOCTL, 0x9b, int)
1766 
1767 //----------------------------------------------------------------------
1768 // From linux-3.16/include/uapi/linux/fs.h
1769 //----------------------------------------------------------------------
1770 
1771 #define VKI_BLKROSET   _VKI_IO(0x12,93)	/* set device read-only (0 = read-write) */
1772 #define VKI_BLKROGET   _VKI_IO(0x12,94)	/* get read-only status (0 = read_write) */
1773 #define VKI_BLKGETSIZE _VKI_IO(0x12,96) /* return device size /512 (long *arg) */
1774 #define VKI_BLKRASET   _VKI_IO(0x12,98)	/* set read ahead for block device */
1775 #define VKI_BLKRAGET   _VKI_IO(0x12,99)	/* get current read ahead setting */
1776 #define VKI_BLKFRASET  _VKI_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
1777 #define VKI_BLKFRAGET  _VKI_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
1778 #define VKI_BLKSECTGET _VKI_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
1779 #define VKI_BLKSSZGET  _VKI_IO(0x12,104)/* get block device sector size */
1780 #define VKI_BLKBSZGET  _VKI_IOR(0x12,112,vki_size_t)
1781 #define VKI_BLKBSZSET  _VKI_IOW(0x12,113,vki_size_t)
1782 #define VKI_BLKGETSIZE64 _VKI_IOR(0x12,114,vki_size_t) /* return device size in bytes (u64 *arg) */
1783 #define VKI_BLKPBSZGET _VKI_IO(0x12,123)
1784 #define VKI_BLKDISCARDZEROES _VKI_IO(0x12,124)
1785 
1786 #define VKI_FIBMAP	_VKI_IO(0x00,1)	/* bmap access */
1787 #define VKI_FIGETBSZ    _VKI_IO(0x00,2)	/* get the block size used for bmap */
1788 
1789 //----------------------------------------------------------------------
1790 // From linux-2.6.8.1/include/scsi/sg.h
1791 //----------------------------------------------------------------------
1792 
1793 typedef struct vki_sg_io_hdr
1794 {
1795     int interface_id;           /* [i] 'S' for SCSI generic (required) */
1796     int dxfer_direction;        /* [i] data transfer direction  */
1797     unsigned char cmd_len;      /* [i] SCSI command length ( <= 16 bytes) */
1798     unsigned char mx_sb_len;    /* [i] max length to write to sbp */
1799     unsigned short iovec_count; /* [i] 0 implies no scatter gather */
1800     unsigned int dxfer_len;     /* [i] byte count of data transfer */
1801     void __user *dxferp;	/* [i], [*io] points to data transfer memory
1802 					      or scatter gather list */
1803     unsigned char __user *cmdp; /* [i], [*i] points to command to perform */
1804     void __user *sbp;		/* [i], [*o] points to sense_buffer memory */
1805     unsigned int timeout;       /* [i] MAX_UINT->no timeout (unit: millisec) */
1806     unsigned int flags;         /* [i] 0 -> default, see SG_FLAG... */
1807     int pack_id;                /* [i->o] unused internally (normally) */
1808     void __user * usr_ptr;      /* [i->o] unused internally */
1809     unsigned char status;       /* [o] scsi status */
1810     unsigned char masked_status;/* [o] shifted, masked scsi status */
1811     unsigned char msg_status;   /* [o] messaging level data (optional) */
1812     unsigned char sb_len_wr;    /* [o] byte count actually written to sbp */
1813     unsigned short host_status; /* [o] errors from host adapter */
1814     unsigned short driver_status;/* [o] errors from software driver */
1815     int resid;                  /* [o] dxfer_len - actual_transferred */
1816     unsigned int duration;      /* [o] time taken by cmd (unit: millisec) */
1817     unsigned int info;          /* [o] auxiliary information */
1818 } vki_sg_io_hdr_t;  /* 64 bytes long (on i386) */
1819 
1820 #define VKI_SG_DXFER_NONE -1        /* e.g. a SCSI Test Unit Ready command */
1821 #define VKI_SG_DXFER_TO_DEV -2      /* e.g. a SCSI WRITE command */
1822 #define VKI_SG_DXFER_FROM_DEV -3    /* e.g. a SCSI READ command */
1823 #define VKI_SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the
1824 				   additional property than during indirect
1825 				   IO the user buffer is copied into the
1826 				   kernel buffers before the transfer */
1827 
1828 typedef struct vki_sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */
1829     int host_no;        /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */
1830     int channel;
1831     int scsi_id;        /* scsi id of target device */
1832     int lun;
1833     int scsi_type;      /* TYPE_... defined in scsi/scsi.h */
1834     short h_cmd_per_lun;/* host (adapter) maximum commands per lun */
1835     short d_queue_depth;/* device (or adapter) maximum queue length */
1836     int unused[2];      /* probably find a good use, set 0 for now */
1837 } vki_sg_scsi_id_t; /* 32 bytes long on i386 */
1838 
1839 #define VKI_SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */
1840 
1841 #define VKI_SG_SET_RESERVED_SIZE 0x2275  /* request a new reserved buffer size */
1842 #define VKI_SG_GET_RESERVED_SIZE 0x2272  /* actual size of reserved buffer */
1843 
1844 #define VKI_SG_GET_SCSI_ID 0x2276   /* Yields fd's bus, chan, dev, lun + type */
1845 
1846 #define VKI_SG_GET_SG_TABLESIZE 0x227F  /* 0 implies can't do scatter gather */
1847 
1848 #define VKI_SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
1849 
1850 #define VKI_SG_IO 0x2285   /* similar effect as write() followed by read() */
1851 
1852 #define VKI_SG_SET_TIMEOUT 0x2201  /* unit: jiffies (10ms on i386) */
1853 #define VKI_SG_GET_TIMEOUT 0x2202  /* yield timeout as _return_ value */
1854 
1855 //#define SG_GET_COMMAND_Q 0x2270   /* Yields 0 (queuing off) or 1 (on) */
1856 #define VKI_SG_SET_COMMAND_Q 0x2271   /* Change queuing state with 0 or 1 */
1857 
1858 //----------------------------------------------------------------------
1859 // From linux-2.6.34/include/scsi/scsi.h and scsi/scsi_ioctl.h
1860 //----------------------------------------------------------------------
1861 
1862 #define VKI_SCSI_IOCTL_DOORLOCK		0x5380 /* Lock the eject mechanism.  */
1863 #define VKI_SCSI_IOCTL_DOORUNLOCK	0x5381 /* Unlock the mechanism.  */
1864 #define VKI_SCSI_IOCTL_GET_IDLUN	0x5382
1865 #define VKI_SCSI_IOCTL_GET_BUS_NUMBER	0x5386
1866 
1867 struct vki_scsi_idlun {
1868 	__vki_u32 dev_id;
1869 	__vki_u32 host_unique_id;
1870 };
1871 
1872 //----------------------------------------------------------------------
1873 // From linux-2.6.8.1/include/linux/cdrom.h
1874 //----------------------------------------------------------------------
1875 
1876 #define VKI_CDROMPLAYMSF		0x5303 /* Play Audio MSF (struct cdrom_msf) */
1877 #define VKI_CDROMREADTOCHDR		0x5305 /* Read TOC header
1878                                 	           (struct cdrom_tochdr) */
1879 #define VKI_CDROMREADTOCENTRY		0x5306 /* Read TOC entry
1880                                 	           (struct cdrom_tocentry) */
1881 #define VKI_CDROMSTOP			0x5307 /* Stop the cdrom drive */
1882 #define VKI_CDROMSUBCHNL		0x530b /* Read subchannel data
1883                                 	           (struct cdrom_subchnl) */
1884 #define VKI_CDROMREADMODE2		0x530c /* Read CDROM mode 2 data (2336 Bytes)
1885                                 	           (struct cdrom_read) */
1886 #define VKI_CDROMREADMODE1		0x530d /* Read CDROM mode 1 data (2048 Bytes)
1887                                                    (struct cdrom_read) */
1888 #define VKI_CDROMREADAUDIO		0x530e /* (struct cdrom_read_audio) */
1889 #define VKI_CDROMMULTISESSION		0x5310 /* Obtain the start-of-last-session
1890                                 	           address of multi session disks
1891                                 	           (struct cdrom_multisession) */
1892 #define VKI_CDROM_GET_MCN		0x5311 /* Obtain the "Universal Product Code"
1893                                 	           if available (struct cdrom_mcn) */
1894 #define VKI_CDROMVOLREAD		0x5313 /* Get the drive's volume setting
1895                                 	          (struct cdrom_volctrl) */
1896 #define VKI_CDROMREADRAW		0x5314	/* read data in raw mode (2352 Bytes)
1897                                 	           (struct cdrom_read) */
1898 #define VKI_CDROM_CLEAR_OPTIONS		0x5321  /* Clear behavior options */
1899 #define VKI_CDROM_DRIVE_STATUS		0x5326  /* Get tray position, etc. */
1900 #define VKI_CDROM_DISC_STATUS		0x5327	/* get CD type information */
1901 #define VKI_CDROM_GET_CAPABILITY	0x5331	/* get capabilities */
1902 
1903 #define VKI_DVD_READ_STRUCT		0x5390  /* read structure */
1904 #define VKI_CDROM_SEND_PACKET		0x5393	/* send a packet to the drive */
1905 
1906 struct vki_cdrom_msf0
1907 {
1908 	__vki_u8	minute;
1909 	__vki_u8	second;
1910 	__vki_u8	frame;
1911 };
1912 
1913 union vki_cdrom_addr
1914 {
1915 	struct vki_cdrom_msf0	msf;
1916 	int			lba;
1917 };
1918 
1919 struct vki_cdrom_msf
1920 {
1921 	__vki_u8	cdmsf_min0;	/* start minute */
1922 	__vki_u8	cdmsf_sec0;	/* start second */
1923 	__vki_u8	cdmsf_frame0;	/* start frame */
1924 	__vki_u8	cdmsf_min1;	/* end minute */
1925 	__vki_u8	cdmsf_sec1;	/* end second */
1926 	__vki_u8	cdmsf_frame1;	/* end frame */
1927 };
1928 
1929 struct vki_cdrom_tochdr
1930 {
1931 	__vki_u8	cdth_trk0;	/* start track */
1932 	__vki_u8	cdth_trk1;	/* end track */
1933 };
1934 
1935 struct vki_cdrom_volctrl
1936 {
1937 	__vki_u8	channel0;
1938 	__vki_u8	channel1;
1939 	__vki_u8	channel2;
1940 	__vki_u8	channel3;
1941 };
1942 
1943 struct vki_cdrom_subchnl
1944 {
1945 	__vki_u8	cdsc_format;
1946 	__vki_u8	cdsc_audiostatus;
1947 	__vki_u8	cdsc_adr:	4;
1948 	__vki_u8	cdsc_ctrl:	4;
1949 	__vki_u8	cdsc_trk;
1950 	__vki_u8	cdsc_ind;
1951 	union vki_cdrom_addr cdsc_absaddr;
1952 	union vki_cdrom_addr cdsc_reladdr;
1953 };
1954 
1955 struct vki_cdrom_tocentry
1956 {
1957 	__vki_u8	cdte_track;
1958 	__vki_u8	cdte_adr	:4;
1959 	__vki_u8	cdte_ctrl	:4;
1960 	__vki_u8	cdte_format;
1961 	union vki_cdrom_addr cdte_addr;
1962 	__vki_u8	cdte_datamode;
1963 };
1964 
1965 struct vki_cdrom_read
1966 {
1967 	int	cdread_lba;
1968 	char 	*cdread_bufaddr;
1969 	int	cdread_buflen;
1970 };
1971 
1972 struct vki_cdrom_read_audio
1973 {
1974 	union vki_cdrom_addr addr; /* frame address */
1975 	__vki_u8 addr_format;      /* CDROM_LBA or CDROM_MSF */
1976 	int nframes;           /* number of 2352-byte-frames to read at once */
1977 	__vki_u8 __user *buf;      /* frame buffer (size: nframes*2352 bytes) */
1978 };
1979 
1980 struct vki_cdrom_multisession
1981 {
1982 	union vki_cdrom_addr addr; /* frame address: start-of-last-session
1983 	                           (not the new "frame 16"!).  Only valid
1984 	                           if the "xa_flag" is true. */
1985 	__vki_u8 xa_flag;        /* 1: "is XA disk" */
1986 	__vki_u8 addr_format;    /* CDROM_LBA or CDROM_MSF */
1987 };
1988 
1989 struct vki_cdrom_mcn
1990 {
1991   __vki_u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
1992 };
1993 
1994 #define VKI_CDROM_PACKET_SIZE	12
1995 
1996 struct vki_cdrom_generic_command
1997 {
1998 	unsigned char 		cmd[VKI_CDROM_PACKET_SIZE];
1999 	unsigned char		__user *buffer;
2000 	unsigned int 		buflen;
2001 	int			stat;
2002         // [[replace with void* to reduce inclusion amounts]]
2003 	void/*struct vki_request_sense	*/__user *sense;
2004 	unsigned char		data_direction;
2005 	int			quiet;
2006 	int			timeout;
2007 	void			__user *reserved[1];	/* unused, actually */
2008 };
2009 
2010 #define VKI_CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
2011 #define VKI_CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
2012 #define VKI_CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
2013 #define VKI_CD_FRAMESIZE_RAW0 (VKI_CD_FRAMESIZE_RAW-VKI_CD_SYNC_SIZE-VKI_CD_HEAD_SIZE) /*2336*/
2014 #define VKI_CD_FRAMESIZE_RAW1  2048 /* bytes per frame, mode 1*/
2015 
2016 //----------------------------------------------------------------------
2017 // From linux-2.6.8.1/include/linux/soundcard.h
2018 //----------------------------------------------------------------------
2019 
2020 #ifndef _VKI_SIOWR
2021 #if defined(_VKI_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__)))
2022 /* Use already defined ioctl defines if they exist (except with Sun or Sparc) */
2023 #define	_VKI_SIO		_VKI_IO
2024 #define	_VKI_SIOR		_VKI_IOR
2025 #define	_VKI_SIOW		_VKI_IOW
2026 #define	_VKI_SIOWR		_VKI_IOWR
2027 #else
2028 // [[Valgrind: Install this case if/when necessary]
2029 #error Valgrind: Cannot handle sparc/sun case yet...
2030 #  endif /* _IOWR */
2031 #endif  /* !_VKI_SIOWR */
2032 
2033 #define VKI_SNDCTL_SEQ_CTRLRATE		_VKI_SIOWR('Q', 3, int)	/* Set/get timer resolution (HZ) */
2034 #define VKI_SNDCTL_SEQ_GETOUTCOUNT	_VKI_SIOR ('Q', 4, int)
2035 #define VKI_SNDCTL_SEQ_GETINCOUNT	_VKI_SIOR ('Q', 5, int)
2036 #define VKI_SNDCTL_SEQ_PERCMODE		_VKI_SIOW ('Q', 6, int)
2037 #define VKI_SNDCTL_SEQ_TESTMIDI		_VKI_SIOW ('Q', 8, int)
2038 #define VKI_SNDCTL_SEQ_RESETSAMPLES	_VKI_SIOW ('Q', 9, int)
2039 #define VKI_SNDCTL_SEQ_NRSYNTHS		_VKI_SIOR ('Q',10, int)
2040 #define VKI_SNDCTL_SEQ_NRMIDIS		_VKI_SIOR ('Q',11, int)
2041 #define VKI_SNDCTL_SEQ_GETTIME		_VKI_SIOR ('Q',19, int)
2042 
2043 #define VKI_SNDCTL_TMR_TIMEBASE		_VKI_SIOWR('T', 1, int)
2044 #define VKI_SNDCTL_TMR_TEMPO		_VKI_SIOWR('T', 5, int)
2045 #define VKI_SNDCTL_TMR_SOURCE		_VKI_SIOWR('T', 6, int)
2046 
2047 #define VKI_SNDCTL_MIDI_PRETIME		_VKI_SIOWR('m', 0, int)
2048 #define VKI_SNDCTL_MIDI_MPUMODE		_VKI_SIOWR('m', 1, int)
2049 
2050 #define VKI_SNDCTL_DSP_RESET		_VKI_SIO  ('P', 0)
2051 #define VKI_SNDCTL_DSP_SYNC		_VKI_SIO  ('P', 1)
2052 #define VKI_SNDCTL_DSP_SPEED		_VKI_SIOWR('P', 2, int)
2053 #define VKI_SNDCTL_DSP_STEREO		_VKI_SIOWR('P', 3, int)
2054 #define VKI_SNDCTL_DSP_GETBLKSIZE	_VKI_SIOWR('P', 4, int)
2055 #define VKI_SNDCTL_DSP_CHANNELS		_VKI_SIOWR('P', 6, int)
2056 #define VKI_SOUND_PCM_WRITE_FILTER	_VKI_SIOWR('P', 7, int)
2057 #define VKI_SNDCTL_DSP_POST		_VKI_SIO  ('P', 8)
2058 #define VKI_SNDCTL_DSP_SUBDIVIDE	_VKI_SIOWR('P', 9, int)
2059 #define VKI_SNDCTL_DSP_SETFRAGMENT	_VKI_SIOWR('P',10, int)
2060 
2061 #define VKI_SNDCTL_DSP_GETFMTS		_VKI_SIOR ('P',11, int) /* Returns a mask */
2062 #define VKI_SNDCTL_DSP_SETFMT		_VKI_SIOWR('P', 5, int) /* Selects ONE fmt */
2063 
2064 typedef struct vki_audio_buf_info {
2065 			int fragments;	/* # of available fragments (partially usend ones not counted) */
2066 			int fragstotal;	/* Total # of fragments allocated */
2067 			int fragsize;	/* Size of a fragment in bytes */
2068 
2069 			int bytes;	/* Available space in bytes (includes partially used fragments) */
2070 			/* Note! 'bytes' could be more than fragments*fragsize */
2071 		} vki_audio_buf_info;
2072 
2073 #define VKI_SNDCTL_DSP_GETOSPACE	_VKI_SIOR ('P',12, vki_audio_buf_info)
2074 #define VKI_SNDCTL_DSP_GETISPACE	_VKI_SIOR ('P',13, vki_audio_buf_info)
2075 #define VKI_SNDCTL_DSP_NONBLOCK		_VKI_SIO  ('P',14)
2076 #define VKI_SNDCTL_DSP_GETCAPS		_VKI_SIOR ('P',15, int)
2077 
2078 #define VKI_SNDCTL_DSP_GETTRIGGER	_VKI_SIOR ('P',16, int)
2079 #define VKI_SNDCTL_DSP_SETTRIGGER	_VKI_SIOW ('P',16, int)
2080 
2081 #define VKI_SNDCTL_DSP_SETSYNCRO	_VKI_SIO  ('P', 21)
2082 #define VKI_SNDCTL_DSP_SETDUPLEX	_VKI_SIO  ('P', 22)
2083 #define VKI_SNDCTL_DSP_GETODELAY	_VKI_SIOR ('P', 23, int)
2084 
2085 #define VKI_SNDCTL_DSP_GETCHANNELMASK	_VKI_SIOWR('P', 64, int)
2086 #define VKI_SNDCTL_DSP_BIND_CHANNEL	_VKI_SIOWR('P', 65, int)
2087 
2088 #define VKI_SNDCTL_DSP_SETSPDIF		_VKI_SIOW ('P', 66, int)
2089 #define VKI_SNDCTL_DSP_GETSPDIF		_VKI_SIOR ('P', 67, int)
2090 
2091 #define VKI_SOUND_PCM_READ_RATE		_VKI_SIOR ('P', 2, int)
2092 #define VKI_SOUND_PCM_READ_CHANNELS	_VKI_SIOR ('P', 6, int)
2093 #define VKI_SOUND_PCM_READ_BITS		_VKI_SIOR ('P', 5, int)
2094 #define VKI_SOUND_PCM_READ_FILTER	_VKI_SIOR ('P', 7, int)
2095 
2096 
2097 //----------------------------------------------------------------------
2098 // From linux-2.6.8.1/include/linux/hdreg.h
2099 //----------------------------------------------------------------------
2100 
2101 struct vki_hd_geometry {
2102       unsigned char heads;
2103       unsigned char sectors;
2104       unsigned short cylinders;
2105       unsigned long start;
2106 };
2107 
2108 #define VKI_HDIO_GETGEO		0x0301	/* get device geometry */
2109 #define VKI_HDIO_GET_DMA	0x030b	/* get use-dma flag */
2110 #define VKI_HDIO_GET_IDENTITY	0x030d	/* get IDE identification info */
2111 
2112 // [[Nb: done like this because the original type is a huge struct that will
2113 //   always be the same size.]]
2114 #define VKI_SIZEOF_STRUCT_HD_DRIVEID   512
2115 
2116 //----------------------------------------------------------------------
2117 // From linux-2.6.8.1/include/linux/fb.h
2118 //----------------------------------------------------------------------
2119 
2120 #define VKI_FBIOGET_VSCREENINFO	0x4600
2121 #define VKI_FBIOPUT_VSCREENINFO	0x4601
2122 #define VKI_FBIOGET_FSCREENINFO	0x4602
2123 #define VKI_FBIOPAN_DISPLAY	0x4606
2124 
2125 struct vki_fb_fix_screeninfo {
2126 	char id[16];			/* identification string eg "TT Builtin" */
2127 	unsigned long smem_start;	/* Start of frame buffer mem */
2128 					/* (physical address) */
2129 	__vki_u32 smem_len;			/* Length of frame buffer mem */
2130 	__vki_u32 type;			/* see FB_TYPE_*		*/
2131 	__vki_u32 type_aux;		/* Interleave for interleaved Planes */
2132 	__vki_u32 visual;		/* see FB_VISUAL_*		*/
2133 	__vki_u16 xpanstep;		/* zero if no hardware panning  */
2134 	__vki_u16 ypanstep;		/* zero if no hardware panning  */
2135 	__vki_u16 ywrapstep;		/* zero if no hardware ywrap    */
2136 	__vki_u32 line_length;		/* length of a line in bytes    */
2137 	unsigned long mmio_start;	/* Start of Memory Mapped I/O   */
2138 					/* (physical address) */
2139 	__vki_u32 mmio_len;		/* Length of Memory Mapped I/O  */
2140 	__vki_u32 accel;		/* Indicate to driver which	*/
2141 					/*  specific chip/card we have	*/
2142 	__vki_u16 reserved[3];		/* Reserved for future compatibility */
2143 };
2144 
2145 struct vki_fb_bitfield {
2146 	__vki_u32 offset;		/* beginning of bitfield	*/
2147 	__vki_u32 length;		/* length of bitfield		*/
2148 	__vki_u32 msb_right;		/* != 0 : Most significant bit is */
2149 					/* right */
2150 };
2151 
2152 struct vki_fb_var_screeninfo {
2153 	__vki_u32 xres;			/* visible resolution		*/
2154 	__vki_u32 yres;
2155 	__vki_u32 xres_virtual;		/* virtual resolution		*/
2156 	__vki_u32 yres_virtual;
2157 	__vki_u32 xoffset;		/* offset from virtual to visible */
2158 	__vki_u32 yoffset;		/* resolution			*/
2159 
2160 	__vki_u32 bits_per_pixel;	/* guess what			*/
2161 	__vki_u32 grayscale;		/* != 0 Graylevels instead of colors */
2162 
2163 	struct vki_fb_bitfield red;	/* bitfield in fb mem if true color, */
2164 	struct vki_fb_bitfield green;	/* else only length is significant */
2165 	struct vki_fb_bitfield blue;
2166 	struct vki_fb_bitfield transp;	/* transparency			*/
2167 
2168 	__vki_u32 nonstd;		/* != 0 Non standard pixel format */
2169 
2170 	__vki_u32 activate;		/* see FB_ACTIVATE_*		*/
2171 
2172 	__vki_u32 height;		/* height of picture in mm    */
2173 	__vki_u32 width;		/* width of picture in mm     */
2174 
2175 	__vki_u32 accel_flags;		/* (OBSOLETE) see fb_info.flags */
2176 
2177 	/* Timing: All values in pixclocks, except pixclock (of course) */
2178 	__vki_u32 pixclock;		/* pixel clock in ps (pico seconds) */
2179 	__vki_u32 left_margin;		/* time from sync to picture	*/
2180 	__vki_u32 right_margin;		/* time from picture to sync	*/
2181 	__vki_u32 upper_margin;		/* time from sync to picture	*/
2182 	__vki_u32 lower_margin;
2183 	__vki_u32 hsync_len;		/* length of horizontal sync	*/
2184 	__vki_u32 vsync_len;		/* length of vertical sync	*/
2185 	__vki_u32 sync;			/* see FB_SYNC_*		*/
2186 	__vki_u32 vmode;		/* see FB_VMODE_*		*/
2187 	__vki_u32 rotate;		/* angle we rotate counter clockwise */
2188 	__vki_u32 reserved[5];		/* Reserved for future compatibility */
2189 };
2190 
2191 //----------------------------------------------------------------------
2192 // From linux-2.6.9/include/linux/kd.h
2193 //----------------------------------------------------------------------
2194 
2195 #define VKI_GIO_FONT       0x4B60  /* gets font in expanded form */
2196 #define VKI_PIO_FONT       0x4B61  /* use font in expanded form */
2197 
2198 #define VKI_GIO_FONTX      0x4B6B  /* get font using struct consolefontdesc */
2199 #define VKI_PIO_FONTX      0x4B6C  /* set font using struct consolefontdesc */
2200 struct vki_consolefontdesc {
2201 	unsigned short charcount;	/* characters in font (256 or 512) */
2202 	unsigned short charheight;	/* scan lines per character (1-32) */
2203 	char __user *chardata;		/* font data in expanded form */
2204 };
2205 
2206 #define VKI_PIO_FONTRESET  0x4B6D  /* reset to default font */
2207 
2208 #define VKI_GIO_CMAP       0x4B70  /* gets colour palette on VGA+ */
2209 #define VKI_PIO_CMAP       0x4B71  /* sets colour palette on VGA+ */
2210 
2211 #define VKI_KIOCSOUND      0x4B2F  /* start sound generation (0 for off) */
2212 #define VKI_KDMKTONE       0x4B30  /* generate tone */
2213 
2214 #define VKI_KDGETLED       0x4B31  /* return current led state */
2215 #define VKI_KDSETLED       0x4B32  /* set led state [lights, not flags] */
2216 
2217 #define VKI_KDGKBTYPE      0x4B33  /* get keyboard type */
2218 
2219 #define VKI_KDADDIO        0x4B34  /* add i/o port as valid */
2220 #define VKI_KDDELIO        0x4B35  /* del i/o port as valid */
2221 #define VKI_KDENABIO       0x4B36  /* enable i/o to video board */
2222 #define VKI_KDDISABIO      0x4B37  /* disable i/o to video board */
2223 
2224 #define VKI_KDSETMODE      0x4B3A  /* set text/graphics mode */
2225 #define VKI_KDGETMODE      0x4B3B  /* get current mode */
2226 
2227 #define VKI_KDMAPDISP      0x4B3C  /* map display into address space */
2228 #define VKI_KDUNMAPDISP    0x4B3D  /* unmap display from address space */
2229 
2230 #define		VKI_E_TABSZ		256
2231 #define VKI_GIO_SCRNMAP    0x4B40  /* get screen mapping from kernel */
2232 #define VKI_PIO_SCRNMAP	   0x4B41  /* put screen mapping table in kernel */
2233 #define VKI_GIO_UNISCRNMAP 0x4B69  /* get full Unicode screen mapping */
2234 #define VKI_PIO_UNISCRNMAP 0x4B6A  /* set full Unicode screen mapping */
2235 
2236 #define VKI_GIO_UNIMAP     0x4B66  /* get unicode-to-font mapping from kernel */
2237 struct vki_unipair {
2238 	unsigned short unicode;
2239 	unsigned short fontpos;
2240 };
2241 struct vki_unimapdesc {
2242 	unsigned short entry_ct;
2243 	struct vki_unipair __user *entries;
2244 };
2245 #define VKI_PIO_UNIMAP     0x4B67  /* put unicode-to-font mapping in kernel */
2246 #define VKI_PIO_UNIMAPCLR  0x4B68  /* clear table, possibly advise hash algorithm */
2247 struct vki_unimapinit {
2248 	unsigned short advised_hashsize;  /* 0 if no opinion */
2249 	unsigned short advised_hashstep;  /* 0 if no opinion */
2250 	unsigned short advised_hashlevel; /* 0 if no opinion */
2251 };
2252 
2253 #define VKI_KDGKBMODE      0x4B44  /* gets current keyboard mode */
2254 #define VKI_KDSKBMODE      0x4B45  /* sets current keyboard mode */
2255 
2256 #define VKI_KDGKBMETA      0x4B62  /* gets meta key handling mode */
2257 #define VKI_KDSKBMETA      0x4B63  /* sets meta key handling mode */
2258 
2259 #define VKI_KDGKBLED       0x4B64  /* get led flags (not lights) */
2260 #define VKI_KDSKBLED       0x4B65  /* set led flags (not lights) */
2261 
2262 struct vki_kbentry {
2263 	unsigned char kb_table;
2264 	unsigned char kb_index;
2265 	unsigned short kb_value;
2266 };
2267 #define VKI_KDGKBENT       0x4B46  /* gets one entry in translation table */
2268 #define VKI_KDSKBENT       0x4B47  /* sets one entry in translation table */
2269 
2270 struct vki_kbsentry {
2271 	unsigned char kb_func;
2272 	unsigned char kb_string[512];
2273 };
2274 #define VKI_KDGKBSENT      0x4B48  /* gets one function key string entry */
2275 #define VKI_KDSKBSENT      0x4B49  /* sets one function key string entry */
2276 
2277 struct vki_kbdiacr {
2278         unsigned char diacr, base, result;
2279 };
2280 struct vki_kbdiacrs {
2281         unsigned int kb_cnt;    /* number of entries in following array */
2282 	struct vki_kbdiacr kbdiacr[256];    /* MAX_DIACR from keyboard.h */
2283 };
2284 #define VKI_KDGKBDIACR     0x4B4A  /* read kernel accent table */
2285 #define VKI_KDSKBDIACR     0x4B4B  /* write kernel accent table */
2286 
2287 struct vki_kbkeycode {
2288 	unsigned int scancode, keycode;
2289 };
2290 #define VKI_KDGETKEYCODE   0x4B4C  /* read kernel keycode table entry */
2291 #define VKI_KDSETKEYCODE   0x4B4D  /* write kernel keycode table entry */
2292 
2293 #define VKI_KDSIGACCEPT    0x4B4E  /* accept kbd generated signals */
2294 
2295 struct vki_kbd_repeat {
2296 	int delay;	/* in msec; <= 0: don't change */
2297 	int period;	/* in msec; <= 0: don't change */
2298 			/* earlier this field was misnamed "rate" */
2299 };
2300 #define VKI_KDKBDREP       0x4B52  /* set keyboard delay/repeat rate;
2301                                     * actually used values are returned */
2302 
2303 #define VKI_KDFONTOP       0x4B72  /* font operations */
2304 
2305 struct vki_console_font_op {
2306 	unsigned int op;	/* operation code KD_FONT_OP_* */
2307 	unsigned int flags;	/* KD_FONT_FLAG_* */
2308 	unsigned int width, height;	/* font size */
2309 	unsigned int charcount;
2310 	unsigned char __user *data;	/* font data with height fixed to 32 */
2311 };
2312 
2313 #define VKI_KD_FONT_OP_SET		0	/* Set font */
2314 #define VKI_KD_FONT_OP_GET		1	/* Get font */
2315 #define VKI_KD_FONT_OP_SET_DEFAULT	2	/* Set font to default, data points to name / NULL */
2316 #define VKI_KD_FONT_OP_COPY		3	/* Copy from another console */
2317 
2318 //----------------------------------------------------------------------
2319 // From linux-2.6.9/include/linux/kb.h
2320 //----------------------------------------------------------------------
2321 
2322 typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory */
2323 
2324 //----------------------------------------------------------------------
2325 // From linux-2.6.20.1/include/linux/ptrace.h
2326 //----------------------------------------------------------------------
2327 
2328 #define VKI_PTRACE_TRACEME         0
2329 #define VKI_PTRACE_PEEKTEXT	   1
2330 #define VKI_PTRACE_PEEKDATA	   2
2331 #define VKI_PTRACE_PEEKUSR	   3
2332 #define VKI_PTRACE_POKEUSR	   6
2333 
2334 #define VKI_PTRACE_DETACH         17
2335 
2336 #define VKI_PTRACE_GETEVENTMSG	0x4201
2337 #define VKI_PTRACE_GETSIGINFO	0x4202
2338 #define VKI_PTRACE_SETSIGINFO	0x4203
2339 #define VKI_PTRACE_GETREGSET	0x4204
2340 #define VKI_PTRACE_SETREGSET	0x4205
2341 
2342 #define VKI_PT_PTRACED 0x00000001
2343 
2344 //----------------------------------------------------------------------
2345 // From linux-2.6.14/include/sound/asound.h
2346 //----------------------------------------------------------------------
2347 
2348 enum {
2349 	VKI_SNDRV_PCM_IOCTL_HW_FREE = _VKI_IO('A', 0x12),
2350 	VKI_SNDRV_PCM_IOCTL_HWSYNC = _VKI_IO('A', 0x22),
2351 	VKI_SNDRV_PCM_IOCTL_PREPARE = _VKI_IO('A', 0x40),
2352 	VKI_SNDRV_PCM_IOCTL_RESET = _VKI_IO('A', 0x41),
2353 	VKI_SNDRV_PCM_IOCTL_START = _VKI_IO('A', 0x42),
2354 	VKI_SNDRV_PCM_IOCTL_DROP = _VKI_IO('A', 0x43),
2355 	VKI_SNDRV_PCM_IOCTL_DRAIN = _VKI_IO('A', 0x44),
2356 	VKI_SNDRV_PCM_IOCTL_PAUSE = _VKI_IOW('A', 0x45, int),
2357 	VKI_SNDRV_PCM_IOCTL_RESUME = _VKI_IO('A', 0x47),
2358 	VKI_SNDRV_PCM_IOCTL_XRUN = _VKI_IO('A', 0x48),
2359 	VKI_SNDRV_PCM_IOCTL_LINK = _VKI_IOW('A', 0x60, int),
2360 	VKI_SNDRV_PCM_IOCTL_UNLINK = _VKI_IO('A', 0x61),
2361 };
2362 
2363 enum {
2364 	VKI_SNDRV_TIMER_IOCTL_START = _VKI_IO('T', 0xa0),
2365 	VKI_SNDRV_TIMER_IOCTL_STOP = _VKI_IO('T', 0xa1),
2366 	VKI_SNDRV_TIMER_IOCTL_CONTINUE = _VKI_IO('T', 0xa2),
2367 	VKI_SNDRV_TIMER_IOCTL_PAUSE = _VKI_IO('T', 0xa3),
2368 };
2369 
2370 struct vki_snd_ctl_card_info {
2371 	int card;			/* card number */
2372 	int pad;			/* reserved for future (was type) */
2373 	unsigned char id[16];		/* ID of card (user selectable) */
2374 	unsigned char driver[16];	/* Driver name */
2375 	unsigned char name[32];		/* Short name of soundcard */
2376 	unsigned char longname[80];	/* name + info text about soundcard */
2377 	unsigned char reserved_[16];	/* reserved for future (was ID of mixer) */
2378 	unsigned char mixername[80];	/* visual mixer identification */
2379 	unsigned char components[128];	/* card components / fine identification, delimited with one space (AC97 etc..) */
2380 };
2381 
2382 typedef int vki_snd_ctl_elem_iface_t;
2383 #define	VKI_SNDRV_CTL_ELEM_IFACE_CARD		((vki_snd_ctl_elem_iface_t) 0) /* global control */
2384 #define	VKI_SNDRV_CTL_ELEM_IFACE_HWDEP		((vki_snd_ctl_elem_iface_t) 1) /* hardware dependent device */
2385 #define	VKI_SNDRV_CTL_ELEM_IFACE_MIXER		((vki_snd_ctl_elem_iface_t) 2) /* virtual mixer device */
2386 #define	VKI_SNDRV_CTL_ELEM_IFACE_PCM		((vki_snd_ctl_elem_iface_t) 3) /* PCM device */
2387 #define	VKI_SNDRV_CTL_ELEM_IFACE_RAWMIDI	((vki_snd_ctl_elem_iface_t) 4) /* RawMidi device */
2388 #define	VKI_SNDRV_CTL_ELEM_IFACE_TIMER		((vki_snd_ctl_elem_iface_t) 5) /* timer device */
2389 #define	VKI_SNDRV_CTL_ELEM_IFACE_SEQUENCER	((vki_snd_ctl_elem_iface_t) 6) /* sequencer client */
2390 #define	VKI_SNDRV_CTL_ELEM_IFACE_LAST		VKI_SNDRV_CTL_ELEM_IFACE_SEQUENCER
2391 
2392 struct vki_snd_ctl_elem_id {
2393 	unsigned int numid;		/* numeric identifier, zero = invalid */
2394 	vki_snd_ctl_elem_iface_t iface;	/* interface identifier */
2395 	unsigned int device;		/* device/client number */
2396 	unsigned int subdevice;		/* subdevice (substream) number */
2397 	unsigned char name[44];		/* ASCII name of item */
2398 	unsigned int index;		/* index of item */
2399 };
2400 
2401 struct vki_snd_ctl_elem_list {
2402 	unsigned int offset;		/* W: first element ID to get */
2403 	unsigned int space;		/* W: count of element IDs to get */
2404 	unsigned int used;		/* R: count of element IDs set */
2405 	unsigned int count;		/* R: count of all elements */
2406 	struct vki_snd_ctl_elem_id __user *pids; /* R: IDs */
2407 	unsigned char reserved[50];
2408 };
2409 
2410 struct vki_snd_ctl_tlv {
2411     unsigned int numid;	/* control element numeric identification */
2412     unsigned int length;	/* in bytes aligned to 4 */
2413     unsigned int tlv[0];	/* first TLV */
2414 };
2415 
2416 #define VKI_SNDRV_CTL_IOCTL_PVERSION	_VKI_IOR('U', 0x00, int)
2417 #define VKI_SNDRV_CTL_IOCTL_CARD_INFO	_VKI_IOR('U', 0x01, struct vki_snd_ctl_card_info)
2418 #define VKI_SNDRV_CTL_IOCTL_ELEM_LIST	_VKI_IOWR('U', 0x10, struct vki_snd_ctl_elem_list)
2419 #define VKI_SNDRV_CTL_IOCTL_TLV_READ	_VKI_IOWR('U', 0x1a, struct vki_snd_ctl_tlv)
2420 #define VKI_SNDRV_CTL_IOCTL_TLV_WRITE	_VKI_IOWR('U', 0x1b, struct vki_snd_ctl_tlv)
2421 #define VKI_SNDRV_CTL_IOCTL_TLV_COMMAND	_VKI_IOWR('U', 0x1c, struct vki_snd_ctl_tlv)
2422 
2423 //----------------------------------------------------------------------
2424 // From linux-2.6.15.4/include/linux/serial.h
2425 //----------------------------------------------------------------------
2426 
2427 struct vki_serial_icounter_struct {
2428 	int cts, dsr, rng, dcd;
2429 	int rx, tx;
2430 	int frame, overrun, parity, brk;
2431 	int buf_overrun;
2432 	int reserved[9];
2433 };
2434 
2435 //----------------------------------------------------------------------
2436 // From linux-2.6.16/include/linux/vt.h
2437 //----------------------------------------------------------------------
2438 
2439 #define VKI_VT_OPENQRY	0x5600	/* find available vt */
2440 
2441 struct vki_vt_mode {
2442 	char mode;		/* vt mode */
2443 	char waitv;		/* if set, hang on writes if not active */
2444 	short relsig;		/* signal to raise on release req */
2445 	short acqsig;		/* signal to raise on acquisition */
2446 	short frsig;		/* unused (set to 0) */
2447 };
2448 #define VKI_VT_GETMODE	0x5601	/* get mode of active vt */
2449 #define VKI_VT_SETMODE	0x5602	/* set mode of active vt */
2450 
2451 struct vki_vt_stat {
2452 	unsigned short v_active;	/* active vt */
2453 	unsigned short v_signal;	/* signal to send */
2454 	unsigned short v_state;		/* vt bitmask */
2455 };
2456 #define VKI_VT_GETSTATE	0x5603	/* get global vt state info */
2457 #define VKI_VT_SENDSIG	0x5604	/* signal to send to bitmask of vts */
2458 
2459 #define VKI_VT_RELDISP	0x5605	/* release display */
2460 
2461 #define VKI_VT_ACTIVATE	0x5606	/* make vt active */
2462 #define VKI_VT_WAITACTIVE	0x5607	/* wait for vt active */
2463 #define VKI_VT_DISALLOCATE	0x5608  /* free memory associated to vt */
2464 
2465 struct vki_vt_sizes {
2466 	unsigned short v_rows;		/* number of rows */
2467 	unsigned short v_cols;		/* number of columns */
2468 	unsigned short v_scrollsize;	/* number of lines of scrollback */
2469 };
2470 #define VKI_VT_RESIZE	0x5609	/* set kernel's idea of screensize */
2471 
2472 struct vki_vt_consize {
2473 	unsigned short v_rows;	/* number of rows */
2474 	unsigned short v_cols;	/* number of columns */
2475 	unsigned short v_vlin;	/* number of pixel rows on screen */
2476 	unsigned short v_clin;	/* number of pixel rows per character */
2477 	unsigned short v_vcol;	/* number of pixel columns on screen */
2478 	unsigned short v_ccol;	/* number of pixel columns per character */
2479 };
2480 #define VKI_VT_RESIZEX      0x560A  /* set kernel's idea of screensize + more */
2481 #define VKI_VT_LOCKSWITCH   0x560B  /* disallow vt switching */
2482 #define VKI_VT_UNLOCKSWITCH 0x560C  /* allow vt switching */
2483 
2484 //----------------------------------------------------------------------
2485 // From linux-2.6.19/include/linux/prctl.h
2486 //----------------------------------------------------------------------
2487 
2488 #define VKI_PR_SET_PDEATHSIG  1  /* Second arg is a signal */
2489 #define VKI_PR_GET_PDEATHSIG  2  /* Second arg is a ptr to return the signal */
2490 
2491 #define VKI_PR_GET_DUMPABLE   3
2492 #define VKI_PR_SET_DUMPABLE   4
2493 
2494 #define VKI_PR_GET_UNALIGN	  5
2495 #define VKI_PR_SET_UNALIGN	  6
2496 # define VKI_PR_UNALIGN_NOPRINT	1	/* silently fix up unaligned user accesses */
2497 # define VKI_PR_UNALIGN_SIGBUS	2	/* generate SIGBUS on unaligned user access */
2498 
2499 #define VKI_PR_GET_KEEPCAPS   7
2500 #define VKI_PR_SET_KEEPCAPS   8
2501 
2502 #define VKI_PR_GET_FPEMU  9
2503 #define VKI_PR_SET_FPEMU 10
2504 # define VKI_PR_FPEMU_NOPRINT	1	/* silently emulate fp operations accesses */
2505 # define VKI_PR_FPEMU_SIGFPE	2	/* don't emulate fp operations, send SIGFPE instead */
2506 
2507 #define VKI_PR_GET_FPEXC	11
2508 #define VKI_PR_SET_FPEXC	12
2509 # define VKI_PR_FP_EXC_SW_ENABLE	0x80	/* Use FPEXC for FP exception enables */
2510 # define VKI_PR_FP_EXC_DIV		0x010000	/* floating point divide by zero */
2511 # define VKI_PR_FP_EXC_OVF		0x020000	/* floating point overflow */
2512 # define VKI_PR_FP_EXC_UND		0x040000	/* floating point underflow */
2513 # define VKI_PR_FP_EXC_RES		0x080000	/* floating point inexact result */
2514 # define VKI_PR_FP_EXC_INV		0x100000	/* floating point invalid operation */
2515 # define VKI_PR_FP_EXC_DISABLED	0	/* FP exceptions disabled */
2516 # define VKI_PR_FP_EXC_NONRECOV	1	/* async non-recoverable exc. mode */
2517 # define VKI_PR_FP_EXC_ASYNC	2	/* async recoverable exception mode */
2518 # define VKI_PR_FP_EXC_PRECISE	3	/* precise exception mode */
2519 
2520 #define VKI_PR_GET_TIMING   13
2521 #define VKI_PR_SET_TIMING   14
2522 # define VKI_PR_TIMING_STATISTICAL  0       /* Normal, traditional,
2523                                                    statistical process timing */
2524 # define VKI_PR_TIMING_TIMESTAMP    1       /* Accurate timestamp based
2525                                                    process timing */
2526 
2527 #define VKI_PR_SET_NAME    15		/* Set process name */
2528 #define VKI_PR_GET_NAME    16		/* Get process name */
2529 
2530 #define VKI_PR_GET_ENDIAN	19
2531 #define VKI_PR_SET_ENDIAN	20
2532 # define VKI_PR_ENDIAN_BIG		0
2533 # define VKI_PR_ENDIAN_LITTLE	1	/* True little endian mode */
2534 # define VKI_PR_ENDIAN_PPC_LITTLE	2	/* "PowerPC" pseudo little endian */
2535 
2536 #define VKI_PR_SET_SECCOMP 22
2537 
2538 #define VKI_PR_SET_PTRACER 0x59616d61
2539 
2540 //----------------------------------------------------------------------
2541 // From linux-2.6.19/include/linux/usbdevice_fs.h
2542 //----------------------------------------------------------------------
2543 
2544 struct vki_usbdevfs_ctrltransfer {
2545 	__vki_u8 bRequestType;
2546 	__vki_u8 bRequest;
2547 	__vki_u16 wValue;
2548 	__vki_u16 wIndex;
2549 	__vki_u16 wLength;
2550 	__vki_u32 timeout;  /* in milliseconds */
2551  	void __user *data;
2552 };
2553 
2554 struct vki_usbdevfs_bulktransfer {
2555 	unsigned int ep;
2556 	unsigned int len;
2557 	unsigned int timeout; /* in milliseconds */
2558 	void __user *data;
2559 };
2560 
2561 #define VKI_USBDEVFS_MAXDRIVERNAME 255
2562 
2563 struct vki_usbdevfs_getdriver {
2564 	unsigned int interface;
2565 	char driver[VKI_USBDEVFS_MAXDRIVERNAME + 1];
2566 };
2567 
2568 struct vki_usbdevfs_connectinfo {
2569 	unsigned int devnum;
2570 	unsigned char slow;
2571 };
2572 
2573 struct vki_usbdevfs_iso_packet_desc {
2574 	unsigned int length;
2575 	unsigned int actual_length;
2576 	unsigned int status;
2577 };
2578 
2579 struct vki_usbdevfs_urb {
2580 	unsigned char type;
2581 	unsigned char endpoint;
2582 	int status;
2583 	unsigned int flags;
2584 	void __user *buffer;
2585 	int buffer_length;
2586 	int actual_length;
2587 	int start_frame;
2588 	int number_of_packets;
2589 	int error_count;
2590 	unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
2591 	void *usercontext;
2592 	struct vki_usbdevfs_iso_packet_desc iso_frame_desc[0];
2593 };
2594 
2595 struct vki_usbdevfs_ioctl {
2596 	int	ifno;		/* interface 0..N ; negative numbers reserved */
2597 	int	ioctl_code;	/* MUST encode size + direction of data so the
2598 				 * macros in <asm/ioctl.h> give correct values */
2599 	void __user *data;	/* param buffer (in, or out) */
2600 };
2601 
2602 #define VKI_USBDEVFS_CONTROL           _VKI_IOWR('U', 0, struct vki_usbdevfs_ctrltransfer)
2603 #define VKI_USBDEVFS_BULK              _VKI_IOWR('U', 2, struct vki_usbdevfs_bulktransfer)
2604 #define VKI_USBDEVFS_GETDRIVER         _VKI_IOW('U', 8, struct vki_usbdevfs_getdriver)
2605 #define VKI_USBDEVFS_SUBMITURB         _VKI_IOR('U', 10, struct vki_usbdevfs_urb)
2606 #define VKI_USBDEVFS_DISCARDURB        _VKI_IO('U', 11)
2607 #define VKI_USBDEVFS_REAPURB           _VKI_IOW('U', 12, void *)
2608 #define VKI_USBDEVFS_REAPURBNDELAY     _VKI_IOW('U', 13, void *)
2609 #define VKI_USBDEVFS_CONNECTINFO       _VKI_IOW('U', 17, struct vki_usbdevfs_connectinfo)
2610 #define VKI_USBDEVFS_IOCTL             _VKI_IOWR('U', 18, struct vki_usbdevfs_ioctl)
2611 #define VKI_USBDEVFS_RESET             _VKI_IO('U', 20)
2612 
2613 #define VKI_USBDEVFS_URB_TYPE_ISO              0
2614 #define VKI_USBDEVFS_URB_TYPE_INTERRUPT        1
2615 #define VKI_USBDEVFS_URB_TYPE_CONTROL          2
2616 #define VKI_USBDEVFS_URB_TYPE_BULK             3
2617 
2618 // [[this is missing in usbdevice_fs.h]]
2619 struct vki_usbdevfs_setuppacket {
2620        __vki_u8 bRequestType;
2621        __vki_u8 bRequest;
2622        __vki_u16 wValue;
2623        __vki_u16 wIndex;
2624        __vki_u16 wLength;
2625 };
2626 
2627 //----------------------------------------------------------------------
2628 // From linux-2.6.20.1/include/linux/i2c.h
2629 //----------------------------------------------------------------------
2630 
2631 #define VKI_I2C_SMBUS_QUICK             0
2632 #define VKI_I2C_SMBUS_BYTE              1
2633 #define VKI_I2C_SMBUS_BYTE_DATA         2
2634 #define VKI_I2C_SMBUS_WORD_DATA         3
2635 #define VKI_I2C_SMBUS_PROC_CALL         4
2636 #define VKI_I2C_SMBUS_BLOCK_DATA        5
2637 #define VKI_I2C_SMBUS_I2C_BLOCK_BROKEN  6
2638 #define VKI_I2C_SMBUS_BLOCK_PROC_CALL   7           /* SMBus 2.0 */
2639 #define VKI_I2C_SMBUS_I2C_BLOCK_DATA    8
2640 
2641 /* smbus_access read or write markers */
2642 #define VKI_I2C_SMBUS_READ  1
2643 #define VKI_I2C_SMBUS_WRITE 0
2644 
2645 #define VKI_I2C_SLAVE        0x0703  /* Change slave address                 */
2646                                      /* Attn.: Slave address is 7 or 10 bits */
2647 #define VKI_I2C_SLAVE_FORCE  0x0706  /* Change slave address                 */
2648                                      /* Attn.: Slave address is 7 or 10 bits */
2649                                      /* This changes the address, even if it */
2650                                      /* is already taken!                    */
2651 #define VKI_I2C_TENBIT       0x0704  /* 0 for 7 bit addrs, != 0 for 10 bit   */
2652 #define VKI_I2C_FUNCS        0x0705  /* Get the adapter functionality */
2653 #define VKI_I2C_RDWR         0x0707  /* Combined R/W transfer (one STOP only) */
2654 #define VKI_I2C_PEC          0x0708  /* != 0 for SMBus PEC                   */
2655 #define VKI_I2C_SMBUS        0x0720  /* SMBus transfer */
2656 
2657 #define VKI_I2C_SMBUS_BLOCK_MAX  32  /* As specified in SMBus standard */
2658 union vki_i2c_smbus_data {
2659         __vki_u8 byte;
2660         __vki_u16 word;
2661         __vki_u8 block[VKI_I2C_SMBUS_BLOCK_MAX + 2];
2662                  /* block[0] is used for length */
2663                  /* and one more for PEC */
2664 };
2665 
2666 /* This is the structure as used in the I2C_SMBUS ioctl call */
2667 struct vki_i2c_smbus_ioctl_data {
2668         __vki_u8 read_write;
2669         __vki_u8 command;
2670         __vki_u32 size;
2671         union vki_i2c_smbus_data __user *data;
2672 };
2673 
2674 struct vki_i2c_msg {
2675 	__vki_u16 addr;		/* slave address			*/
2676 	__vki_u16 flags;
2677 #define VKI_I2C_M_TEN		0x0010	/* this is a ten bit chip address */
2678 #define VKI_I2C_M_RD		0x0001	/* read data, from slave to master */
2679 #define VKI_I2C_M_NOSTART	0x4000	/* if I2C_FUNC_PROTOCOL_MANGLING */
2680 #define VKI_I2C_M_REV_DIR_ADDR	0x2000	/* if I2C_FUNC_PROTOCOL_MANGLING */
2681 #define VKI_I2C_M_IGNORE_NAK	0x1000	/* if I2C_FUNC_PROTOCOL_MANGLING */
2682 #define VKI_I2C_M_NO_RD_ACK	0x0800	/* if I2C_FUNC_PROTOCOL_MANGLING */
2683 #define VKI_I2C_M_RECV_LEN	0x0400	/* length will be first received byte */
2684 	__vki_u16 len;		/* msg length				*/
2685 	__vki_u8 *buf;		/* pointer to msg data			*/
2686 };
2687 
2688 struct vki_i2c_rdwr_ioctl_data {
2689 	struct vki_i2c_msg *msgs;	/* pointers to i2c_msgs */
2690 	__vki_u32 nmsgs;		/* number of i2c_msgs */
2691 };
2692 
2693 //----------------------------------------------------------------------
2694 // From linux-2.6.20.1/include/linux/keyctl.h
2695 //----------------------------------------------------------------------
2696 
2697 /* keyctl commands */
2698 #define VKI_KEYCTL_GET_KEYRING_ID	0	/* ask for a keyring's ID */
2699 #define VKI_KEYCTL_JOIN_SESSION_KEYRING	1	/* join or start named session keyring */
2700 #define VKI_KEYCTL_UPDATE		2	/* update a key */
2701 #define VKI_KEYCTL_REVOKE		3	/* revoke a key */
2702 #define VKI_KEYCTL_CHOWN		4	/* set ownership of a key */
2703 #define VKI_KEYCTL_SETPERM		5	/* set perms on a key */
2704 #define VKI_KEYCTL_DESCRIBE		6	/* describe a key */
2705 #define VKI_KEYCTL_CLEAR		7	/* clear contents of a keyring */
2706 #define VKI_KEYCTL_LINK			8	/* link a key into a keyring */
2707 #define VKI_KEYCTL_UNLINK		9	/* unlink a key from a keyring */
2708 #define VKI_KEYCTL_SEARCH		10	/* search for a key in a keyring */
2709 #define VKI_KEYCTL_READ			11	/* read a key or keyring's contents */
2710 #define VKI_KEYCTL_INSTANTIATE		12	/* instantiate a partially constructed key */
2711 #define VKI_KEYCTL_NEGATE		13	/* negate a partially constructed key */
2712 #define VKI_KEYCTL_SET_REQKEY_KEYRING	14	/* set default request-key keyring */
2713 #define VKI_KEYCTL_SET_TIMEOUT		15	/* set key timeout */
2714 #define VKI_KEYCTL_ASSUME_AUTHORITY	16	/* assume request_key() authorisation */
2715 
2716 /*--------------------------------------------------------------------*/
2717 // From linux-2.6.20.1/include/linux/key.h
2718 /*--------------------------------------------------------------------*/
2719 
2720 /* key handle serial number */
2721 typedef vki_int32_t vki_key_serial_t;
2722 
2723 /* key handle permissions mask */
2724 typedef vki_uint32_t vki_key_perm_t;
2725 
2726 //----------------------------------------------------------------------
2727 // From linux-2.6.24.7/include/linux/wireless.h
2728 // (wireless extensions version 22, 2007-03-16)
2729 //----------------------------------------------------------------------
2730 
2731 /*
2732  * [[Wireless extensions ioctls.]]
2733  */
2734 
2735 /* Wireless Identification */
2736 #define VKI_SIOCSIWCOMMIT	0x8B00	/* Commit pending changes to driver */
2737 #define VKI_SIOCGIWNAME		0x8B01	/* get name == wireless protocol */
2738 
2739 /* Basic operations */
2740 #define VKI_SIOCSIWNWID		0x8B02	/* set network id (pre-802.11) */
2741 #define VKI_SIOCGIWNWID		0x8B03	/* get network id (the cell) */
2742 #define VKI_SIOCSIWFREQ		0x8B04	/* set channel/frequency (Hz) */
2743 #define VKI_SIOCGIWFREQ		0x8B05	/* get channel/frequency (Hz) */
2744 #define VKI_SIOCSIWMODE		0x8B06	/* set operation mode */
2745 #define VKI_SIOCGIWMODE		0x8B07	/* get operation mode */
2746 #define VKI_SIOCSIWSENS		0x8B08	/* set sensitivity (dBm) */
2747 #define VKI_SIOCGIWSENS		0x8B09	/* get sensitivity (dBm) */
2748 
2749 /* Informative stuff */
2750 #define VKI_SIOCSIWRANGE	0x8B0A	/* Unused */
2751 #define VKI_SIOCGIWRANGE	0x8B0B	/* Get range of parameters */
2752 #define VKI_SIOCSIWPRIV		0x8B0C	/* Unused */
2753 #define VKI_SIOCGIWPRIV		0x8B0D	/* get private ioctl interface info */
2754 #define VKI_SIOCSIWSTATS	0x8B0E	/* Unused */
2755 #define VKI_SIOCGIWSTATS	0x8B0F	/* Get /proc/net/wireless stats */
2756 
2757 /* Spy support (statistics per MAC address - used for Mobile IP support) */
2758 #define VKI_SIOCSIWSPY		0x8B10	/* set spy addresses */
2759 #define VKI_SIOCGIWSPY		0x8B11	/* get spy info (quality of link) */
2760 #define VKI_SIOCSIWTHRSPY	0x8B12	/* set spy threshold (spy event) */
2761 #define VKI_SIOCGIWTHRSPY	0x8B13	/* get spy threshold */
2762 
2763 /* Access Point manipulation */
2764 #define VKI_SIOCSIWAP		0x8B14	/* set access point MAC addresses */
2765 #define VKI_SIOCGIWAP		0x8B15	/* get access point MAC addresses */
2766 #define VKI_SIOCGIWAPLIST	0x8B17	/* Deprecated in favor of scanning */
2767 #define VKI_SIOCSIWSCAN         0x8B18	/* trigger scanning (list cells) */
2768 #define VKI_SIOCGIWSCAN         0x8B19	/* get scanning results */
2769 
2770 /* 802.11 specific support */
2771 #define VKI_SIOCSIWESSID	0x8B1A	/* set ESSID (network name) */
2772 #define VKI_SIOCGIWESSID	0x8B1B	/* get ESSID */
2773 #define VKI_SIOCSIWNICKN	0x8B1C	/* set node name/nickname */
2774 #define VKI_SIOCGIWNICKN	0x8B1D	/* get node name/nickname */
2775 
2776 /* Other parameters useful in 802.11 and some other devices */
2777 #define VKI_SIOCSIWRATE		0x8B20	/* set default bit rate (bps) */
2778 #define VKI_SIOCGIWRATE		0x8B21	/* get default bit rate (bps) */
2779 #define VKI_SIOCSIWRTS		0x8B22	/* set RTS/CTS threshold (bytes) */
2780 #define VKI_SIOCGIWRTS		0x8B23	/* get RTS/CTS threshold (bytes) */
2781 #define VKI_SIOCSIWFRAG		0x8B24	/* set fragmentation thr (bytes) */
2782 #define VKI_SIOCGIWFRAG		0x8B25	/* get fragmentation thr (bytes) */
2783 #define VKI_SIOCSIWTXPOW	0x8B26	/* set transmit power (dBm) */
2784 #define VKI_SIOCGIWTXPOW	0x8B27	/* get transmit power (dBm) */
2785 #define VKI_SIOCSIWRETRY	0x8B28	/* set retry limits and lifetime */
2786 #define VKI_SIOCGIWRETRY	0x8B29	/* get retry limits and lifetime */
2787 
2788 /* Encoding stuff (scrambling, hardware security, WEP...) */
2789 #define VKI_SIOCSIWENCODE	0x8B2A	/* set encoding token & mode */
2790 #define VKI_SIOCGIWENCODE	0x8B2B	/* get encoding token & mode */
2791 
2792 /* Power saving stuff (power management, unicast and multicast) */
2793 #define VKI_SIOCSIWPOWER	0x8B2C	/* set Power Management settings */
2794 #define VKI_SIOCGIWPOWER	0x8B2D	/* get Power Management settings */
2795 
2796 /* WPA : Generic IEEE 802.11 information element (e.g., for WPA/RSN/WMM). */
2797 #define VKI_SIOCSIWGENIE	0x8B30		/* set generic IE */
2798 #define VKI_SIOCGIWGENIE	0x8B31		/* get generic IE */
2799 
2800 /* WPA : IEEE 802.11 MLME requests */
2801 #define VKI_SIOCSIWMLME		0x8B16	/* request MLME operation; uses
2802 					 * struct iw_mlme */
2803 /* WPA : Authentication mode parameters */
2804 #define VKI_SIOCSIWAUTH		0x8B32	/* set authentication mode params */
2805 #define VKI_SIOCGIWAUTH		0x8B33	/* get authentication mode params */
2806 
2807 /* WPA : Extended version of encoding configuration */
2808 #define VKI_SIOCSIWENCODEEXT	0x8B34	/* set encoding token & mode */
2809 #define VKI_SIOCGIWENCODEEXT	0x8B35	/* get encoding token & mode */
2810 
2811 /* WPA2 : PMKSA cache management */
2812 #define VKI_SIOCSIWPMKSA	0x8B36	/* PMKSA cache operation */
2813 
2814 /*
2815  * [[Payload for the wireless extensions ioctls.]]
2816  */
2817 
2818 struct	vki_iw_param
2819 {
2820   __vki_s32	value;		/* The value of the parameter itself */
2821   __vki_u8	fixed;		/* Hardware should not use auto select */
2822   __vki_u8	disabled;	/* Disable the feature */
2823   __vki_u16	flags;		/* Various specific flags (if any) */
2824 };
2825 
2826 struct	vki_iw_point
2827 {
2828   void __user	*pointer;	/* Pointer to the data  (in user space) */
2829   __vki_u16	length;		/* number of fields or size in bytes */
2830   __vki_u16	flags;		/* Optional params */
2831 };
2832 
2833 struct	vki_iw_freq
2834 {
2835 	__vki_s32	m;		/* Mantissa */
2836 	__vki_s16	e;		/* Exponent */
2837 	__vki_u8	i;		/* List index (when in range struct) */
2838 	__vki_u8	flags;		/* Flags (fixed/auto) */
2839 };
2840 
2841 struct	vki_iw_quality
2842 {
2843 	__vki_u8	qual;		/* link quality (%retries, SNR,
2844 					   %missed beacons or better...) */
2845 	__vki_u8	level;		/* signal level (dBm) */
2846 	__vki_u8	noise;		/* noise level (dBm) */
2847 	__vki_u8	updated;	/* Flags to know if updated */
2848 };
2849 
2850 union	vki_iwreq_data
2851 {
2852 	/* Config - generic */
2853 	char		name[VKI_IFNAMSIZ];
2854 	/* Name : used to verify the presence of  wireless extensions.
2855 	 * Name of the protocol/provider... */
2856 
2857 	struct vki_iw_point	essid;	/* Extended network name */
2858 	struct vki_iw_param	nwid;	/* network id (or domain - the cell) */
2859 	struct vki_iw_freq	freq;	/* frequency or channel :
2860 					 * 0-1000 = channel
2861 					 * > 1000 = frequency in Hz */
2862 
2863 	struct vki_iw_param	sens;	/* signal level threshold */
2864 	struct vki_iw_param	bitrate;/* default bit rate */
2865 	struct vki_iw_param	txpower;/* default transmit power */
2866 	struct vki_iw_param	rts;	/* RTS threshold threshold */
2867 	struct vki_iw_param	frag;	/* Fragmentation threshold */
2868 	__vki_u32		mode;	/* Operation mode */
2869 	struct vki_iw_param	retry;	/* Retry limits & lifetime */
2870 
2871 	struct vki_iw_point	encoding; /* Encoding stuff : tokens */
2872 	struct vki_iw_param	power;	/* PM duration/timeout */
2873 	struct vki_iw_quality	qual;	/* Quality part of statistics */
2874 
2875 	struct vki_sockaddr ap_addr;	/* Access point address */
2876 	struct vki_sockaddr addr;	/* Destination address (hw/mac) */
2877 
2878 	struct vki_iw_param	param;	/* Other small parameters */
2879 	struct vki_iw_point	data;	/* Other large parameters */
2880 };
2881 
2882 struct	vki_iwreq
2883 {
2884 	union
2885 	{
2886 		char ifrn_name[VKI_IFNAMSIZ];	/* if name, e.g. "eth0" */
2887 	} ifr_ifrn;
2888 
2889 	/* Data part (defined just above) */
2890 	union	vki_iwreq_data	u;
2891 };
2892 
2893 /*--------------------------------------------------------------------*/
2894 // From linux-2.6.31.5/include/linux/perf_event.h
2895 /*--------------------------------------------------------------------*/
2896 
2897 struct vki_perf_event_attr {
2898 
2899 	/*
2900 	 * Major type: hardware/software/tracepoint/etc.
2901 	 */
2902 	__vki_u32			type;
2903 
2904 	/*
2905 	 * Size of the attr structure, for fwd/bwd compat.
2906 	 */
2907 	__vki_u32			size;
2908 
2909 	/*
2910 	 * Type specific configuration information.
2911 	 */
2912 	__vki_u64			config;
2913 
2914 	union {
2915 		__vki_u64		sample_period;
2916 		__vki_u64		sample_freq;
2917 	};
2918 
2919 	__vki_u64			sample_type;
2920 	__vki_u64			read_format;
2921 
2922 	__vki_u64			disabled       :  1, /* off by default        */
2923 					inherit	       :  1, /* children inherit it   */
2924 					pinned	       :  1, /* must always be on PMU */
2925 					exclusive      :  1, /* only group on PMU     */
2926 					exclude_user   :  1, /* don't count user      */
2927 					exclude_kernel :  1, /* ditto kernel          */
2928 					exclude_hv     :  1, /* ditto hypervisor      */
2929 					exclude_idle   :  1, /* don't count when idle */
2930 					mmap           :  1, /* include mmap data     */
2931 					comm	       :  1, /* include comm data     */
2932 					freq           :  1, /* use freq, not period  */
2933 					inherit_stat   :  1, /* per task counts       */
2934 					enable_on_exec :  1, /* next exec enables     */
2935 					task           :  1, /* trace fork/exit       */
2936 					watermark      :  1, /* wakeup_watermark      */
2937 					/*
2938 					 * precise_ip:
2939 					 *
2940 					 *  0 - SAMPLE_IP can have arbitrary skid
2941 					 *  1 - SAMPLE_IP must have constant skid
2942 					 *  2 - SAMPLE_IP requested to have 0 skid
2943 					 *  3 - SAMPLE_IP must have 0 skid
2944 					 *
2945 					 *  See also PERF_RECORD_MISC_EXACT_IP
2946 					 */
2947 					precise_ip     :  2, /* skid constraint       */
2948 					mmap_data      :  1, /* non-exec mmap data    */
2949 					sample_id_all  :  1, /* sample_type all events */
2950 
2951 					__reserved_1   : 45;
2952 
2953 	union {
2954 		__vki_u32		wakeup_events;	  /* wakeup every n events */
2955 		__vki_u32		wakeup_watermark; /* bytes before wakeup   */
2956 	};
2957 
2958 	__vki_u32			bp_type;
2959 	union {
2960 		__vki_u64		bp_addr;
2961 		__vki_u64		config1; /* extension of config */
2962 	};
2963 	union {
2964 		__vki_u64		bp_len;
2965 		__vki_u64		config2; /* extension of config1 */
2966 	};
2967 };
2968 
2969 #define VKI_PERF_EVENT_IOC_ENABLE       _VKI_IO ('$', 0)
2970 #define VKI_PERF_EVENT_IOC_DISABLE      _VKI_IO ('$', 1)
2971 #define VKI_PERF_EVENT_IOC_REFRESH      _VKI_IO ('$', 2)
2972 #define VKI_PERF_EVENT_IOC_RESET        _VKI_IO ('$', 3)
2973 #define VKI_PERF_EVENT_IOC_PERIOD       _VKI_IOW('$', 4, __vki_u64)
2974 #define VKI_PERF_EVENT_IOC_SET_OUTPUT   _VKI_IO ('$', 5)
2975 #define VKI_PERF_EVENT_IOC_SET_FILTER   _VKI_IOW('$', 6, char *)
2976 #define VKI_PERF_EVENT_IOC_ID           _VKI_IOR('$', 7, __vki_u64 *)
2977 #define VKI_PERF_EVENT_IOC_SET_BPF      _VKI_IOW('$', 8, __vki_u32)
2978 
2979 /*--------------------------------------------------------------------*/
2980 // From linux-2.6.32.4/include/linux/getcpu.h
2981 /*--------------------------------------------------------------------*/
2982 
2983 struct vki_getcpu_cache {
2984 	unsigned long blob[128 / sizeof(long)];
2985 };
2986 
2987 //----------------------------------------------------------------------
2988 // From linux-2.6.33.3/include/linux/input.h
2989 //----------------------------------------------------------------------
2990 
2991 /*
2992  * IOCTLs (0x00 - 0x7f)
2993  */
2994 
2995 #define VKI_EVIOCGNAME(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x06, len)		/* get device name */
2996 #define VKI_EVIOCGPHYS(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x07, len)		/* get physical location */
2997 #define VKI_EVIOCGUNIQ(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x08, len)		/* get unique identifier */
2998 
2999 #define VKI_EVIOCGKEY(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x18, len)		/* get global keystate */
3000 #define VKI_EVIOCGLED(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x19, len)		/* get all LEDs */
3001 #define VKI_EVIOCGSND(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x1a, len)		/* get all sounds status */
3002 #define VKI_EVIOCGSW(len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x1b, len)		/* get all switch states */
3003 
3004 #define VKI_EVIOCGBIT(ev,len)	_VKI_IOC(_VKI_IOC_READ, 'E', 0x20 + ev, len)	/* get event bits */
3005 
3006 /*
3007  * Event types
3008  */
3009 
3010 #define VKI_EV_SYN		0x00
3011 #define VKI_EV_KEY		0x01
3012 #define VKI_EV_REL		0x02
3013 #define VKI_EV_ABS		0x03
3014 #define VKI_EV_MSC		0x04
3015 #define VKI_EV_SW		0x05
3016 #define VKI_EV_LED		0x11
3017 #define VKI_EV_SND		0x12
3018 #define VKI_EV_REP		0x14
3019 #define VKI_EV_FF		0x15
3020 #define VKI_EV_PWR		0x16
3021 #define VKI_EV_FF_STATUS	0x17
3022 #define VKI_EV_MAX		0x1f
3023 #define VKI_EV_CNT		(VKI_EV_MAX+1)
3024 
3025 //----------------------------------------------------------------------
3026 // From linux-2.6.39-rc2/include/asm_generic/ioctls.h
3027 //----------------------------------------------------------------------
3028 
3029 #ifndef VKI_FIOQSIZE
3030 #define VKI_FIOQSIZE 0x5460     /* Value differs on some platforms */
3031 #endif
3032 
3033 #ifndef VKI_TIOCSIG
3034 #define VKI_TIOCSIG _VKI_IOW('T', 0x36, int) /* Value differs on some platforms */
3035 #endif
3036 
3037 //----------------------------------------------------------------------
3038 // From kernel/common/include/linux/ashmem.h
3039 //----------------------------------------------------------------------
3040 
3041 #if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
3042     || defined(VGPV_mips32_linux_android) \
3043     || defined(VGPV_arm64_linux_android)
3044 
3045 #define VKI_ASHMEM_NAME_LEN 256
3046 
3047 #define VKI_ASHMEM_NAME_DEF "dev/ashmem"
3048 
3049 #define VKI_ASHMEM_NOT_PURGED 0
3050 #define VKI_ASHMEM_WAS_PURGED 1
3051 
3052 #define VKI_ASHMEM_IS_UNPINNED 0
3053 #define VKI_ASHMEM_IS_PINNED 1
3054 
3055 struct vki_ashmem_pin {
3056    vki_uint32_t offset;
3057    vki_uint32_t len;
3058 };
3059 
3060 #define __VKI_ASHMEMIOC 0x77
3061 
3062 #define VKI_ASHMEM_SET_NAME _VKI_IOW(__VKI_ASHMEMIOC, 1, char[VKI_ASHMEM_NAME_LEN])
3063 #define VKI_ASHMEM_GET_NAME _VKI_IOR(__VKI_ASHMEMIOC, 2, char[VKI_ASHMEM_NAME_LEN])
3064 #define VKI_ASHMEM_SET_SIZE _VKI_IOW(__VKI_ASHMEMIOC, 3, vki_size_t)
3065 #define VKI_ASHMEM_GET_SIZE _VKI_IO(__VKI_ASHMEMIOC, 4)
3066 #define VKI_ASHMEM_SET_PROT_MASK _VKI_IOW(__VKI_ASHMEMIOC, 5, unsigned long)
3067 #define VKI_ASHMEM_GET_PROT_MASK _VKI_IO(__VKI_ASHMEMIOC, 6)
3068 #define VKI_ASHMEM_PIN _VKI_IOW(__VKI_ASHMEMIOC, 7, struct vki_ashmem_pin)
3069 #define VKI_ASHMEM_UNPIN _VKI_IOW(__VKI_ASHMEMIOC, 8, struct vki_ashmem_pin)
3070 #define VKI_ASHMEM_GET_PIN_STATUS _VKI_IO(__VKI_ASHMEMIOC, 9)
3071 #define VKI_ASHMEM_PURGE_ALL_CACHES _VKI_IO(__VKI_ASHMEMIOC, 10)
3072 
3073 //----------------------------------------------------------------------
3074 // From kernel/common/include/linux/binder.h
3075 //----------------------------------------------------------------------
3076 
3077 struct vki_binder_write_read {
3078  signed long write_size;
3079  signed long write_consumed;
3080  unsigned long write_buffer;
3081  signed long read_size;
3082  signed long read_consumed;
3083  unsigned long read_buffer;
3084 };
3085 
3086 struct vki_binder_version {
3087  signed long protocol_version;
3088 };
3089 
3090 #define VKI_BINDER_WRITE_READ _VKI_IOWR('b', 1, struct vki_binder_write_read)
3091 #define VKI_BINDER_SET_IDLE_TIMEOUT _VKI_IOW('b', 3, vki_int64_t)
3092 #define VKI_BINDER_SET_MAX_THREADS _VKI_IOW('b', 5, vki_size_t)
3093 #define VKI_BINDER_SET_IDLE_PRIORITY _VKI_IOW('b', 6, int)
3094 #define VKI_BINDER_SET_CONTEXT_MGR _VKI_IOW('b', 7, int)
3095 #define VKI_BINDER_THREAD_EXIT _VKI_IOW('b', 8, int)
3096 #define VKI_BINDER_VERSION _VKI_IOWR('b', 9, struct vki_binder_version)
3097 
3098 #endif /* defined(VGPV_*_linux_android) */
3099 
3100 //----------------------------------------------------------------------
3101 // From linux-3.0.4/include/net/bluetooth/bluetooth.h
3102 //----------------------------------------------------------------------
3103 
3104 typedef struct {
3105    __vki_u8 b[6];
3106 } __vki_packed vki_bdaddr_t;
3107 
3108 //----------------------------------------------------------------------
3109 // From linux-3.0.4/include/net/bluetooth/hci.h
3110 //----------------------------------------------------------------------
3111 
3112 #define VKI_HCIDEVUP        _VKI_IOW('H', 201, int)
3113 #define VKI_HCIDEVDOWN      _VKI_IOW('H', 202, int)
3114 #define VKI_HCIDEVRESET     _VKI_IOW('H', 203, int)
3115 #define VKI_HCIDEVRESTAT    _VKI_IOW('H', 204, int)
3116 
3117 #define VKI_HCIGETDEVLIST   _VKI_IOR('H', 210, int)
3118 
3119 struct vki_hci_dev_req {
3120 	__vki_u16  dev_id;
3121 	__vki_u32  dev_opt;
3122 };
3123 
3124 struct vki_hci_dev_list_req {
3125 	__vki_u16  dev_num;
3126 	struct vki_hci_dev_req dev_req[0];	/* hci_dev_req structures */
3127 };
3128 
3129 #define VKI_HCIGETDEVINFO   _VKI_IOR('H', 211, int)
3130 #define VKI_HCIGETCONNLIST  _VKI_IOR('H', 212, int)
3131 #define VKI_HCIGETCONNINFO  _VKI_IOR('H', 213, int)
3132 #define VKI_HCIGETAUTHINFO  _VKI_IOR('H', 215, int)
3133 
3134 #define VKI_HCISETRAW       _VKI_IOW('H', 220, int)
3135 #define VKI_HCISETSCAN      _VKI_IOW('H', 221, int)
3136 #define VKI_HCISETAUTH      _VKI_IOW('H', 222, int)
3137 #define VKI_HCISETENCRYPT   _VKI_IOW('H', 223, int)
3138 #define VKI_HCISETPTYPE     _VKI_IOW('H', 224, int)
3139 #define VKI_HCISETLINKPOL   _VKI_IOW('H', 225, int)
3140 #define VKI_HCISETLINKMODE  _VKI_IOW('H', 226, int)
3141 #define VKI_HCISETACLMTU    _VKI_IOW('H', 227, int)
3142 #define VKI_HCISETSCOMTU    _VKI_IOW('H', 228, int)
3143 
3144 #define VKI_HCIBLOCKADDR    _VKI_IOW('H', 230, int)
3145 #define VKI_HCIUNBLOCKADDR  _VKI_IOW('H', 231, int)
3146 
3147 #define VKI_HCIINQUIRY      _VKI_IOR('H', 240, int)
3148 
3149 struct vki_inquiry_info {
3150    vki_bdaddr_t bdaddr;
3151    __vki_u8     pscan_rep_mode;
3152    __vki_u8     pscan_period_mode;
3153    __vki_u8     pscan_mode;
3154    __vki_u8     dev_class[3];
3155    __vki_le16   clock_offset;
3156 } __vki_packed;
3157 
3158 struct vki_hci_inquiry_req {
3159    __vki_u16 dev_id;
3160    __vki_u16 flags;
3161    __vki_u8  lap[3];
3162    __vki_u8  length;
3163    __vki_u8  num_rsp;
3164 };
3165 
3166 //----------------------------------------------------------------------
3167 // From linux-3.9.2/include/net/bluetooth/rfcomm.h
3168 //----------------------------------------------------------------------
3169 
3170 struct vki_sockaddr_rc {
3171         vki_sa_family_t     rc_family;
3172         vki_bdaddr_t        rc_bdaddr;
3173         __vki_u8            rc_channel;
3174 };
3175 
3176 //----------------------------------------------------------------------
3177 // From linux-3.4/include/linux/kvm.h
3178 //----------------------------------------------------------------------
3179 #define KVMIO 0xAE
3180 
3181 #define VKI_KVM_GET_API_VERSION       _VKI_IO(KVMIO,   0x00)
3182 #define VKI_KVM_CREATE_VM             _VKI_IO(KVMIO,   0x01) /* returns a VM fd */
3183 #define VKI_KVM_CHECK_EXTENSION       _VKI_IO(KVMIO,   0x03)
3184 #define VKI_KVM_GET_VCPU_MMAP_SIZE    _VKI_IO(KVMIO,   0x04) /* in bytes */
3185 #define VKI_KVM_S390_ENABLE_SIE       _VKI_IO(KVMIO,   0x06)
3186 #define VKI_KVM_CREATE_VCPU           _VKI_IO(KVMIO,   0x41)
3187 #define VKI_KVM_SET_NR_MMU_PAGES      _VKI_IO(KVMIO,   0x44)
3188 #define VKI_KVM_GET_NR_MMU_PAGES      _VKI_IO(KVMIO,   0x45)
3189 #define VKI_KVM_SET_TSS_ADDR          _VKI_IO(KVMIO,   0x47)
3190 #define VKI_KVM_CREATE_IRQCHIP        _VKI_IO(KVMIO,   0x60)
3191 #define VKI_KVM_CREATE_PIT            _VKI_IO(KVMIO,   0x64)
3192 #define VKI_KVM_REINJECT_CONTROL      _VKI_IO(KVMIO,   0x71)
3193 #define VKI_KVM_SET_BOOT_CPU_ID       _VKI_IO(KVMIO,   0x78)
3194 #define VKI_KVM_SET_TSC_KHZ           _VKI_IO(KVMIO,  0xa2)
3195 #define VKI_KVM_GET_TSC_KHZ           _VKI_IO(KVMIO,  0xa3)
3196 #define VKI_KVM_RUN                   _VKI_IO(KVMIO,   0x80)
3197 #define VKI_KVM_S390_INITIAL_RESET    _VKI_IO(KVMIO,   0x97)
3198 #define VKI_KVM_NMI                   _VKI_IO(KVMIO,   0x9a)
3199 #define VKI_KVM_KVMCLOCK_CTRL         _VKI_IO(KVMIO,   0xad)
3200 
3201 struct vki_kvm_s390_mem_op {
3202         /* in */
3203         __vki_u64 gaddr;            /* the guest address */
3204         __vki_u64 flags;            /* flags */
3205         __vki_u32 size;             /* amount of bytes */
3206         __vki_u32 op;               /* type of operation */
3207         __vki_u64 buf;              /* buffer in userspace */
3208         __vki_u8 ar;                /* the access register number */
3209         __vki_u8 reserved[31];      /* should be set to 0 */
3210 };
3211 
3212 #define VKI_KVM_S390_MEMOP_LOGICAL_READ		0
3213 #define VKI_KVM_S390_MEMOP_LOGICAL_WRITE	1
3214 #define VKI_KVM_S390_MEMOP_F_CHECK_ONLY		(1ULL << 0)
3215 #define VKI_KVM_S390_MEMOP_F_INJECT_EXCEPTION	(1ULL << 1)
3216 
3217 #define VKI_KVM_S390_MEM_OP           _VKI_IOW(KVMIO,  0xb1, struct vki_kvm_s390_mem_op)
3218 
3219 //----------------------------------------------------------------------
3220 // From linux-2.6/include/linux/net_stamp.h
3221 //----------------------------------------------------------------------
3222 
3223 struct vki_hwtstamp_config {
3224 	int flags;
3225 	int tx_type;
3226 	int rx_filter;
3227 };
3228 
3229 //----------------------------------------------------------------------
3230 // From linux-2.6.12-rc2/include/linux/uinput.h
3231 //----------------------------------------------------------------------
3232 
3233 #define VKI_UINPUT_IOCTL_BASE       'U'
3234 #define VKI_UI_DEV_CREATE		_VKI_IO(VKI_UINPUT_IOCTL_BASE, 1)
3235 #define VKI_UI_DEV_DESTROY		_VKI_IO(VKI_UINPUT_IOCTL_BASE, 2)
3236 
3237 #define VKI_UI_SET_EVBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 100, int)
3238 #define VKI_UI_SET_KEYBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 101, int)
3239 #define VKI_UI_SET_RELBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 102, int)
3240 #define VKI_UI_SET_ABSBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 103, int)
3241 #define VKI_UI_SET_MSCBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 104, int)
3242 #define VKI_UI_SET_LEDBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 105, int)
3243 #define VKI_UI_SET_SNDBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 106, int)
3244 #define VKI_UI_SET_FFBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 107, int)
3245 #define VKI_UI_SET_SWBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 109, int)
3246 #define VKI_UI_SET_PROPBIT		_VKI_IOW(VKI_UINPUT_IOCTL_BASE, 110, int)
3247 
3248 //----------------------------------------------------------------------
3249 // From linux-2.6/include/uapi/rdma/ib_user_mad.h
3250 //----------------------------------------------------------------------
3251 
3252 #define VKI_IB_IOCTL_MAGIC          0x1b
3253 
3254 #define VKI_IB_USER_MAD_REGISTER_AGENT    _VKI_IOWR(VKI_IB_IOCTL_MAGIC, 1, \
3255                                               struct ib_user_mad_reg_req)
3256 
3257 #define VKI_IB_USER_MAD_UNREGISTER_AGENT  _VKI_IOW(VKI_IB_IOCTL_MAGIC, 2, __u32)
3258 
3259 #define VKI_IB_USER_MAD_ENABLE_PKEY       _VKI_IO(VKI_IB_IOCTL_MAGIC, 3)
3260 
3261 //----------------------------------------------------------------------
3262 // From linux-3.8/include/uapi/linux/if_tun.h
3263 //----------------------------------------------------------------------
3264 
3265 #define VKI_TUNSETNOCSUM  _VKI_IOW('T', 200, int)
3266 #define VKI_TUNSETDEBUG   _VKI_IOW('T', 201, int)
3267 #define VKI_TUNSETIFF     _VKI_IOW('T', 202, int)
3268 #define VKI_TUNSETPERSIST _VKI_IOW('T', 203, int)
3269 #define VKI_TUNSETOWNER   _VKI_IOW('T', 204, int)
3270 #define VKI_TUNSETLINK    _VKI_IOW('T', 205, int)
3271 #define VKI_TUNSETGROUP   _VKI_IOW('T', 206, int)
3272 #define VKI_TUNGETFEATURES _VKI_IOR('T', 207, unsigned int)
3273 #define VKI_TUNSETOFFLOAD  _VKI_IOW('T', 208, unsigned int)
3274 #define VKI_TUNSETTXFILTER _VKI_IOW('T', 209, unsigned int)
3275 #define VKI_TUNGETIFF      _VKI_IOR('T', 210, unsigned int)
3276 #define VKI_TUNGETSNDBUF   _VKI_IOR('T', 211, int)
3277 #define VKI_TUNSETSNDBUF   _VKI_IOW('T', 212, int)
3278 //#define VKI_TUNATTACHFILTER _VKI_IOW('T', 213, struct sock_fprog)
3279 //#define VKI_TUNDETACHFILTER _VKI_IOW('T', 214, struct sock_fprog)
3280 #define VKI_TUNGETVNETHDRSZ _VKI_IOR('T', 215, int)
3281 #define VKI_TUNSETVNETHDRSZ _VKI_IOW('T', 216, int)
3282 #define VKI_TUNSETQUEUE  _VKI_IOW('T', 217, int)
3283 #define VKI_TUNSETIFINDEX	_VKI_IOW('T', 218, unsigned int)
3284 //#define VKI_TUNGETFILTER _VKI_IOR('T', 219, struct sock_fprog)
3285 
3286 //----------------------------------------------------------------------
3287 // From linux-3.8/include/uapi/linux/vhost.h
3288 //----------------------------------------------------------------------
3289 
3290 #define VKI_VHOST_VIRTIO 0xAF
3291 #define VKI_VHOST_SET_OWNER _VKI_IO(VKI_VHOST_VIRTIO, 0x01)
3292 #define VKI_VHOST_RESET_OWNER _VKI_IO(VKI_VHOST_VIRTIO, 0x02)
3293 
3294 //----------------------------------------------------------------------
3295 // Xen privcmd IOCTL
3296 //----------------------------------------------------------------------
3297 
3298 typedef unsigned long __vki_xen_pfn_t;
3299 
3300 struct vki_xen_privcmd_hypercall {
3301        __vki_u64 op;
3302        __vki_u64 arg[5];
3303 };
3304 
3305 struct vki_xen_privcmd_mmap_entry {
3306         __vki_u64 va;
3307         __vki_u64 mfn;
3308         __vki_u64 npages;
3309 };
3310 
3311 struct vki_xen_privcmd_mmap {
3312         int num;
3313         __vki_u16 dom; /* target domain */
3314         struct vki_xen_privcmd_mmap_entry *entry;
3315 };
3316 
3317 struct vki_xen_privcmd_mmapbatch {
3318         int num;     /* number of pages to populate */
3319         __vki_u16 dom; /* target domain */
3320         __vki_u64 addr;  /* virtual address */
3321         __vki_xen_pfn_t *arr; /* array of mfns - top nibble set on err */
3322 };
3323 
3324 struct vki_xen_privcmd_mmapbatch_v2 {
3325         unsigned int num; /* number of pages to populate */
3326         __vki_u16 dom;      /* target domain */
3327         __vki_u64 addr;       /* virtual address */
3328         const __vki_xen_pfn_t *arr; /* array of mfns */
3329         int __user *err;  /* array of error codes */
3330 };
3331 
3332 #define VKI_XEN_IOCTL_PRIVCMD_HYPERCALL    _VKI_IOC(_VKI_IOC_NONE, 'P', 0, sizeof(struct vki_xen_privcmd_hypercall))
3333 #define VKI_XEN_IOCTL_PRIVCMD_MMAP         _VKI_IOC(_VKI_IOC_NONE, 'P', 2, sizeof(struct vki_xen_privcmd_mmap))
3334 
3335 #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH    _VKI_IOC(_VKI_IOC_NONE, 'P', 3, sizeof(struct vki_xen_privcmd_mmapbatch))
3336 #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2 _VKI_IOC(_VKI_IOC_NONE, 'P', 4, sizeof(struct vki_xen_privcmd_mmapbatch_v2))
3337 
3338 //----------------------------------------------------------------------
3339 // Xen evtchn IOCTL
3340 //----------------------------------------------------------------------
3341 
3342 #define VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ				\
3343 	_VKI_IOC(_VKI_IOC_NONE, 'E', 0, sizeof(struct vki_xen_ioctl_evtchn_bind_virq))
3344 struct vki_xen_ioctl_evtchn_bind_virq {
3345 	vki_uint32_t virq;
3346 };
3347 
3348 #define VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN			\
3349 	_VKI_IOC(_VKI_IOC_NONE, 'E', 1, sizeof(struct vki_xen_ioctl_evtchn_bind_interdomain))
3350 struct vki_xen_ioctl_evtchn_bind_interdomain {
3351 	vki_uint32_t remote_domain;
3352 	vki_uint32_t remote_port;
3353 };
3354 
3355 #define VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT			\
3356 	_VKI_IOC(_VKI_IOC_NONE, 'E', 2, sizeof(struct vki_xen_ioctl_evtchn_bind_unbound_port))
3357 struct vki_xen_ioctl_evtchn_bind_unbound_port {
3358 	vki_uint32_t remote_domain;
3359 };
3360 
3361 #define VKI_XEN_IOCTL_EVTCHN_UNBIND				\
3362 	_VKI_IOC(_VKI_IOC_NONE, 'E', 3, sizeof(struct vki_xen_ioctl_evtchn_unbind))
3363 struct vki_xen_ioctl_evtchn_unbind {
3364 	vki_uint32_t port;
3365 };
3366 
3367 #define VKI_XEN_IOCTL_EVTCHN_NOTIFY				\
3368 	_VKI_IOC(_VKI_IOC_NONE, 'E', 4, sizeof(struct vki_xen_ioctl_evtchn_notify))
3369 struct vki_xen_ioctl_evtchn_notify {
3370 	vki_uint32_t port;
3371 };
3372 
3373 #define VKI_XEN_IOCTL_EVTCHN_RESET				\
3374 	_VKI_IOC(_VKI_IOC_NONE, 'E', 5, 0)
3375 
3376 
3377 //----------------------------------------------------------------------
3378 // From linux-3.4.0/include/linux/fs.h
3379 //----------------------------------------------------------------------
3380 
3381 struct vki_file_handle {
3382    __vki_u32 handle_bytes;
3383    int handle_type;
3384    /* file identifier */
3385    unsigned char f_handle[0];
3386 };
3387 
3388 //----------------------------------------------------------------------
3389 // From linux-3.2.0/include/linux/filter.h
3390 //----------------------------------------------------------------------
3391 
3392 struct vki_sock_filter {
3393 	__vki_u16 code; /* Actual filter code */
3394 	__vki_u8 jt;    /* Jump true */
3395 	__vki_u8 jf;    /* Jump false */
3396 	__vki_u32 k;    /* Generic multiuse field */
3397 };
3398 
3399 struct vki_sock_fprog {
3400 	__vki_u16 len;  /* actually unsigned short */
3401 	struct vki_sock_filter *filter;
3402 };
3403 
3404 //----------------------------------------------------------------------
3405 // From linux/include/uapi/linux/ethtool.h
3406 //----------------------------------------------------------------------
3407 
3408 struct vki_ethtool_cmd {
3409 	__vki_u32	cmd;
3410 	__vki_u32	supported;
3411 	__vki_u32	advertising;
3412 	__vki_u16	speed;
3413 	__vki_u8	duplex;
3414 	__vki_u8	port;
3415 	__vki_u8	phy_address;
3416 	__vki_u8	transceiver;
3417 	__vki_u8	autoneg;
3418 	__vki_u8	mdio_support;
3419 	__vki_u32	maxtxpkt;
3420 	__vki_u32	maxrxpkt;
3421 	__vki_u16	speed_hi;
3422 	__vki_u8	eth_tp_mdix;
3423 	__vki_u8	eth_tp_mdix_ctrl;
3424 	__vki_u32	lp_advertising;
3425 	__vki_u32	reserved[2];
3426 };
3427 
3428 #define VKI_ETHTOOL_FWVERS_LEN	32
3429 #define VKI_ETHTOOL_BUSINFO_LEN	32
3430 
3431 struct vki_ethtool_drvinfo {
3432 	__vki_u32	cmd;
3433 	char	driver[32];
3434 	char	version[32];
3435 	char	fw_version[VKI_ETHTOOL_FWVERS_LEN];
3436 	char	bus_info[VKI_ETHTOOL_BUSINFO_LEN];
3437 	char	reserved1[32];
3438 	char	reserved2[12];
3439 	__vki_u32	n_priv_flags;
3440 	__vki_u32	n_stats;
3441 	__vki_u32	testinfo_len;
3442 	__vki_u32	eedump_len;
3443 	__vki_u32	regdump_len;
3444 };
3445 
3446 #define VKI_SOPASS_MAX	6
3447 
3448 struct vki_ethtool_wolinfo {
3449 	__vki_u32	cmd;
3450 	__vki_u32	supported;
3451 	__vki_u32	wolopts;
3452 	__vki_u8	sopass[VKI_SOPASS_MAX];
3453 };
3454 
3455 struct vki_ethtool_value {
3456 	__vki_u32	cmd;
3457 	__vki_u32	data;
3458 };
3459 
3460 struct vki_ethtool_regs {
3461 	__vki_u32	cmd;
3462 	__vki_u32	version;
3463 	__vki_u32	len;
3464 	__vki_u8	data[0];
3465 };
3466 
3467 struct vki_ethtool_ringparam {
3468 	__vki_u32	cmd;
3469 	__vki_u32	rx_max_pending;
3470 	__vki_u32	rx_mini_max_pending;
3471 	__vki_u32	rx_jumbo_max_pending;
3472 	__vki_u32	tx_max_pending;
3473 	__vki_u32	rx_pending;
3474 	__vki_u32	rx_mini_pending;
3475 	__vki_u32	rx_jumbo_pending;
3476 	__vki_u32	tx_pending;
3477 };
3478 
3479 struct vki_ethtool_channels {
3480 	__vki_u32	cmd;
3481 	__vki_u32	max_rx;
3482 	__vki_u32	max_tx;
3483 	__vki_u32	max_other;
3484 	__vki_u32	max_combined;
3485 	__vki_u32	rx_count;
3486 	__vki_u32	tx_count;
3487 	__vki_u32	other_count;
3488 	__vki_u32	combined_count;
3489 };
3490 
3491 struct vki_ethtool_sset_info {
3492 	__vki_u32	cmd;
3493 	__vki_u32	reserved;
3494 	__vki_u64	sset_mask;
3495 	__vki_u32	data[0];
3496 };
3497 
3498 struct vki_ethtool_test {
3499 	__vki_u32	cmd;
3500 	__vki_u32	flags;
3501 	__vki_u32	reserved;
3502 	__vki_u32	len;
3503 	__vki_u64	data[0];
3504 };
3505 
3506 struct vki_ethtool_perm_addr {
3507 	__vki_u32	cmd;
3508 	__vki_u32	size;
3509 	__vki_u8	data[0];
3510 };
3511 
3512 struct vki_ethtool_get_features_block {
3513 	__vki_u32	available;
3514 	__vki_u32	requested;
3515 	__vki_u32	active;
3516 	__vki_u32	never_changed;
3517 };
3518 
3519 struct vki_ethtool_gfeatures {
3520 	__vki_u32	cmd;
3521 	__vki_u32	size;
3522 	struct vki_ethtool_get_features_block features[0];
3523 };
3524 
3525 struct vki_ethtool_set_features_block {
3526 	__vki_u32	valid;
3527 	__vki_u32	requested;
3528 };
3529 
3530 struct vki_ethtool_sfeatures {
3531 	__vki_u32	cmd;
3532 	__vki_u32	size;
3533 	struct vki_ethtool_set_features_block features[0];
3534 };
3535 
3536 struct vki_ethtool_ts_info {
3537 	__vki_u32	cmd;
3538 	__vki_u32	so_timestamping;
3539 	__vki_s32	phc_index;
3540 	__vki_u32	tx_types;
3541 	__vki_u32	tx_reserved[3];
3542 	__vki_u32	rx_filters;
3543 	__vki_u32	rx_reserved[3];
3544 };
3545 
3546 #define VKI_ETHTOOL_GSET	0x00000001 /* Get settings. */
3547 #define VKI_ETHTOOL_SSET	0x00000002 /* Set settings. */
3548 #define VKI_ETHTOOL_GDRVINFO	0x00000003 /* Get driver info. */
3549 #define VKI_ETHTOOL_GREGS	0x00000004 /* Get NIC registers. */
3550 #define VKI_ETHTOOL_GWOL	0x00000005 /* Get wake-on-lan options. */
3551 #define VKI_ETHTOOL_SWOL	0x00000006 /* Set wake-on-lan options. */
3552 #define VKI_ETHTOOL_GMSGLVL	0x00000007 /* Get driver message level */
3553 #define VKI_ETHTOOL_SMSGLVL	0x00000008 /* Set driver msg level. */
3554 #define VKI_ETHTOOL_NWAY_RST	0x00000009 /* Restart autonegotiation. */
3555 #define VKI_ETHTOOL_GLINK	0x0000000a
3556 #define VKI_ETHTOOL_GRINGPARAM	0x00000010 /* Get ring parameters */
3557 #define VKI_ETHTOOL_SRINGPARAM	0x00000011 /* Set ring parameters. */
3558 #define VKI_ETHTOOL_GRXCSUM	0x00000014 /* Get RX hw csum enable (ethtool_value) */
3559 #define VKI_ETHTOOL_SRXCSUM	0x00000015 /* Set RX hw csum enable (ethtool_value) */
3560 #define VKI_ETHTOOL_GTXCSUM	0x00000016 /* Get TX hw csum enable (ethtool_value) */
3561 #define VKI_ETHTOOL_STXCSUM	0x00000017 /* Set TX hw csum enable (ethtool_value) */
3562 #define VKI_ETHTOOL_GSG		0x00000018 /* Get scatter-gather enable
3563 					    * (ethtool_value) */
3564 #define VKI_ETHTOOL_SSG		0x00000019 /* Set scatter-gather enable
3565 					    * (ethtool_value). */
3566 #define VKI_ETHTOOL_TEST	0x0000001a /* execute NIC self-test. */
3567 #define VKI_ETHTOOL_PHYS_ID	0x0000001c /* identify the NIC */
3568 #define VKI_ETHTOOL_GTSO	0x0000001e /* Get TSO enable (ethtool_value) */
3569 #define VKI_ETHTOOL_STSO	0x0000001f /* Set TSO enable (ethtool_value) */
3570 #define VKI_ETHTOOL_GPERMADDR	0x00000020 /* Get permanent hardware address */
3571 #define VKI_ETHTOOL_GUFO	0x00000021 /* Get UFO enable (ethtool_value) */
3572 #define VKI_ETHTOOL_SUFO	0x00000022 /* Set UFO enable (ethtool_value) */
3573 #define VKI_ETHTOOL_GGSO	0x00000023 /* Get GSO enable (ethtool_value) */
3574 #define VKI_ETHTOOL_SGSO	0x00000024 /* Set GSO enable (ethtool_value) */
3575 #define VKI_ETHTOOL_GFLAGS	0x00000025 /* Get flags bitmap(ethtool_value) */
3576 #define VKI_ETHTOOL_SFLAGS	0x00000026 /* Set flags bitmap(ethtool_value) */
3577 #define VKI_ETHTOOL_GGRO	0x0000002b /* Get GRO enable (ethtool_value) */
3578 #define VKI_ETHTOOL_SGRO	0x0000002c /* Set GRO enable (ethtool_value) */
3579 #define VKI_ETHTOOL_RESET	0x00000034 /* Reset hardware */
3580 #define VKI_ETHTOOL_GSSET_INFO	0x00000037 /* Get string set info */
3581 #define VKI_ETHTOOL_GFEATURES	0x0000003a /* Get device offload settings */
3582 #define VKI_ETHTOOL_SFEATURES	0x0000003b /* Change device offload settings */
3583 #define VKI_ETHTOOL_GCHANNELS	0x0000003c /* Get no of channels */
3584 #define VKI_ETHTOOL_SCHANNELS	0x0000003d /* Set no of channels */
3585 #define VKI_ETHTOOL_GET_TS_INFO	0x00000041 /* Get time stamping and PHC info */
3586 
3587 //----------------------------------------------------------------------
3588 // From linux-3.15.8/drivers/staging/android/uapi/ion.h
3589 //----------------------------------------------------------------------
3590 
3591 typedef int vki_ion_user_handle_t;
3592 
3593 struct vki_ion_allocation_data {
3594         vki_size_t len;
3595         vki_size_t align;
3596         unsigned int heap_id_mask;
3597         unsigned int flags;
3598         vki_ion_user_handle_t handle;
3599 };
3600 
3601 struct vki_ion_fd_data {
3602         vki_ion_user_handle_t handle;
3603         int fd;
3604 };
3605 
3606 struct vki_ion_handle_data {
3607         vki_ion_user_handle_t handle;
3608 };
3609 
3610 struct vki_ion_custom_data {
3611         unsigned int cmd;
3612         unsigned long arg;
3613 };
3614 
3615 #define VKI_ION_IOC_MAGIC   'I'
3616 
3617 #define VKI_ION_IOC_ALLOC \
3618    _VKI_IOWR(VKI_ION_IOC_MAGIC, 0, struct vki_ion_allocation_data)
3619 
3620 #define VKI_ION_IOC_FREE \
3621    _VKI_IOWR(VKI_ION_IOC_MAGIC, 1, struct vki_ion_handle_data)
3622 
3623 #define VKI_ION_IOC_MAP \
3624    _VKI_IOWR(VKI_ION_IOC_MAGIC, 2, struct vki_ion_fd_data)
3625 
3626 #define VKI_ION_IOC_SHARE \
3627    _VKI_IOWR(VKI_ION_IOC_MAGIC, 4, struct vki_ion_fd_data)
3628 
3629 #define VKI_ION_IOC_IMPORT \
3630    _VKI_IOWR(VKI_ION_IOC_MAGIC, 5, struct vki_ion_fd_data)
3631 
3632 #define VKI_ION_IOC_SYNC \
3633    _VKI_IOWR(VKI_ION_IOC_MAGIC, 7, struct vki_ion_fd_data)
3634 
3635 #define VKI_ION_IOC_CUSTOM \
3636    _VKI_IOWR(VKI_ION_IOC_MAGIC, 6, struct vki_ion_custom_data)
3637 
3638 //----------------------------------------------------------------------
3639 // From linux-3.19-rc5/drivers/staging/android/uapi/sync.h
3640 //----------------------------------------------------------------------
3641 
3642 struct vki_sync_merge_data {
3643         __vki_s32 fd2;
3644         char      name[32];
3645         __vki_s32 fence;
3646 };
3647 
3648 struct vki_sync_pt_info {
3649         __vki_u32 len;
3650         char      obj_name[32];
3651         char      driver_name[32];
3652         __vki_s32 status;
3653         __vki_u64 timestamp_ns;
3654         __vki_u8  driver_data[0];
3655 };
3656 
3657 struct vki_sync_fence_info_data {
3658         __vki_u32 len;
3659         char      name[32];
3660         __vki_s32 status;
3661         __vki_u8  pt_info[0];
3662 };
3663 
3664 #define VKI_SYNC_IOC_MAGIC   '>'
3665 
3666 #define VKI_SYNC_IOC_WAIT \
3667    _VKI_IOW(VKI_SYNC_IOC_MAGIC, 0, __vki_s32)
3668 
3669 #define VKI_SYNC_IOC_MERGE \
3670    _VKI_IOWR(VKI_SYNC_IOC_MAGIC, 1, struct vki_sync_merge_data)
3671 
3672 #define VKI_SYNC_IOC_FENCE_INFO \
3673    _VKI_IOWR(VKI_SYNC_IOC_MAGIC, 2, struct vki_sync_fence_info_data)
3674 
3675 //----------------------------------------------------------------------
3676 // From drivers/staging/lustre/lustre/include/lustre/lustre_user.h
3677 //----------------------------------------------------------------------
3678 
3679 struct vki_lu_fid {
3680 	__vki_u64	f_seq;
3681 	__vki_u32	f_oid;
3682 	__vki_u32	f_ver;
3683 };
3684 
3685 //----------------------------------------------------------------------
3686 // From drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
3687 //----------------------------------------------------------------------
3688 
3689 struct vki_getinfo_fid2path {
3690 	struct vki_lu_fid	gf_fid;
3691 	__vki_u64		gf_recno;
3692 	__vki_u32		gf_linkno;
3693 	__vki_u32		gf_pathlen;
3694 	char			gf_path[0];
3695 } __attribute__((packed));
3696 
3697 //----------------------------------------------------------------------
3698 // From drivers/staging/lustre/lustre/include/linux/lustre_lib.h
3699 //----------------------------------------------------------------------
3700 
3701 #define VKI_OBD_IOC_DATA_TYPE               long
3702 
3703 //----------------------------------------------------------------------
3704 // From drivers/staging/lustre/lustre/include/lustre_lib.h
3705 //----------------------------------------------------------------------
3706 
3707 #define VKI_OBD_IOC_FID2PATH \
3708            _VKI_IOWR ('f', 150, VKI_OBD_IOC_DATA_TYPE)
3709 #define VKI_LL_IOC_PATH2FID \
3710            _VKI_IOR ('f', 173, long)
3711 
3712 //----------------------------------------------------------------------
3713 // From lustre/include/lustre/lustre_idl.h
3714 //----------------------------------------------------------------------
3715 
3716 struct vki_getparent {
3717     struct vki_lu_fid   gp_fid;
3718     __vki_u32       gp_linkno;
3719     __vki_u32       gp_name_size;
3720     char            gp_name[0];
3721 } __attribute__((packed));
3722 
3723 //----------------------------------------------------------------------
3724 // From Lustre's lustre/include/lustre/lustre_user.h
3725 //----------------------------------------------------------------------
3726 #define VKI_LL_IOC_GROUP_LOCK \
3727            _VKI_IOW('f', 158, long)
3728 #define VKI_LL_IOC_GROUP_UNLOCK \
3729            _VKI_IOW('f', 159, long)
3730 #define VKI_LL_IOC_GETPARENT \
3731            _VKI_IOWR('f', 249, struct vki_getparent)
3732 
3733 
3734 struct vki_v4l2_rect {
3735 	__vki_s32   left;
3736 	__vki_s32   top;
3737 	__vki_u32   width;
3738 	__vki_u32   height;
3739 };
3740 
3741 struct vki_v4l2_fract {
3742 	__vki_u32   numerator;
3743 	__vki_u32   denominator;
3744 };
3745 
3746 struct vki_v4l2_capability {
3747 	__vki_u8	driver[16];
3748 	__vki_u8	card[32];
3749 	__vki_u8	bus_info[32];
3750 	__vki_u32   version;
3751 	__vki_u32	capabilities;
3752 	__vki_u32	device_caps;
3753 	__vki_u32	reserved[3];
3754 };
3755 
3756 struct vki_v4l2_pix_format {
3757 	__vki_u32         		width;
3758 	__vki_u32			height;
3759 	__vki_u32			pixelformat;
3760 	__vki_u32			field;		/* enum vki_v4l2_field */
3761 	__vki_u32            	bytesperline;	/* for padding, zero if unused */
3762 	__vki_u32          		sizeimage;
3763 	__vki_u32			colorspace;	/* enum vki_v4l2_colorspace */
3764 	__vki_u32			priv;		/* private data, depends on pixelformat */
3765 	__vki_u32			flags;		/* format flags (VKI_V4L2_PIX_FMT_FLAG_*) */
3766 	__vki_u32			ycbcr_enc;
3767 	__vki_u32			quantization;
3768 };
3769 
3770 struct vki_v4l2_fmtdesc {
3771 	__vki_u32		    index;             /* Format number      */
3772 	__vki_u32		    type;              /* enum vki_v4l2_buf_type */
3773 	__vki_u32               flags;
3774 	__vki_u8		    description[32];   /* Description string */
3775 	__vki_u32		    pixelformat;       /* Format fourcc      */
3776 	__vki_u32		    reserved[4];
3777 };
3778 
3779 struct vki_v4l2_frmsize_discrete {
3780 	__vki_u32			width;		/* Frame width [pixel] */
3781 	__vki_u32			height;		/* Frame height [pixel] */
3782 };
3783 
3784 struct vki_v4l2_frmsize_stepwise {
3785 	__vki_u32			min_width;	/* Minimum frame width [pixel] */
3786 	__vki_u32			max_width;	/* Maximum frame width [pixel] */
3787 	__vki_u32			step_width;	/* Frame width step size [pixel] */
3788 	__vki_u32			min_height;	/* Minimum frame height [pixel] */
3789 	__vki_u32			max_height;	/* Maximum frame height [pixel] */
3790 	__vki_u32			step_height;	/* Frame height step size [pixel] */
3791 };
3792 
3793 struct vki_v4l2_frmsizeenum {
3794 	__vki_u32			index;		/* Frame size number */
3795 	__vki_u32			pixel_format;	/* Pixel format */
3796 	__vki_u32			type;		/* Frame size type the device supports. */
3797 
3798 	union {					/* Frame size */
3799 		struct vki_v4l2_frmsize_discrete	discrete;
3800 		struct vki_v4l2_frmsize_stepwise	stepwise;
3801 	};
3802 
3803 	__vki_u32   reserved[2];			/* Reserved space for future use */
3804 };
3805 
3806 struct vki_v4l2_frmival_stepwise {
3807 	struct vki_v4l2_fract	min;
3808 	struct vki_v4l2_fract	max;
3809 	struct vki_v4l2_fract	step;
3810 };
3811 
3812 struct vki_v4l2_frmivalenum {
3813 	__vki_u32			index;
3814 	__vki_u32			pixel_format;
3815 	__vki_u32			width;
3816 	__vki_u32			height;
3817 	__vki_u32			type;
3818 
3819 	union {
3820 		struct vki_v4l2_fract		discrete;
3821 		struct vki_v4l2_frmival_stepwise	stepwise;
3822 	};
3823 
3824 	__vki_u32	reserved[2];
3825 };
3826 
3827 struct vki_v4l2_timecode {
3828 	__vki_u32	type;
3829 	__vki_u32	flags;
3830 	__vki_u8	frames;
3831 	__vki_u8	seconds;
3832 	__vki_u8	minutes;
3833 	__vki_u8	hours;
3834 	__vki_u8	userbits[4];
3835 };
3836 
3837 struct vki_v4l2_jpegcompression {
3838 	int quality;
3839 	int  APPn;
3840 	int  APP_len;
3841 	char APP_data[60];
3842 	int  COM_len;
3843 	char COM_data[60];
3844 	__vki_u32 jpeg_markers;
3845 };
3846 
3847 struct vki_v4l2_requestbuffers {
3848 	__vki_u32			count;
3849 	__vki_u32			type;
3850 	__vki_u32			memory;
3851 	__vki_u32			reserved[2];
3852 };
3853 
3854 struct vki_v4l2_plane {
3855 	__vki_u32			bytesused;
3856 	__vki_u32			length;
3857 	union {
3858 		__vki_u32		mem_offset;
3859 		unsigned long	userptr;
3860 		__vki_s32		fd;
3861 	} m;
3862 	__vki_u32			data_offset;
3863 	__vki_u32			reserved[11];
3864 };
3865 
3866 #define VKI_V4L2_MEMORY_MMAP             1
3867 #define VKI_V4L2_MEMORY_DMABUF           4
3868 #define VKI_V4L2_BUF_FLAG_TIMESTAMP_MASK		0x0000e000
3869 #define VKI_V4L2_BUF_FLAG_TIMESTAMP_COPY		0x00004000
3870 struct vki_v4l2_buffer {
3871 	__vki_u32			index;
3872 	__vki_u32			type;
3873 	__vki_u32			bytesused;
3874 	__vki_u32			flags;
3875 	__vki_u32			field;
3876 	struct vki_timeval		timestamp;
3877 	struct vki_v4l2_timecode	timecode;
3878 	__vki_u32			sequence;
3879 
3880 	/* memory location */
3881 	__vki_u32			memory;
3882 	union {
3883 		__vki_u32           offset;
3884 		unsigned long   userptr;
3885 		struct vki_v4l2_plane *planes;
3886 		__vki_s32		fd;
3887 	} m;
3888 	__vki_u32			length;
3889 	__vki_u32			reserved2;
3890 	__vki_u32			reserved;
3891 };
3892 
3893 struct vki_v4l2_exportbuffer {
3894 	__vki_u32		type; /* enum vki_v4l2_buf_type */
3895 	__vki_u32		index;
3896 	__vki_u32		plane;
3897 	__vki_u32		flags;
3898 	__vki_s32		fd;
3899 	__vki_u32		reserved[11];
3900 };
3901 
3902 struct vki_v4l2_framebuffer {
3903 	__vki_u32			capability;
3904 	__vki_u32			flags;
3905 	void                    *base;
3906 	struct {
3907 		__vki_u32		width;
3908 		__vki_u32		height;
3909 		__vki_u32		pixelformat;
3910 		__vki_u32		field;		/* enum vki_v4l2_field */
3911 		__vki_u32		bytesperline;	/* for padding, zero if unused */
3912 		__vki_u32		sizeimage;
3913 		__vki_u32		colorspace;	/* enum vki_v4l2_colorspace */
3914 		__vki_u32		priv;		/* reserved field, set to 0 */
3915 	} fmt;
3916 };
3917 
3918 struct vki_v4l2_clip {
3919 	struct vki_v4l2_rect        c;
3920 	struct vki_v4l2_clip	__user *next;
3921 };
3922 
3923 struct vki_v4l2_window {
3924 	struct vki_v4l2_rect        w;
3925 	__vki_u32			field;	 /* enum vki_v4l2_field */
3926 	__vki_u32			chromakey;
3927 	struct vki_v4l2_clip	__user *clips;
3928 	__vki_u32			clipcount;
3929 	void			__user *bitmap;
3930 	__vki_u8                    global_alpha;
3931 };
3932 
3933 struct vki_v4l2_captureparm {
3934 	__vki_u32		   capability;	  /*  Supported modes */
3935 	__vki_u32		   capturemode;	  /*  Current mode */
3936 	struct vki_v4l2_fract  timeperframe;  /*  Time per frame in seconds */
3937 	__vki_u32		   extendedmode;  /*  Driver-specific extensions */
3938 	__vki_u32              readbuffers;   /*  # of buffers for read */
3939 	__vki_u32		   reserved[4];
3940 };
3941 
3942 struct vki_v4l2_outputparm {
3943 	__vki_u32		   capability;	 /*  Supported modes */
3944 	__vki_u32		   outputmode;	 /*  Current mode */
3945 	struct vki_v4l2_fract  timeperframe; /*  Time per frame in seconds */
3946 	__vki_u32		   extendedmode; /*  Driver-specific extensions */
3947 	__vki_u32              writebuffers; /*  # of buffers for write */
3948 	__vki_u32		   reserved[4];
3949 };
3950 
3951 struct vki_v4l2_cropcap {
3952 	__vki_u32			type;	/* enum vki_v4l2_buf_type */
3953 	struct vki_v4l2_rect        bounds;
3954 	struct vki_v4l2_rect        defrect;
3955 	struct vki_v4l2_fract       pixelaspect;
3956 };
3957 
3958 struct vki_v4l2_crop {
3959 	__vki_u32			type;	/* enum vki_v4l2_buf_type */
3960 	struct vki_v4l2_rect        c;
3961 };
3962 
3963 struct vki_v4l2_selection {
3964 	__vki_u32			type;
3965 	__vki_u32			target;
3966 	__vki_u32                   flags;
3967 	struct vki_v4l2_rect        r;
3968 	__vki_u32                   reserved[9];
3969 };
3970 
3971 typedef __vki_u64 vki_v4l2_std_id;
3972 
3973 struct vki_v4l2_standard {
3974 	__vki_u32		     index;
3975 	vki_v4l2_std_id          id;
3976 	__vki_u8		     name[24];
3977 	struct vki_v4l2_fract    frameperiod; /* Frames, not fields */
3978 	__vki_u32		     framelines;
3979 	__vki_u32		     reserved[4];
3980 };
3981 
3982 struct vki_v4l2_bt_timings {
3983 	__vki_u32	width;
3984 	__vki_u32	height;
3985 	__vki_u32	interlaced;
3986 	__vki_u32	polarities;
3987 	__vki_u64	pixelclock;
3988 	__vki_u32	hfrontporch;
3989 	__vki_u32	hsync;
3990 	__vki_u32	hbackporch;
3991 	__vki_u32	vfrontporch;
3992 	__vki_u32	vsync;
3993 	__vki_u32	vbackporch;
3994 	__vki_u32	il_vfrontporch;
3995 	__vki_u32	il_vsync;
3996 	__vki_u32	il_vbackporch;
3997 	__vki_u32	standards;
3998 	__vki_u32	flags;
3999 	__vki_u32	reserved[14];
4000 } __attribute__ ((packed));
4001 
4002 struct vki_v4l2_dv_timings {
4003 	__vki_u32 type;
4004 	union {
4005 		struct vki_v4l2_bt_timings	bt;
4006 		__vki_u32	reserved[32];
4007 	};
4008 } __attribute__ ((packed));
4009 
4010 struct vki_v4l2_enum_dv_timings {
4011 	__vki_u32 index;
4012 	__vki_u32 pad;
4013 	__vki_u32 reserved[2];
4014 	struct vki_v4l2_dv_timings timings;
4015 };
4016 
4017 struct vki_v4l2_bt_timings_cap {
4018 	__vki_u32	min_width;
4019 	__vki_u32	max_width;
4020 	__vki_u32	min_height;
4021 	__vki_u32	max_height;
4022 	__vki_u64	min_pixelclock;
4023 	__vki_u64	max_pixelclock;
4024 	__vki_u32	standards;
4025 	__vki_u32	capabilities;
4026 	__vki_u32	reserved[16];
4027 } __attribute__ ((packed));
4028 
4029 struct vki_v4l2_dv_timings_cap {
4030 	__vki_u32 type;
4031 	__vki_u32 pad;
4032 	__vki_u32 reserved[2];
4033 	union {
4034 		struct vki_v4l2_bt_timings_cap bt;
4035 		__vki_u32 raw_data[32];
4036 	};
4037 };
4038 
4039 struct vki_v4l2_input {
4040 	__vki_u32	     index;		/*  Which input */
4041 	__vki_u8	     name[32];		/*  Label */
4042 	__vki_u32	     type;		/*  Type of input */
4043 	__vki_u32	     audioset;		/*  Associated audios (bitfield) */
4044 	__vki_u32        tuner;             /*  enum vki_v4l2_tuner_type */
4045 	vki_v4l2_std_id  std;
4046 	__vki_u32	     status;
4047 	__vki_u32	     capabilities;
4048 	__vki_u32	     reserved[3];
4049 };
4050 
4051 struct vki_v4l2_output {
4052 	__vki_u32	     index;		/*  Which output */
4053 	__vki_u8	     name[32];		/*  Label */
4054 	__vki_u32	     type;		/*  Type of output */
4055 	__vki_u32	     audioset;		/*  Associated audios (bitfield) */
4056 	__vki_u32	     modulator;         /*  Associated modulator */
4057 	vki_v4l2_std_id  std;
4058 	__vki_u32	     capabilities;
4059 	__vki_u32	     reserved[3];
4060 };
4061 
4062 struct vki_v4l2_control {
4063 	__vki_u32		     id;
4064 	__vki_s32		     value;
4065 };
4066 
4067 struct vki_v4l2_ext_control {
4068 	__vki_u32 id;
4069 	__vki_u32 size;
4070 	__vki_u32 reserved2[1];
4071 	union {
4072 		__vki_s32 value;
4073 		__vki_s64 value64;
4074 		char *string;
4075 		__vki_u8 *p_u8;
4076 		__vki_u16 *p_u16;
4077 		__vki_u32 *p_u32;
4078 		void *ptr;
4079 	};
4080 } __attribute__ ((packed));
4081 
4082 struct vki_v4l2_ext_controls {
4083 	__vki_u32 ctrl_class;
4084 	__vki_u32 count;
4085 	__vki_u32 error_idx;
4086 	__vki_u32 reserved[2];
4087 	struct vki_v4l2_ext_control *controls;
4088 };
4089 
4090 struct vki_v4l2_queryctrl {
4091 	__vki_u32		     id;
4092 	__vki_u32		     type;	/* enum vki_v4l2_ctrl_type */
4093 	__vki_u8		     name[32];	/* Whatever */
4094 	__vki_s32		     minimum;	/* Note signedness */
4095 	__vki_s32		     maximum;
4096 	__vki_s32		     step;
4097 	__vki_s32		     default_value;
4098 	__vki_u32                flags;
4099 	__vki_u32		     reserved[2];
4100 };
4101 
4102 #define VKI_V4L2_CTRL_MAX_DIMS	  (4)
4103 struct vki_v4l2_query_ext_ctrl {
4104 	__vki_u32		     id;
4105 	__vki_u32		     type;
4106 	char		     name[32];
4107 	__vki_s64		     minimum;
4108 	__vki_s64		     maximum;
4109 	__vki_u64		     step;
4110 	__vki_s64		     default_value;
4111 	__vki_u32                flags;
4112 	__vki_u32                elem_size;
4113 	__vki_u32                elems;
4114 	__vki_u32                nr_of_dims;
4115 	__vki_u32                dims[VKI_V4L2_CTRL_MAX_DIMS];
4116 	__vki_u32		     reserved[32];
4117 };
4118 
4119 struct vki_v4l2_querymenu {
4120 	__vki_u32		id;
4121 	__vki_u32		index;
4122 	union {
4123 		__vki_u8	name[32];	/* Whatever */
4124 		__vki_s64	value;
4125 	};
4126 	__vki_u32		reserved;
4127 } __attribute__ ((packed));
4128 
4129 struct vki_v4l2_tuner {
4130 	__vki_u32                   index;
4131 	__vki_u8			name[32];
4132 	__vki_u32			type;	/* enum vki_v4l2_tuner_type */
4133 	__vki_u32			capability;
4134 	__vki_u32			rangelow;
4135 	__vki_u32			rangehigh;
4136 	__vki_u32			rxsubchans;
4137 	__vki_u32			audmode;
4138 	__vki_s32			signal;
4139 	__vki_s32			afc;
4140 	__vki_u32			reserved[4];
4141 };
4142 
4143 struct vki_v4l2_modulator {
4144 	__vki_u32			index;
4145 	__vki_u8			name[32];
4146 	__vki_u32			capability;
4147 	__vki_u32			rangelow;
4148 	__vki_u32			rangehigh;
4149 	__vki_u32			txsubchans;
4150 	__vki_u32			reserved[4];
4151 };
4152 
4153 struct vki_v4l2_frequency {
4154 	__vki_u32	tuner;
4155 	__vki_u32	type;	/* enum vki_v4l2_tuner_type */
4156 	__vki_u32	frequency;
4157 	__vki_u32	reserved[8];
4158 };
4159 
4160 struct vki_v4l2_frequency_band {
4161 	__vki_u32	tuner;
4162 	__vki_u32	type;	/* enum vki_v4l2_tuner_type */
4163 	__vki_u32	index;
4164 	__vki_u32	capability;
4165 	__vki_u32	rangelow;
4166 	__vki_u32	rangehigh;
4167 	__vki_u32	modulation;
4168 	__vki_u32	reserved[9];
4169 };
4170 
4171 struct vki_v4l2_hw_freq_seek {
4172 	__vki_u32	tuner;
4173 	__vki_u32	type;	/* enum vki_v4l2_tuner_type */
4174 	__vki_u32	seek_upward;
4175 	__vki_u32	wrap_around;
4176 	__vki_u32	spacing;
4177 	__vki_u32	rangelow;
4178 	__vki_u32	rangehigh;
4179 	__vki_u32	reserved[5];
4180 };
4181 
4182 struct vki_v4l2_audio {
4183 	__vki_u32	index;
4184 	__vki_u8	name[32];
4185 	__vki_u32	capability;
4186 	__vki_u32	mode;
4187 	__vki_u32	reserved[2];
4188 };
4189 
4190 struct vki_v4l2_audioout {
4191 	__vki_u32	index;
4192 	__vki_u8	name[32];
4193 	__vki_u32	capability;
4194 	__vki_u32	mode;
4195 	__vki_u32	reserved[2];
4196 };
4197 
4198 struct vki_v4l2_enc_idx_entry {
4199 	__vki_u64 offset;
4200 	__vki_u64 pts;
4201 	__vki_u32 length;
4202 	__vki_u32 flags;
4203 	__vki_u32 reserved[2];
4204 };
4205 
4206 #define VKI_V4L2_ENC_IDX_ENTRIES (64)
4207 struct vki_v4l2_enc_idx {
4208 	__vki_u32 entries;
4209 	__vki_u32 entries_cap;
4210 	__vki_u32 reserved[4];
4211 	struct vki_v4l2_enc_idx_entry entry[VKI_V4L2_ENC_IDX_ENTRIES];
4212 };
4213 
4214 struct vki_v4l2_encoder_cmd {
4215 	__vki_u32 cmd;
4216 	__vki_u32 flags;
4217 	union {
4218 		struct {
4219 			__vki_u32 data[8];
4220 		} raw;
4221 	};
4222 };
4223 
4224 struct vki_v4l2_decoder_cmd {
4225 	__vki_u32 cmd;
4226 	__vki_u32 flags;
4227 	union {
4228 		struct {
4229 			__vki_u64 pts;
4230 		} stop;
4231 
4232 		struct {
4233 			__vki_s32 speed;
4234 			__vki_u32 format;
4235 		} start;
4236 
4237 		struct {
4238 			__vki_u32 data[16];
4239 		} raw;
4240 	};
4241 };
4242 
4243 struct vki_v4l2_vbi_format {
4244 	__vki_u32	sampling_rate;		/* in 1 Hz */
4245 	__vki_u32	offset;
4246 	__vki_u32	samples_per_line;
4247 	__vki_u32	sample_format;		/* VKI_V4L2_PIX_FMT_* */
4248 	__vki_s32	start[2];
4249 	__vki_u32	count[2];
4250 	__vki_u32	flags;			/* VKI_V4L2_VBI_* */
4251 	__vki_u32	reserved[2];		/* must be zero */
4252 };
4253 
4254 struct vki_v4l2_sliced_vbi_format {
4255 	__vki_u16   service_set;
4256 	__vki_u16   service_lines[2][24];
4257 	__vki_u32   io_size;
4258 	__vki_u32   reserved[2];            /* must be zero */
4259 };
4260 
4261 struct vki_v4l2_sliced_vbi_cap {
4262 	__vki_u16   service_set;
4263 	__vki_u16   service_lines[2][24];
4264 	__vki_u32	type;		/* enum vki_v4l2_buf_type */
4265 	__vki_u32   reserved[3];    /* must be 0 */
4266 };
4267 
4268 struct vki_v4l2_sliced_vbi_data {
4269 	__vki_u32   id;
4270 	__vki_u32   field;          /* 0: first field, 1: second field */
4271 	__vki_u32   line;           /* 1-23 */
4272 	__vki_u32   reserved;       /* must be 0 */
4273 	__vki_u8    data[48];
4274 };
4275 
4276 struct vki_v4l2_plane_pix_format {
4277 	__vki_u32		sizeimage;
4278 	__vki_u32		bytesperline;
4279 	__vki_u16		reserved[6];
4280 } __attribute__ ((packed));
4281 
4282 #define VKI_VIDEO_MAX_PLANES               8
4283 
4284 struct vki_v4l2_pix_format_mplane {
4285 	__vki_u32				width;
4286 	__vki_u32				height;
4287 	__vki_u32				pixelformat;
4288 	__vki_u32				field;
4289 	__vki_u32				colorspace;
4290 
4291 	struct vki_v4l2_plane_pix_format	plane_fmt[VKI_VIDEO_MAX_PLANES];
4292 	__vki_u8				num_planes;
4293 	__vki_u8				flags;
4294 	__vki_u8				ycbcr_enc;
4295 	__vki_u8				quantization;
4296 	__vki_u8				reserved[8];
4297 } __attribute__ ((packed));
4298 
4299 struct vki_v4l2_sdr_format {
4300 	__vki_u32				pixelformat;
4301 	__vki_u32				buffersize;
4302 	__vki_u8				reserved[24];
4303 } __attribute__ ((packed));
4304 
4305 enum vki_v4l2_buf_type {
4306 	VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE        = 1,
4307 	VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT         = 2,
4308 	VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY        = 3,
4309 	VKI_V4L2_BUF_TYPE_VBI_CAPTURE          = 4,
4310 	VKI_V4L2_BUF_TYPE_VBI_OUTPUT           = 5,
4311 	VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE   = 6,
4312 	VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT    = 7,
4313 	VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
4314 	VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
4315 	VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE  = 10,
4316 	VKI_V4L2_BUF_TYPE_SDR_CAPTURE          = 11,
4317 };
4318 
4319 struct vki_v4l2_format {
4320 	__vki_u32	 type;
4321 	union {
4322 		struct vki_v4l2_pix_format		pix;
4323 		struct vki_v4l2_pix_format_mplane	pix_mp;
4324 		struct vki_v4l2_window		win;
4325 		struct vki_v4l2_vbi_format		vbi;
4326 		struct vki_v4l2_sliced_vbi_format	sliced;
4327 		struct vki_v4l2_sdr_format		sdr;
4328 		__vki_u8	raw_data[200];
4329 	} fmt;
4330 };
4331 
4332 struct vki_v4l2_streamparm {
4333 	__vki_u32	 type;
4334 	union {
4335 		struct vki_v4l2_captureparm	capture;
4336 		struct vki_v4l2_outputparm	output;
4337 		__vki_u8	raw_data[200];  /* user-defined */
4338 	} parm;
4339 };
4340 
4341 struct vki_v4l2_event_vsync {
4342 	__vki_u8 field;
4343 } __attribute__ ((packed));
4344 
4345 struct vki_v4l2_event_ctrl {
4346 	__vki_u32 changes;
4347 	__vki_u32 type;
4348 	union {
4349 		__vki_s32 value;
4350 		__vki_s64 value64;
4351 	};
4352 	__vki_u32 flags;
4353 	__vki_s32 minimum;
4354 	__vki_s32 maximum;
4355 	__vki_s32 step;
4356 	__vki_s32 default_value;
4357 };
4358 
4359 struct vki_v4l2_event_frame_sync {
4360 	__vki_u32 frame_sequence;
4361 };
4362 
4363 struct vki_v4l2_event_src_change {
4364 	__vki_u32 changes;
4365 };
4366 
4367 struct vki_v4l2_event_motion_det {
4368 	__vki_u32 flags;
4369 	__vki_u32 frame_sequence;
4370 	__vki_u32 region_mask;
4371 };
4372 
4373 struct vki_v4l2_event {
4374 	__vki_u32				type;
4375 	union {
4376 		struct vki_v4l2_event_vsync		vsync;
4377 		struct vki_v4l2_event_ctrl		ctrl;
4378 		struct vki_v4l2_event_frame_sync	frame_sync;
4379 		struct vki_v4l2_event_src_change	src_change;
4380 		struct vki_v4l2_event_motion_det	motion_det;
4381 		__vki_u8				data[64];
4382 	} u;
4383 	__vki_u32				pending;
4384 	__vki_u32				sequence;
4385 	struct vki_timespec			timestamp;
4386 	__vki_u32				id;
4387 	__vki_u32				reserved[8];
4388 };
4389 
4390 struct vki_v4l2_event_subscription {
4391 	__vki_u32				type;
4392 	__vki_u32				id;
4393 	__vki_u32				flags;
4394 	__vki_u32				reserved[5];
4395 };
4396 
4397 struct vki_v4l2_dbg_match {
4398 	__vki_u32 type; /* Match type */
4399 	union {     /* Match this chip, meaning determined by type */
4400 		__vki_u32 addr;
4401 		char name[32];
4402 	};
4403 } __attribute__ ((packed));
4404 
4405 struct vki_v4l2_dbg_register {
4406 	struct vki_v4l2_dbg_match match;
4407 	__vki_u32 size;	/* register size in bytes */
4408 	__vki_u64 reg;
4409 	__vki_u64 val;
4410 } __attribute__ ((packed));
4411 
4412 struct vki_v4l2_dbg_chip_info {
4413 	struct vki_v4l2_dbg_match match;
4414 	char name[32];
4415 	__vki_u32 flags;
4416 	__vki_u32 reserved[32];
4417 } __attribute__ ((packed));
4418 
4419 struct vki_v4l2_create_buffers {
4420 	__vki_u32			index;
4421 	__vki_u32			count;
4422 	__vki_u32			memory;
4423 	struct vki_v4l2_format	format;
4424 	__vki_u32			reserved[8];
4425 };
4426 
4427 struct vki_v4l2_edid {
4428 	__vki_u32 pad;
4429 	__vki_u32 start_block;
4430 	__vki_u32 blocks;
4431 	__vki_u32 reserved[5];
4432 	__vki_u8  *edid;
4433 };
4434 
4435 #define VKI_V4L2_QUERYCAP		_VKI_IOR('V',  0, struct vki_v4l2_capability)
4436 #define VKI_V4L2_ENUM_FMT		_VKI_IOWR('V',  2, struct vki_v4l2_fmtdesc)
4437 #define VKI_V4L2_G_FMT			_VKI_IOWR('V',  4, struct vki_v4l2_format)
4438 #define VKI_V4L2_S_FMT			_VKI_IOWR('V',  5, struct vki_v4l2_format)
4439 #define VKI_V4L2_REQBUFS		_VKI_IOWR('V',  8, struct vki_v4l2_requestbuffers)
4440 #define VKI_V4L2_QUERYBUF		_VKI_IOWR('V',  9, struct vki_v4l2_buffer)
4441 #define VKI_V4L2_G_FBUF		 	_VKI_IOR('V', 10, struct vki_v4l2_framebuffer)
4442 #define VKI_V4L2_S_FBUF		 	_VKI_IOW('V', 11, struct vki_v4l2_framebuffer)
4443 #define VKI_V4L2_OVERLAY	 	_VKI_IOW('V', 14, int)
4444 #define VKI_V4L2_QBUF			_VKI_IOWR('V', 15, struct vki_v4l2_buffer)
4445 #define VKI_V4L2_EXPBUF			_VKI_IOWR('V', 16, struct vki_v4l2_exportbuffer)
4446 #define VKI_V4L2_DQBUF			_VKI_IOWR('V', 17, struct vki_v4l2_buffer)
4447 #define VKI_V4L2_STREAMON	 	_VKI_IOW('V', 18, int)
4448 #define VKI_V4L2_STREAMOFF	 	_VKI_IOW('V', 19, int)
4449 #define VKI_V4L2_G_PARM			_VKI_IOWR('V', 21, struct vki_v4l2_streamparm)
4450 #define VKI_V4L2_S_PARM			_VKI_IOWR('V', 22, struct vki_v4l2_streamparm)
4451 #define VKI_V4L2_G_STD			_VKI_IOR('V', 23, vki_v4l2_std_id)
4452 #define VKI_V4L2_S_STD			_VKI_IOW('V', 24, vki_v4l2_std_id)
4453 #define VKI_V4L2_ENUMSTD		_VKI_IOWR('V', 25, struct vki_v4l2_standard)
4454 #define VKI_V4L2_ENUMINPUT		_VKI_IOWR('V', 26, struct vki_v4l2_input)
4455 #define VKI_V4L2_G_CTRL			_VKI_IOWR('V', 27, struct vki_v4l2_control)
4456 #define VKI_V4L2_S_CTRL			_VKI_IOWR('V', 28, struct vki_v4l2_control)
4457 #define VKI_V4L2_G_TUNER		_VKI_IOWR('V', 29, struct vki_v4l2_tuner)
4458 #define VKI_V4L2_S_TUNER		_VKI_IOW('V', 30, struct vki_v4l2_tuner)
4459 #define VKI_V4L2_G_AUDIO		_VKI_IOR('V', 33, struct vki_v4l2_audio)
4460 #define VKI_V4L2_S_AUDIO		_VKI_IOW('V', 34, struct vki_v4l2_audio)
4461 #define VKI_V4L2_QUERYCTRL		_VKI_IOWR('V', 36, struct vki_v4l2_queryctrl)
4462 #define VKI_V4L2_QUERYMENU		_VKI_IOWR('V', 37, struct vki_v4l2_querymenu)
4463 #define VKI_V4L2_G_INPUT		_VKI_IOR('V', 38, int)
4464 #define VKI_V4L2_S_INPUT		_VKI_IOWR('V', 39, int)
4465 #define VKI_V4L2_G_EDID			_VKI_IOWR('V', 40, struct vki_v4l2_edid)
4466 #define VKI_V4L2_S_EDID			_VKI_IOWR('V', 41, struct vki_v4l2_edid)
4467 #define VKI_V4L2_G_OUTPUT		_VKI_IOR('V', 46, int)
4468 #define VKI_V4L2_S_OUTPUT		_VKI_IOWR('V', 47, int)
4469 #define VKI_V4L2_ENUMOUTPUT		_VKI_IOWR('V', 48, struct vki_v4l2_output)
4470 #define VKI_V4L2_G_AUDOUT		_VKI_IOR('V', 49, struct vki_v4l2_audioout)
4471 #define VKI_V4L2_S_AUDOUT		_VKI_IOW('V', 50, struct vki_v4l2_audioout)
4472 #define VKI_V4L2_G_MODULATOR		_VKI_IOWR('V', 54, struct vki_v4l2_modulator)
4473 #define VKI_V4L2_S_MODULATOR		_VKI_IOW('V', 55, struct vki_v4l2_modulator)
4474 #define VKI_V4L2_G_FREQUENCY		_VKI_IOWR('V', 56, struct vki_v4l2_frequency)
4475 #define VKI_V4L2_S_FREQUENCY		_VKI_IOW('V', 57, struct vki_v4l2_frequency)
4476 #define VKI_V4L2_CROPCAP		_VKI_IOWR('V', 58, struct vki_v4l2_cropcap)
4477 #define VKI_V4L2_G_CROP			_VKI_IOWR('V', 59, struct vki_v4l2_crop)
4478 #define VKI_V4L2_S_CROP			_VKI_IOW('V', 60, struct vki_v4l2_crop)
4479 #define VKI_V4L2_G_JPEGCOMP		_VKI_IOR('V', 61, struct vki_v4l2_jpegcompression)
4480 #define VKI_V4L2_S_JPEGCOMP		_VKI_IOW('V', 62, struct vki_v4l2_jpegcompression)
4481 #define VKI_V4L2_QUERYSTD      		_VKI_IOR('V', 63, vki_v4l2_std_id)
4482 #define VKI_V4L2_TRY_FMT      		_VKI_IOWR('V', 64, struct vki_v4l2_format)
4483 #define VKI_V4L2_ENUMAUDIO		_VKI_IOWR('V', 65, struct vki_v4l2_audio)
4484 #define VKI_V4L2_ENUMAUDOUT		_VKI_IOWR('V', 66, struct vki_v4l2_audioout)
4485 #define VKI_V4L2_G_PRIORITY		_VKI_IOR('V', 67, __vki_u32)
4486 #define VKI_V4L2_S_PRIORITY		_VKI_IOW('V', 68, __vki_u32)
4487 #define VKI_V4L2_G_SLICED_VBI_CAP 	_VKI_IOWR('V', 69, struct vki_v4l2_sliced_vbi_cap)
4488 #define VKI_V4L2_LOG_STATUS     	_VKI_IO('V', 70)
4489 #define VKI_V4L2_G_EXT_CTRLS		_VKI_IOWR('V', 71, struct vki_v4l2_ext_controls)
4490 #define VKI_V4L2_S_EXT_CTRLS		_VKI_IOWR('V', 72, struct vki_v4l2_ext_controls)
4491 #define VKI_V4L2_TRY_EXT_CTRLS		_VKI_IOWR('V', 73, struct vki_v4l2_ext_controls)
4492 #define VKI_V4L2_ENUM_FRAMESIZES	_VKI_IOWR('V', 74, struct vki_v4l2_frmsizeenum)
4493 #define VKI_V4L2_ENUM_FRAMEINTERVALS 	_VKI_IOWR('V', 75, struct vki_v4l2_frmivalenum)
4494 #define VKI_V4L2_G_ENC_INDEX    	_VKI_IOR('V', 76, struct vki_v4l2_enc_idx)
4495 #define VKI_V4L2_ENCODER_CMD    	_VKI_IOWR('V', 77, struct vki_v4l2_encoder_cmd)
4496 #define VKI_V4L2_TRY_ENCODER_CMD 	_VKI_IOWR('V', 78, struct vki_v4l2_encoder_cmd)
4497 #define	VKI_V4L2_DBG_S_REGISTER 	_VKI_IOW('V', 79, struct vki_v4l2_dbg_register)
4498 #define	VKI_V4L2_DBG_G_REGISTER 	_VKI_IOWR('V', 80, struct vki_v4l2_dbg_register)
4499 #define VKI_V4L2_S_HW_FREQ_SEEK		_VKI_IOW('V', 82, struct vki_v4l2_hw_freq_seek)
4500 #define	VKI_V4L2_S_DV_TIMINGS		_VKI_IOWR('V', 87, struct vki_v4l2_dv_timings)
4501 #define	VKI_V4L2_G_DV_TIMINGS		_VKI_IOWR('V', 88, struct vki_v4l2_dv_timings)
4502 #define	VKI_V4L2_DQEVENT		_VKI_IOR('V', 89, struct vki_v4l2_event)
4503 #define	VKI_V4L2_SUBSCRIBE_EVENT	_VKI_IOW('V', 90, struct vki_v4l2_event_subscription)
4504 #define	VKI_V4L2_UNSUBSCRIBE_EVENT 	_VKI_IOW('V', 91, struct vki_v4l2_event_subscription)
4505 #define VKI_V4L2_CREATE_BUFS		_VKI_IOWR('V', 92, struct vki_v4l2_create_buffers)
4506 #define VKI_V4L2_PREPARE_BUF		_VKI_IOWR('V', 93, struct vki_v4l2_buffer)
4507 #define VKI_V4L2_G_SELECTION		_VKI_IOWR('V', 94, struct vki_v4l2_selection)
4508 #define VKI_V4L2_S_SELECTION		_VKI_IOWR('V', 95, struct vki_v4l2_selection)
4509 #define VKI_V4L2_DECODER_CMD		_VKI_IOWR('V', 96, struct vki_v4l2_decoder_cmd)
4510 #define VKI_V4L2_TRY_DECODER_CMD	_VKI_IOWR('V', 97, struct vki_v4l2_decoder_cmd)
4511 #define VKI_V4L2_ENUM_DV_TIMINGS 	_VKI_IOWR('V', 98, struct vki_v4l2_enum_dv_timings)
4512 #define VKI_V4L2_QUERY_DV_TIMINGS 	_VKI_IOR('V', 99, struct vki_v4l2_dv_timings)
4513 #define VKI_V4L2_DV_TIMINGS_CAP   	_VKI_IOWR('V', 100, struct vki_v4l2_dv_timings_cap)
4514 #define VKI_V4L2_ENUM_FREQ_BANDS	_VKI_IOWR('V', 101, struct vki_v4l2_frequency_band)
4515 #define VKI_V4L2_DBG_G_CHIP_INFO 	_VKI_IOWR('V', 102, struct vki_v4l2_dbg_chip_info)
4516 #define VKI_V4L2_QUERY_EXT_CTRL		_VKI_IOWR('V', 103, struct vki_v4l2_query_ext_ctrl)
4517 
4518 struct vki_v4l2_mbus_framefmt {
4519 	__vki_u32			width;
4520 	__vki_u32			height;
4521 	__vki_u32			code;
4522 	__vki_u32			field;
4523 	__vki_u32			colorspace;
4524 	__vki_u16			ycbcr_enc;
4525 	__vki_u16			quantization;
4526 	__vki_u32			reserved[6];
4527 };
4528 
4529 struct vki_v4l2_subdev_format {
4530 	__vki_u32 which;
4531 	__vki_u32 pad;
4532 	struct vki_v4l2_mbus_framefmt format;
4533 	__vki_u32 reserved[8];
4534 };
4535 
4536 struct vki_v4l2_subdev_crop {
4537 	__vki_u32 which;
4538 	__vki_u32 pad;
4539 	struct vki_v4l2_rect rect;
4540 	__vki_u32 reserved[8];
4541 };
4542 
4543 struct vki_v4l2_subdev_mbus_code_enum {
4544 	__vki_u32 pad;
4545 	__vki_u32 index;
4546 	__vki_u32 code;
4547 	__vki_u32 which;
4548 	__vki_u32 reserved[8];
4549 };
4550 
4551 struct vki_v4l2_subdev_frame_size_enum {
4552 	__vki_u32 index;
4553 	__vki_u32 pad;
4554 	__vki_u32 code;
4555 	__vki_u32 min_width;
4556 	__vki_u32 max_width;
4557 	__vki_u32 min_height;
4558 	__vki_u32 max_height;
4559 	__vki_u32 which;
4560 	__vki_u32 reserved[8];
4561 };
4562 
4563 struct vki_v4l2_subdev_frame_interval {
4564 	__vki_u32 pad;
4565 	struct vki_v4l2_fract interval;
4566 	__vki_u32 reserved[9];
4567 };
4568 
4569 struct vki_v4l2_subdev_frame_interval_enum {
4570 	__vki_u32 index;
4571 	__vki_u32 pad;
4572 	__vki_u32 code;
4573 	__vki_u32 width;
4574 	__vki_u32 height;
4575 	struct vki_v4l2_fract interval;
4576 	__vki_u32 which;
4577 	__vki_u32 reserved[8];
4578 };
4579 
4580 struct vki_v4l2_subdev_selection {
4581 	__vki_u32 which;
4582 	__vki_u32 pad;
4583 	__vki_u32 target;
4584 	__vki_u32 flags;
4585 	struct vki_v4l2_rect r;
4586 	__vki_u32 reserved[8];
4587 };
4588 
4589 #define VKI_V4L2_SUBDEV_G_FMT			_VKI_IOWR('V',  4, struct vki_v4l2_subdev_format)
4590 #define VKI_V4L2_SUBDEV_S_FMT			_VKI_IOWR('V',  5, struct vki_v4l2_subdev_format)
4591 #define VKI_V4L2_SUBDEV_G_FRAME_INTERVAL	_VKI_IOWR('V', 21, struct vki_v4l2_subdev_frame_interval)
4592 #define VKI_V4L2_SUBDEV_S_FRAME_INTERVAL	_VKI_IOWR('V', 22, struct vki_v4l2_subdev_frame_interval)
4593 #define VKI_V4L2_SUBDEV_ENUM_MBUS_CODE		_VKI_IOWR('V',  2, struct vki_v4l2_subdev_mbus_code_enum)
4594 #define VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE		_VKI_IOWR('V', 74, struct vki_v4l2_subdev_frame_size_enum)
4595 #define VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL	_VKI_IOWR('V', 75, struct vki_v4l2_subdev_frame_interval_enum)
4596 #define VKI_V4L2_SUBDEV_G_CROP			_VKI_IOWR('V', 59, struct vki_v4l2_subdev_crop)
4597 #define VKI_V4L2_SUBDEV_S_CROP			_VKI_IOWR('V', 60, struct vki_v4l2_subdev_crop)
4598 #define VKI_V4L2_SUBDEV_G_SELECTION		_VKI_IOWR('V', 61, struct vki_v4l2_subdev_selection)
4599 #define VKI_V4L2_SUBDEV_S_SELECTION		_VKI_IOWR('V', 62, struct vki_v4l2_subdev_selection)
4600 
4601 struct vki_media_device_info {
4602 	char driver[16];
4603 	char model[32];
4604 	char serial[40];
4605 	char bus_info[32];
4606 	__vki_u32 media_version;
4607 	__vki_u32 hw_revision;
4608 	__vki_u32 driver_version;
4609 	__vki_u32 reserved[31];
4610 };
4611 
4612 struct vki_media_entity_desc {
4613 	__vki_u32 id;
4614 	char name[32];
4615 	__vki_u32 type;
4616 	__vki_u32 revision;
4617 	__vki_u32 flags;
4618 	__vki_u32 group_id;
4619 	__vki_u16 pads;
4620 	__vki_u16 links;
4621 
4622 	__vki_u32 reserved[4];
4623 
4624 	union {
4625 		/* Node specifications */
4626 		struct {
4627 			__vki_u32 major;
4628 			__vki_u32 minor;
4629 		} v4l;
4630 		struct {
4631 			__vki_u32 major;
4632 			__vki_u32 minor;
4633 		} fb;
4634 		struct {
4635 			__vki_u32 card;
4636 			__vki_u32 device;
4637 			__vki_u32 subdevice;
4638 		} alsa;
4639 		int dvb;
4640 
4641 		/* Sub-device specifications */
4642 		/* Nothing needed yet */
4643 		__vki_u8 raw[184];
4644 	};
4645 };
4646 
4647 struct vki_media_pad_desc {
4648 	__vki_u32 entity;		/* entity ID */
4649 	__vki_u16 index;		/* pad index */
4650 	__vki_u32 flags;		/* pad flags */
4651 	__vki_u32 reserved[2];
4652 };
4653 
4654 struct vki_media_link_desc {
4655 	struct vki_media_pad_desc source;
4656 	struct vki_media_pad_desc sink;
4657 	__vki_u32 flags;
4658 	__vki_u32 reserved[2];
4659 };
4660 
4661 struct vki_media_links_enum {
4662 	__vki_u32 entity;
4663 	struct vki_media_pad_desc __user *pads;
4664 	struct vki_media_link_desc __user *links;
4665 	__vki_u32 reserved[4];
4666 };
4667 
4668 #define VKI_MEDIA_IOC_DEVICE_INFO		_VKI_IOWR('|', 0x00, struct vki_media_device_info)
4669 #define VKI_MEDIA_IOC_ENUM_ENTITIES		_VKI_IOWR('|', 0x01, struct vki_media_entity_desc)
4670 #define VKI_MEDIA_IOC_ENUM_LINKS		_VKI_IOWR('|', 0x02, struct vki_media_links_enum)
4671 #define VKI_MEDIA_IOC_SETUP_LINK		_VKI_IOWR('|', 0x03, struct vki_media_link_desc)
4672 
4673 /* DVB demux API */
4674 #define	VKI_DMX_STOP	_VKI_IO('o', 42)
4675 
4676 /* Comparison type */
4677 enum vki_kcmp_type {
4678    VKI_KCMP_FILE,
4679    VKI_KCMP_VM,
4680    VKI_KCMP_FILES,
4681    VKI_KCMP_FS,
4682    VKI_KCMP_SIGHAND,
4683    VKI_KCMP_IO,
4684    VKI_KCMP_SYSVSEM,
4685 
4686    VKI_KCMP_TYPES
4687 };
4688 
4689 //----------------------------------------------------------------------
4690 // From linux-3.19-rc5/include/uapi/linux/seccomp.h
4691 //----------------------------------------------------------------------
4692 
4693 #define VKI_SECCOMP_MODE_FILTER 2
4694 
4695 //----------------------------------------------------------------------
4696 // From linux-3.19.3/include/uapi/linux/binfmts.h
4697 //----------------------------------------------------------------------
4698 #define VKI_BINPRM_BUF_SIZE 128
4699 
4700 //----------------------------------------------------------------------
4701 // From linux-3.19.0/include/linux/serial.h
4702 //----------------------------------------------------------------------
4703 
4704 struct vki_serial_struct {
4705 	int	type;
4706 	int	line;
4707 	unsigned int	port;
4708 	int	irq;
4709 	int	flags;
4710 	int	xmit_fifo_size;
4711 	int	custom_divisor;
4712 	int	baud_base;
4713 	unsigned short	close_delay;
4714 	char	io_type;
4715 	char	reserved_char[1];
4716 	int	hub6;
4717 	unsigned short	closing_wait; /* time to wait before closing */
4718 	unsigned short	closing_wait2; /* no longer used... */
4719 	unsigned char	*iomem_base;
4720 	unsigned short	iomem_reg_shift;
4721 	unsigned int	port_high;
4722 	unsigned long	iomap_base;	/* cookie passed into ioremap */
4723 };
4724 
4725 //----------------------------------------------------------------------
4726 // From linux-3.19.0/fs/binfmt_elf.c
4727 //----------------------------------------------------------------------
4728 
4729 #if !defined(VKI_INIT_ARCH_ELF_STATE)
4730    /* This structure is used to preserve architecture specific data during
4731       the loading of an ELF file, throughout the checking of architecture
4732       specific ELF headers & through to the point where the ELF load is
4733       known to be proceeding. This implementation is a dummy for
4734       architectures which require no specific state. */
4735    struct vki_arch_elf_state {
4736    };
4737 
4738 #  define VKI_INIT_ARCH_ELF_STATE { }
4739 
4740 #endif
4741 
4742 //----------------------------------------------------------------------
4743 // From linux-4.0/include/uapi/linux/prctl.h
4744 //----------------------------------------------------------------------
4745 
4746 #define VKI_PR_SET_FP_MODE          45
4747 #define VKI_PR_GET_FP_MODE          46
4748 # define VKI_PR_FP_MODE_FR          (1 << 0)     /* 64b FP registers  */
4749 # define VKI_PR_FP_MODE_FRE         (1 << 1)     /* 32b compatibility */
4750 
4751 #endif // __VKI_LINUX_H
4752 
4753 /*--------------------------------------------------------------------*/
4754 /*--- end                                                          ---*/
4755 /*--------------------------------------------------------------------*/
4756