2 * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
5 * This software was developed by the University of Cambridge Computer
6 * Laboratory as part of the CTSRD Project, with support from the UK Higher
7 * Education Innovation Fund (HEIF).
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met: redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer;
13 * redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution;
16 * neither the name of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef __ARCH_ARM_FREEBSD_FREEBSD_HH__
34 #define __ARCH_ARM_FREEBSD_FREEBSD_HH__
36 #include "kern/freebsd/freebsd.hh"
38 class ArmFreebsd : public FreeBSD
41 static const ByteOrder byteOrder = LittleEndianByteOrder;
44 class ArmFreebsd32 : public ArmFreebsd
47 /// This table maps the target open() flags to the corresponding
48 /// host open() flags.
49 static SyscallFlagTransTable openFlagTable[];
51 /// Number of entries in openFlagTable[].
52 static const int NUM_OPEN_FLAGS;
55 /// Basic ARM FreeBSD types
56 typedef uint32_t size_t;
57 typedef uint32_t off_t;
58 typedef int32_t time_t;
59 typedef int32_t clock_t;
63 /// open(2) flag values.
64 static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY
65 static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY
66 static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR
67 static const int TGT_O_CREAT = 0x00000200; //!< O_CREAT
68 static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL
69 static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY
70 static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC
71 static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND
72 static const int TGT_O_NONBLOCK = 0x00000004; //!< O_NONBLOCK
73 static const int TGT_O_SYNC = 0x00000080; //!< O_SYNC
74 static const int TGT_FASYNC = 0x00000040; //!< FASYNC
75 static const int TGT_O_DIRECT = 0x00010000; //!< O_DIRECT
76 static const int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY
77 static const int TGT_O_NOFOLLOW = 0x00000100; //!< O_NOFOLLOW
78 static const int TGT_O_CLOEXEC = 0x00100000; //!< O_CLOEXEC
82 static const unsigned TGT_MAP_SHARED = 0x0001;
83 static const unsigned TGT_MAP_PRIVATE = 0x0002;
84 static const unsigned TGT_MAP_ANONYMOUS = 0x1000;
85 static const unsigned TGT_MAP_FIXED = 0x0010;
87 /// Limit struct for getrlimit/setrlimit.
89 uint32_t rlim_cur; //!< soft limit
90 uint32_t rlim_max; //!< hard limit
93 /// For gettimeofday().
95 int32_t tv_sec; //!< seconds
96 int32_t tv_usec; //!< microseconds
101 uint32_t iov_base; // void *
117 * sizeof st_blksize 4
132 uint64_t st_atime_nsec;
134 uint64_t st_mtime_nsec;
136 uint64_t st_ctime_nsec;
143 uint64_t st_birthtimX;
144 uint64_t st_birthtim;
156 uint64_t st_atime_nsec;
158 uint64_t st_mtime_nsec;
160 uint64_t st_ctime_nsec;
167 uint64_t st_birthtimX;
168 uint64_t st_birthtim;
173 struct timeval ru_utime; //!< user time used
174 struct timeval ru_stime; //!< system time used
175 int32_t ru_maxrss; //!< max rss
176 int32_t ru_ixrss; //!< integral shared memory size
177 int32_t ru_idrss; //!< integral unshared data "
178 int32_t ru_isrss; //!< integral unshared stack "
179 int32_t ru_minflt; //!< page reclaims - total vmfaults
180 int32_t ru_majflt; //!< page faults
181 int32_t ru_nswap; //!< swaps
182 int32_t ru_inblock; //!< block input operations
183 int32_t ru_oublock; //!< block output operations
184 int32_t ru_msgsnd; //!< messages sent
185 int32_t ru_msgrcv; //!< messages received
186 int32_t ru_nsignals; //!< signals received
187 int32_t ru_nvcsw; //!< voluntary context switches
188 int32_t ru_nivcsw; //!< involuntary "
193 int32_t tms_utime; //!< user time
194 int32_t tms_stime; //!< system time
195 int32_t tms_cutime; //!< user time of children
196 int32_t tms_cstime; //!< system time of children
200 class ArmFreebsd64 : public ArmFreebsd
204 /// This table maps the target open() flags to the corresponding
205 /// host open() flags.
206 static SyscallFlagTransTable openFlagTable[];
208 /// Number of entries in openFlagTable[].
209 static const int NUM_OPEN_FLAGS;
212 /// Basic ARM FreeBSD types
213 typedef uint64_t size_t;
214 typedef uint64_t off_t;
215 typedef int64_t time_t;
216 typedef int64_t clock_t;
220 /// open(2) flag values.
221 static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY
222 static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY
223 static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR
224 static const int TGT_O_CREAT = 0x00000200; //!< O_CREAT
225 static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL
226 static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY
227 static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC
228 static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND
229 static const int TGT_O_NONBLOCK = 0x00000004; //!< O_NONBLOCK
230 static const int TGT_O_SYNC = 0x00000080; //!< O_SYNC
231 static const int TGT_FASYNC = 0x00000040; //!< FASYNC
232 static const int TGT_O_DIRECT = 0x00010000; //!< O_DIRECT
233 static const int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY
234 static const int TGT_O_NOFOLLOW = 0x00000100; //!< O_NOFOLLOW
235 static const int TGT_O_CLOEXEC = 0x00100000; //!< O_CLOEXEC
239 static const unsigned TGT_MAP_SHARED = 0x0001;
240 static const unsigned TGT_MAP_PRIVATE = 0x0002;
241 static const unsigned TGT_MAP_ANONYMOUS = 0x1000;
242 static const unsigned TGT_MAP_FIXED = 0x0010;
246 static const int TGT_RUSAGE_SELF = 0;
247 static const int TGT_RUSAGE_CHILDREN = -1;
248 static const int TGT_RUSAGE_THREAD = 1;
251 /// Resource enumeration for getrlimit().
252 enum rlimit_resources {
254 TGT_RLIMIT_FSIZE = 1,
256 TGT_RLIMIT_STACK = 3,
259 TGT_RLIMIT_MEMLOCK = 6,
260 TGT_RLIMIT_NPROC = 7,
261 TGT_RLIMIT_NOFILE = 8,
262 TGT_RLIMIT_SBSIZE = 9,
263 TGT_RLIMIT_VMEM = 10,
264 TGT_RLIMIT_AS = TGT_RLIMIT_VMEM,
265 TGT_RLIMIT_NPTS = 11,
266 TGT_RLIMIT_SWAP = 12,
267 TGT_RLIMIT_KQUEUES = 13
270 /// Limit struct for getrlimit/setrlimit.
272 uint64_t rlim_cur; //!< soft limit
273 uint64_t rlim_max; //!< hard limit
276 /// For gettimeofday().
278 int64_t tv_sec; //!< seconds
279 int64_t tv_usec; //!< microseconds
284 uint64_t iov_base; // void *
297 uint64_t st_atime_nsec;
299 uint64_t st_mtime_nsec;
301 uint64_t st_ctime_nsec;
308 uint64_t st_birthtimX;
309 uint64_t st_birthtim;
321 uint64_t st_atime_nsec;
323 uint64_t st_mtime_nsec;
325 uint64_t st_ctime_nsec;
332 uint64_t st_birthtimX;
333 uint64_t st_birthtim;
338 struct timeval ru_utime; //!< user time used
339 struct timeval ru_stime; //!< system time used
340 int64_t ru_maxrss; //!< max rss
341 int64_t ru_ixrss; //!< integral shared memory size
342 int64_t ru_idrss; //!< integral unshared data "
343 int64_t ru_isrss; //!< integral unshared stack "
344 int64_t ru_minflt; //!< page reclaims - total vmfaults
345 int64_t ru_majflt; //!< page faults
346 int64_t ru_nswap; //!< swaps
347 int64_t ru_inblock; //!< block input operations
348 int64_t ru_oublock; //!< block output operations
349 int64_t ru_msgsnd; //!< messages sent
350 int64_t ru_msgrcv; //!< messages received
351 int64_t ru_nsignals; //!< signals received
352 int64_t ru_nvcsw; //!< voluntary context switches
353 int64_t ru_nivcsw; //!< involuntary "
358 int64_t tms_utime; //!< user time
359 int64_t tms_stime; //!< system time
360 int64_t tms_cutime; //!< user time of children
361 int64_t tms_cstime; //!< system time of children