184778508Sblueswir1 /* 2366c5c9fSWarner Losh * System call related declarations 384778508Sblueswir1 * 4366c5c9fSWarner Losh * Copyright (c) 2013-15 Stacey D. Son (sson at FreeBSD) 584778508Sblueswir1 * 6366c5c9fSWarner Losh * This program is free software; you can redistribute it and/or modify 7366c5c9fSWarner Losh * it under the terms of the GNU General Public License as published by 8366c5c9fSWarner Losh * the Free Software Foundation; either version 2 of the License, or 9366c5c9fSWarner Losh * (at your option) any later version. 1084778508Sblueswir1 * 11366c5c9fSWarner Losh * This program is distributed in the hope that it will be useful, 12366c5c9fSWarner Losh * but WITHOUT ANY WARRANTY; without even the implied warranty of 13366c5c9fSWarner Losh * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14366c5c9fSWarner Losh * GNU General Public License for more details. 15366c5c9fSWarner Losh * 16366c5c9fSWarner Losh * You should have received a copy of the GNU General Public License 17366c5c9fSWarner Losh * along with this program; if not, see <http://www.gnu.org/licenses/>. 1884778508Sblueswir1 */ 1984778508Sblueswir1 20366c5c9fSWarner Losh #ifndef _SYSCALL_DEFS_H_ 21366c5c9fSWarner Losh #define _SYSCALL_DEFS_H_ 2284778508Sblueswir1 23366c5c9fSWarner Losh #include <sys/syscall.h> 24*37714547SWarner Losh #include <sys/resource.h> 2584778508Sblueswir1 2684778508Sblueswir1 #include "errno_defs.h" 2784778508Sblueswir1 2884778508Sblueswir1 #include "freebsd/syscall_nr.h" 2984778508Sblueswir1 #include "netbsd/syscall_nr.h" 3084778508Sblueswir1 #include "openbsd/syscall_nr.h" 3178cfb07fSJuergen Lock 32366c5c9fSWarner Losh /* 33366c5c9fSWarner Losh * machine/_types.h 34366c5c9fSWarner Losh * or x86/_types.h 35366c5c9fSWarner Losh */ 36366c5c9fSWarner Losh 37366c5c9fSWarner Losh /* 38366c5c9fSWarner Losh * time_t seems to be very inconsistly defined for the different *BSD's... 39366c5c9fSWarner Losh * 40366c5c9fSWarner Losh * FreeBSD uses a 64bits time_t except on i386 41366c5c9fSWarner Losh * so we have to add a special case here. 42366c5c9fSWarner Losh * 43366c5c9fSWarner Losh * On NetBSD time_t is always defined as an int64_t. On OpenBSD time_t 44366c5c9fSWarner Losh * is always defined as an int. 45366c5c9fSWarner Losh * 46366c5c9fSWarner Losh */ 47366c5c9fSWarner Losh #if (!defined(TARGET_I386)) 48366c5c9fSWarner Losh typedef int64_t target_freebsd_time_t; 49366c5c9fSWarner Losh #else 50366c5c9fSWarner Losh typedef int32_t target_freebsd_time_t; 51366c5c9fSWarner Losh #endif 52366c5c9fSWarner Losh 5378cfb07fSJuergen Lock struct target_iovec { 5478cfb07fSJuergen Lock abi_long iov_base; /* Starting address */ 5578cfb07fSJuergen Lock abi_long iov_len; /* Number of bytes */ 5678cfb07fSJuergen Lock }; 5778cfb07fSJuergen Lock 58366c5c9fSWarner Losh /* 59366c5c9fSWarner Losh * sys/mman.h 60366c5c9fSWarner Losh */ 61366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplemented */ 62366c5c9fSWarner Losh /* MAP_INHERIT */ 63366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented */ 64366c5c9fSWarner Losh /* MAP_NOEXTEND */ 65366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_STACK 0x0400 /* region grows down, like a */ 66366c5c9fSWarner Losh /* stack */ 67366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_NOSYNC 0x0800 /* page to but do not sync */ 68366c5c9fSWarner Losh /* underlying file */ 69366c5c9fSWarner Losh 70366c5c9fSWarner Losh #define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7 71366c5c9fSWarner Losh 72366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_INHERIT 0x0080 /* region is retained after */ 73366c5c9fSWarner Losh /* exec */ 74366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even */ 75366c5c9fSWarner Losh /* within break */ 76366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_WIRED 0x0800 /* mlock() mapping when it is */ 77366c5c9fSWarner Losh /* established */ 78366c5c9fSWarner Losh 79366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_STACK 0x2000 /* allocated from memory, */ 80366c5c9fSWarner Losh /* swap space (stack) */ 81366c5c9fSWarner Losh 82366c5c9fSWarner Losh #define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7 83366c5c9fSWarner Losh 84366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_INHERIT 0x0080 /* region is retained after */ 85366c5c9fSWarner Losh /* exec */ 86366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change */ 87366c5c9fSWarner Losh /* file size */ 88366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, */ 89366c5c9fSWarner Losh /* even within heap */ 90366c5c9fSWarner Losh 91366c5c9fSWarner Losh #define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7 92366c5c9fSWarner Losh 93366c5c9fSWarner Losh /* XXX */ 94366c5c9fSWarner Losh #define TARGET_BSD_MAP_FLAGMASK 0x3ff7 95366c5c9fSWarner Losh 96366c5c9fSWarner Losh /* 97366c5c9fSWarner Losh * sys/time.h 98366c5c9fSWarner Losh * sys/timex.h 99366c5c9fSWarner Losh */ 100366c5c9fSWarner Losh 101366c5c9fSWarner Losh typedef abi_long target_freebsd_suseconds_t; 102366c5c9fSWarner Losh 103366c5c9fSWarner Losh /* compare to sys/timespec.h */ 104366c5c9fSWarner Losh struct target_freebsd_timespec { 105366c5c9fSWarner Losh target_freebsd_time_t tv_sec; /* seconds */ 106366c5c9fSWarner Losh abi_long tv_nsec; /* and nanoseconds */ 107366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 108366c5c9fSWarner Losh abi_long _pad; 109366c5c9fSWarner Losh #endif 110366c5c9fSWarner Losh }; 111366c5c9fSWarner Losh 112366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_PID 0 113366c5c9fSWarner Losh #define TARGET_CPUCLOCK_WHICH_TID 1 114366c5c9fSWarner Losh 115366c5c9fSWarner Losh /* sys/umtx.h */ 116366c5c9fSWarner Losh struct target_freebsd__umtx_time { 117366c5c9fSWarner Losh struct target_freebsd_timespec _timeout; 118366c5c9fSWarner Losh uint32_t _flags; 119366c5c9fSWarner Losh uint32_t _clockid; 120366c5c9fSWarner Losh }; 121366c5c9fSWarner Losh 122366c5c9fSWarner Losh struct target_freebsd_timeval { 123366c5c9fSWarner Losh target_freebsd_time_t tv_sec; /* seconds */ 124366c5c9fSWarner Losh target_freebsd_suseconds_t tv_usec;/* and microseconds */ 125366c5c9fSWarner Losh #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32 126366c5c9fSWarner Losh abi_long _pad; 127366c5c9fSWarner Losh #endif 128366c5c9fSWarner Losh }; 129366c5c9fSWarner Losh 130366c5c9fSWarner Losh /* 131366c5c9fSWarner Losh * sys/resource.h 132366c5c9fSWarner Losh */ 133366c5c9fSWarner Losh #if defined(__FreeBSD__) 134366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY RLIM_INFINITY 135366c5c9fSWarner Losh #else 136366c5c9fSWarner Losh #define TARGET_RLIM_INFINITY ((abi_ulong)-1) 137366c5c9fSWarner Losh #endif 138366c5c9fSWarner Losh 139366c5c9fSWarner Losh #define TARGET_RLIMIT_CPU 0 140366c5c9fSWarner Losh #define TARGET_RLIMIT_FSIZE 1 141366c5c9fSWarner Losh #define TARGET_RLIMIT_DATA 2 142366c5c9fSWarner Losh #define TARGET_RLIMIT_STACK 3 143366c5c9fSWarner Losh #define TARGET_RLIMIT_CORE 4 144366c5c9fSWarner Losh #define TARGET_RLIMIT_RSS 5 145366c5c9fSWarner Losh #define TARGET_RLIMIT_MEMLOCK 6 146366c5c9fSWarner Losh #define TARGET_RLIMIT_NPROC 7 147366c5c9fSWarner Losh #define TARGET_RLIMIT_NOFILE 8 148366c5c9fSWarner Losh #define TARGET_RLIMIT_SBSIZE 9 149366c5c9fSWarner Losh #define TARGET_RLIMIT_AS 10 150366c5c9fSWarner Losh #define TARGET_RLIMIT_NPTS 11 151366c5c9fSWarner Losh #define TARGET_RLIMIT_SWAP 12 152366c5c9fSWarner Losh 153366c5c9fSWarner Losh struct target_rlimit { 154366c5c9fSWarner Losh uint64_t rlim_cur; 155366c5c9fSWarner Losh uint64_t rlim_max; 156366c5c9fSWarner Losh }; 157366c5c9fSWarner Losh 158366c5c9fSWarner Losh struct target_freebsd_rusage { 159366c5c9fSWarner Losh struct target_freebsd_timeval ru_utime; /* user time used */ 160366c5c9fSWarner Losh struct target_freebsd_timeval ru_stime; /* system time used */ 161366c5c9fSWarner Losh abi_long ru_maxrss; /* maximum resident set size */ 162366c5c9fSWarner Losh abi_long ru_ixrss; /* integral shared memory size */ 163366c5c9fSWarner Losh abi_long ru_idrss; /* integral unshared data size */ 164366c5c9fSWarner Losh abi_long ru_isrss; /* integral unshared stack size */ 165366c5c9fSWarner Losh abi_long ru_minflt; /* page reclaims */ 166366c5c9fSWarner Losh abi_long ru_majflt; /* page faults */ 167366c5c9fSWarner Losh abi_long ru_nswap; /* swaps */ 168366c5c9fSWarner Losh abi_long ru_inblock; /* block input operations */ 169366c5c9fSWarner Losh abi_long ru_oublock; /* block output operations */ 170366c5c9fSWarner Losh abi_long ru_msgsnd; /* messages sent */ 171366c5c9fSWarner Losh abi_long ru_msgrcv; /* messages received */ 172366c5c9fSWarner Losh abi_long ru_nsignals; /* signals received */ 173366c5c9fSWarner Losh abi_long ru_nvcsw; /* voluntary context switches */ 174366c5c9fSWarner Losh abi_long ru_nivcsw; /* involuntary context switches */ 175366c5c9fSWarner Losh }; 176366c5c9fSWarner Losh 177366c5c9fSWarner Losh struct target_freebsd__wrusage { 178366c5c9fSWarner Losh struct target_freebsd_rusage wru_self; 179366c5c9fSWarner Losh struct target_freebsd_rusage wru_children; 180366c5c9fSWarner Losh }; 181366c5c9fSWarner Losh 182366c5c9fSWarner Losh #endif /* ! _SYSCALL_DEFS_H_ */ 183