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 ArmFreebsd32 : public FreeBSD
42 /// This table maps the target open() flags to the corresponding
43 /// host open() flags.
44 static OpenFlagTransTable openFlagTable[];
46 /// Number of entries in openFlagTable[].
47 static const int NUM_OPEN_FLAGS;
50 /// Basic ARM FreeBSD types
51 typedef uint32_t size_t;
52 typedef uint32_t off_t;
53 typedef int32_t time_t;
54 typedef int32_t clock_t;
58 /// open(2) flag values.
59 static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY
60 static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY
61 static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR
62 static const int TGT_O_CREAT = 0x00000200; //!< O_CREAT
63 static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL
64 static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY
65 static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC
66 static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND
67 static const int TGT_O_NONBLOCK = 0x00000004; //!< O_NONBLOCK
68 static const int TGT_O_SYNC = 0x00000080; //!< O_SYNC
69 static const int TGT_FASYNC = 0x00000040; //!< FASYNC
70 static const int TGT_O_DIRECT = 0x00010000; //!< O_DIRECT
71 static const int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY
72 static const int TGT_O_NOFOLLOW = 0x00000100; //!< O_NOFOLLOW
73 static const int TGT_O_CLOEXEC = 0x00100000; //!< O_CLOEXEC
77 static const unsigned TGT_MAP_ANONYMOUS = 0x1000;
78 static const unsigned TGT_MAP_FIXED = 0x0010;
80 /// Limit struct for getrlimit/setrlimit.
82 uint32_t rlim_cur; //!< soft limit
83 uint32_t rlim_max; //!< hard limit
86 /// For gettimeofday().
88 int32_t tv_sec; //!< seconds
89 int32_t tv_usec; //!< microseconds
94 uint32_t iov_base; // void *
110 * sizeof st_blksize 4
125 uint64_t st_atime_nsec;
127 uint64_t st_mtime_nsec;
129 uint64_t st_ctime_nsec;
136 uint64_t st_birthtimX;
137 uint64_t st_birthtim;
149 uint64_t st_atime_nsec;
151 uint64_t st_mtime_nsec;
153 uint64_t st_ctime_nsec;
160 uint64_t st_birthtimX;
161 uint64_t st_birthtim;
166 struct timeval ru_utime; //!< user time used
167 struct timeval ru_stime; //!< system time used
168 int32_t ru_maxrss; //!< max rss
169 int32_t ru_ixrss; //!< integral shared memory size
170 int32_t ru_idrss; //!< integral unshared data "
171 int32_t ru_isrss; //!< integral unshared stack "
172 int32_t ru_minflt; //!< page reclaims - total vmfaults
173 int32_t ru_majflt; //!< page faults
174 int32_t ru_nswap; //!< swaps
175 int32_t ru_inblock; //!< block input operations
176 int32_t ru_oublock; //!< block output operations
177 int32_t ru_msgsnd; //!< messages sent
178 int32_t ru_msgrcv; //!< messages received
179 int32_t ru_nsignals; //!< signals received
180 int32_t ru_nvcsw; //!< voluntary context switches
181 int32_t ru_nivcsw; //!< involuntary "
186 int32_t tms_utime; //!< user time
187 int32_t tms_stime; //!< system time
188 int32_t tms_cutime; //!< user time of children
189 int32_t tms_cstime; //!< system time of children
193 class ArmFreebsd64 : public FreeBSD
197 /// This table maps the target open() flags to the corresponding
198 /// host open() flags.
199 static OpenFlagTransTable openFlagTable[];
201 /// Number of entries in openFlagTable[].
202 static const int NUM_OPEN_FLAGS;
205 /// Basic ARM FreeBSD types
206 typedef uint64_t size_t;
207 typedef uint64_t off_t;
208 typedef int64_t time_t;
209 typedef int64_t clock_t;
213 /// open(2) flag values.
214 static const int TGT_O_RDONLY = 0x00000000; //!< O_RDONLY
215 static const int TGT_O_WRONLY = 0x00000001; //!< O_WRONLY
216 static const int TGT_O_RDWR = 0x00000002; //!< O_RDWR
217 static const int TGT_O_CREAT = 0x00000200; //!< O_CREAT
218 static const int TGT_O_EXCL = 0x00000800; //!< O_EXCL
219 static const int TGT_O_NOCTTY = 0x00008000; //!< O_NOCTTY
220 static const int TGT_O_TRUNC = 0x00000400; //!< O_TRUNC
221 static const int TGT_O_APPEND = 0x00000008; //!< O_APPEND
222 static const int TGT_O_NONBLOCK = 0x00000004; //!< O_NONBLOCK
223 static const int TGT_O_SYNC = 0x00000080; //!< O_SYNC
224 static const int TGT_FASYNC = 0x00000040; //!< FASYNC
225 static const int TGT_O_DIRECT = 0x00010000; //!< O_DIRECT
226 static const int TGT_O_DIRECTORY = 0x00020000; //!< O_DIRECTORY
227 static const int TGT_O_NOFOLLOW = 0x00000100; //!< O_NOFOLLOW
228 static const int TGT_O_CLOEXEC = 0x00100000; //!< O_CLOEXEC
232 static const unsigned TGT_MAP_ANONYMOUS = 0x1000;
233 static const unsigned TGT_MAP_FIXED = 0x0010;
237 static const int TGT_RUSAGE_SELF = 0;
238 static const int TGT_RUSAGE_CHILDREN = -1;
239 static const int TGT_RUSAGE_THREAD = 1;
242 /// Resource enumeration for getrlimit().
243 enum rlimit_resources {
245 TGT_RLIMIT_FSIZE = 1,
247 TGT_RLIMIT_STACK = 3,
250 TGT_RLIMIT_MEMLOCK = 6,
251 TGT_RLIMIT_NPROC = 7,
252 TGT_RLIMIT_NOFILE = 8,
253 TGT_RLIMIT_SBSIZE = 9,
254 TGT_RLIMIT_VMEM = 10,
255 TGT_RLIMIT_AS = TGT_RLIMIT_VMEM,
256 TGT_RLIMIT_NPTS = 11,
257 TGT_RLIMIT_SWAP = 12,
258 TGT_RLIMIT_KQUEUES = 13
261 /// Limit struct for getrlimit/setrlimit.
263 uint64_t rlim_cur; //!< soft limit
264 uint64_t rlim_max; //!< hard limit
267 /// For gettimeofday().
269 int64_t tv_sec; //!< seconds
270 int64_t tv_usec; //!< microseconds
275 uint64_t iov_base; // void *
288 uint64_t st_atime_nsec;
290 uint64_t st_mtime_nsec;
292 uint64_t st_ctime_nsec;
299 uint64_t st_birthtimX;
300 uint64_t st_birthtim;
312 uint64_t st_atime_nsec;
314 uint64_t st_mtime_nsec;
316 uint64_t st_ctime_nsec;
323 uint64_t st_birthtimX;
324 uint64_t st_birthtim;
329 struct timeval ru_utime; //!< user time used
330 struct timeval ru_stime; //!< system time used
331 int64_t ru_maxrss; //!< max rss
332 int64_t ru_ixrss; //!< integral shared memory size
333 int64_t ru_idrss; //!< integral unshared data "
334 int64_t ru_isrss; //!< integral unshared stack "
335 int64_t ru_minflt; //!< page reclaims - total vmfaults
336 int64_t ru_majflt; //!< page faults
337 int64_t ru_nswap; //!< swaps
338 int64_t ru_inblock; //!< block input operations
339 int64_t ru_oublock; //!< block output operations
340 int64_t ru_msgsnd; //!< messages sent
341 int64_t ru_msgrcv; //!< messages received
342 int64_t ru_nsignals; //!< signals received
343 int64_t ru_nvcsw; //!< voluntary context switches
344 int64_t ru_nivcsw; //!< involuntary "
349 int64_t tms_utime; //!< user time
350 int64_t tms_stime; //!< system time
351 int64_t tms_cutime; //!< user time of children
352 int64_t tms_cstime; //!< system time of children