1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef SYSCALL_DEFS_H
21#define SYSCALL_DEFS_H
22
23#include <sys/syscall.h>
24#include <sys/resource.h>
25
26#include "errno_defs.h"
27
28#include "freebsd/syscall_nr.h"
29#include "netbsd/syscall_nr.h"
30#include "openbsd/syscall_nr.h"
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47#if (!defined(TARGET_I386))
48typedef int64_t target_time_t;
49#else
50typedef int32_t target_time_t;
51#endif
52
53struct target_iovec {
54 abi_long iov_base;
55 abi_long iov_len;
56};
57
58
59
60
61struct target_ipc_perm {
62 uint32_t cuid;
63 uint32_t cgid;
64 uint32_t uid;
65 uint32_t gid;
66 uint16_t mode;
67 uint16_t seq;
68 abi_long key;
69};
70
71#define TARGET_IPC_RMID 0
72#define TARGET_IPC_SET 1
73#define TARGET_IPC_STAT 2
74
75
76
77
78struct target_shmid_ds {
79 struct target_ipc_perm shm_perm;
80 abi_ulong shm_segsz;
81 int32_t shm_lpid;
82 int32_t shm_cpid;
83 int32_t shm_nattch;
84 target_time_t shm_atime;
85 target_time_t shm_dtime;
86 target_time_t shm_ctime;
87};
88
89#define N_BSD_SHM_REGIONS 32
90struct bsd_shm_regions {
91 abi_long start;
92 abi_long size;
93};
94
95
96
97
98#define TARGET_MADV_DONTNEED 4
99
100#define TARGET_FREEBSD_MAP_RESERVED0080 0x0080
101
102#define TARGET_FREEBSD_MAP_RESERVED0100 0x0100
103
104#define TARGET_FREEBSD_MAP_STACK 0x0400
105
106#define TARGET_FREEBSD_MAP_NOSYNC 0x0800
107
108
109#define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7
110
111#define TARGET_NETBSD_MAP_INHERIT 0x0080
112
113#define TARGET_NETBSD_MAP_TRYFIXED 0x0400
114
115#define TARGET_NETBSD_MAP_WIRED 0x0800
116
117
118#define TARGET_NETBSD_MAP_STACK 0x2000
119
120
121#define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7
122
123#define TARGET_OPENBSD_MAP_INHERIT 0x0080
124
125#define TARGET_OPENBSD_MAP_NOEXTEND 0x0100
126
127#define TARGET_OPENBSD_MAP_TRYFIXED 0x0400
128
129
130#define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7
131
132
133#define TARGET_BSD_MAP_FLAGMASK 0x3ff7
134
135
136
137
138
139
140typedef abi_long target_freebsd_suseconds_t;
141
142
143struct target_freebsd_timespec {
144 target_time_t tv_sec;
145 abi_long tv_nsec;
146#if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
147 abi_long _pad;
148#endif
149};
150
151#define TARGET_CPUCLOCK_WHICH_PID 0
152#define TARGET_CPUCLOCK_WHICH_TID 1
153
154
155struct target_freebsd__umtx_time {
156 struct target_freebsd_timespec _timeout;
157 uint32_t _flags;
158 uint32_t _clockid;
159};
160
161struct target_freebsd_timeval {
162 target_time_t tv_sec;
163 target_freebsd_suseconds_t tv_usec;
164#if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
165 abi_long _pad;
166#endif
167};
168
169
170
171
172#define TARGET_RLIM_INFINITY RLIM_INFINITY
173
174#define TARGET_RLIMIT_CPU 0
175#define TARGET_RLIMIT_FSIZE 1
176#define TARGET_RLIMIT_DATA 2
177#define TARGET_RLIMIT_STACK 3
178#define TARGET_RLIMIT_CORE 4
179#define TARGET_RLIMIT_RSS 5
180#define TARGET_RLIMIT_MEMLOCK 6
181#define TARGET_RLIMIT_NPROC 7
182#define TARGET_RLIMIT_NOFILE 8
183#define TARGET_RLIMIT_SBSIZE 9
184#define TARGET_RLIMIT_AS 10
185#define TARGET_RLIMIT_NPTS 11
186#define TARGET_RLIMIT_SWAP 12
187
188struct target_rlimit {
189 uint64_t rlim_cur;
190 uint64_t rlim_max;
191};
192
193struct target_freebsd_rusage {
194 struct target_freebsd_timeval ru_utime;
195 struct target_freebsd_timeval ru_stime;
196 abi_long ru_maxrss;
197 abi_long ru_ixrss;
198 abi_long ru_idrss;
199 abi_long ru_isrss;
200 abi_long ru_minflt;
201 abi_long ru_majflt;
202 abi_long ru_nswap;
203 abi_long ru_inblock;
204 abi_long ru_oublock;
205 abi_long ru_msgsnd;
206 abi_long ru_msgrcv;
207 abi_long ru_nsignals;
208 abi_long ru_nvcsw;
209 abi_long ru_nivcsw;
210};
211
212struct target_freebsd__wrusage {
213 struct target_freebsd_rusage wru_self;
214 struct target_freebsd_rusage wru_children;
215};
216
217
218
219
220struct target_freebsd11_stat {
221 uint32_t st_dev;
222 uint32_t st_ino;
223 int16_t st_mode;
224 int16_t st_nlink;
225 uint32_t st_uid;
226 uint32_t st_gid;
227 uint32_t st_rdev;
228 struct target_freebsd_timespec st_atim;
229 struct target_freebsd_timespec st_mtim;
230 struct target_freebsd_timespec st_ctim;
231 int64_t st_size;
232 int64_t st_blocks;
233 uint32_t st_blksize;
234 uint32_t st_flags;
235 uint32_t st_gen;
236 int32_t st_lspare;
237 struct target_freebsd_timespec st_birthtim;
238
239
240
241
242
243
244
245
246 unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
247 unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
248} __packed;
249
250#if defined(__i386__)
251#define TARGET_HAS_STAT_TIME_T_EXT 1
252#endif
253
254struct target_stat {
255 uint64_t st_dev;
256 uint64_t st_ino;
257 uint64_t st_nlink;
258 int16_t st_mode;
259 int16_t st_padding0;
260 uint32_t st_uid;
261 uint32_t st_gid;
262 int32_t st_padding1;
263 uint64_t st_rdev;
264#ifdef TARGET_HAS_STAT_TIME_T_EXT
265 int32_t st_atim_ext;
266#endif
267 struct target_freebsd_timespec st_atim;
268#ifdef TARGET_HAS_STAT_TIME_T_EXT
269 int32_t st_mtim_ext;
270#endif
271 struct target_freebsd_timespec st_mtim;
272#ifdef TARGET_HAS_STAT_TIME_T_EXT
273 int32_t st_ctim_ext;
274#endif
275 struct target_freebsd_timespec st_ctim;
276#ifdef TARGET_HAS_STAT_TIME_T_EXT
277 int32_t st_btim_ext;
278#endif
279 struct target_freebsd_timespec st_birthtim;
280 int64_t st_size;
281 int64_t st_blocks;
282 uint32_t st_blksize;
283 uint32_t st_flags;
284 uint64_t st_gen;
285 uint64_t st_spare[10];
286};
287
288
289
290struct target_freebsd11_nstat {
291 uint32_t st_dev;
292 uint32_t st_ino;
293 int16_t st_mode;
294 int16_t st_nlink;
295 uint32_t st_uid;
296 uint32_t st_gid;
297 uint32_t st_rdev;
298 struct target_freebsd_timespec st_atim;
299 struct target_freebsd_timespec st_mtim;
300 struct target_freebsd_timespec st_ctim;
301 int64_t st_size;
302 int64_t st_blocks;
303 uint32_t st_blksize;
304 uint32_t st_flags;
305 uint32_t st_gen;
306 struct target_freebsd_timespec st_birthtim;
307
308
309
310
311
312
313
314
315 unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
316 unsigned int:(8 / 2) * (16 - (int)sizeof(struct target_freebsd_timespec));
317} __packed;
318
319
320
321
322
323
324typedef struct target_freebsd_fsid { int32_t val[2]; } target_freebsd_fsid_t;
325
326
327struct target_freebsd11_statfs {
328 uint32_t f_version;
329 uint32_t f_type;
330 uint64_t f_flags;
331 uint64_t f_bsize;
332 uint64_t f_iosize;
333 uint64_t f_blocks;
334 uint64_t f_bfree;
335 int64_t f_bavail;
336 uint64_t f_files;
337 int64_t f_ffree;
338 uint64_t f_syncwrites;
339 uint64_t f_asyncwrites;
340 uint64_t f_syncreads;
341 uint64_t f_asyncreads;
342 uint64_t f_spare[10];
343 uint32_t f_namemax;
344 uint32_t f_owner;
345 target_freebsd_fsid_t f_fsid;
346 char f_charspare[80];
347 char f_fstypename[16];
348 char f_mntfromname[88];
349 char f_mntonname[88];
350};
351
352struct target_statfs {
353 uint32_t f_version;
354 uint32_t f_type;
355 uint64_t f_flags;
356 uint64_t f_bsize;
357 uint64_t f_iosize;
358 uint64_t f_blocks;
359 uint64_t f_bfree;
360 int64_t f_bavail;
361 uint64_t f_files;
362 int64_t f_ffree;
363 uint64_t f_syncwrites;
364 uint64_t f_asyncwrites;
365 uint64_t f_syncreads;
366 uint64_t f_asyncreads;
367 uint64_t f_spare[10];
368 uint32_t f_namemax;
369 uint32_t f_owner;
370 target_freebsd_fsid_t f_fsid;
371 char f_charspare[80];
372 char f_fstypename[16];
373 char f_mntfromname[1024];
374 char f_mntonname[1024];
375};
376
377
378#define TARGET_MAXFIDSZ 16
379
380struct target_freebsd_fid {
381 uint16_t fid_len;
382 uint16_t fid_data0;
383 char fid_data[TARGET_MAXFIDSZ];
384};
385
386
387struct target_freebsd_fhandle {
388 target_freebsd_fsid_t fh_fsid;
389 struct target_freebsd_fid fh_fid;
390};
391typedef struct target_freebsd_fhandle target_freebsd_fhandle_t;
392
393
394
395
396#define TARGET_F_DUPFD 0
397#define TARGET_F_GETFD 1
398#define TARGET_F_SETFD 2
399#define TARGET_F_GETFL 3
400#define TARGET_F_SETFL 4
401#define TARGET_F_GETOWN 5
402#define TARGET_F_SETOWN 6
403#define TARGET_F_OGETLK 7
404#define TARGET_F_OSETLK 8
405#define TARGET_F_OSETLKW 9
406#define TARGET_F_DUP2FD 10
407#define TARGET_F_GETLK 11
408#define TARGET_F_SETLK 12
409#define TARGET_F_SETLKW 13
410#define TARGET_F_SETLK_REMOTE 14
411#define TARGET_F_READAHEAD 15
412#define TARGET_F_RDAHEAD 16
413#define TARGET_F_DUPFD_CLOEXEC 17
414#define TARGET_F_DUP2FD_CLOEXEC 18
415
416#define TARGET_F_ADD_SEALS 19
417#define TARGET_F_GET_SEALS 20
418
419struct target_freebsd_flock {
420 int64_t l_start;
421 int64_t l_len;
422 int32_t l_pid;
423 int16_t l_type;
424 int16_t l_whence;
425 int32_t l_sysid;
426} QEMU_PACKED;
427
428
429
430#define TARGET_RFSPAWN (1U << 31)
431
432
433
434
435#define TARGET_PROC_SPROTECT 1
436#define TARGET_PROC_REAP_ACQUIRE 2
437#define TARGET_PROC_REAP_RELEASE 3
438#define TARGET_PROC_REAP_STATUS 4
439#define TARGET_PROC_REAP_GETPIDS 5
440#define TARGET_PROC_REAP_KILL 6
441
442struct target_procctl_reaper_status {
443 uint32_t rs_flags;
444 uint32_t rs_children;
445 uint32_t rs_descendants;
446 uint32_t rs_reaper;
447 uint32_t rs_pid;
448 uint32_t rs_pad0[15];
449};
450
451struct target_procctl_reaper_pidinfo {
452 uint32_t pi_pid;
453 uint32_t pi_subtree;
454 uint32_t pi_flags;
455 uint32_t pi_pad0[15];
456};
457
458struct target_procctl_reaper_pids {
459 uint32_t rp_count;
460 uint32_t rp_pad0[15];
461 abi_ulong rp_pids;
462};
463
464struct target_procctl_reaper_kill {
465 int32_t rk_sig;
466 uint32_t rk_flags;
467 uint32_t rk_subtree;
468 uint32_t rk_killed;
469 uint32_t rk_fpid;
470 uint32_t rk_pad0[15];
471};
472
473
474#define safe_syscall0(type, name) \
475type safe_##name(void) \
476{ \
477 return safe_syscall(SYS_##name); \
478}
479
480#define safe_syscall1(type, name, type1, arg1) \
481type safe_##name(type1 arg1) \
482{ \
483 return safe_syscall(SYS_##name, arg1); \
484}
485
486#define safe_syscall2(type, name, type1, arg1, type2, arg2) \
487type safe_##name(type1 arg1, type2 arg2) \
488{ \
489 return safe_syscall(SYS_##name, arg1, arg2); \
490}
491
492#define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
493type safe_##name(type1 arg1, type2 arg2, type3 arg3) \
494{ \
495 return safe_syscall(SYS_##name, arg1, arg2, arg3); \
496}
497
498#define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \
499 type4, arg4) \
500type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
501{ \
502 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \
503}
504
505#define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \
506 type4, arg4, type5, arg5) \
507type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
508 type5 arg5) \
509{ \
510 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \
511}
512
513#define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \
514 type4, arg4, type5, arg5, type6, arg6) \
515type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
516 type5 arg5, type6 arg6) \
517{ \
518 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
519}
520
521#define safe_fcntl(...) safe_syscall(SYS_fcntl, __VA_ARGS__)
522
523
524#undef target_to_host_bitmask
525#define target_to_host_bitmask(x, tbl) (x)
526#undef host_to_target_bitmask
527#define host_to_target_bitmask(x, tbl) (x)
528
529#endif
530