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