xref: /qemu/bsd-user/syscall_defs.h (revision b355f08a)
1 /*
2  *  System call related declarations
3  *
4  *  Copyright (c) 2013-15 Stacey D. Son (sson at FreeBSD)
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef _SYSCALL_DEFS_H_
21 #define _SYSCALL_DEFS_H_
22 
23 #include <sys/syscall.h>
24 
25 #include "errno_defs.h"
26 
27 #include "freebsd/syscall_nr.h"
28 #include "netbsd/syscall_nr.h"
29 #include "openbsd/syscall_nr.h"
30 
31 /*
32  * machine/_types.h
33  * or x86/_types.h
34  */
35 
36 /*
37  * time_t seems to be very inconsistly defined for the different *BSD's...
38  *
39  * FreeBSD uses a 64bits time_t except on i386
40  * so we have to add a special case here.
41  *
42  * On NetBSD time_t is always defined as an int64_t.  On OpenBSD time_t
43  * is always defined as an int.
44  *
45  */
46 #if (!defined(TARGET_I386))
47 typedef int64_t target_freebsd_time_t;
48 #else
49 typedef int32_t target_freebsd_time_t;
50 #endif
51 
52 struct target_iovec {
53     abi_long iov_base;   /* Starting address */
54     abi_long iov_len;   /* Number of bytes */
55 };
56 
57 /*
58  *  sys/mman.h
59  */
60 #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080  /* previously misimplemented */
61                                                 /* MAP_INHERIT */
62 #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100  /* previously unimplemented */
63                                                 /* MAP_NOEXTEND */
64 #define TARGET_FREEBSD_MAP_STACK        0x0400  /* region grows down, like a */
65                                                 /* stack */
66 #define TARGET_FREEBSD_MAP_NOSYNC       0x0800  /* page to but do not sync */
67                                                 /* underlying file */
68 
69 #define TARGET_FREEBSD_MAP_FLAGMASK     0x1ff7
70 
71 #define TARGET_NETBSD_MAP_INHERIT       0x0080  /* region is retained after */
72                                                 /* exec */
73 #define TARGET_NETBSD_MAP_TRYFIXED      0x0400  /* attempt hint address, even */
74                                                 /* within break */
75 #define TARGET_NETBSD_MAP_WIRED         0x0800  /* mlock() mapping when it is */
76                                                 /* established */
77 
78 #define TARGET_NETBSD_MAP_STACK         0x2000  /* allocated from memory, */
79                                                 /* swap space (stack) */
80 
81 #define TARGET_NETBSD_MAP_FLAGMASK      0x3ff7
82 
83 #define TARGET_OPENBSD_MAP_INHERIT      0x0080  /* region is retained after */
84                                                 /* exec */
85 #define TARGET_OPENBSD_MAP_NOEXTEND     0x0100  /* for MAP_FILE, don't change */
86                                                 /* file size */
87 #define TARGET_OPENBSD_MAP_TRYFIXED     0x0400  /* attempt hint address, */
88                                                 /* even within heap */
89 
90 #define TARGET_OPENBSD_MAP_FLAGMASK     0x17f7
91 
92 /* XXX */
93 #define TARGET_BSD_MAP_FLAGMASK         0x3ff7
94 
95 /*
96  * sys/time.h
97  * sys/timex.h
98  */
99 
100 typedef abi_long target_freebsd_suseconds_t;
101 
102 /* compare to sys/timespec.h */
103 struct target_freebsd_timespec {
104     target_freebsd_time_t   tv_sec;     /* seconds */
105     abi_long                tv_nsec;    /* and nanoseconds */
106 #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
107     abi_long _pad;
108 #endif
109 };
110 
111 #define TARGET_CPUCLOCK_WHICH_PID   0
112 #define TARGET_CPUCLOCK_WHICH_TID   1
113 
114 /* sys/umtx.h */
115 struct target_freebsd__umtx_time {
116     struct target_freebsd_timespec  _timeout;
117     uint32_t    _flags;
118     uint32_t    _clockid;
119 };
120 
121 struct target_freebsd_timeval {
122     target_freebsd_time_t       tv_sec; /* seconds */
123     target_freebsd_suseconds_t  tv_usec;/* and microseconds */
124 #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
125     abi_long _pad;
126 #endif
127 };
128 
129 /*
130  *  sys/resource.h
131  */
132 #if defined(__FreeBSD__)
133 #define TARGET_RLIM_INFINITY    RLIM_INFINITY
134 #else
135 #define TARGET_RLIM_INFINITY    ((abi_ulong)-1)
136 #endif
137 
138 #define TARGET_RLIMIT_CPU       0
139 #define TARGET_RLIMIT_FSIZE     1
140 #define TARGET_RLIMIT_DATA      2
141 #define TARGET_RLIMIT_STACK     3
142 #define TARGET_RLIMIT_CORE      4
143 #define TARGET_RLIMIT_RSS       5
144 #define TARGET_RLIMIT_MEMLOCK   6
145 #define TARGET_RLIMIT_NPROC     7
146 #define TARGET_RLIMIT_NOFILE    8
147 #define TARGET_RLIMIT_SBSIZE    9
148 #define TARGET_RLIMIT_AS        10
149 #define TARGET_RLIMIT_NPTS      11
150 #define TARGET_RLIMIT_SWAP      12
151 
152 struct target_rlimit {
153     uint64_t rlim_cur;
154     uint64_t rlim_max;
155 };
156 
157 struct target_freebsd_rusage {
158     struct target_freebsd_timeval ru_utime; /* user time used */
159     struct target_freebsd_timeval ru_stime; /* system time used */
160     abi_long    ru_maxrss;      /* maximum resident set size */
161     abi_long    ru_ixrss;       /* integral shared memory size */
162     abi_long    ru_idrss;       /* integral unshared data size */
163     abi_long    ru_isrss;       /* integral unshared stack size */
164     abi_long    ru_minflt;      /* page reclaims */
165     abi_long    ru_majflt;      /* page faults */
166     abi_long    ru_nswap;       /* swaps */
167     abi_long    ru_inblock;     /* block input operations */
168     abi_long    ru_oublock;     /* block output operations */
169     abi_long    ru_msgsnd;      /* messages sent */
170     abi_long    ru_msgrcv;      /* messages received */
171     abi_long    ru_nsignals;    /* signals received */
172     abi_long    ru_nvcsw;       /* voluntary context switches */
173     abi_long    ru_nivcsw;      /* involuntary context switches */
174 };
175 
176 struct target_freebsd__wrusage {
177     struct target_freebsd_rusage wru_self;
178     struct target_freebsd_rusage wru_children;
179 };
180 
181 #endif /* ! _SYSCALL_DEFS_H_ */
182