Bug 480052 - WARNING: unhandled amd64-freebsd syscall: 580
[valgrind.git] / include / vki / vki-freebsd.h
blobd19c8de0184dc81b5bc7618b682de36b04118083
2 /*--------------------------------------------------------------------*/
3 /*--- FreeBSD-specific kernel interface. vki-freebsd.h ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2000-2005 Julian Seward
11 jseward@acm.org
12 Copyright (C) 2018-2021 Paul Floyd
13 pjfloyd@wanadoo.fr
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation; either version 2 of the
18 License, or (at your option) any later version.
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, see <http://www.gnu.org/licenses/>.
28 The GNU General Public License is contained in the file COPYING.
31 /* This file defines types and constants for the kernel interface, and to
32 make that clear everything is prefixed VKI_/vki_.
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.
42 The files the code is taken from is indicated.
45 #ifndef VKI_FREEBSD_H
46 #define VKI_FREEBSD_H
48 //----------------------------------------------------------------------
49 // Arch-specific POSIX types
50 //----------------------------------------------------------------------
52 #if defined(VGA_x86)
53 # include "vki-machine-types-x86-freebsd.h"
54 #elif defined(VGA_amd64)
55 # include "vki-machine-types-amd64-freebsd.h"
56 #else
57 # error Unknown platform
58 #endif
60 #include <sys/fcntl.h>
61 #include <sys/param.h>
64 //----------------------------------------------------------------------
65 // From sys/select.h
66 //----------------------------------------------------------------------
68 typedef unsigned long __vki_fd_mask;
70 #undef __VKI_NFDBITS
71 #define __VKI_NFDBITS (8 * sizeof(__vki_fd_mask))
73 #undef __VKI_FD_SETSIZE
74 #define __VKI_FD_SETSIZE 1024U
76 #undef __VKI_FDSET_LONGS
77 #define __VKI_FDSET_LONGS (__VKI_FD_SETSIZE/__VKI_NFDBITS)
79 #undef __VKI_FDELT
80 #define __VKI_FDELT(d) ((d) / __VKI_NFDBITS)
82 #undef __VKI_FDMASK
83 #define __VKI_FDMASK(d) (1UL << ((d) % __VKI_NFDBITS))
85 typedef struct {
86 unsigned long fds_bits [__VKI_FDSET_LONGS];
87 } __vki_fd_set;
89 //----------------------------------------------------------------------
90 // sys/_types.h
91 //----------------------------------------------------------------------
92 /* MD QQQ 32 on 64 */
93 typedef long __vki_key_t;
94 typedef long __vki_suseconds_t;
95 typedef struct __timer *__vki_timer_t;
96 typedef struct __mq *__vki_mqd_t;
98 /* MI */
99 typedef vki_uint32_t __vki_blksize_t;
100 typedef vki_int64_t __vki_blkcnt_t;
101 typedef vki_int32_t __vki_clockid_t;
102 typedef vki_int32_t __vki_ct_rune_t;
103 typedef vki_uint32_t __vki_fflags_t;
104 typedef vki_uint64_t __vki_fsblkcnt_t;
105 typedef vki_uint64_t __vki_fsfilcnt_t;
106 typedef vki_uint32_t __vki_gid_t;
107 typedef vki_int64_t __vki_id_t;
108 typedef vki_uint64_t __vki_ino_t;
109 typedef vki_int32_t __vki_lwpid_t;
110 typedef vki_uint16_t __vki_mode_t;
111 typedef vki_uint64_t __vki_nlink_t;
112 typedef vki_int64_t __vki_off_t;
113 typedef vki_int32_t __vki_pid_t;
114 typedef vki_int64_t __vki_rlim_t;
115 typedef vki_uint8_t __vki_sa_family_t;
116 typedef vki_uint32_t __vki_socklen_t;
117 typedef vki_uint32_t __vki_uid_t;
118 typedef vki_int32_t __vki_useconds_t;
119 typedef __vki_ct_rune_t __vki_rune_t;
120 typedef __vki_ct_rune_t __vki_wchar_t;
121 typedef __vki_ct_rune_t __vki_wint_t;
122 typedef vki_uint64_t __vki_dev_t;
123 typedef vki_uint32_t __vki_fixpt_t;
126 //----------------------------------------------------------------------
127 // sys/types.h
128 //----------------------------------------------------------------------
130 typedef vki_uint8_t vki_u_int8_t;
131 typedef vki_uint16_t vki_u_int16_t;
132 typedef vki_uint32_t vki_u_int32_t;
133 typedef vki_uint64_t vki_u_int64_t;
135 typedef vki_uint64_t vki_u_quad_t;
136 typedef vki_int64_t vki_quad_t;
137 typedef __vki_caddr_t vki_caddr_t;
138 typedef __const __vki_caddr_t vki_c_caddr_t;
139 typedef __volatile __vki_caddr_t vki_v_caddr_t;
141 typedef __vki_blksize_t vki_blksize_t;
142 typedef __vki_blkcnt_t vki_blkcnt_t;
143 typedef __vki_clock_t vki_clock_t;
144 typedef __vki_clockid_t vki_clockid_t;
145 typedef __vki_dev_t vki_dev_t;
146 typedef __vki_fflags_t vki_fflags_t;
147 typedef __vki_fixpt_t vki_fixpt_t;
148 typedef __vki_fsblkcnt_t vki_fsblkcnt_t;
149 typedef __vki_fsfilcnt_t vki_fsfilcnt_t;
150 typedef __vki_gid_t vki_gid_t;
151 typedef vki_uint32_t vki_in_addr_t;
152 typedef vki_uint16_t vki_in_port_t;
153 typedef __vki_id_t vki_id_t;
154 typedef __vki_ino_t vki_ino_t;
155 typedef __vki_key_t vki_key_t;
156 typedef __vki_lwpid_t vki_lwpid_t;
157 typedef __vki_mode_t vki_mode_t;
158 typedef __vki_nlink_t vki_nlink_t;
159 typedef __vki_off_t vki_off_t;
160 typedef __vki_pid_t vki_pid_t;
161 typedef __vki_register_t vki_register_t;
162 typedef __vki_rlim_t vki_rlim_t;
163 typedef __vki_segsz_t vki_segsz_t;
164 typedef __vki_size_t vki_size_t;
165 typedef __vki_ssize_t vki_ssize_t;
166 typedef __vki_suseconds_t vki_suseconds_t;
167 typedef __vki_time_t vki_time_t;
168 typedef __vki_timer_t vki_timer_t;
169 typedef __vki_mqd_t vki_mqd_t;
170 typedef __vki_u_register_t vki_u_register_t;
171 typedef __vki_uid_t vki_uid_t;
172 typedef __vki_useconds_t vki_useconds_t;
173 typedef int vki_cpuwhich_t;
174 typedef int vki_cpulevel_t;
175 typedef int vki_cpusetid_t;
178 typedef __vki_vm_offset_t vki_vm_offset_t;
179 typedef __vki_vm_ooffset_t vki_vm_ooffset_t;
180 typedef __vki_vm_paddr_t vki_vm_paddr_t;
181 typedef __vki_vm_pindex_t vki_vm_pindex_t;
182 typedef __vki_vm_size_t vki_vm_size_t;
184 //----------------------------------------------------------------------
185 // sys/select.h
186 //----------------------------------------------------------------------
188 typedef __vki_fd_set vki_fd_set;
190 //----------------------------------------------------------------------
191 // Now the rest of the arch-specific stuff
192 //----------------------------------------------------------------------
194 #if defined(VGA_x86)
195 # include "vki-x86-freebsd.h"
196 #elif defined(VGA_amd64)
197 # include "vki-amd64-freebsd.h"
198 #else
199 # error Unknown platform
200 #endif
202 //----------------------------------------------------------------------
203 // freebsd version hacks
204 //----------------------------------------------------------------------
205 #ifndef ELFMAG
206 #define ELFMAG "\177ELF" /* magic string */
207 #endif
208 #ifndef SELFMAG
209 #define SELFMAG 4 /* magic string size */
210 #endif
212 // see http://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239669
213 #if !defined(ELF_NOTE_GNU)
214 #define ELF_NOTE_GNU "GNU"
215 #endif
218 #define VKI_ELF_NOTE_ROUNDSIZE 4
221 //----------------------------------------------------------------------
222 // From sys/syslimits.h
223 //----------------------------------------------------------------------
225 #define VKI_PATH_MAX 1024
228 //----------------------------------------------------------------------
229 // From sys/timespec.h
230 //----------------------------------------------------------------------
232 struct vki_timespec {
233 vki_time_t tv_sec; /* seconds */
234 long tv_nsec; /* nanoseconds */
237 struct vki_itimerspec {
238 struct vki_timespec it_interval; /* timer period */
239 struct vki_timespec it_value; /* timer expiration */
242 //----------------------------------------------------------------------
243 // From sys/_time.h
244 //----------------------------------------------------------------------
246 struct vki_timeval {
247 vki_time_t tv_sec; /* seconds */
248 vki_suseconds_t tv_usec; /* microseconds */
251 //----------------------------------------------------------------------
252 // From sys/time.h
253 //----------------------------------------------------------------------
255 #define VKI_CLOCK_REALTIME 0
256 #define VKI_CLOCK_MONOTONIC 1
257 #define VKI_CLOCK_PROCESS_CPUTIME_ID 2
258 #define VKI_CLOCK_THREAD_CPUTIME_ID 3
260 struct vki_timezone {
261 int tz_minuteswest; /* minutes west of Greenwich */
262 int tz_dsttime; /* type of dst correction */
265 struct vki_itimerval {
266 struct vki_timeval it_interval; /* timer interval */
267 struct vki_timeval it_value; /* current value */
270 //----------------------------------------------------------------------
271 // From sys/timex.h
272 //----------------------------------------------------------------------
274 struct vki_ntptimeval {
275 struct vki_timespec time;
276 long maxerror;
277 long esterror;
278 long tai;
279 int time_state;
282 struct vki_timex {
283 unsigned int modes; /* mode selector */
284 long offset; /* time offset (usec) */
285 long freq; /* frequency offset (scaled ppm) */
286 long maxerror; /* maximum error (usec) */
287 long esterror; /* estimated error (usec) */
288 int status; /* clock command/status */
289 long constant; /* pll time constant */
290 long precision; /* clock precision (usec) (read only) */
291 long tolerance; /* clock frequency tolerance (ppm)
292 * (read only)
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) */
304 #define MOD_OFFSET 0x0001 /* time offset */
305 #define MOD_FREQUENCY 0x0002 /* frequency offset */
306 #define MOD_MAXERROR 0x0004 /* maximum time error */
307 #define MOD_ESTERROR 0x0008 /* estimated time error */
308 #define MOD_STATUS 0x0010 /* clock status */
309 #define MOD_TIMECONST 0x0020 /* pll time constant */
310 #define MOD_PPSMAX 0x0040
311 #define MOD_TAI 0x0080
312 #define MOD_MICRO 0x1000
313 #define MOD_NANO 0x2000
314 #define MOD_CLKB 0x4000
315 #define MOD_CLKA 0x8000
317 //----------------------------------------------------------------------
318 // From sys/times.h
319 //----------------------------------------------------------------------
321 struct vki_tms {
322 vki_clock_t tms_utime;
323 vki_clock_t tms_stime;
324 vki_clock_t tms_cutime;
325 vki_clock_t tms_cstime;
328 //----------------------------------------------------------------------
329 // From sys/stat.h
330 //----------------------------------------------------------------------
332 /* QQQ 4.x stat layout */
333 struct vki_freebsd11_stat {
334 vki_uint32_t st_dev;
335 vki_uint32_t st_ino;
336 vki_mode_t st_mode;
337 vki_uint16_t st_nlink;
338 vki_uid_t st_uid;
339 vki_gid_t st_gid;
340 vki_uint32_t st_rdev;
341 #if 0
342 struct vki_timespec st_atimespec;
343 struct vki_timespec st_mtimespec;
344 struct vki_timespec st_ctimespec;
345 #else
346 vki_time_t st_atime;
347 long st_atime_nsec;
348 vki_time_t st_mtime;
349 long st_mtime_nsec;
350 vki_time_t st_ctime;
351 long st_ctime_nsec;
352 #endif
353 vki_off_t st_size;
354 vki_blkcnt_t st_blocks;
355 vki_blksize_t st_blksize;
356 vki_fflags_t st_flags;
357 vki_uint32_t st_gen;
358 vki_int32_t st_lspare;
359 struct vki_timespec st_birthtimespec;
360 unsigned int :
361 (8 / 2) * (16 - (int)sizeof(struct vki_timespec));
362 unsigned int :
363 (8 / 2) * (16 - (int)sizeof(struct vki_timespec));
366 #if defined(VGP_x86_freebsd)
367 #define VKI_STAT_TIME_T_EXT 1
368 #endif
371 * FreeBSD 12 has two versions of the stat struct
372 * freebsd11_stat, which is the same as vki_stat above
373 * and just stat, which is the same as vki_stat below
374 * Since vki_stat is used by other OSes, it's best not to
375 * use the same naming
378 struct vki_stat {
379 vki_dev_t st_dev;
380 vki_ino_t st_ino;
381 vki_nlink_t st_nlink;
382 vki_mode_t st_mode;
383 vki_int16_t st_padding0;
384 vki_uid_t st_uid;
385 vki_gid_t st_gid;
386 vki_int32_t st_padding1;
387 vki_dev_t st_rdev;
388 #ifdef VKI_STAT_TIME_T_EXT
389 vki_int32_t st_atim_ext;
390 #endif
391 //struct vki_timespec st_atim;
392 vki_time_t st_atime;
393 long st_atime_nsec;
394 #ifdef VKI_STAT_TIME_T_EXT
395 vki_int32_t st_mtim_ext;
396 #endif
397 //struct vki_timespec st_mtim;
398 vki_time_t st_mtime;
399 long st_mtime_nsec;
400 #ifdef VKI_STAT_TIME_T_EXT
401 vki_int32_t st_ctim_ext;
402 #endif
403 //struct vki_timespec st_ctim;
404 vki_time_t st_ctime;
405 long st_ctime_nsec;
406 #ifdef VKI_STAT_TIME_T_EXT
407 vki_int32_t st_btim_ext;
408 #endif
409 //struct vki_timespec st_birthtim;
410 vki_time_t st_btime;
411 long st_btime_nsec;
412 vki_off_t st_size;
413 vki_blkcnt_t st_blocks;
414 vki_blksize_t st_blksize;
415 vki_fflags_t st_flags;
416 vki_uint64_t st_gen;
417 vki_uint64_t st_spare[10];
422 //----------------------------------------------------------------------
423 // From linux-2.6.8.1/include/linux/sched.h
424 //----------------------------------------------------------------------
426 struct vki_sched_param {
427 int sched_priority;
430 //----------------------------------------------------------------------
431 // From sys/signal.h
432 //----------------------------------------------------------------------
434 #define VKI_SIG_BLOCK 1 /* block specified signal set */
435 #define VKI_SIG_UNBLOCK 2 /* unblock specified signal set */
436 #define VKI_SIG_SETMASK 3 /* set specified signal set */
438 #define VKI_SIG_DFL ((__vki_sighandler_t)0)
439 #define VKI_SIG_IGN ((__vki_sighandler_t)1)
440 #define VKI_SIG_ERR ((__vki_sighandler_t)-1)
442 typedef void __vki_signalfn_t(int);
443 typedef __vki_signalfn_t *__vki_sighandler_t;
445 #define VKI_SIGHUP 1
446 #define VKI_SIGINT 2
447 #define VKI_SIGQUIT 3
448 #define VKI_SIGILL 4
449 #define VKI_SIGTRAP 5
450 #define VKI_SIGABRT 6
451 #define VKI_SIGEMT 7
452 #define VKI_SIGFPE 8
453 #define VKI_SIGKILL 9
454 #define VKI_SIGBUS 10
455 #define VKI_SIGSEGV 11
456 #define VKI_SIGSYS 12
457 #define VKI_SIGPIPE 13
458 #define VKI_SIGALRM 14
459 #define VKI_SIGTERM 15
460 #define VKI_SIGURG 16
461 #define VKI_SIGSTOP 17
462 #define VKI_SIGTSTP 18
463 #define VKI_SIGCONT 19
464 #define VKI_SIGCHLD 20
465 #define VKI_SIGTTIN 21
466 #define VKI_SIGTTOU 22
467 #define VKI_SIGIO 23
468 #define VKI_SIGXCPU 24
469 #define VKI_SIGXFSZ 25
470 #define VKI_SIGVTALRM 26
471 #define VKI_SIGPROF 27
472 #define VKI_SIGWINCH 28
473 #define VKI_SIGINFO 29
474 #define VKI_SIGUSR1 30
475 #define VKI_SIGUSR2 31
476 #define VKI_SIGTHR 32
477 #define VKI_SIGLIBRT 33
479 #define VKI_SIGRTMIN 65
480 #define VKI_SIGRTMAX 126
482 #define VKI_SA_ONSTACK 0x0001
483 #define VKI_SA_RESTART 0x0002
484 #define VKI_SA_RESETHAND 0x0004
485 #define VKI_SA_NOCLDSTOP 0x0008
486 #define VKI_SA_NODEFER 0x0010
487 #define VKI_SA_NOCLDWAIT 0x0020
488 #define VKI_SA_SIGINFO 0x0040
489 #define VKI_SA_RESTORER 0 /* FreeBSD doesn't have this */
491 #define VKI_SS_ONSTACK 0x0001
492 #define VKI_SS_DISABLE 0x0004
494 #define VKI_SA_ONESHOT VKI_SA_RESETHAND
495 #define VKI_SA_NOMASK VKI_SA_NODEFER
497 struct vki_sigaction {
498 __vki_sighandler_t ksa_handler;
499 int sa_flags;
500 vki_sigset_t sa_mask;
503 typedef struct vki_sigaltstack {
504 void *ss_sp;
505 vki_size_t ss_size;
506 int ss_flags;
507 } vki_stack_t;
509 typedef union vki_sigval {
510 int sival_int;
511 void *sival_ptr;
512 } vki_sigval_t;
514 typedef struct vki_siginfo {
515 int si_signo;
516 int si_errno;
517 int si_code;
518 vki_pid_t si_pid;
519 vki_uid_t si_uid;
520 int si_status;
521 void *si_addr;
522 vki_sigval_t si_value;
523 // 666: not valid. switch to above def
524 #ifdef si_band
525 #undef si_band
526 #endif
527 long si_band;
528 int __spare__[7];
529 } vki_siginfo_t;
532 * si_code values
534 #define VKI_SI_USER 0x10001 /* sent by kill, sigsend, raise */
535 #define VKI_SI_QUEUE 0x10002
536 #define VKI_SI_TIMER 0x10003
537 #define VKI_SI_ASYNCIO 0x10004
538 #define VKI_SI_MESGQ 0x10005
539 #define VKI_SI_KERNEL 0x10006
540 #define VKI_SI_LWP 0x10007
542 * SIGILL si_codes
544 #define VKI_ILL_ILLOPC 1 /* illegal opcode */
545 #define VKI_ILL_ILLOPN 2 /* illegal operand */
546 #define VKI_ILL_ILLADR 3 /* illegal addressing mode */
547 #define VKI_ILL_ILLTRP 4 /* illegal trap */
548 #define VKI_ILL_PRVOPC 5 /* privileged opcode */
549 #define VKI_ILL_PRVREG 6 /* privileged register */
550 #define VKI_ILL_COPROC 7 /* coprocessor error */
551 #define VKI_ILL_BADSTK 8 /* internal stack error */
554 * SIGFPE si_codes
556 #define VKI_FPE_INTOVF 1 /* integer overflow */
557 #define VKI_FPE_INTDIV 2 /* integer divide by zero */
558 #define VKI_FPE_FLTDIV 3 /* floating point divide by zero */
559 #define VKI_FPE_FLTOVF 4 /* floating point overflow */
560 #define VKI_FPE_FLTUND 5 /* floating point underflow */
561 #define VKI_FPE_FLTRES 6 /* floating point inexact result */
562 #define VKI_FPE_FLTINV 7 /* floating point invalid operation */
563 #define VKI_FPE_FLTSUB 8 /* subscript out of range */
566 * SIGSEGV si_codes
568 #define VKI_SEGV_MAPERR 1 /* address not mapped to object */
569 #define VKI_SEGV_ACCERR 2 /* invalid permissions for mapped object */
570 /* XXX i386 and amd64 specific */
571 #define VKI_SEGV_PAGE_FAULT 12
574 * SIGBUS si_codes
576 #define VKI_BUS_ADRALN 1 /* invalid address alignment */
577 #define VKI_BUS_ADRERR 2 /* non-existant physical address */
578 #define VKI_BUS_OBJERR 3 /* object specific hardware error */
579 #define VKI_BUS_OOMERR 100 /* Non-standard: No memory. */
582 * SIGTRAP si_codes
584 #define VKI_TRAP_BRKPT 1 /* process breakpoint */
585 #define VKI_TRAP_TRACE 2 /* process trace trap */
586 #define VKI_TRAP_DTRACE 3 /* DTrace induced trap. */
587 #define VKI_TRAP_CAP 4 /* Capabilities protective trap. */
590 * SIGCHLD si_codes
592 #define VKI_CLD_EXITED 1 /* child has exited */
593 #define VKI_CLD_KILLED 2 /* child was killed */
594 #define VKI_CLD_DUMPED 3 /* child terminated abnormally */
595 #define VKI_CLD_TRAPPED 4 /* traced child has trapped */
596 #define VKI_CLD_STOPPED 5 /* child has stopped */
597 #define VKI_CLD_CONTINUED 6 /* stopped child has continued */
599 #if 0 /* freebsd-6 */
600 typedef struct vki_sigevent {
601 int sigev_notify;
602 int sigev_signo;
603 vki_sigval_t sigev_value;
604 union {
605 int _threadid;
607 struct {
608 void (*_function)(vki_sigval_t);
609 void *_attribute; /* really pthread_attr_t */
610 } _sigev_thread;
611 long __spare__[8];
612 } _sigev_un;
613 } vki_sigevent_t;
614 #endif
616 struct vki_sigevent {
617 int sigev_notify; /* Notification type */
618 union {
619 int __sigev_signo; /* Signal number */
620 int __sigev_notify_kqueue;
621 } __sigev_u;
622 vki_sigval_t sigev_value; /* Signal value */
624 #if 0
625 #define sigev_signo __sigev_u.__sigev_signo
626 #define sigev_notify_kqueue __sigev_u.__sigev_notify_kqueue
627 #endif
629 //----------------------------------------------------------------------
630 // From sys/_iovec.h
631 //----------------------------------------------------------------------
633 struct vki_iovec {
634 void *iov_base;
635 __vki_size_t iov_len;
638 //----------------------------------------------------------------------
639 // From sys/socket.h
640 //----------------------------------------------------------------------
642 typedef __vki_sa_family_t vki_sa_family_t;
643 typedef __vki_socklen_t vki_socklen_t;
645 struct vki_sockaddr {
646 vki_uint8_t sa_len;
647 vki_sa_family_t sa_family; /* address family, AF_xxx */
648 char sa_data[14]; /* 14 bytes of protocol address */
651 struct vki_msghdr {
652 void * msg_name; /* Socket name */
653 vki_socklen_t msg_namelen; /* Length of name */
654 struct vki_iovec * msg_iov; /* Data blocks */
655 int msg_iovlen; /* Number of blocks */
656 void * msg_control; /* Per protocol magic (eg BSD file descriptor passing) */
657 vki_socklen_t msg_controllen; /* Length of cmsg list */
658 int msg_flags;
661 struct vki_cmsghdr {
662 vki_socklen_t cmsg_len; /* data byte count, including hdr */
663 int cmsg_level; /* originating protocol */
664 int cmsg_type; /* protocol-specific type */
667 #define __VKI_CMSG_NXTHDR(ctl, len, cmsg) __vki_cmsg_nxthdr((ctl),(len),(cmsg))
668 #define VKI_CMSG_NXTHDR(mhdr, cmsg) vki_cmsg_nxthdr((mhdr), (cmsg))
670 #define VKI_CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
672 #define VKI_CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr))))
674 #define __VKI_CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct vki_cmsghdr) ? \
675 (struct vki_cmsghdr *)(ctl) : \
676 (struct vki_cmsghdr *)NULL)
677 #define VKI_CMSG_FIRSTHDR(msg) __VKI_CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
679 // [[Urgh, this is revolting...]
680 // QQQ check
681 static __inline struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, vki_socklen_t __size,
682 struct vki_cmsghdr *__cmsg)
684 struct vki_cmsghdr * __ptr;
686 __ptr = (struct vki_cmsghdr*)(((unsigned char *) __cmsg) + VKI_CMSG_ALIGN(__cmsg->cmsg_len));
687 if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
688 return (struct vki_cmsghdr *)0;
690 return __ptr;
693 static __inline struct vki_cmsghdr * vki_cmsg_nxthdr (struct vki_msghdr *__msg, struct vki_cmsghdr *__cmsg)
695 return __vki_cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
698 #define VKI_SCM_RIGHTS 0x01 /* rw: access rights (array of int) */
700 #define VKI_AF_UNIX 1 /* Unix domain sockets */
701 #define VKI_AF_INET 2 /* Internet IP Protocol */
702 #define VKI_AF_INET6 28 /* IP version 6 */
704 #define VKI_MSG_NOSIGNAL 0x20000 /* Do not generate SIGPIPE */
706 #define VKI_SOL_SOCKET 0xffff
708 #define VKI_SO_TYPE 0x1008
710 #define VKI_SOCK_STREAM 1
712 #include <netinet/tcp.h>
714 #define VKI_TCP_NODELAY TCP_NODELAY
716 #include <netinet/in.h>
718 #define VKI_IPPROTO_TCP IPPROTO_TCP
720 struct vki_sf_hdtr {
721 struct iovec *headers;
722 int hdr_cnt;
723 struct iovec *trailers;
724 int trl_cnt;
728 //----------------------------------------------------------------------
729 // From netinet/in.h
730 //----------------------------------------------------------------------
732 struct vki_in_addr {
733 vki_in_addr_t s_addr;
736 /* Structure describing an Internet (IP) socket address. */
737 #define __VKI_SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
738 struct vki_sockaddr_in {
739 vki_uint8_t sin_len;
740 vki_sa_family_t sin_family; /* Address family */
741 vki_in_port_t sin_port; /* Port number */
742 struct vki_in_addr sin_addr; /* Internet address */
743 char sin_zero[8];
746 //----------------------------------------------------------------------
747 // From netinet6/in6.h
748 //----------------------------------------------------------------------
750 struct vki_in6_addr {
751 union {
752 vki_uint8_t u6_addr8[16];
753 vki_uint16_t u6_addr16[8];
754 vki_uint32_t u6_addr32[4];
755 } vki_in6_u;
756 #define vki_s6_addr vki_in6_u.u6_addr8
757 #define vki_s6_addr16 vki_in6_u.u6_addr16
758 #define vki_s6_addr32 vki_in6_u.u6_addr32
761 struct vki_sockaddr_in6 {
762 vki_uint8_t sin6_len;
763 vki_sa_family_t sin6_family; /* AF_INET6 */
764 vki_uint16_t sin6_port; /* Transport layer port # */
765 vki_uint32_t sin6_flowinfo; /* IPv6 flow information */
766 struct vki_in6_addr sin6_addr; /* IPv6 address */
767 vki_uint32_t sin6_scope_id; /* scope id (new in RFC2553) */
770 //----------------------------------------------------------------------
771 // From netinet/sctp_uio.h
772 //----------------------------------------------------------------------
773 #define VKI_SCTP_ALIGN_RESV_PAD 92
775 typedef vki_uint32_t vki_sctp_assoc_t;
777 struct vki_sctp_sndrcvinfo {
778 vki_uint16_t sinfo_stream;
779 vki_uint16_t sinfo_ssn;
780 vki_uint16_t sinfo_flags;
781 vki_uint32_t sinfo_ppid;
782 vki_uint32_t sinfo_context;
783 vki_uint32_t sinfo_timetolive;
784 vki_uint32_t sinfo_tsn;
785 vki_uint32_t sinfo_cumtsn;
786 vki_sctp_assoc_t sinfo_assoc_id;
787 vki_uint16_t sinfo_keynumber;
788 vki_uint16_t sinfo_keynumber_valid;
789 vki_uint8_t __reserve_pad[VKI_SCTP_ALIGN_RESV_PAD];
792 //----------------------------------------------------------------------
793 // From sys/un.h
794 //----------------------------------------------------------------------
796 #define VKI_UNIX_PATH_MAX 104 /* QQQ overridden by sun_len */
798 struct vki_sockaddr_un {
799 unsigned char sun_len;
800 vki_sa_family_t sun_family; /* AF_UNIX */
801 char sun_path[VKI_UNIX_PATH_MAX]; /* pathname */
804 //----------------------------------------------------------------------
805 // From aio.h
806 //----------------------------------------------------------------------
808 struct vki___aiocb_private {
809 long status;
810 long error;
811 void *kernelinfo;
814 typedef struct vki_aiocb {
815 int aio_fildes;
816 vki_off_t aio_offset;
817 volatile void *aio_buf;
818 vki_size_t aio_nbytes;
819 int __spare__[2];
820 void *__spare2__;
821 int aio_lio_opcode;
822 int aio_reqprio;
823 struct vki___aiocb_private _aiocb_private;
824 struct vki_sigevent aio_sigevent;
825 } aiocb_t;
827 #define VKI_LIO_NOP 0x0
828 #define VKI_LIO_WRITE 0x1
829 #define VKI_LIO_READ 0x2
831 #define VKI_LIO_NOWAIT 0x0
832 #define VKI_LIO_WAIT 0x1
835 #define VKI_LIO_NOWAIT 0x0
837 //----------------------------------------------------------------------
838 // From sys/mount.h
839 //----------------------------------------------------------------------
841 typedef struct vki_fsid {
842 vki_int32_t val[2];
843 } vki_fsid_t;
844 #define VKI_OMFSNAMELEN 16
845 #define VKI_OMNAMELEN (88 - 2 * sizeof(long))
846 #define VKI_MFSNAMELEN 16
847 #define VKI_FREEBSD11_MNAMELEN 88
849 struct vki_freebsd11_statfs {
850 vki_uint32_t f_version;
851 vki_uint32_t f_type;
852 vki_uint64_t f_flags;
853 vki_uint64_t f_bsize;
854 vki_uint64_t f_iosize;
855 vki_uint64_t f_blocks;
856 vki_uint64_t f_bfree;
857 vki_int64_t f_bavail;
858 vki_uint64_t f_files;
859 vki_int64_t f_ffree;
860 vki_uint64_t f_syncwrites;
861 vki_uint64_t f_asyncwrites;
862 vki_uint64_t f_syncreads;
863 vki_uint64_t f_asyncreads;
864 vki_uint64_t f_spare[10];
865 vki_uint32_t f_namemax;
866 vki_uid_t f_owner;
867 vki_fsid_t f_fsid;
868 char f_charspare[80];
869 char f_fstypename[VKI_OMFSNAMELEN];
870 char f_mntfromname[VKI_FREEBSD11_MNAMELEN];
871 char f_mntonname[VKI_FREEBSD11_MNAMELEN];
875 #define MAXFIDSZ 16
877 struct vki_fid {
878 vki_uint16_t fid_len;
879 vki_uint16_t fid_reserved;
880 char fid_data[MAXFIDSZ];
883 struct vki_fhandle {
884 vki_fsid_t fh_fsid;
885 struct vki_fid fh_fid;
889 #define VKI_MNAMELEN 1024
890 struct vki_statfs {
891 vki_uint32_t f_version;
892 vki_uint32_t f_type;
893 vki_uint64_t f_flags;
894 vki_uint64_t f_bsize;
895 vki_uint64_t f_iosize;
896 vki_uint64_t f_blocks;
897 vki_uint64_t f_bfree;
898 vki_int64_t f_bavail;
899 vki_uint64_t f_files;
900 vki_int64_t f_ffree;
901 vki_uint64_t f_syncwrites;
902 vki_uint64_t f_asyncwrites;
903 vki_uint64_t f_syncreads;
904 vki_uint64_t f_asyncreads;
905 vki_uint64_t f_spare[10];
906 vki_uint32_t f_namemax;
907 vki_uid_t f_owner;
908 vki_fsid_t f_fsid;
909 char f_charspare[80];
910 char f_fstypename[VKI_MFSNAMELEN];
911 char f_mntfromname[VKI_MNAMELEN];
912 char f_mntonname[VKI_MNAMELEN];
915 typedef struct vki_fhandle vki_fhandle_t;
917 //----------------------------------------------------------------------
918 // From sys/ttycom.h
919 //----------------------------------------------------------------------
921 struct vki_winsize {
922 unsigned short ws_row;
923 unsigned short ws_col;
924 unsigned short ws_xpixel;
925 unsigned short ws_ypixel;
929 //----------------------------------------------------------------------
930 // From sys/termios.h
931 //----------------------------------------------------------------------
933 typedef unsigned int vki_tcflag_t;
934 typedef unsigned char vki_cc_t;
935 typedef unsigned int vki_speed_t;
937 #define VKI_NCCS 20
938 struct vki_termios {
939 vki_tcflag_t c_iflag; /* input mode flags */
940 vki_tcflag_t c_oflag; /* output mode flags */
941 vki_tcflag_t c_cflag; /* control mode flags */
942 vki_tcflag_t c_lflag; /* local mode flags */
943 vki_cc_t c_cc[VKI_NCCS]; /* control characters */
944 vki_speed_t c_ispeed;
945 vki_speed_t c_ospeed;
948 //----------------------------------------------------------------------
949 // From sys/ioccom.h
950 //----------------------------------------------------------------------
952 /* QQQ keep linux's naming, but use our layout */
955 * We actually have a 16 bit "base" ioctl, which may or may not be decoded
956 * into number/group
958 #define _VKI_IOC_BASEBITS 16U
959 #define _VKI_IOC_NRBITS 8U /* "num" on freebsd */
960 #define _VKI_IOC_TYPEBITS 8U /* "group" on freebsd */
962 #define _VKI_IOC_SIZEBITS 13U
963 #define _VKI_IOC_DIRBITS 3U
965 #define _VKI_IOC_BASEMASK ((1ul << _VKI_IOC_BASEBITS)-1)
966 #define _VKI_IOC_NRMASK ((1ul << _VKI_IOC_NRBITS)-1)
967 #define _VKI_IOC_TYPEMASK ((1ul << _VKI_IOC_TYPEBITS)-1)
968 #define _VKI_IOC_SIZEMASK ((1ul << _VKI_IOC_SIZEBITS)-1)
969 #define _VKI_IOC_DIRMASK ((1ul << _VKI_IOC_DIRBITS)-1)
971 #define _VKI_IOC_BASESHIFT 0U
972 #define _VKI_IOC_NRSHIFT 0U
973 #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
974 #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
975 #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
977 #define _VKI_IOC_NONE 1U /* "void" on freebsd, as a specific mode */
978 #define _VKI_IOC_READ 2U /* "out", copyout in reversed linux terminology */
979 #define _VKI_IOC_WRITE 4U /* "in", copyin in reversed linux terminology */
980 #define _VKI_IOC_RDWR 6U /* "inout", copyin and copyout */
982 #define _VKI_IOC(dir,type,nr,size) \
983 (((dir) << _VKI_IOC_DIRSHIFT) | \
984 ((type) << _VKI_IOC_TYPESHIFT) | \
985 ((nr) << _VKI_IOC_NRSHIFT) | \
986 ((size) << _VKI_IOC_SIZESHIFT))
988 /* provoke compile error for invalid uses of size argument */
989 extern unsigned int __vki_invalid_size_argument_for_IOC;
990 #define _VKI_IOC_TYPECHECK(t) \
991 ((sizeof(t) == sizeof(t[1]) && \
992 sizeof(t) < (1 << _VKI_IOC_SIZEBITS)) ? \
993 sizeof(t) : __vki_invalid_size_argument_for_IOC)
995 /* used to create numbers */
996 #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
997 #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
998 #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
999 #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),(_VKI_IOC_TYPECHECK(size)))
1001 /* used to decode ioctl numbers.. */
1002 #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
1003 #define _VKI_IOC_TYPE(nr) (((nr) >> _VKI_IOC_TYPESHIFT) & _VKI_IOC_TYPEMASK)
1004 #define _VKI_IOC_NR(nr) (((nr) >> _VKI_IOC_NRSHIFT) & _VKI_IOC_NRMASK)
1005 #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
1006 #define _VKI_IOC_BASE(nr) (((nr) >> _VKI_IOC_BASESHIFT) & _VKI_IOC_BASEMASK)
1008 //----------------------------------------------------------------------
1009 // From sys/random.h
1010 //----------------------------------------------------------------------
1012 #define VKI_GRND_NONBLOCK 0x1U
1014 //----------------------------------------------------------------------
1015 // From sys/termios.h
1016 //----------------------------------------------------------------------
1018 #if 0
1019 #define VKI_TCGETS 0x5401
1020 #define VKI_TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */
1021 #define VKI_TCSETSW 0x5403
1022 #define VKI_TCSETSF 0x5404
1023 #define VKI_TCGETA 0x5405 y
1024 #define VKI_TCSETA 0x5406 y
1025 #define VKI_TCSETAW 0x5407 y
1026 #define VKI_TCSETAF 0x5408 y
1027 #define VKI_TCSBRK 0x5409
1028 #define VKI_TCXONC 0x540A
1029 #define VKI_TCFLSH 0x540B y
1030 #define VKI_TIOCSCTTY 0x540E
1031 #define VKI_TIOCGPGRP 0x540F y
1032 #define VKI_TIOCSPGRP 0x5410 y
1033 #define VKI_TIOCOUTQ 0x5411
1034 #define VKI_TIOCGWINSZ 0x5413 y
1035 #define VKI_TIOCSWINSZ 0x5414 y
1036 #define VKI_TIOCMGET 0x5415 y
1037 #define VKI_TIOCMBIS 0x5416 y
1038 #define VKI_TIOCMBIC 0x5417 y
1039 #define VKI_TIOCMSET 0x5418 y
1040 #define VKI_FIONREAD 0x541B
1041 #define VKI_TIOCLINUX 0x541C
1042 #define VKI_FIONBIO 0x5421
1043 #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
1044 #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
1045 #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */
1047 #define VKI_FIOASYNC 0x5452
1048 #define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */
1050 #define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
1051 #endif
1053 #define VKI_TIOCFLUSH _VKI_IOW('t', 16, int);
1054 #define VKI_TIOCGETA _VKI_IOR('t', 19, struct vki_termios) /* get termios */
1055 #define VKI_TIOCSETA _VKI_IOR('t', 20, struct vki_termios) /* set termios */
1056 #define VKI_TIOCSETAW _VKI_IOR('t', 21, struct vki_termios) /* drain,set */
1057 #define VKI_TIOCSETAF _VKI_IOR('t', 22, struct vki_termios) /* flush,set */
1059 #define _VKI_TIOCPTMASTER _VKI_IO('t', 28) /* pts master validation */
1061 #define VKI_TIOCSWINSZ _VKI_IOW('t', 103, struct vki_winsize) /* set window size */
1062 #define VKI_TIOCGWINSZ _VKI_IOR('t', 104, struct vki_winsize) /* get window size */
1064 #define VKI_TIOCMGET _VKI_IOR('t', 106, int) /* get all modem bits */
1065 #define VKI_TIOCMBIC _VKI_IOW('t', 107, int) /* bic modem bits */
1066 #define VKI_TIOCMBIS _VKI_IOW('t', 108, int) /* bis modem bits */
1067 #define VKI_TIOCMSET _VKI_IOW('t', 109, int) /* set all modem bits */
1068 #define VKI_TIOCSTART _VKI_IO('t', 110) /* start output, like ^Q */
1069 #define VKI_TIOCSTOP _VKI_IO('t', 111) /* stop output, like ^S */
1070 #define VKI_TIOCPKT _VKI_IOW('t', 112, int) /* pty: set/clear packet mode */
1072 #define VKI_TIOCSPGRP _VKI_IOW('t', 118, int) /* set pgrp */
1073 #define VKI_TIOCGPGRP _VKI_IOR('t', 119, int) /* get pgrp */
1074 #define VKI_TIOCCBRK _VKI_IO('t', 122)
1075 #define VKI_TIOCSBRK _VKI_IO('t', 123)
1078 //----------------------------------------------------------------------
1079 // From sys/filio.h
1080 //----------------------------------------------------------------------
1082 #define VKI_FIOCLEX _VKI_IO('f', 1) /* close on exec */
1083 #define VKI_FIONCLEX _VKI_IO('f', 2) /* no close on exec */
1084 #define VKI_FIONREAD _VKI_IOR('f', 127, int)
1085 #define VKI_FIONBIO _VKI_IOW('f', 126, int)
1086 #define VKI_FIOASYNC _VKI_IOW('f', 125, int)
1087 #define VKI_FIOSETOWN _VKI_IOW('f', 124, int)
1088 #define VKI_FIOGETOWN _VKI_IOW('f', 123, int)
1090 // See syswrap-freebsd.c PRE/POST(sys_ioctl)
1091 #if 0
1092 //----------------------------------------------------------------------
1093 // From net/if.h
1094 //----------------------------------------------------------------------
1095 #define VKI_IFNAMSIZ 16
1097 struct vki_ifmediareq {
1098 char ifm_name[VKI_IFNAMSIZ];
1099 int ifm_current;
1100 int ifm_mask;
1101 int ifm_status;
1102 int ifm_active;
1103 int ifm_count;
1104 int *ifm_ulist;
1108 //----------------------------------------------------------------------
1109 // From sys/sockio.h
1110 //----------------------------------------------------------------------
1111 #define VKI_SIOCGIFMEDIA _VKI_IOWR('i', 56, struct vki_ifmediareq)
1112 #endif
1114 //----------------------------------------------------------------------
1115 // From sys/poll.h
1116 //----------------------------------------------------------------------
1118 #define VKI_POLLIN 0x0001
1120 struct vki_pollfd {
1121 int fd;
1122 short events;
1123 short revents;
1126 //----------------------------------------------------------------------
1127 // From sys/event.h
1128 //----------------------------------------------------------------------
1129 struct vki_kevent_freebsd11 {
1130 vki_uintptr_t ident;
1131 vki_int16_t filter;
1132 vki_uint16_t flags;
1133 vki_uint32_t fflags;
1134 vki_intptr_t data;
1135 void *udata;
1138 struct vki_kevent {
1139 vki_uintptr_t ident;
1140 vki_int16_t filter;
1141 vki_uint16_t flags;
1142 vki_uint32_t fflags;
1143 vki_int64_t data;
1144 void *udata;
1145 vki_uint64_t ext[4];
1149 // QQQ sort
1151 //----------------------------------------------------------------------
1152 // From sys/resource.h
1153 //----------------------------------------------------------------------
1155 #define VKI_RUSAGE_SELF 0
1156 #define VKI_RUSAGE_CHILDREN -1
1157 #define VKI_RUSAGE_THREAD 1
1159 struct vki_rusage {
1160 struct vki_timeval ru_utime; /* user time used */
1161 struct vki_timeval ru_stime; /* system time used */
1162 long ru_maxrss; /* maximum resident set size */
1163 long ru_ixrss; /* integral shared memory size */
1164 long ru_idrss; /* integral unshared data size */
1165 long ru_isrss; /* integral unshared stack size */
1166 long ru_minflt; /* page reclaims */
1167 long ru_majflt; /* page faults */
1168 long ru_nswap; /* swaps */
1169 long ru_inblock; /* block input operations */
1170 long ru_oublock; /* block output operations */
1171 long ru_msgsnd; /* messages sent */
1172 long ru_msgrcv; /* messages received */
1173 long ru_nsignals; /* signals received */
1174 long ru_nvcsw; /* voluntary context switches */
1175 long ru_nivcsw; /* involuntary " */
1178 struct vki_rlimit {
1179 vki_rlim_t rlim_cur;
1180 vki_rlim_t rlim_max;
1183 #define VKI_RLIMIT_DATA 2 /* max data size */
1184 #define VKI_RLIMIT_STACK 3 /* max stack size */
1185 #define VKI_RLIMIT_CORE 4 /* max core file size */
1186 #define VKI_RLIMIT_NOFILE 8 /* max number of open files */
1188 struct vki___wrusage {
1189 struct vki_rusage wru_self;
1190 struct vki_rusage wru_children;
1194 //----------------------------------------------------------------------
1195 // From sys/procfs.h
1196 //----------------------------------------------------------------------
1198 #define VKI_PRSTATUS_VERSION 1
1199 struct vki_elf_prstatus {
1200 int pr_version; /* version of struct - PRSTATUS_VERSION */
1201 vki_size_t pr_statussz;
1202 vki_size_t pr_gregsetsz;
1203 vki_size_t pr_fpregsetsz;
1204 int pr_osreldate;
1205 int pr_cursig; /* Current signal */
1206 vki_pid_t pr_pid;
1207 vki_elf_gregset_t pr_reg; /* GP registers */
1210 #define VKI_ELF_PRARGSZ (80) /* Number of chars for args */
1211 #define VKI_MAXCOMLEN (16)
1213 #define VKI_PRPSINFO_VERSION 1
1214 struct vki_elf_prpsinfo {
1215 int pr_version; /* version of struct - PRPSINFO_VERSION */
1216 vki_size_t pr_psinfosz;
1217 char pr_fname[VKI_MAXCOMLEN+1]; /* filename of executable */
1218 char pr_psargs[VKI_ELF_PRARGSZ]; /* initial part of arg list */
1221 //----------------------------------------------------------------------
1222 // From posix4/mqueue.h
1223 //----------------------------------------------------------------------
1225 struct vki_mq_attr {
1226 long mq_flags; /* message queue flags */
1227 long mq_maxmsg; /* maximum number of messages */
1228 long mq_msgsize; /* maximum message size */
1229 long mq_curmsgs; /* number of messages currently queued */
1232 //----------------------------------------------------------------------
1233 // From sys/ucontext.h
1234 //----------------------------------------------------------------------
1236 #define VKI_UCF_SWAPPED 1
1238 struct vki_ucontext {
1239 vki_sigset_t uc_sigmask;
1240 struct vki_mcontext uc_mcontext;
1241 struct vki_ucontext *uc_link;
1242 vki_stack_t uc_stack;
1243 int uc_flags;
1244 unsigned int __spare__[4];
1247 //----------------------------------------------------------------------
1248 // From sys/utsname.h
1249 //----------------------------------------------------------------------
1251 #define VKI_SYS_NMLN 32
1253 struct vki_utsname {
1254 char sysname[VKI_SYS_NMLN]; /* Name of this OS. */
1255 char nodename[VKI_SYS_NMLN]; /* Name of this network node. */
1256 char release[VKI_SYS_NMLN]; /* Release level. */
1257 char version[VKI_SYS_NMLN]; /* Version level. */
1258 char machine[VKI_SYS_NMLN]; /* Hardware type. */
1261 #define VKI_IPC_CREAT 00001000 /* create if key is nonexistent */
1262 #define VKI_IPC_EXCL 00002000 /* fail if key exists */
1263 #define VKI_IPC_NOWAIT 00004000 /* return error on wait */
1265 #define VKI_IPC_RMID 0 /* remove resource */
1266 #define VKI_IPC_SET 1 /* set ipc_perm options */
1267 #define VKI_IPC_STAT 2 /* get ipc_perm options */
1268 #define VKI_IPC_INFO 3 /* see ipcs */
1270 //----------------------------------------------------------------------
1271 // From sys/ipc.h
1272 //----------------------------------------------------------------------
1274 struct vki_ipc_perm_old {
1275 unsigned short cuid;
1276 unsigned short cgid;
1277 unsigned short uid;
1278 unsigned short gid;
1279 unsigned short mode;
1280 unsigned short seq;
1281 vki_key_t key;
1284 struct vki_ipc_perm {
1285 vki_uid_t cuid;
1286 vki_gid_t cgid;
1287 vki_uid_t uid;
1288 vki_gid_t gid;
1289 vki_mode_t mode;
1290 unsigned short seq;
1291 vki_key_t key;
1294 //----------------------------------------------------------------------
1295 // From sys/sem.h
1296 //----------------------------------------------------------------------
1298 #define VKI_GETALL 6 /* get all semval's */
1299 #define VKI_SETVAL 8 /* set semval */
1300 #define VKI_SETALL 9 /* set all semval's */
1301 #define VKI_SEM_STAT 10
1302 #define VKI_SEM_INFO 11
1304 struct vki_semid_ds_old {
1305 struct vki_ipc_perm_old sem_perm;
1306 struct sem *__sem_base;
1307 unsigned short sem_nsems;
1308 vki_time_t sem_otime;
1309 long sem_pad1;
1310 vki_time_t sem_ctime;
1311 long sem_pad2;
1312 long sem_pad3[4];
1316 /* Obsolete, used only for backwards compatibility and libc5 compiles */
1317 struct vki_semid_ds {
1318 struct vki_ipc_perm sem_perm; /* permissions .. see ipc.h */
1319 // [[Use void* to avoid excess header copying]]
1320 void/*struct sem */*sem_base; /* ptr to first semaphore in array */
1321 unsigned short sem_nsems; /* no. of semaphores in array */
1322 vki_time_t sem_otime; /* last semop time */
1323 vki_time_t sem_ctime; /* last change time */
1326 struct vki_sembuf {
1327 vki_uint16_t sem_num; /* semaphore index in array */
1328 vki_int16_t sem_op; /* semaphore operation */
1329 vki_int16_t sem_flg; /* operation flags */
1332 union vki_semun {
1333 int val; /* value for SETVAL */
1334 struct vki_semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
1335 vki_uint16_t *array; /* array for GETALL & SETALL */
1339 //----------------------------------------------------------------------
1340 // From sys/errno.h
1341 //----------------------------------------------------------------------
1343 #define VKI_ERESTART -1
1344 #define VKI_EPERM 1 /* Operation not permitted */
1345 #define VKI_ENOENT 2 /* No such file or directory */
1346 #define VKI_ESRCH 3 /* No such process */
1347 #define VKI_EINTR 4 /* Interrupted system call */
1348 #define VKI_EIO 5 /* Input/output error */
1349 #define VKI_ENXIO 6 /* Device not configured */
1350 #define VKI_E2BIG 7 /* Argument list too long */
1351 #define VKI_ENOEXEC 8 /* Exec format error */
1352 #define VKI_EBADF 9 /* Bad file descriptor */
1353 #define VKI_ECHILD 10 /* No child processes */
1354 #define VKI_EDEADLK 11 /* Resource deadlock avoided */
1355 #define VKI_ENOMEM 12 /* Cannot allocate memory */
1356 #define VKI_EACCES 13 /* Permission denied */
1357 #define VKI_EFAULT 14 /* Bad address */
1358 #define VKI_ENOTBLK 15 /* Block device required */
1359 #define VKI_EBUSY 16 /* Device busy */
1360 #define VKI_EEXIST 17 /* File exists */
1361 #define VKI_EXDEV 18 /* Cross-device link */
1362 #define VKI_ENODEV 19 /* Operation not supported by device */
1363 #define VKI_ENOTDIR 20 /* Not a directory */
1364 #define VKI_EISDIR 21 /* Is a directory */
1365 #define VKI_EINVAL 22 /* Invalid argument */
1366 #define VKI_ENFILE 23 /* Too many open files in system */
1367 #define VKI_EMFILE 24 /* Too many open files */
1368 #define VKI_ENOTTY 25 /* Inappropriate ioctl for device */
1369 #define VKI_ETXTBSY 26 /* Text file busy */
1370 #define VKI_EFBIG 27 /* File too large */
1371 #define VKI_ENOSPC 28 /* No space left on device */
1372 #define VKI_ESPIPE 29 /* Illegal seek */
1373 #define VKI_EROFS 30 /* Read-only filesystem */
1374 #define VKI_EMLINK 31 /* Too many links */
1375 #define VKI_EPIPE 32 /* Broken pipe */
1376 #define VKI_EDOM 33 /* Numerical argument out of domain */
1377 #define VKI_ERANGE 34 /* Result too large */
1378 #define VKI_EAGAIN 35 /* Resource temporarily unavailable */
1379 #define VKI_EWOULDBLOCK VKI_EAGAIN /* Operation would block */
1380 #define VKI_EINPROGRESS 36 /* Operation now in progress */
1381 #define VKI_EALREADY 37 /* Operation already in progress */
1382 #define VKI_ENOTSOCK 38 /* Socket operation on non-socket */
1383 #define VKI_EDESTADDRREQ 39 /* Destination address required */
1384 #define VKI_EMSGSIZE 40 /* Message too long */
1385 #define VKI_EPROTOTYPE 41 /* Protocol wrong type for socket */
1386 #define VKI_ENOPROTOOPT 42 /* Protocol not available */
1387 #define VKI_EPROTONOSUPPORT 43 /* Protocol not supported */
1388 #define VKI_ESOCKTNOSUPPORT 44 /* Socket type not supported */
1389 #define VKI_EOPNOTSUPP 45 /* Operation not supported */
1390 #define VKI_ENOTSUP VKI_EOPNOTSUPP /* Operation not supported */
1391 #define VKI_EPFNOSUPPORT 46 /* Protocol family not supported */
1392 #define VKI_EAFNOSUPPORT 47 /* Address family not supported by protocol family */
1393 #define VKI_EADDRINUSE 48 /* Address already in use */
1394 #define VKI_EADDRNOTAVAIL 49
1395 #define VKI_ENETDOWN 50 /* Network is down */
1396 #define VKI_ENETUNREACH 51 /* Network is unreachable */
1397 #define VKI_ENETRESET 52 /* Network dropped connection on reset */
1398 #define VKI_ECONNABORTED 53 /* Software caused connection abort */
1399 #define VKI_ECONNRESET 54 /* Connection reset by peer */
1400 #define VKI_ENOBUFS 55 /* No buffer space available */
1401 #define VKI_EISCONN 56 /* Socket is already connected */
1402 #define VKI_ENOTCONN 57 /* Socket is not connected */
1403 #define VKI_ESHUTDOWN 58 /* Can't send after socket shutdown */
1404 #define VKI_ETOOMANYREFS 59 /* Too many references: can't splice */
1405 #define VKI_ETIMEDOUT 60 /* Operation timed out */
1406 #define VKI_ECONNREFUSED 61 /* Connection refused */
1407 #define VKI_ELOOP 62 /* Too many levels of symbolic links */
1408 #define VKI_ENAMETOOLONG 63 /* File name too long */
1409 #define VKI_EHOSTDOWN 64 /* Host is down */
1410 #define VKI_EHOSTUNREACH 65 /* No route to host */
1411 #define VKI_ENOTEMPTY 66 /* Directory not empty */
1412 #define VKI_EPROCLIM 67 /* Too many processes */
1413 #define VKI_EUSERS 68 /* Too many users */
1414 #define VKI_EDQUOT 69 /* Disc quota exceeded */
1415 #define VKI_ESTALE 70 /* Stale NFS file handle */
1416 #define VKI_EREMOTE 71 /* Too many levels of remote in path */
1417 #define VKI_EBADRPC 72 /* RPC struct is bad */
1418 #define VKI_ERPCMISMATCH 73 /* RPC version wrong */
1419 #define VKI_EPROGUNAVAIL 74 /* RPC prog. not avail */
1420 #define VKI_EPROGMISMATCH 75 /* Program version wrong */
1421 #define VKI_EPROCUNAVAIL 76 /* Bad procedure for program */
1422 #define VKI_ENOLCK 77 /* No locks available */
1423 #define VKI_ENOSYS 78 /* Function not implemented */
1424 #define VKI_EFTYPE 79 /* Inappropriate file type or format */
1425 #define VKI_EAUTH 80 /* Authentication error */
1426 #define VKI_ENEEDAUTH 81 /* Need authenticator */
1427 #define VKI_EIDRM 82 /* Identifier removed */
1428 #define VKI_ENOMSG 83 /* No message of desired type */
1429 #define VKI_EOVERFLOW 84 /* Value too large to be stored in data type */
1430 #define VKI_ECANCELED 85 /* Operation canceled */
1431 #define VKI_EILSEQ 86 /* Illegal byte sequence */
1432 #define VKI_ENOATTR 87 /* Attribute not found */
1433 #define VKI_EDOOFUS 88 /* Programming error */
1434 #define VKI_EBADMSG 89 /* Bad message */
1435 #define VKI_EMULTIHOP 90 /* Multihop attempted */
1436 #define VKI_ENOLINK 91 /* Link has been severed */
1437 #define VKI_EPROTO 92 /* Protocol error */
1438 #define VKI_ENOTCAPABLE 93 /* Capabilities insufficient */
1439 #define VKI_ECAPMODE 94 /* Not permitted in capability mode */
1441 //----------------------------------------------------------------------
1442 // From sys/wait.h
1443 //----------------------------------------------------------------------
1445 #define VKI_WNOHANG 0x00000001
1447 typedef enum vki_idtype {
1448 VKI_P_PID,
1449 VKI_P_PPID,
1450 VKI_P_PGID,
1451 VKI_P_SID,
1452 VKI_P_CID,
1453 VKI_P_UID,
1454 VKI_P_GID,
1455 VKI_P_ALL,
1456 VKI_P_LWPID,
1457 VKI_P_TASKID,
1458 VKI_P_PROJID,
1459 VLI_P_POOLID,
1460 VKI_P_JAILID,
1461 VKI_P_CTID,
1462 VKI_P_CPUID,
1463 VKI_P_PSETID
1464 } vki_idtype_t;
1466 //----------------------------------------------------------------------
1467 // From sys/mman.h
1468 //----------------------------------------------------------------------
1470 #define VKI_PROT_NONE 0x00 /* No page permissions */
1471 #define VKI_PROT_READ 0x01 /* page can be read */
1472 #define VKI_PROT_WRITE 0x02 /* page can be written */
1473 #define VKI_PROT_EXEC 0x04 /* page can be executed */
1475 #define VKI_MAP_SHARED 0x01 /* Share changes */
1476 #define VKI_MAP_PRIVATE 0x02 /* Changes are private */
1477 #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
1478 #define VKI_MAP_NORESERVE 0x0040 /* don't check for reservations */
1479 #define VKI_MAP_STACK 0x400
1480 #define VKI_MAP_ANON 0x1000 /* don't use a file */
1481 #define VKI_MAP_ANONYMOUS VKI_MAP_ANON
1483 //----------------------------------------------------------------------
1484 // From sys/stat.h
1485 //----------------------------------------------------------------------
1487 #define VKI_S_IFMT 00170000
1489 #define VKI_S_IFWHT 0160000
1490 #define VKI_S_IFSOCK 0140000
1491 #define VKI_S_IFLNK 0120000
1492 #define VKI_S_IFREG 0100000
1493 #define VKI_S_IFBLK 0060000
1494 #define VKI_S_IFDIR 0040000
1495 #define VKI_S_IFCHR 0020000
1496 #define VKI_S_IFIFO 0010000
1497 #define VKI_S_ISUID 0004000
1498 #define VKI_S_ISGID 0002000
1499 #define VKI_S_ISTXT 0001000
1501 #define VKI_S_ISLNK(m) (((m) & VKI_S_IFMT) == VKI_S_IFLNK)
1502 #define VKI_S_ISREG(m) (((m) & VKI_S_IFMT) == VKI_S_IFREG)
1503 #define VKI_S_ISDIR(m) (((m) & VKI_S_IFMT) == VKI_S_IFDIR)
1504 #define VKI_S_ISCHR(m) (((m) & VKI_S_IFMT) == VKI_S_IFCHR)
1505 #define VKI_S_ISBLK(m) (((m) & VKI_S_IFMT) == VKI_S_IFBLK)
1506 #define VKI_S_ISFIFO(m) (((m) & VKI_S_IFMT) == VKI_S_IFIFO)
1507 #define VKI_S_ISSOCK(m) (((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
1508 #define VKI_S_ISWHT(m) (((m) & VKI_S_IFMT) == VKI_S_IFWHT)
1510 #define VKI_S_IRWXU 00700
1511 #define VKI_S_IRUSR 00400
1512 #define VKI_S_IWUSR 00200
1513 #define VKI_S_IXUSR 00100
1515 #define VKI_S_IRWXG 00070
1516 #define VKI_S_IRGRP 00040
1517 #define VKI_S_IWGRP 00020
1518 #define VKI_S_IXGRP 00010
1520 #define VKI_S_IRWXO 00007
1521 #define VKI_S_IROTH 00004
1522 #define VKI_S_IWOTH 00002
1523 #define VKI_S_IXOTH 00001
1526 //----------------------------------------------------------------------
1527 // From sys/dirent.h
1528 //----------------------------------------------------------------------
1530 struct vki_dirent {
1531 vki_uint32_t d_fileno;
1532 vki_uint16_t d_reclen;
1533 vki_uint8_t d_type;
1534 vki_uint8_t d_namelen;
1535 char vki_d_name[256]; /* We must not include limits.h! */
1538 //----------------------------------------------------------------------
1539 // From sys/fcntl.h
1540 //----------------------------------------------------------------------
1542 #define VKI_O_RDONLY O_RDONLY
1543 #define VKI_O_WRONLY O_WRONLY
1544 #define VKI_O_RDWR O_RDWR
1546 #define VKI_FREAD FREAD
1547 #define VKI_WRITE WRITE
1549 #define VKI_O_NONBLOCK O_NONBLOCK
1550 #define VKI_O_APPEND O_APPEND
1551 #define VKI_O_CREAT O_CREAT
1552 #define VKI_O_TRUNC O_TRUNC
1553 #define VKI_O_EXCL O_EXCL
1554 #define VKI_O_DIRECTORY O_DIRECTORY
1555 #define VKI_O_EXEC O_EXEC
1556 #define VKI_O_SEARCH O_EXEC
1558 #define VKI_AT_FDCWD AT_FDCWD
1559 #define VKI_AT_SYMLINK_NOFOLLOW 0x0200
1562 #define VKI_F_DUPFD 0 /* dup */
1563 #define VKI_F_GETFD 1 /* get close_on_exec */
1564 #define VKI_F_SETFD 2 /* set/clear close_on_exec */
1565 #define VKI_F_GETFL 3 /* get file->f_flags */
1566 #define VKI_F_SETFL 4 /* set file->f_flags */
1567 #define VKI_F_SETOWN 5 /* for sockets. */
1568 #define VKI_F_GETOWN 6 /* for sockets. */
1569 #define VKI_F_OGETLK 7 /* get record locking information */
1570 #define VKI_F_OSETLK 8 /* set record locking information */
1571 #define VKI_F_OSETLKW 9 /* F_SETLK; wait if blocked */
1572 #define VKI_F_DUP2FD 10 /* duplicate file descriptor to arg */
1573 #define VKI_F_GETLK 11 /* get record locking information */
1574 #define VKI_F_SETLK 12 /* set record locking information */
1575 #define VKI_F_SETLKW 13 /* F_SETLK; wait if blocked */
1576 #define VKI_F_SETLK_REMOTE 14 /* debugging support for remote locks */
1577 #define VKI_F_READAHEAD 15 /* read ahead */
1578 #define VKI_F_RDAHEAD 16 /* Darwin compatible read ahead */
1579 #define VKI_F_DUPFD_CLOEXEC 17 /* dup close_on_exec */
1580 #define VKI_F_DUP2FD_CLOEXEC 18 /* Like F_DUP2FD, but FD_CLOEXEC is set */
1581 #define VKI_F_ADD_SEALS 19 /* apply seals to underlying file */
1582 #define VKI_F_GET_SEALS 20 /* get seals to underlying file */
1583 #define VKI_F_ISUNIONSTACK 21 /* kludge for libc (part of a union stack?) */
1584 /* FreeBSD 13.1 and later */
1585 #define VKI_F_KINFO 22 /* Return kinfo_file for this fd */
1587 /* for F_[GET|SET]FL */
1588 #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */
1590 /* for F_[ADD|GET]_SEALS */
1591 #define VKI_F_SEAL_SEAL 0x0001
1592 #define VKI_F_SEAL_SHRINK 0x0002
1593 #define VKI_F_SEAL_GROW 0x0004
1594 #define VKI_F_SEAL_WRITE 0x0008
1596 struct vki_spacectl_range {
1597 vki_off_t r_offset;
1598 vki_off_t r_len;
1602 //----------------------------------------------------------------------
1603 // From sys/unistd.h
1604 //----------------------------------------------------------------------
1606 #define VKI_SEEK_SET 0
1607 #define VKI_SEEK_CUR 1
1608 #define VKI_SEEK_END 2
1610 #define VKI_F_OK 0 /* test for existence of file */
1611 #define VKI_X_OK 0x01 /* test for execute or search permission */
1612 #define VKI_W_OK 0x02 /* test for write permission */
1613 #define VKI_R_OK 0x04 /* test for read permission */
1615 #define VKI_RFSPAWN (1U<<31U)
1617 #define VKI_CLOSE_RANGE_CLOEXEC (1<<2)
1619 //----------------------------------------------------------------------
1620 // From sys/msg.h
1621 //----------------------------------------------------------------------
1623 #if 0 /* not in freebsd */
1624 #define VKI_MSGSND 11
1625 #define VKI_MSGRCV 12
1626 #define VKI_MSGGET 13
1627 #define VKI_MSGCTL 14
1628 #endif
1630 typedef unsigned long vki_msglen_t;
1631 typedef unsigned long vki_msgqnum_t;
1633 struct vki_msqid_ds_old {
1634 struct vki_ipc_perm_old msg_perm;
1635 struct vki_msg *msg_first;
1636 struct vki_msg *msg_last;
1637 vki_msglen_t msg_cbytes;
1638 vki_msgqnum_t msg_qnum;
1639 vki_msglen_t msg_qbytes;
1640 vki_pid_t msg_lspid;
1641 vki_pid_t msg_lrpid;
1642 vki_time_t msg_stime;
1643 vki_uint32_t msg_pad1;
1644 vki_time_t msg_rtime;
1645 vki_uint32_t msg_pad2;
1646 vki_time_t msg_ctime;
1647 vki_uint32_t msg_pad3;
1648 vki_uint32_t msg_pad4[4];
1651 struct vki_msqid_ds {
1652 struct vki_ipc_perm msg_perm;
1653 struct vki_msg *msg_first;
1654 struct vki_msg *msg_last;
1655 vki_msglen_t msg_cbytes;
1656 vki_msgqnum_t msg_qnum;
1657 vki_msglen_t msg_qbytes;
1658 vki_pid_t msg_lspid;
1659 vki_pid_t msg_lrpid;
1660 vki_time_t msg_stime;
1661 vki_time_t msg_rtime;
1662 vki_time_t msg_ctime;
1666 struct vki_msgbuf {
1667 long mtype; /* type of message */
1668 char mtext[1]; /* message text */
1672 //----------------------------------------------------------------------
1673 // From sys/shm.h
1674 //----------------------------------------------------------------------
1676 struct vki_shmid_ds_old {
1677 struct vki_ipc_perm_old shm_perm; /* operation perms */
1678 int shm_segsz; /* size of segment (bytes) */
1679 vki_pid_t shm_lpid; /* pid of last operator */
1680 vki_pid_t shm_cpid; /* pid of creator */
1681 short shm_nattch; /* no. of current attaches */
1682 vki_time_t shm_atime; /* last attach time */
1683 vki_time_t shm_dtime; /* last detach time */
1684 vki_time_t shm_ctime; /* last change time */
1685 void *shm_internal; /* sysv stupidity */
1689 struct vki_shmid_ds {
1690 struct vki_ipc_perm shm_perm; /* operation perms */
1691 vki_size_t shm_segsz; /* size of segment (bytes) */
1692 vki_pid_t shm_lpid; /* pid of last operator */
1693 vki_pid_t shm_cpid; /* pid of creator */
1694 int shm_nattch; /* no. of current attaches */
1695 vki_time_t shm_atime; /* last attach time */
1696 vki_time_t shm_dtime; /* last detach time */
1697 vki_time_t shm_ctime; /* last change time */
1700 #define VKI_SHMLBA VKI_PAGE_SIZE
1701 #define VKI_SHM_RDONLY 010000 /* read-only access */
1702 #define VKI_SHM_ANON (1UL)
1704 #if 0 /* not in freebsd abi */
1705 #define VKI_SHMAT 21
1706 #define VKI_SHMDT 22
1707 #define VKI_SHMGET 23
1708 #define VKI_SHMCTL 24
1709 #endif
1711 #if 0
1712 //----------------------------------------------------------------------
1713 // From linux-2.6.8.1/include/linux/sockios.h
1714 //----------------------------------------------------------------------
1716 #define VKI_SIOCOUTQ VKI_TIOCOUTQ
1718 #define VKI_SIOCADDRT 0x890B /* add routing table entry */
1719 #define VKI_SIOCDELRT 0x890C /* delete routing table entry */
1721 #define VKI_SIOCGIFNAME 0x8910 /* get iface name */
1722 #define VKI_SIOCGIFCONF 0x8912 /* get iface list */
1723 #define VKI_SIOCGIFFLAGS 0x8913 /* get flags */
1724 #define VKI_SIOCSIFFLAGS 0x8914 /* set flags */
1725 #define VKI_SIOCGIFADDR 0x8915 /* get PA address */
1726 #define VKI_SIOCSIFADDR 0x8916 /* set PA address */
1727 #define VKI_SIOCGIFDSTADDR 0x8917 /* get remote PA address */
1728 #define VKI_SIOCSIFDSTADDR 0x8918 /* set remote PA address */
1729 #define VKI_SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */
1730 #define VKI_SIOCSIFBRDADDR 0x891a /* set broadcast PA address */
1731 #define VKI_SIOCGIFNETMASK 0x891b /* get network PA mask */
1732 #define VKI_SIOCSIFNETMASK 0x891c /* set network PA mask */
1733 #define VKI_SIOCGIFMETRIC 0x891d /* get metric */
1734 #define VKI_SIOCSIFMETRIC 0x891e /* set metric */
1735 #define VKI_SIOCGIFMTU 0x8921 /* get MTU size */
1736 #define VKI_SIOCSIFMTU 0x8922 /* set MTU size */
1737 #define VKI_SIOCSIFHWADDR 0x8924 /* set hardware address */
1738 #define VKI_SIOCGIFHWADDR 0x8927 /* Get hardware address */
1739 #define VKI_SIOCGIFINDEX 0x8933 /* name -> if_index mapping */
1741 #define VKI_SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */
1742 #define VKI_SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */
1744 #define VKI_SIOCGMIIPHY 0x8947 /* Get address of MII PHY in use. */
1745 #define VKI_SIOCGMIIREG 0x8948 /* Read MII PHY register. */
1746 #define VKI_SIOCSMIIREG 0x8949 /* Write MII PHY register. */
1748 #define VKI_SIOCDARP 0x8953 /* delete ARP table entry */
1749 #define VKI_SIOCGARP 0x8954 /* get ARP table entry */
1750 #define VKI_SIOCSARP 0x8955 /* set ARP table entry */
1752 #define VKI_SIOCDRARP 0x8960 /* delete RARP table entry */
1753 #define VKI_SIOCGRARP 0x8961 /* get RARP table entry */
1754 #define VKI_SIOCSRARP 0x8962 /* set RARP table entry */
1756 #define VKI_SIOCGIFMAP 0x8970 /* Get device parameters */
1757 #define VKI_SIOCSIFMAP 0x8971 /* Set device parameters */
1759 //----------------------------------------------------------------------
1760 // From linux-2.6.9/include/linux/kb.h
1761 //----------------------------------------------------------------------
1763 #define VKI_GIO_FONT 0x4B60 /* gets font in expanded form */
1764 #define VKI_PIO_FONT 0x4B61 /* use font in expanded form */
1766 #define VKI_GIO_FONTX 0x4B6B /* get font using struct consolefontdesc */
1767 #define VKI_PIO_FONTX 0x4B6C /* set font using struct consolefontdesc */
1768 struct vki_consolefontdesc {
1769 unsigned short charcount; /* characters in font (256 or 512) */
1770 unsigned short charheight; /* scan lines per character (1-32) */
1771 char __user *chardata; /* font data in expanded form */
1774 #define VKI_PIO_FONTRESET 0x4B6D /* reset to default font */
1776 #define VKI_GIO_CMAP 0x4B70 /* gets colour palette on VGA+ */
1777 #define VKI_PIO_CMAP 0x4B71 /* sets colour palette on VGA+ */
1779 #define VKI_KIOCSOUND 0x4B2F /* start sound generation (0 for off) */
1780 #define VKI_KDMKTONE 0x4B30 /* generate tone */
1782 #define VKI_KDGETLED 0x4B31 /* return current led state */
1783 #define VKI_KDSETLED 0x4B32 /* set led state [lights, not flags] */
1785 #define VKI_KDGKBTYPE 0x4B33 /* get keyboard type */
1787 #define VKI_KDADDIO 0x4B34 /* add i/o port as valid */
1788 #define VKI_KDDELIO 0x4B35 /* del i/o port as valid */
1789 #define VKI_KDENABIO 0x4B36 /* enable i/o to video board */
1790 #define VKI_KDDISABIO 0x4B37 /* disable i/o to video board */
1792 #define VKI_KDSETMODE 0x4B3A /* set text/graphics mode */
1793 #define VKI_KDGETMODE 0x4B3B /* get current mode */
1795 #define VKI_KDMAPDISP 0x4B3C /* map display into address space */
1796 #define VKI_KDUNMAPDISP 0x4B3D /* unmap display from address space */
1798 #define VKI_E_TABSZ 256
1799 #define VKI_GIO_SCRNMAP 0x4B40 /* get screen mapping from kernel */
1800 #define VKI_PIO_SCRNMAP 0x4B41 /* put screen mapping table in kernel */
1801 #define VKI_GIO_UNISCRNMAP 0x4B69 /* get full Unicode screen mapping */
1802 #define VKI_PIO_UNISCRNMAP 0x4B6A /* set full Unicode screen mapping */
1804 #define VKI_GIO_UNIMAP 0x4B66 /* get unicode-to-font mapping from kernel */
1805 #define VKI_PIO_UNIMAP 0x4B67 /* put unicode-to-font mapping in kernel */
1806 #define VKI_PIO_UNIMAPCLR 0x4B68 /* clear table, possibly advise hash algorithm */
1808 #define VKI_KDGKBMODE 0x4B44 /* gets current keyboard mode */
1809 #define VKI_KDSKBMODE 0x4B45 /* sets current keyboard mode */
1811 #define VKI_KDGKBMETA 0x4B62 /* gets meta key handling mode */
1812 #define VKI_KDSKBMETA 0x4B63 /* sets meta key handling mode */
1814 #define VKI_KDGKBLED 0x4B64 /* get led flags (not lights) */
1815 #define VKI_KDSKBLED 0x4B65 /* set led flags (not lights) */
1817 struct vki_kbentry {
1818 unsigned char kb_table;
1819 unsigned char kb_index;
1820 unsigned short kb_value;
1822 #define VKI_KDGKBENT 0x4B46 /* gets one entry in translation table */
1823 #define VKI_KDSKBENT 0x4B47 /* sets one entry in translation table */
1825 struct vki_kbsentry {
1826 unsigned char kb_func;
1827 unsigned char kb_string[512];
1829 #define VKI_KDGKBSENT 0x4B48 /* gets one function key string entry */
1830 #define VKI_KDSKBSENT 0x4B49 /* sets one function key string entry */
1832 struct vki_kbdiacr {
1833 unsigned char diacr, base, result;
1835 struct vki_kbdiacrs {
1836 unsigned int kb_cnt; /* number of entries in following array */
1837 struct vki_kbdiacr kbdiacr[256]; /* MAX_DIACR from keyboard.h */
1839 #define VKI_KDGKBDIACR 0x4B4A /* read kernel accent table */
1840 #define VKI_KDSKBDIACR 0x4B4B /* write kernel accent table */
1842 struct vki_kbkeycode {
1843 unsigned int scancode, keycode;
1845 #define VKI_KDGETKEYCODE 0x4B4C /* read kernel keycode table entry */
1846 #define VKI_KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
1848 #define VKI_KDSIGACCEPT 0x4B4E /* accept kbd generated signals */
1850 struct vki_kbd_repeat {
1851 int delay; /* in msec; <= 0: don't change */
1852 int period; /* in msec; <= 0: don't change */
1853 /* earlier this field was misnamed "rate" */
1855 #define VKI_KDKBDREP 0x4B52 /* set keyboard delay/repeat rate;
1856 * actually used values are returned */
1858 #define VKI_KDFONTOP 0x4B72 /* font operations */
1860 //----------------------------------------------------------------------
1861 // From linux-2.6.9/include/linux/kb.h
1862 //----------------------------------------------------------------------
1864 typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory */
1866 #endif
1868 //----------------------------------------------------------------------
1869 // From sys/ptrace.h
1870 //----------------------------------------------------------------------
1872 #define VKI_PTRACE_TRACEME 0
1873 #define VKI_PTRACE_READ_I 1
1874 #define VKI_PTRACE_READ_D 2
1875 /* 3 - read user struct */
1876 #define VKI_PTRACE_WRITE_I 4
1877 #define VKI_PTRACE_WRITE_D 5
1878 /* 6 - write user struct */
1879 #define VKI_PTRACE_CONTINUE 7
1880 #define VKI_PTRACE_KILL 8
1881 #define VKI_PTRACE_STEP 9
1882 #define VKI_PTRACE_ATTACH 10
1883 #define VKI_PTRACE_DETACH 11
1884 #define VKI_PTRACE_IO 12
1885 #define VKI_PTRACE_LWPINFO 13
1886 #define VKI_PTRACE_GETNUMLWPS 14
1887 #define VKI_PTRACE_GETLWPLIST 15
1888 #define VKI_PTRACE_CLEARSTEP 16
1889 #define VKI_PTRACE_SETSTEP 17
1890 #define VKI_PTRACE_SUSPEND 18
1891 #define VKI_PTRACE_RESUME 19
1892 #define VKI_PTRACE_TO_SCE 20
1893 #define VKI_PTRACE_TO_SCX 21
1894 #define VKI_PTRACE_SYSCALL 22
1895 /* md */
1896 #define VKI_PTRACE_GETREGS 33
1897 #define VKI_PTRACE_SETREGS 34
1898 #define VKI_PTRACE_GETFPREGS 35
1899 #define VKI_PTRACE_SETFPREGS 36
1900 #define VKI_PTRACE_GETDBREGS 37
1901 #define VKI_PTRACE_SETDBREGS 38
1903 #define VKI_PTRACE_VM_TIMESTAMP 40
1904 #define VKI_PTRACE_VM_ENTRY 41
1906 #define VKI_PTRACE_FIRSTMACH 64
1908 struct vki_ptrace_io_desc {
1909 int piod_op;
1910 void * piod_offs;
1911 void * piod_addr;
1912 vki_size_t piod_len;
1914 #define VKI_PIOD_READ_D 1
1915 #define VKI_PIOD_WRITE_D 2
1916 #define VKI_PIOD_READ_I 3
1917 #define VKI_PIOD_WRITE_I 4
1919 struct vki_ptrace_lwpinfo {
1920 vki_lwpid_t pl_lwpid;
1921 int pl_event;
1922 #define VKI_PL_EVENT_NONE 0
1923 #define VKI_PL_EVENT_SIGNAL 1
1924 int pl_flags;
1925 #define VKI_FLAG_SA 0x01
1926 #define VKI_FLAG_BOUND 0x02
1927 vki_sigset_t pl_sigmask;
1928 vki_sigset_t pl_siglist;
1931 struct vki_ptrace_vm_entry {
1932 int pve_entry; /* Entry number used for iteration. */
1933 int pve_timestamp; /* Generation number of VM map. */
1934 unsigned long pve_start; /* Start VA of range. */
1935 unsigned long pve_end; /* End VA of range (incl). */
1936 unsigned long pve_offset; /* Offset in backing object. */
1937 unsigned int pve_prot; /* Protection of memory range. */
1938 unsigned int pve_pathlen; /* Size of path. */
1939 long pve_fileid; /* File ID. */
1940 vki_uint32_t pve_fsid; /* File system ID. */
1941 char *pve_path; /* Path name of object. */
1944 #endif // __VKI_FREEBSD_H
1946 //----------------------------------------------------------------------
1947 // From x86/sysarch.h
1948 //----------------------------------------------------------------------
1950 // @todo PJF missing VKI_I386_VM86 VKI_I386_SET_PKRU VKI_I386_CLEAR_PKRU VKI_AMD64_SET_PKRU VKI_AMD64_CLEAR_PKRU
1951 #define VKI_I386_GET_FSBASE 7
1952 #define VKI_I386_SET_FSBASE 8
1953 #define VKI_I386_GET_GSBASE 9
1954 #define VKI_I386_SET_GSBASE 10
1955 #define VKI_I386_GET_XFPUSTATE 11
1957 #define VKI_AMD64_GET_FSBASE 128
1958 #define VKI_AMD64_SET_FSBASE 129
1959 #define VKI_AMD64_GET_GSBASE 130
1960 #define VKI_AMD64_SET_GSBASE 131
1961 #define VKI_AMD64_GET_XFPUSTATE 132
1963 //----------------------------------------------------------------------
1964 // From sys/module.h
1965 //----------------------------------------------------------------------
1967 #define VKI_MAXMODNAME 32
1969 typedef union vki_modspecific {
1970 vki_int32_t intval;
1971 vki_uint32_t u_intval;
1972 #if defined(VGP_x86_freebsd)
1973 vki_int32_t longval;
1974 vki_uint32_t u_longval;
1975 #elif defined(VGP_amd64_freebsd)
1976 vki_int64_t longval;
1977 vki_uint64_t u_longval;
1978 #else
1979 #error Unknown platform
1980 #endif
1981 } vki_modspecific_t;
1983 struct vki_module_stat {
1984 int version;
1985 char name[VKI_MAXMODNAME];
1986 int refs;
1987 int id;
1988 vki_modspecific_t data;
1991 //----------------------------------------------------------------------
1992 // From sys/rtprio.h
1993 //----------------------------------------------------------------------
1995 struct vki_rtprio {
1996 vki_uint16_t type;
1997 vki_uint16_t prio;
2000 #define VKI_RTP_LOOKUP 0
2001 #define VKI_RTP_SET 1
2003 //----------------------------------------------------------------------
2004 // From sys/umtx.h
2005 //----------------------------------------------------------------------
2007 struct vki_umtx {
2008 unsigned long u_owner;
2011 struct vki_umutex {
2012 vki_lwpid_t m_owner;
2013 vki_uint32_t m_flags;
2014 vki_uint32_t m_ceilings[2];
2015 vki_uint32_t m_spare[4];
2018 struct vki_ucond {
2019 vki_uint32_t c_has_waiters;
2020 vki_uint32_t c_flags;
2021 vki_uint32_t c_spare[2];
2024 struct vki_urwlock {
2025 vki_uint32_t rw_state;
2026 vki_uint32_t rw_flags;
2027 vki_uint32_t rw_blocked_readers;
2028 vki_uint32_t rw_blocked_writers;
2029 vki_uint32_t rw_spare[4];
2032 struct vki_usem {
2033 vki_uint32_t has_waiters;
2034 vki_uint32_t count;
2035 vki_uint32_t flags;
2038 struct vki_umtx_time {
2039 struct vki_timespec timeout;
2040 vki_uint32_t flags;
2041 vki_uint32_t clockid;
2044 struct vki_usem2 {
2045 vki_uint32_t count;
2046 vki_uint32_t flags;
2049 struct vki_umtx_robust_lists_params {
2050 vki_uintptr_t robust_list_offset;
2051 vki_uintptr_t robust_priv_list_offset;
2052 vki_uintptr_t robust_inact_offset;
2055 #define VKI_UMTX_OP_LOCK 0
2056 #define VKI_UMTX_OP_UNLOCK 1
2057 #define VKI_UMTX_OP_WAIT 2
2058 #define VKI_UMTX_OP_WAKE 3
2059 #define VKI_UMTX_OP_MUTEX_TRYLOCK 4
2060 #define VKI_UMTX_OP_MUTEX_LOCK 5
2061 #define VKI_UMTX_OP_MUTEX_UNLOCK 6
2062 #define VKI_UMTX_OP_SET_CEILING 7
2063 #define VKI_UMTX_OP_CV_WAIT 8
2064 #define VKI_UMTX_OP_CV_SIGNAL 9
2065 #define VKI_UMTX_OP_CV_BROADCAST 10
2066 #define VKI_UMTX_OP_WAIT_UINT 11
2067 #define VKI_UMTX_OP_RW_RDLOCK 12
2068 #define VKI_UMTX_OP_RW_WRLOCK 13
2069 #define VKI_UMTX_OP_RW_UNLOCK 14
2070 #define VKI_UMTX_OP_WAIT_UINT_PRIVATE 15
2071 #define VKI_UMTX_OP_WAKE_PRIVATE 16
2072 #define VKI_UMTX_OP_MUTEX_WAIT 17
2073 #define VKI_UMTX_OP_MUTEX_WAKE 18 /* deprecated */
2074 #define VKI_UMTX_OP_SEM_WAIT 19
2075 #define VKI_UMTX_OP_SEM_WAKE 20
2076 #define VKI_UMTX_OP_NWAKE_PRIVATE 21
2077 #define VKI_UMTX_OP_MUTEX_WAKE2 22
2078 #define VKI_UMTX_OP_SEM2_WAIT 23
2079 #define VKI_UMTX_OP_SEM2_WAKE 24
2080 #define VKI_UMTX_OP_SHM 25
2081 #define VKI_UMTX_OP_ROBUST_LISTS 26
2082 #if (FREEBSD_VERS >= FREEBSD_14)
2083 #define VKI_UMTX_OP_GET_MIN_TIMEOUT 27
2084 #define VKI_UMTX_OP_SET_MIN_TIMEOUT 28
2085 #endif
2088 //----------------------------------------------------------------------
2089 // From sys/acl.h
2090 //----------------------------------------------------------------------
2092 struct vki_acl_entry {
2093 int ae_tag;
2094 vki_uid_t ae_uid;
2095 vki_mode_t ae_perm;
2098 #define VKI_ACL_MAX_ENTRIES 32
2099 struct vki_acl {
2100 int acl_cnt;
2101 struct vki_acl_entry acl_entry[VKI_ACL_MAX_ENTRIES];
2105 //----------------------------------------------------------------------
2106 // From sys/uuid.h
2107 //----------------------------------------------------------------------
2109 struct vki_uuid {
2110 vki_uint32_t time_low;
2111 vki_uint16_t time_mid;
2112 vki_uint16_t time_hi_and_version;
2113 vki_uint8_t clock_seq_hi_and_reserved;
2114 vki_uint8_t clock_seq_low;
2115 vki_uint8_t node[6];
2118 //----------------------------------------------------------------------
2119 // sys/_sockaddr_storage.h
2120 //----------------------------------------------------------------------
2122 #define VKI__SS_MAXSIZE 128U
2123 #define VKI__SS_ALIGNSIZE (sizeof(__int64_t))
2124 #define VKI__SS_PAD1SIZE (VKI__SS_ALIGNSIZE - sizeof(unsigned char) - \
2125 sizeof(vki_sa_family_t))
2126 #define VKI__SS_PAD2SIZE (VKI__SS_MAXSIZE - sizeof(unsigned char) - \
2127 sizeof(sa_family_t) - VKI__SS_PAD1SIZE - VKI__SS_ALIGNSIZE)
2129 struct vki_sockaddr_storage {
2130 unsigned char vki_ss_len; /* address length */
2131 vki_sa_family_t vki_ss_family; /* address family */
2132 char vki___ss_pad1[VKI__SS_PAD1SIZE];
2133 __int64_t vki___ss_align; /* force desired struct alignment */
2134 char vki___ss_pad2VKI_[_SS_PAD2SIZE];
2137 //----------------------------------------------------------------------
2138 // From sys/captrights.h
2139 //----------------------------------------------------------------------
2141 #define VKI_CAP_RIGHTS_VERSION_00 0
2142 #define VKI_CAP_RIGHTS_VERSION VKI_CAP_RIGHTS_VERSION_00
2144 struct vki_cap_rights {
2145 vki_uint64_t cki_cr_rights[VKI_CAP_RIGHTS_VERSION + 2];
2148 typedef struct vki_cap_rights vki_cap_rights_t;
2151 //----------------------------------------------------------------------
2152 // From sys/user.h
2153 //----------------------------------------------------------------------
2155 #define VKI_KVME_TYPE_NONE 0
2156 #define VKI_KVME_TYPE_DEFAULT 1
2157 #define VKI_KVME_TYPE_VNODE 2
2158 #define VKI_KVME_TYPE_SWAP 3
2159 #define VKI_KVME_TYPE_DEVICE 4
2160 #define VKI_KVME_TYPE_PHYS 5
2161 #define VKI_KVME_TYPE_DEAD 6
2162 #define VKI_KVME_TYPE_UNKNOWN 255
2164 #define VKI_KVME_PROT_READ 0x00000001
2165 #define VKI_KVME_PROT_WRITE 0x00000002
2166 #define VKI_KVME_PROT_EXEC 0x00000004
2168 #define VKI_KVME_FLAG_COW 0x00000001
2169 #define VKI_KVME_FLAG_NEEDS_COPY 0x00000002
2171 struct vki_kinfo_vmentry {
2172 int kve_structsize;
2173 int kve_type;
2174 ULong kve_start;
2175 ULong kve_end;
2176 ULong kve_offset;
2177 ULong kve_fileid;
2178 UInt kve_vn_fsid_freebsd11;
2179 int kve_flags;
2180 int kve_resident;
2181 int kve_private_resident;
2182 int kve_protection;
2183 int kve_ref_count;
2184 int kve_shadow_count;
2185 int kve_vn_type;
2186 ULong kve_vn_size;
2187 UInt kve_vn_rdev_freebsd11;
2188 UShort kve_vn_mode;
2189 UShort kve_status;
2190 ULong kve_vn_fsid;
2191 ULong kve_vn_rdev;
2192 int _kve_ispare[8];
2193 char kve_path[VKI_PATH_MAX];
2196 #define VKI_KINFO_FILE_SIZE 1392
2198 struct vki_kinfo_file {
2199 int vki_kf_structsize; /* Variable size of record. */
2200 int vki_kf_type; /* Descriptor type. */
2201 int vki_kf_fd; /* Array index. */
2202 int vki_kf_ref_count; /* Reference count. */
2203 int vki_kf_flags; /* Flags. */
2204 int vki_kf_pad0; /* Round to 64 bit alignment. */
2205 Off64T vki_kf_offset; /* Seek location. */
2206 union {
2207 struct {
2208 /* API compatiblity with FreeBSD < 12. */
2209 int vki_kf_vnode_type;
2210 int vki_kf_sock_domain;
2211 int vki_kf_sock_type;
2212 int kf_sock_protocol;
2213 struct vki_sockaddr_storage vki_kf_sa_local;
2214 struct vki_sockaddr_storage vki_kf_sa_peer;
2216 union {
2217 struct {
2218 /* Sendq size */
2219 vki_uint32_t vki_kf_sock_sendq;
2220 /* Socket domain. */
2221 int vki_kf_sock_domain0;
2222 /* Socket type. */
2223 int vki_kf_sock_type0;
2224 /* Socket protocol. */
2225 int vki_kf_sock_protocol0;
2226 /* Socket address. */
2227 struct vki_sockaddr_storage vki_kf_sa_local;
2228 /* Peer address. */
2229 struct vki_sockaddr_storage vki_kf_sa_peer;
2230 /* Address of so_pcb. */
2231 vki_uint64_t vki_kf_sock_pcb;
2232 /* Address of inp_ppcb. */
2233 vki_uint64_t vki_kf_sock_inpcb;
2234 /* Address of unp_conn. */
2235 vki_uint64_t vki_kf_sock_unpconn;
2236 /* Send buffer state. */
2237 vki_uint16_t vki_kf_sock_snd_sb_state;
2238 /* Receive buffer state. */
2239 vki_uint16_t vki_kf_sock_rcv_sb_state;
2240 /* Recvq size. */
2241 vki_uint32_t vki_kf_sock_recvq;
2242 } vki_kf_sock;
2243 struct {
2244 /* Vnode type. */
2245 int vki_kf_file_type;
2246 /* Space for future use */
2247 int vki_kf_spareint[3];
2248 vki_uint64_t vki_kf_spareint64[30];
2249 /* Vnode filesystem id. */
2250 vki_uint64_t vki_kf_file_fsid;
2251 /* File device. */
2252 vki_uint64_t vki_kf_file_rdev;
2253 /* Global file id. */
2254 vki_uint64_t vki_kf_file_fileid;
2255 /* File size. */
2256 vki_uint64_t vki_kf_file_size;
2257 /* Vnode filesystem id, FreeBSD 11 compat. */
2258 vki_uint32_t vki_kf_file_fsid_freebsd11;
2259 /* File device, FreeBSD 11 compat. */
2260 vki_uint32_t kf_file_rdev_freebsd11;
2261 /* File mode. */
2262 vki_uint16_t vki_kf_file_mode;
2263 /* Round to 64 bit alignment. */
2264 vki_uint16_t vki_kf_file_pad0;
2265 vki_uint32_t kf_file_pad1;
2266 } kf_file;
2267 struct {
2268 vki_uint32_t vki_kf_spareint[4];
2269 vki_uint64_t vki_kf_spareint64[32];
2270 vki_uint32_t vki_kf_sem_value;
2271 vki_uint16_t vki_kf_sem_mode;
2272 } kf_sem;
2273 struct {
2274 vki_uint32_t vki_kf_spareint[4];
2275 vki_uint64_t vki_kf_spareint64[32];
2276 vki_uint64_t vki_kf_pipe_addr;
2277 vki_uint64_t vki_kf_pipe_peer;
2278 vki_uint32_t vki_kf_pipe_buffer_cnt;
2279 /* Round to 64 bit alignment. */
2280 vki_uint32_t vki_kf_pipe_pad0[3];
2281 } kf_pipe;
2282 struct {
2283 vki_uint32_t vki_kf_spareint[4];
2284 vki_uint64_t vki_kf_spareint64[32];
2285 vki_uint32_t vki_kf_pts_dev_freebsd11;
2286 vki_uint32_t vki_kf_pts_pad0;
2287 vki_uint64_t vki_kf_pts_dev;
2288 /* Round to 64 bit alignment. */
2289 vki_uint32_t vki_kf_pts_pad1[4];
2290 } kf_pts;
2291 struct {
2292 vki_uint32_t vki_kf_spareint[4];
2293 vki_uint64_t vki_kf_spareint64[32];
2294 vki_pid_t vki_kf_pid;
2295 } vki_kf_proc;
2296 struct {
2297 vki_uint64_t vki_kf_eventfd_value;
2298 vki_uint32_t vki_kf_eventfd_flags;
2299 } vki_kf_eventfd;
2300 } vki_kf_un;
2302 vki_uint16_t vki_kf_status; /* Status flags. */
2303 vki_uint16_t vki_kf_pad1; /* Round to 32 bit alignment. */
2304 int vki__kf_ispare0; /* Space for more stuff. */
2305 vki_cap_rights_t vki_kf_cap_rights; /* Capability rights. */
2306 vki_uint64_t vki__kf_cap_spare; /* Space for future cap_rights_t. */
2307 /* Truncated before copyout in sysctl */
2308 char vki_kf_path[VKI_PATH_MAX]; /* Path to file, if any. */
2311 //----------------------------------------------------------------------
2312 // From sys/kenv.h
2313 //----------------------------------------------------------------------
2314 #define VKI_KENV_GET 0
2315 #define VKI_KENV_SET 1
2316 #define VKI_KENV_UNSET 2
2317 #define VKI_KENV_DUMP 3
2319 //----------------------------------------------------------------------
2320 // From sys/sysctl.h (and related)
2321 //----------------------------------------------------------------------
2323 #include <sys/types.h>
2324 #include <sys/sysctl.h>
2326 #define VKI_CTL_KERN CTL_KERN
2327 #define VKI_CTL_HW CTL_HW
2328 #define VKI_KERN_PROC KERN_PROC
2329 #define VKI_KERN_PROC_VMMAP KERN_PROC_VMMAP
2330 #define VKI_KERN_PROC_FILEDESC KERN_PROC_FILEDESC
2331 #define VKI_HW_MACHINE HW_MACHINE
2333 //----------------------------------------------------------------------
2334 // From sys/thr.h
2335 //----------------------------------------------------------------------
2337 struct vki_thr_param {
2338 void (*start_func)(void *);
2339 void *arg;
2340 char *stack_base;
2341 vki_size_t stack_size;
2342 char *tls_base;
2343 vki_size_t tls_size;
2344 long *child_tid;
2345 long *parent_tid;
2346 int flags;
2347 struct vki_rtprio *rtp;
2348 void *spare[3];
2351 //----------------------------------------------------------------------
2352 // From sys/linker.h
2353 //----------------------------------------------------------------------
2355 struct vki_kld_file_stat {
2356 int version; /* set to sizeof(struct kld_file_stat) */
2357 char name[MAXPATHLEN];
2358 int refs;
2359 int id;
2360 vki_caddr_t address; /* load address */
2361 vki_size_t size; /* size in bytes */
2362 char pathname[MAXPATHLEN];
2366 struct vki_kld_sym_lookup {
2367 int version; /* set to sizeof(struct kld_sym_lookup) */
2368 char *symname; /* Symbol name we are looking up */
2369 unsigned long symvalue;
2370 vki_size_t symsize;
2373 #if !defined(VKI_INIT_ARCH_ELF_STATE)
2374 /* This structure is used to preserve architecture specific data during
2375 the loading of an ELF file, throughout the checking of architecture
2376 specific ELF headers & through to the point where the ELF load is
2377 known to be proceeding. This implementation is a dummy for
2378 architectures which require no specific state. */
2379 struct vki_arch_elf_state {
2382 # define VKI_INIT_ARCH_ELF_STATE { }
2384 #endif
2386 //----------------------------------------------------------------------
2387 // From ufs/ufs/quota.h
2388 //----------------------------------------------------------------------
2390 #define VKI_Q_QUOTAON 0x0100
2391 #define VKI_Q_QUOTAOFF 0x0200
2392 #define VKI_Q_GETQUOTA32 0x0300
2393 #define VKI_Q_SETQUOTA32 0x0400
2394 #define VKI_Q_SETUSE32 0x0500
2395 #define VKI_Q_SYNC 0x0600
2396 #define VKI_Q_GETQUOTA 0x0700
2397 #define VKI_Q_SETQUOTA 0x0800
2398 #define VKI_Q_SETUSE 0x0900
2399 #define VKI_Q_GETQUOTASIZE 0x0A00
2401 //----------------------------------------------------------------------
2402 // From sys/_bitset.h
2403 //----------------------------------------------------------------------
2405 #define VKI_BITSET_BITS (sizeof(long) * 8)
2407 #define vki__howmany(x, y) (((x) + ((y) - 1)) / (y))
2409 #define vki__bitset_words(_s) (vki__howmany(_s, VKI_BITSET_BITS))
2411 #define VKI_BITSET_DEFINE(t, _s) \
2412 struct t { \
2413 long __bits[vki__bitset_words((_s))]; \
2416 //----------------------------------------------------------------------
2417 // From sys/_domainset.h
2418 //----------------------------------------------------------------------
2420 #define VKI_DOMAINSET_MAXSIZE 256
2422 #ifndef VKI_DOMAINSET_SETSIZE
2423 #define VKI_DOMAINSET_SETSIZE VKI_DOMAINSET_MAXSIZE
2424 #endif
2426 VKI_BITSET_DEFINE(vki_domainset, VKI_DOMAINSET_SETSIZE);
2428 typedef struct vki_domainset vki_domainset_t;
2430 //----------------------------------------------------------------------
2431 // From sys/procctl.h
2432 //----------------------------------------------------------------------
2434 #define VKI_PROC_SPROTECT 1
2435 #define VKI_PROC_REAP_ACQUIRE 2
2436 #define VKI_PROC_REAP_RELEASE 3
2437 #define VKI_PROC_REAP_STATUS 4
2438 #define VKI_PROC_REAP_GETPIDS 5
2439 #define VKI_PROC_REAP_KILL 6
2440 #define VKI_PROC_TRACE_CTL 7
2441 #define VKI_PROC_TRACE_STATUS 8
2442 #define VKI_PROC_TRAPCAP_CTL 9
2443 #define VKI_PROC_TRAPCAP_STATUS 10
2444 #define VKI_PROC_PDEATHSIG_CTL 11
2445 #define VKI_PROC_PDEATHSIG_STATUS 12
2446 #define VKI_PROC_ASLR_CTL 13
2447 #define VKI_PROC_ASLR_STATUS 14
2448 #define VKI_PROC_STACKGAP_CTL 17
2449 #define VKI_PROC_STACKGAP_STATUS 18
2450 #define VKI_PROC_NO_NEW_PRIVS_CTL 19
2451 #define VKI_PROC_NO_NEW_PRIVS_STATUS 20
2452 #define VKI_PROC_WXMAP_CTL 21
2453 #define VKI_PROC_WXMAP_STATUS 22
2455 struct vki_procctl_reaper_status {
2456 u_int rs_flags;
2457 u_int rs_children;
2458 u_int rs_descendants;
2459 vki_pid_t rs_reaper;
2460 vki_pid_t rs_pid;
2461 u_int rs_pad0[15];
2464 struct vki_procctl_reaper_pidinfo;
2466 struct vki_procctl_reaper_pids {
2467 u_int rp_count;
2468 u_int rp_pad0[15];
2469 struct vki_procctl_reaper_pidinfo *rp_pids;
2472 struct vki_procctl_reaper_kill {
2473 int rk_sig;
2474 u_int rk_flags;
2475 vki_pid_t rk_subtree;
2476 u_int rk_killed;
2477 vki_pid_t rk_fpid;
2478 u_int rk_pad0[15];
2481 //----------------------------------------------------------------------
2482 // From sys/jail.h
2483 //----------------------------------------------------------------------
2485 struct vki_jail {
2486 uint32_t version;
2487 char *path;
2488 char *hostname;
2489 char *jailname;
2490 uint32_t ip4s;
2491 uint32_t ip6s;
2492 struct in_addr *ip4;
2493 struct in6_addr *ip6;
2496 //----------------------------------------------------------------------
2497 // From sys/exec.h
2498 //----------------------------------------------------------------------
2500 struct vki_ps_strings {
2501 char** ps_argvstr;
2502 unsigned int ps_nargvstr;
2504 char** ps_envstr;
2505 unsigned int ps_nenvstr;
2508 //----------------------------------------------------------------------
2509 // From sys/elf_common.h
2510 //----------------------------------------------------------------------
2512 #define VKI_AT_NULL 0
2513 #define VKI_AT_IGNORE 1
2514 #define VKI_AT_EXECFD 2
2515 #define VKI_AT_PHDR 3
2516 #define VKI_AT_PHENT 4
2517 #define VKI_AT_PHNUM 5
2518 #define VKI_AT_PAGESZ 6
2519 #define VKI_AT_BASE 7
2520 #define VKI_AT_FLAGS 8
2521 #define VKI_AT_ENTRY 9
2522 #define VKI_AT_NOTELF 10
2523 #define VKI_AT_UID 11
2524 #define VKI_AT_EUID 12
2525 #define VKI_AT_GID 13
2526 #define VKI_AT_EGID 14
2527 #define VKI_AT_EXECPATH 15
2528 #define VKI_AT_CANARY 16
2529 #define VKI_AT_CANARYLEN 17
2530 #define VKI_AT_OSRELDATE 18
2531 #define VKI_AT_NCPUS 19
2532 #define VKI_AT_PAGESIZES 20
2533 #define VKI_AT_PAGESIZESLEN 21
2534 #define VKI_AT_TIMEKEEP 22
2535 #define VKI_AT_STACKPROT 23
2536 #define VKI_AT_EHDRFLAGS 24
2537 #define VKI_AT_HWCAP 25
2538 #define VKI_AT_HWCAP2 26
2539 /* added in FreeBSD 13 */
2540 #define VKI_AT_BSDFLAGS 27
2541 #define VKI_AT_ARGC 28
2542 #define VKI_AT_ARGV 29
2543 #define VKI_AT_ENVC 30
2544 #define VKI_AT_ENVV 31
2545 #define VKI_AT_PS_STRINGS 32
2546 /* added in FreeBSD 13.1 */
2547 #define VKI_AT_FXRNG 33
2548 #define VKI_AT_KPRELOAD 34
2549 /* added in FreeBSD 14 */
2550 #define VKI_AT_USRSTACKBASE 35
2551 #define VKI_AT_USRSTACKLIM 36
2553 /* AT_COUNT depends on the FreeBSD version, not currently used */
2556 #define VKI_NT_FREEBSD_ABI_TAG 1
2557 #define VKI_NT_FREEBSD_FEATURE_CTL 4
2558 #define VKI_NT_FREEBSD_FCTL_WXNEEDED 0x00000008
2560 // See syswrap-freebsd.c PRE/POST(sys_ioctl)
2561 #if 0
2563 //----------------------------------------------------------------------
2564 // From sys/pciio.h
2565 //----------------------------------------------------------------------
2567 typedef unsigned long vki_u_long;
2568 typedef unsigned int vki_u_int;
2569 #define VKI_PCI_MAXNAMELEN 16
2571 typedef enum {
2572 VKI_PCI_GETCONF_LAST_DEVICE,
2573 VKI_PCI_GETCONF_LIST_CHANGED,
2574 VKI_PCI_GETCONF_MORE_DEVS,
2575 VKI_PCI_GETCONF_ERROR
2576 } vki_pci_getconf_status;
2578 typedef enum {
2579 VKI_PCI_GETCONF_NO_MATCH = 0x0000,
2580 VKI_PCI_GETCONF_MATCH_DOMAIN = 0x0001,
2581 VKI_PCI_GETCONF_MATCH_BUS = 0x0002,
2582 VKI_PCI_GETCONF_MATCH_DEV = 0x0004,
2583 VKI_PCI_GETCONF_MATCH_FUNC = 0x0008,
2584 VKI_PCI_GETCONF_MATCH_NAME = 0x0010,
2585 VKI_PCI_GETCONF_MATCH_UNIT = 0x0020,
2586 VKI_PCI_GETCONF_MATCH_VENDOR = 0x0040,
2587 VKI_PCI_GETCONF_MATCH_DEVICE = 0x0080,
2588 VKI_PCI_GETCONF_MATCH_CLASS = 0x0100
2589 } vki_pci_getconf_flags;
2591 struct vki_pcisel {
2592 vki_uint32_t pc_domain; /* domain number */
2593 vki_uint8_t pc_bus; /* bus number */
2594 vki_uint8_t pc_dev; /* device on this bus */
2595 vki_uint8_t pc_func; /* function on this device */
2598 struct vki_pci_conf {
2599 struct vki_pcisel pc_sel; /* domain+bus+slot+function */
2600 vki_uint8_t pc_hdr; /* PCI header type */
2601 vki_uint16_t pc_subvendor; /* card vendor ID */
2602 vki_uint16_t pc_subdevice; /* card device ID, assigned by
2603 card vendor */
2604 vki_uint16_t pc_vendor; /* chip vendor ID */
2605 vki_uint16_t pc_device; /* chip device ID, assigned by
2606 chip vendor */
2607 vki_uint8_t pc_class; /* chip PCI class */
2608 vki_uint8_t pc_subclass; /* chip PCI subclass */
2609 vki_uint8_t pc_progif; /* chip PCI programming interface */
2610 vki_uint8_t pc_revid; /* chip revision ID */
2611 char pd_name[VKI_PCI_MAXNAMELEN + 1]; /* device name */
2612 vki_u_long pd_unit; /* device unit number */
2615 struct vki_pci_match_conf {
2616 struct vki_pcisel pc_sel; /* domain+bus+slot+function */
2617 char pd_name[VKI_PCI_MAXNAMELEN + 1]; /* device name */
2618 vki_u_long pd_unit; /* Unit number */
2619 vki_uint16_t pc_vendor; /* PCI Vendor ID */
2620 vki_uint16_t pc_device; /* PCI Device ID */
2621 vki_uint8_t pc_class; /* PCI class */
2622 vki_pci_getconf_flags flags; /* Matching expression */
2625 struct vki_pci_conf_io {
2626 vki_uint32_t pat_buf_len; /* pattern buffer length */
2627 vki_uint32_t num_patterns; /* number of patterns */
2628 struct vki_pci_match_conf *patterns; /* pattern buffer */
2629 vki_uint32_t match_buf_len; /* match buffer length */
2630 vki_uint32_t num_matches; /* number of matches returned */
2631 struct vki_pci_conf *matches; /* match buffer */
2632 vki_uint32_t offset; /* offset into device list */
2633 vki_uint32_t generation; /* device list generation */
2634 vki_pci_getconf_status status; /* request status */
2637 #define VKI_PCIOCGETCONF _VKI_IOWR('p', 5, struct vki_pci_conf_io)
2639 //----------------------------------------------------------------------
2640 // From cam/cam.h
2641 //----------------------------------------------------------------------
2643 #define VKI_CAM_MAX_CDBLEN 16
2645 typedef unsigned int vki_path_id_t;
2646 typedef unsigned int vki_target_id_t;
2647 typedef unsigned int vki_lun_id_t;
2649 typedef struct {
2650 vki_uint32_t priority;
2651 vki_uint32_t generation;
2652 int index;
2653 } vki_cam_pinfo;
2656 //----------------------------------------------------------------------
2657 // From sys/ata.h
2658 //----------------------------------------------------------------------
2660 struct vki_ata_params {
2661 /*000*/ vki_u_int16_t config; /* configuration info */
2662 /*001*/ vki_u_int16_t cylinders; /* # of cylinders */
2663 /*002*/ vki_u_int16_t specconf; /* specific configuration */
2664 /*003*/ vki_u_int16_t heads; /* # heads */
2665 vki_u_int16_t obsolete4;
2666 vki_u_int16_t obsolete5;
2667 /*006*/ vki_u_int16_t sectors; /* # sectors/track */
2668 /*007*/ vki_u_int16_t vendor7[3];
2669 /*010*/ vki_u_int8_t serial[20]; /* serial number */
2670 /*020*/ vki_u_int16_t retired20;
2671 vki_u_int16_t retired21;
2672 vki_u_int16_t obsolete22;
2673 /*023*/ vki_u_int8_t revision[8]; /* firmware revision */
2674 /*027*/ vki_u_int8_t model[40]; /* model name */
2675 /*047*/ vki_u_int16_t sectors_intr; /* sectors per interrupt */
2676 /*048*/ vki_u_int16_t usedmovsd; /* double word read/write? */
2677 /*049*/ vki_u_int16_t capabilities1;
2678 /*050*/ vki_u_int16_t capabilities2;
2679 /*051*/ vki_u_int16_t retired_piomode; /* PIO modes 0-2 */
2680 /*052*/ vki_u_int16_t retired_dmamode; /* DMA modes */
2681 /*053*/ vki_u_int16_t atavalid; /* fields valid */
2682 /*054*/ vki_u_int16_t current_cylinders;
2683 /*055*/ vki_u_int16_t current_heads;
2684 /*056*/ vki_u_int16_t current_sectors;
2685 /*057*/ vki_u_int16_t current_size_1;
2686 /*058*/ vki_u_int16_t current_size_2;
2687 /*059*/ vki_u_int16_t multi;
2688 /*060*/ vki_u_int16_t lba_size_1;
2689 vki_u_int16_t lba_size_2;
2690 vki_u_int16_t obsolete62;
2691 /*063*/ vki_u_int16_t mwdmamodes; /* multiword DMA modes */
2692 /*064*/ vki_u_int16_t apiomodes; /* advanced PIO modes */
2694 /*065*/ vki_u_int16_t mwdmamin; /* min. M/W DMA time/word ns */
2695 /*066*/ vki_u_int16_t mwdmarec; /* rec. M/W DMA time ns */
2696 /*067*/ vki_u_int16_t pioblind; /* min. PIO cycle w/o flow */
2697 /*068*/ vki_u_int16_t pioiordy; /* min. PIO cycle IORDY flow */
2698 /*069*/ vki_u_int16_t support3;
2699 vki_u_int16_t reserved70;
2700 /*071*/ vki_u_int16_t rlsovlap; /* rel time (us) for overlap */
2701 /*072*/ vki_u_int16_t rlsservice; /* rel time (us) for service */
2702 vki_u_int16_t reserved73;
2703 vki_u_int16_t reserved74;
2704 /*075*/ vki_u_int16_t queue;
2705 /*76*/ vki_u_int16_t satacapabilities;
2706 /*77*/ vki_u_int16_t satacapabilities2;
2707 /*78*/ vki_u_int16_t satasupport;
2708 /*79*/ vki_u_int16_t sataenabled;
2709 /*080*/ vki_u_int16_t version_major;
2710 /*081*/ vki_u_int16_t version_minor;
2712 struct {
2713 /*082/085*/ vki_u_int16_t command1;
2714 /*083/086*/ vki_u_int16_t command2;
2715 /*084/087*/ vki_u_int16_t extension;
2716 } __packed support, enabled;
2718 /*088*/ vki_u_int16_t udmamodes; /* UltraDMA modes */
2719 /*089*/ vki_u_int16_t erase_time;
2720 /*090*/ vki_u_int16_t enhanced_erase_time;
2721 /*091*/ vki_u_int16_t apm_value;
2722 /*092*/ vki_u_int16_t master_passwd_revision;
2723 /*093*/ vki_u_int16_t hwres;
2724 /*094*/ vki_u_int16_t acoustic;
2725 /*095*/ vki_u_int16_t stream_min_req_size;
2726 /*096*/ vki_u_int16_t stream_transfer_time;
2727 /*097*/ vki_u_int16_t stream_access_latency;
2728 /*098*/ vki_u_int32_t stream_granularity;
2729 /*100*/ vki_u_int16_t lba_size48_1;
2730 vki_u_int16_t lba_size48_2;
2731 vki_u_int16_t lba_size48_3;
2732 vki_u_int16_t lba_size48_4;
2733 vki_u_int16_t reserved104;
2734 /*105*/ vki_u_int16_t max_dsm_blocks;
2735 /*106*/ vki_u_int16_t pss;
2736 /*107*/ vki_u_int16_t isd;
2737 /*108*/ vki_u_int16_t wwn[4];
2738 vki_u_int16_t reserved112[5];
2739 /*117*/ vki_u_int16_t lss_1;
2740 /*118*/ vki_u_int16_t lss_2;
2741 /*119*/ vki_u_int16_t support2;
2742 /*120*/ vki_u_int16_t enabled2;
2743 vki_u_int16_t reserved121[6];
2744 /*127*/ vki_u_int16_t removable_status;
2745 /*128*/ vki_u_int16_t security_status;
2746 vki_u_int16_t reserved129[31];
2747 /*160*/ vki_u_int16_t cfa_powermode1;
2748 vki_u_int16_t reserved161;
2749 /*162*/ vki_u_int16_t cfa_kms_support;
2750 /*163*/ vki_u_int16_t cfa_trueide_modes;
2751 /*164*/ vki_u_int16_t cfa_memory_modes;
2752 vki_u_int16_t reserved165[4];
2753 /*169*/ vki_u_int16_t support_dsm;
2754 vki_u_int16_t reserved170[6];
2755 /*176*/ vki_u_int8_t media_serial[60];
2756 /*206*/ vki_u_int16_t sct;
2757 vki_u_int16_t reserved206[2];
2758 /*209*/ vki_u_int16_t lsalign;
2759 /*210*/ vki_u_int16_t wrv_sectors_m3_1;
2760 vki_u_int16_t wrv_sectors_m3_2;
2761 /*212*/ vki_u_int16_t wrv_sectors_m2_1;
2762 vki_u_int16_t wrv_sectors_m2_2;
2763 /*214*/ vki_u_int16_t nv_cache_caps;
2764 /*215*/ vki_u_int16_t nv_cache_size_1;
2765 vki_u_int16_t nv_cache_size_2;
2766 /*217*/ vki_u_int16_t media_rotation_rate;
2767 vki_u_int16_t reserved218;
2768 /*219*/ vki_u_int16_t nv_cache_opt;
2769 /*220*/ vki_u_int16_t wrv_mode;
2770 vki_u_int16_t reserved221;
2771 /*222*/ vki_u_int16_t transport_major;
2772 /*223*/ vki_u_int16_t transport_minor;
2773 vki_u_int16_t reserved224[31];
2774 /*255*/ vki_u_int16_t integrity;
2775 } __packed;
2777 //----------------------------------------------------------------------
2778 // From sys/callout.h
2779 //----------------------------------------------------------------------
2781 struct vki_callout_handle {
2782 struct vki_callout *callout;
2786 //----------------------------------------------------------------------
2787 // From cam/scsi/scsi_all.h
2788 //----------------------------------------------------------------------
2790 struct vki_scsi_sense_data {
2791 vki_u_int8_t error_code;
2792 vki_u_int8_t segment;
2793 vki_u_int8_t flags;
2794 vki_u_int8_t info[4];
2795 vki_u_int8_t extra_len;
2796 vki_u_int8_t cmd_spec_info[4];
2797 vki_u_int8_t add_sense_code;
2798 vki_u_int8_t add_sense_code_qual;
2799 vki_u_int8_t fru;
2800 vki_u_int8_t sense_key_spec[3];
2801 vki_u_int8_t extra_bytes[14];
2802 #define VKI_SSD_FULL_SIZE sizeof(struct vki_scsi_sense_data)
2805 struct vki_scsi_inquiry_data {
2806 vki_uint8_t device;
2807 vki_uint8_t dev_qual2;
2808 vki_uint8_t version;
2809 vki_uint8_t response_format;
2810 vki_uint8_t additional_length;
2811 vki_uint8_t spc3_flags;
2812 vki_uint8_t spc2_flags;
2813 vki_uint8_t flags;
2814 #define VKI_SID_VENDOR_SIZE 8
2815 char vendor[VKI_SID_VENDOR_SIZE];
2816 #define VKI_SID_PRODUCT_SIZE 16
2817 char product[VKI_SID_PRODUCT_SIZE];
2818 #define VKI_SID_REVISION_SIZE 4
2819 char revision[VKI_SID_REVISION_SIZE];
2820 #define VKI_SID_VENDOR_SPECIFIC_0_SIZE 20
2821 vki_uint8_t vendor_specific0[VKI_SID_VENDOR_SPECIFIC_0_SIZE];
2822 vki_uint8_t spi3data;
2823 vki_uint8_t reserved2;
2825 * Version Descriptors, stored 2 byte values.
2827 vki_uint8_t version1[2];
2828 vki_uint8_t version2[2];
2829 vki_uint8_t version3[2];
2830 vki_uint8_t version4[2];
2831 vki_uint8_t version5[2];
2832 vki_uint8_t version6[2];
2833 vki_uint8_t version7[2];
2834 vki_uint8_t version8[2];
2836 vki_uint8_t reserved3[22];
2838 #define VKI_SID_VENDOR_SPECIFIC_1_SIZE 160
2839 vki_uint8_t vendor_specific1[VKI_SID_VENDOR_SPECIFIC_1_SIZE];
2842 //----------------------------------------------------------------------
2843 // From sys/queue.h
2844 //----------------------------------------------------------------------
2846 #define SLIST_ENTRY(type) \
2847 struct { \
2848 struct type *sle_next; /* next element */ \
2851 #define LIST_ENTRY(type) \
2852 struct { \
2853 struct type *le_next; /* next element */ \
2854 struct type **le_prev; /* address of previous next element */ \
2857 #define STAILQ_ENTRY(type) \
2858 struct { \
2859 struct type *stqe_next; /* next element */ \
2862 struct qm_trace {
2863 unsigned long lastline;
2864 unsigned long prevline;
2865 const char *lastfile;
2866 const char *prevfile;
2869 #define TRACEBUF struct qm_trace trace;
2871 #define TAILQ_ENTRY(type) \
2872 struct { \
2873 struct type *tqe_next; /* next element */ \
2874 struct type **tqe_prev; /* address of previous next element */ \
2875 TRACEBUF \
2879 //----------------------------------------------------------------------
2880 // From cam/cam_ccb.h
2881 //----------------------------------------------------------------------
2883 #define VKI_CAM_VERSION 0x15 /* Hex value for current version */
2885 typedef union {
2886 LIST_ENTRY(vki_ccb_hdr) le;
2887 SLIST_ENTRY(vki_ccb_hdr) sle;
2888 TAILQ_ENTRY(vki_ccb_hdr) tqe;
2889 STAILQ_ENTRY(vki_ccb_hdr) stqe;
2890 } vki_camq_entry;
2892 typedef enum {
2893 /* Function code flags are bits greater than 0xff */
2894 VKI_XPT_FC_QUEUED = 0x100,
2895 /* Non-immediate function code */
2896 VKI_XPT_FC_USER_CCB = 0x200,
2897 VKI_XPT_FC_XPT_ONLY = 0x400,
2898 /* Only for the transport layer device */
2899 VKI_XPT_FC_DEV_QUEUED = 0x800 | VKI_XPT_FC_QUEUED,
2900 /* Passes through the device queues */
2901 /* Common function commands: 0x00->0x0F */
2902 VKI_XPT_NOOP = 0x00,
2903 /* Execute Nothing */
2904 VKI_XPT_SCSI_IO = 0x01 | VKI_XPT_FC_DEV_QUEUED,
2905 /* Execute the requested I/O operation */
2906 VKI_XPT_GDEV_TYPE = 0x02,
2907 /* Get type information for specified device */
2908 VKI_XPT_GDEVLIST = 0x03,
2909 /* Get a list of peripheral devices */
2910 VKI_XPT_PATH_INQ = 0x04,
2911 /* Path routing inquiry */
2912 VKI_XPT_REL_SIMQ = 0x05,
2913 /* Release a frozen device queue */
2914 VKI_XPT_SASYNC_CB = 0x06,
2915 /* Set Asynchronous Callback Parameters */
2916 VKI_XPT_SDEV_TYPE = 0x07,
2917 /* Set device type information */
2918 VKI_XPT_SCAN_BUS = 0x08 | VKI_XPT_FC_QUEUED | VKI_XPT_FC_USER_CCB
2919 | VKI_XPT_FC_XPT_ONLY,
2920 /* (Re)Scan the SCSI Bus */
2921 VKI_XPT_DEV_MATCH = 0x09 | VKI_XPT_FC_XPT_ONLY,
2922 /* Get EDT entries matching the given pattern */
2923 VKI_XPT_DEBUG = 0x0a,
2924 /* Turn on debugging for a bus, target or lun */
2925 VKI_XPT_PATH_STATS = 0x0b,
2926 /* Path statistics (error counts, etc.) */
2927 VKI_XPT_GDEV_STATS = 0x0c,
2928 /* Device statistics (error counts, etc.) */
2929 VKI_XPT_FREEZE_QUEUE = 0x0d,
2930 /* Freeze device queue */
2931 /* SCSI Control Functions: 0x10->0x1F */
2932 VKI_XPT_ABORT = 0x10,
2933 /* Abort the specified CCB */
2934 VKI_XPT_RESET_BUS = 0x11 | VKI_XPT_FC_XPT_ONLY,
2935 /* Reset the specified SCSI bus */
2936 VKI_XPT_RESET_DEV = 0x12 | VKI_XPT_FC_DEV_QUEUED,
2937 /* Bus Device Reset the specified SCSI device */
2938 VKI_XPT_TERM_IO = 0x13,
2939 /* Terminate the I/O process */
2940 VKI_XPT_SCAN_LUN = 0x14 | VKI_XPT_FC_QUEUED | VKI_XPT_FC_USER_CCB
2941 | VKI_XPT_FC_XPT_ONLY,
2942 /* Scan Logical Unit */
2943 VKI_XPT_GET_TRAN_SETTINGS = 0x15,
2945 * Get default/user transfer settings
2946 * for the target
2948 VKI_XPT_SET_TRAN_SETTINGS = 0x16,
2950 * Set transfer rate/width
2951 * negotiation settings
2953 VKI_XPT_CALC_GEOMETRY = 0x17,
2955 * Calculate the geometry parameters for
2956 * a device give the sector size and
2957 * volume size.
2959 VKI_XPT_ATA_IO = 0x18 | VKI_XPT_FC_DEV_QUEUED,
2960 /* Execute the requested ATA I/O operation */
2961 VKI_XPT_GET_SIM_KNOB = 0x18,
2963 * Get SIM specific knob values.
2966 VKI_XPT_SET_SIM_KNOB = 0x19,
2968 * Set SIM specific knob values.
2970 /* HBA engine commands 0x20->0x2F */
2971 VKI_XPT_ENG_INQ = 0x20 | VKI_XPT_FC_XPT_ONLY,
2972 /* HBA engine feature inquiry */
2973 VKI_XPT_ENG_EXEC = 0x21 | VKI_XPT_FC_DEV_QUEUED,
2974 /* HBA execute engine request */
2976 /* Target mode commands: 0x30->0x3F */
2977 VKI_XPT_EN_LUN = 0x30,
2978 /* Enable LUN as a target */
2979 VKI_XPT_TARGET_IO = 0x31 | VKI_XPT_FC_DEV_QUEUED,
2980 /* Execute target I/O request */
2981 VKI_XPT_ACCEPT_TARGET_IO = 0x32 | VKI_XPT_FC_QUEUED | VKI_XPT_FC_USER_CCB,
2982 /* Accept Host Target Mode CDB */
2983 VKI_XPT_CONT_TARGET_IO = 0x33 | VKI_XPT_FC_DEV_QUEUED,
2984 /* Continue Host Target I/O Connection */
2985 VKI_XPT_IMMED_NOTIFY = 0x34 | VKI_XPT_FC_QUEUED | VKI_XPT_FC_USER_CCB,
2986 /* Notify Host Target driver of event (obsolete) */
2987 VKI_XPT_NOTIFY_ACK = 0x35,
2988 /* Acknowledgement of event (obsolete) */
2989 VKI_XPT_IMMEDIATE_NOTIFY = 0x36 | VKI_XPT_FC_QUEUED | VKI_XPT_FC_USER_CCB,
2990 /* Notify Host Target driver of event */
2991 VKI_XPT_NOTIFY_ACKNOWLEDGE = 0x37 | VKI_XPT_FC_QUEUED | VKI_XPT_FC_USER_CCB,
2992 /* Acknowledgement of event */
2994 /* Vendor Unique codes: 0x80->0x8F */
2995 VKI_XPT_VUNIQUE = 0x80
2996 } vki_xpt_opcode;
2999 /* CAM CCB flags */
3000 typedef enum {
3001 VKI_CAM_CDB_POINTER = 0x00000001,/* The CDB field is a pointer */
3002 VKI_CAM_QUEUE_ENABLE = 0x00000002,/* SIM queue actions are enabled */
3003 VKI_CAM_CDB_LINKED = 0x00000004,/* CCB contains a linked CDB */
3004 VKI_CAM_NEGOTIATE = 0x00000008,/*
3005 * Perform transport negotiation
3006 * with this command.
3008 VKI_CAM_SCATTER_VALID = 0x00000010,/* Scatter/gather list is valid */
3009 VKI_CAM_DIS_AUTOSENSE = 0x00000020,/* Disable autosense feature */
3010 VKI_CAM_DIR_RESV = 0x00000000,/* Data direction (00:reserved) */
3011 VKI_CAM_DIR_IN = 0x00000040,/* Data direction (01:DATA IN) */
3012 VKI_CAM_DIR_OUT = 0x00000080,/* Data direction (10:DATA OUT) */
3013 VKI_CAM_DIR_NONE = 0x000000C0,/* Data direction (11:no data) */
3014 VKI_CAM_DIR_MASK = 0x000000C0,/* Data direction Mask */
3015 VKI_CAM_SOFT_RST_OP = 0x00000100,/* Use Soft reset alternative */
3016 VKI_CAM_ENG_SYNC = 0x00000200,/* Flush resid bytes on complete */
3017 VKI_CAM_DEV_QFRZDIS = 0x00000400,/* Disable DEV Q freezing */
3018 VKI_CAM_DEV_QFREEZE = 0x00000800,/* Freeze DEV Q on execution */
3019 VKI_CAM_HIGH_POWER = 0x00001000,/* Command takes a lot of power */
3020 VKI_CAM_SENSE_PTR = 0x00002000,/* Sense data is a pointer */
3021 VKI_CAM_SENSE_PHYS = 0x00004000,/* Sense pointer is physical addr*/
3022 VKI_CAM_TAG_ACTION_VALID = 0x00008000,/* Use the tag action in this ccb*/
3023 VKI_CAM_PASS_ERR_RECOVER = 0x00010000,/* Pass driver does err. recovery*/
3024 VKI_CAM_DIS_DISCONNECT = 0x00020000,/* Disable disconnect */
3025 VKI_CAM_SG_LIST_PHYS = 0x00040000,/* SG list has physical addrs. */
3026 VKI_CAM_MSG_BUF_PHYS = 0x00080000,/* Message buffer ptr is physical*/
3027 VKI_CAM_SNS_BUF_PHYS = 0x00100000,/* Autosense data ptr is physical*/
3028 VKI_CAM_DATA_PHYS = 0x00200000,/* SG/Buffer data ptrs are phys. */
3029 VKI_CAM_CDB_PHYS = 0x00400000,/* CDB poiner is physical */
3030 VKI_CAM_ENG_SGLIST = 0x00800000,/* SG list is for the HBA engine */
3032 /* Phase cognizant mode flags */
3033 VKI_CAM_DIS_AUTOSRP = 0x01000000,/* Disable autosave/restore ptrs */
3034 VKI_CAM_DIS_AUTODISC = 0x02000000,/* Disable auto disconnect */
3035 VKI_CAM_TGT_CCB_AVAIL = 0x04000000,/* Target CCB available */
3036 VKI_CAM_TGT_PHASE_MODE = 0x08000000,/* The SIM runs in phase mode */
3037 VKI_CAM_MSGB_VALID = 0x10000000,/* Message buffer valid */
3038 VKI_CAM_STATUS_VALID = 0x20000000,/* Status buffer valid */
3039 VKI_CAM_DATAB_VALID = 0x40000000,/* Data buffer valid */
3041 /* Host target Mode flags */
3042 VKI_CAM_SEND_SENSE = 0x08000000,/* Send sense data with status */
3043 VKI_CAM_TERM_IO = 0x10000000,/* Terminate I/O Message sup. */
3044 VKI_CAM_DISCONNECT = 0x20000000,/* Disconnects are mandatory */
3045 VKI_CAM_SEND_STATUS = 0x40000000 /* Send status after data phase */
3046 } vki_ccb_flags;
3048 typedef union {
3049 void *ptr;
3050 vki_u_long field;
3051 vki_uint8_t bytes[sizeof(vki_uintptr_t)];
3052 } vki_ccb_priv_entry;
3054 #define VKI_IOCDBLEN VKI_CAM_MAX_CDBLEN /* Space for CDB bytes/pointer */
3055 #define VKI_CCB_PERIPH_PRIV_SIZE 2 /* size of peripheral private area */
3056 #define VKI_CCB_SIM_PRIV_SIZE 2 /* size of sim private area */
3058 typedef union {
3059 vki_ccb_priv_entry entries[VKI_CCB_PERIPH_PRIV_SIZE];
3060 vki_uint8_t bytes[VKI_CCB_PERIPH_PRIV_SIZE * sizeof(vki_ccb_priv_entry)];
3061 } vki_ccb_ppriv_area;
3063 typedef union {
3064 vki_ccb_priv_entry entries[VKI_CCB_SIM_PRIV_SIZE];
3065 vki_uint8_t bytes[VKI_CCB_SIM_PRIV_SIZE * sizeof(vki_ccb_priv_entry)];
3066 } vki_ccb_spriv_area;
3068 union vki_ccb;
3069 struct vki_cam_periph;
3071 struct vki_ccb_hdr {
3072 vki_cam_pinfo pinfo; /* Info for priority scheduling */
3073 vki_camq_entry xpt_links; /* For chaining in the XPT layer */
3074 vki_camq_entry sim_links; /* For chaining in the SIM layer */
3075 vki_camq_entry periph_links; /* For chaining in the type driver */
3076 vki_uint32_t retry_count;
3077 void (*cbfcnp)(struct vki_cam_periph *, union vki_ccb *);
3078 /* Callback on completion function */
3079 vki_xpt_opcode func_code; /* XPT function code */
3080 vki_uint32_t status; /* Status returned by CAM subsystem */
3081 struct vki_cam_path *path; /* Compiled path for this ccb */
3082 vki_path_id_t path_id; /* Path ID for the request */
3083 vki_target_id_t target_id; /* Target device ID */
3084 vki_lun_id_t target_lun; /* Target LUN number */
3085 vki_uint32_t flags; /* ccb_flags */
3086 vki_ccb_ppriv_area periph_priv;
3087 vki_ccb_spriv_area sim_priv;
3088 vki_uint32_t timeout; /* Timeout value */
3091 * Deprecated, only for use by non-MPSAFE SIMs. All others must
3092 * allocate and initialize their own callout storage.
3094 struct vki_callout_handle timeout_ch;
3097 typedef union {
3098 vki_u_int8_t *cdb_ptr; /* Pointer to the CDB bytes to send */
3099 /* Area for the CDB send */
3100 vki_u_int8_t cdb_bytes[VKI_IOCDBLEN];
3101 } vki_cdb_t;
3105 * SCSI I/O Request CCB used for the XPT_SCSI_IO and XPT_CONT_TARGET_IO
3106 * function codes.
3108 struct vki_ccb_scsiio {
3109 struct vki_ccb_hdr ccb_h;
3110 union vki_ccb *next_ccb; /* Ptr for next CCB for action */
3111 vki_u_int8_t *req_map; /* Ptr to mapping info */
3112 vki_u_int8_t *data_ptr; /* Ptr to the data buf/SG list */
3113 vki_u_int32_t dxfer_len; /* Data transfer length */
3114 /* Autosense storage */
3115 struct vki_scsi_sense_data sense_data;
3116 vki_u_int8_t sense_len; /* Number of bytes to autosense */
3117 vki_u_int8_t cdb_len; /* Number of bytes for the CDB */
3118 vki_u_int16_t sglist_cnt; /* Number of SG list entries */
3119 vki_u_int8_t scsi_status; /* Returned SCSI status */
3120 vki_u_int8_t sense_resid; /* Autosense resid length: 2's comp */
3121 vki_u_int32_t resid; /* Transfer residual length: 2's comp */
3122 vki_cdb_t cdb_io; /* Union for CDB bytes/pointer */
3123 vki_u_int8_t *msg_ptr; /* Pointer to the message buffer */
3124 vki_u_int16_t msg_len; /* Number of bytes for the Message */
3125 vki_u_int8_t tag_action; /* What to do for tag queueing */
3127 * The tag action should be either the define below (to send a
3128 * non-tagged transaction) or one of the defined scsi tag messages
3129 * from scsi_message.h.
3131 vki_u_int tag_id; /* tag id from initator (target mode) */
3132 vki_u_int init_id; /* initiator id of who selected */
3135 typedef enum {
3136 VKI_CAM_DEV_MATCH_LAST,
3137 VKI_CAM_DEV_MATCH_MORE,
3138 VKI_CAM_DEV_MATCH_LIST_CHANGED,
3139 VKI_CAM_DEV_MATCH_SIZE_ERROR,
3140 VKI_CAM_DEV_MATCH_ERROR
3141 } vki_ccb_dev_match_status;
3144 struct vki_dev_match_pattern;
3146 typedef enum {
3147 VKI_DEV_MATCH_PERIPH,
3148 VKI_DEV_MATCH_DEVICE,
3149 VKI_DEV_MATCH_BUS
3150 } vki_dev_match_type;
3152 #define VKI_DEV_IDLEN 16 /* ASCII string len for device names */
3154 struct vki_periph_match_result {
3155 char periph_name[VKI_DEV_IDLEN];
3156 vki_uint32_t unit_number;
3157 vki_path_id_t path_id;
3158 vki_target_id_t target_id;
3159 vki_lun_id_t target_lun;
3162 typedef enum {
3163 VKI_PROTO_UNKNOWN,
3164 VKI_PROTO_UNSPECIFIED,
3165 VKI_PROTO_SCSI, /* Small Computer System Interface */
3166 VKI_PROTO_ATA, /* AT Attachment */
3167 VKI_PROTO_ATAPI, /* AT Attachment Packetized Interface */
3168 VKI_PROTO_SATAPM, /* SATA Port Multiplier */
3169 } vki_cam_proto;
3171 typedef enum {
3172 VKI_DEV_RESULT_NOFLAG = 0x00,
3173 VKI_DEV_RESULT_UNCONFIGURED = 0x01
3174 } vki_dev_result_flags;
3177 struct vki_device_match_result {
3178 vki_path_id_t path_id;
3179 vki_target_id_t target_id;
3180 vki_lun_id_t target_lun;
3181 vki_cam_proto protocol;
3182 struct vki_scsi_inquiry_data inq_data;
3183 struct vki_ata_params ident_data;
3184 vki_dev_result_flags flags;
3187 struct vki_bus_match_result {
3188 vki_path_id_t path_id;
3189 char dev_name[VKI_DEV_IDLEN];
3190 vki_uint32_t unit_number;
3191 vki_uint32_t bus_id;
3194 union vki_match_result {
3195 struct vki_periph_match_result periph_result;
3196 struct vki_device_match_result device_result;
3197 struct vki_bus_match_result bus_result;
3200 struct vki_dev_match_result {
3201 vki_dev_match_type type;
3202 union vki_match_result result;
3205 typedef enum {
3206 VKI_CAM_DEV_POS_NONE = 0x000,
3207 VKI_CAM_DEV_POS_BUS = 0x001,
3208 VKI_CAM_DEV_POS_TARGET = 0x002,
3209 VKI_CAM_DEV_POS_DEVICE = 0x004,
3210 VKI_CAM_DEV_POS_PERIPH = 0x008,
3211 VKI_CAM_DEV_POS_PDPTR = 0x010,
3212 VKI_CAM_DEV_POS_TYPEMASK = 0xf00,
3213 VKI_CAM_DEV_POS_EDT = 0x100,
3214 VKI_CAM_DEV_POS_PDRV = 0x200
3215 } vki_dev_pos_type;
3217 struct vki_ccb_dm_cookie {
3218 void *bus;
3219 void *target;
3220 void *device;
3221 void *periph;
3222 void *pdrv;
3225 struct vki_ccb_dev_position {
3226 vki_u_int generations[4];
3227 #define VKI_CAM_BUS_GENERATION 0x00
3228 #define VKI_CAM_TARGET_GENERATION 0x01
3229 #define VKI_CAM_DEV_GENERATION 0x02
3230 #define VKI_CAM_PERIPH_GENERATION 0x03
3231 vki_dev_pos_type position_type;
3232 struct vki_ccb_dm_cookie cookie;
3235 struct vki_ccb_dev_match {
3236 struct vki_ccb_hdr ccb_h;
3237 vki_ccb_dev_match_status status;
3238 vki_uint32_t num_patterns;
3239 vki_uint32_t pattern_buf_len;
3240 struct vki_dev_match_pattern *patterns;
3241 vki_uint32_t num_matches;
3242 vki_uint32_t match_buf_len;
3243 struct vki_dev_match_result *matches;
3244 struct vki_ccb_dev_position pos;
3248 * Union of all CCB types for kernel space allocation. This union should
3249 * never be used for manipulating CCBs - its only use is for the allocation
3250 * and deallocation of raw CCB space and is the return type of xpt_ccb_alloc
3251 * and the argument to xpt_ccb_free.
3253 union vki_ccb {
3254 /* Only letting out ones currently handled */
3255 struct vki_ccb_hdr ccb_h; /* For convenience */
3256 struct vki_ccb_scsiio csio;
3257 #if 0
3258 struct ccb_getdev cgd;
3259 struct ccb_getdevlist cgdl;
3260 struct ccb_pathinq cpi;
3261 struct ccb_relsim crs;
3262 struct ccb_setasync csa;
3263 struct ccb_setdev csd;
3264 struct ccb_pathstats cpis;
3265 struct ccb_getdevstats cgds;
3266 #endif
3267 struct vki_ccb_dev_match cdm;
3268 #if 0
3269 struct ccb_trans_settings cts;
3270 struct ccb_calc_geometry ccg;
3271 struct ccb_sim_knob knob;
3272 struct ccb_abort cab;
3273 struct ccb_resetbus crb;
3274 struct ccb_resetdev crd;
3275 struct ccb_termio tio;
3276 struct ccb_accept_tio atio;
3277 struct ccb_scsiio ctio;
3278 struct ccb_en_lun cel;
3279 struct ccb_immed_notify cin;
3280 struct ccb_notify_ack cna;
3281 struct ccb_immediate_notify cin1;
3282 struct ccb_notify_acknowledge cna2;
3283 struct ccb_eng_inq cei;
3284 struct ccb_eng_exec cee;
3285 struct ccb_rescan crcn;
3286 struct ccb_debug cdbg;
3287 struct ccb_ataio ataio;
3288 #endif
3289 char make_union_right_size[0x4A8];
3292 #define VKI_CAMIOCOMMAND _VKI_IOWR(VKI_CAM_VERSION, 2, union vki_ccb)
3294 #endif
3295 /*--------------------------------------------------------------------*/
3296 /*--- end ---*/
3297 /*--------------------------------------------------------------------*/