gem5  v22.1.0.0
freebsd.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
3  * All rights reserved.
4  *
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).
8  *
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.
19  *
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.
31  */
32 
33 #ifndef __ARCH_ARM_FREEBSD_FREEBSD_HH__
34 #define __ARCH_ARM_FREEBSD_FREEBSD_HH__
35 
36 #include <map>
37 
38 #include "kern/freebsd/freebsd.hh"
40 #include "sim/byteswap.hh"
41 
42 namespace gem5
43 {
44 
45 class ArmFreebsd : public FreeBSD
46 {
47  public:
48  static const ByteOrder byteOrder = ByteOrder::little;
49 };
50 
51 class ArmFreebsd32 : public ArmFreebsd, public OpenFlagTable<ArmFreebsd32>
52 {
53  public:
55  typedef uint32_t size_t;
57  typedef uint32_t off_t;
58  typedef int32_t time_t;
59  typedef int32_t clock_t;
61 
63  static constexpr int TGT_O_RDONLY = 0x00000000;
65  static constexpr int TGT_O_WRONLY = 0x00000001;
66  static constexpr int TGT_O_RDWR = 0x00000002;
67  static constexpr int TGT_O_CREAT = 0x00000200;
68  static constexpr int TGT_O_EXCL = 0x00000800;
69  static constexpr int TGT_O_NOCTTY = 0x00008000;
70  static constexpr int TGT_O_TRUNC = 0x00000400;
71  static constexpr int TGT_O_APPEND = 0x00000008;
72  static constexpr int TGT_O_NONBLOCK = 0x00000004;
73  static constexpr int TGT_O_SYNC = 0x00000080;
74  static constexpr int TGT_FASYNC = 0x00000040;
75  static constexpr int TGT_O_DIRECT = 0x00010000;
76  static constexpr int TGT_O_DIRECTORY = 0x00020000;
77  static constexpr int TGT_O_NOFOLLOW = 0x00000100;
78  static constexpr int TGT_O_CLOEXEC = 0x00100000;
80 
82  static constexpr unsigned TGT_MAP_SHARED = 0x0001;
83  static constexpr unsigned TGT_MAP_PRIVATE = 0x0002;
84  static constexpr unsigned TGT_MAP_ANONYMOUS = 0x1000;
85  static constexpr unsigned TGT_MAP_FIXED = 0x0010;
86 
88  struct rlimit
89  {
90  uint32_t rlim_cur;
91  uint32_t rlim_max;
92  };
93 
95  struct timeval
96  {
97  int32_t tv_sec;
98  int32_t tv_usec;
99  };
100 
101  // For writev/readv
102  struct tgt_iovec
103  {
104  uint32_t iov_base; // void *
105  uint32_t iov_len;
106  };
107 
108  /*
109  * sizeof st 120
110  * sizeof st_dev 4
111  * sizeof st_ino 4
112  * sizeof st_mode 2
113  * sizeof st_nlink 2
114  * sizeof st_uid 4
115  * sizeof st_gid 4
116  * sizeof st_rdev 4
117  * sizeof st_atim 16
118  * sizeof st_size 8
119  * sizeof st_blocks 8
120  * sizeof st_blksize 4
121  * sizeof st_flags 4
122  * sizeof st_gen 4
123  * sizeof st_lspare 4
124  */
125 
126  struct tgt_stat
127  {
128  uint32_t st_dev;
129  uint32_t st_ino;
130  uint16_t st_mode;
131  uint16_t st_nlink;
132  uint32_t st_uid;
133  uint32_t st_gid;
134  uint32_t st_rdev;
135  uint64_t st_atimeX;
136  uint64_t st_atime_nsec;
137  uint64_t st_mtimeX;
138  uint64_t st_mtime_nsec;
139  uint64_t st_ctimeX;
140  uint64_t st_ctime_nsec;
141  uint64_t st_size;
142  uint64_t st_blocks;
143  uint32_t st_blksize;
144  uint32_t st_flags;
145  uint32_t st_gen;
146  uint32_t st_lspare;
147  uint64_t st_birthtimX;
148  uint64_t st_birthtim;
149  };
150 
151  struct tgt_stat64
152  {
153  uint32_t st_dev;
154  uint32_t st_ino;
155  uint16_t st_mode;
156  uint16_t st_nlink;
157  uint32_t st_uid;
158  uint32_t st_gid;
159  uint32_t st_rdev;
160  uint64_t st_atimeX;
161  uint64_t st_atime_nsec;
162  uint64_t st_mtimeX;
163  uint64_t st_mtime_nsec;
164  uint64_t st_ctimeX;
165  uint64_t st_ctime_nsec;
166  uint64_t st_size;
167  uint64_t st_blocks;
168  uint32_t st_blksize;
169  uint32_t st_flags;
170  uint32_t st_gen;
171  uint32_t st_lspare;
172  uint64_t st_birthtimX;
173  uint64_t st_birthtim;
174  };
175 
177  struct rusage
178  {
179  struct timeval ru_utime;
180  struct timeval ru_stime;
181  int32_t ru_maxrss;
182  int32_t ru_ixrss;
183  int32_t ru_idrss;
184  int32_t ru_isrss;
185  int32_t ru_minflt;
186  int32_t ru_majflt;
187  int32_t ru_nswap;
188  int32_t ru_inblock;
189  int32_t ru_oublock;
190  int32_t ru_msgsnd;
191  int32_t ru_msgrcv;
192  int32_t ru_nsignals;
193  int32_t ru_nvcsw;
194  int32_t ru_nivcsw;
195  };
196 
198  struct tms
199  {
200  int32_t tms_utime;
201  int32_t tms_stime;
202  int32_t tms_cutime;
203  int32_t tms_cstime;
204  };
205 };
206 
207 class ArmFreebsd64 : public ArmFreebsd, public OpenFlagTable<ArmFreebsd64>
208 {
209  public:
210 
212  typedef uint64_t size_t;
214  typedef uint64_t off_t;
215  typedef int64_t time_t;
216  typedef int64_t clock_t;
218 
220  static constexpr int TGT_O_RDONLY = 0x00000000;
222  static constexpr int TGT_O_WRONLY = 0x00000001;
223  static constexpr int TGT_O_RDWR = 0x00000002;
224  static constexpr int TGT_O_CREAT = 0x00000200;
225  static constexpr int TGT_O_EXCL = 0x00000800;
226  static constexpr int TGT_O_NOCTTY = 0x00008000;
227  static constexpr int TGT_O_TRUNC = 0x00000400;
228  static constexpr int TGT_O_APPEND = 0x00000008;
229  static constexpr int TGT_O_NONBLOCK = 0x00000004;
230  static constexpr int TGT_O_SYNC = 0x00000080;
231  static constexpr int TGT_FASYNC = 0x00000040;
232  static constexpr int TGT_O_DIRECT = 0x00010000;
233  static constexpr int TGT_O_DIRECTORY = 0x00020000;
234  static constexpr int TGT_O_NOFOLLOW = 0x00000100;
235  static constexpr int TGT_O_CLOEXEC = 0x00100000;
237 
239  static constexpr unsigned TGT_MAP_SHARED = 0x0001;
240  static constexpr unsigned TGT_MAP_PRIVATE = 0x0002;
241  static constexpr unsigned TGT_MAP_ANONYMOUS = 0x1000;
242  static constexpr unsigned TGT_MAP_FIXED = 0x0010;
243 
245  static const int TGT_RUSAGE_SELF = 0;
247  static const int TGT_RUSAGE_CHILDREN = -1;
248  static const int TGT_RUSAGE_THREAD = 1;
250 
253  {
268  TGT_RLIMIT_KQUEUES = 13
269  };
270 
272  struct rlimit
273  {
274  uint64_t rlim_cur;
275  uint64_t rlim_max;
276  };
277 
279  struct timeval
280  {
281  int64_t tv_sec;
282  int64_t tv_usec;
283  };
284 
285  // For writev/readv
286  struct tgt_iovec
287  {
288  uint64_t iov_base; // void *
289  uint64_t iov_len;
290  };
291 
292  struct tgt_stat
293  {
294  uint32_t st_dev;
295  uint32_t st_ino;
296  uint16_t st_mode;
297  uint16_t st_nlink;
298  uint32_t st_uid;
299  uint32_t st_gid;
300  uint32_t st_rdev;
301  uint64_t st_atimeX;
302  uint64_t st_atime_nsec;
303  uint64_t st_mtimeX;
304  uint64_t st_mtime_nsec;
305  uint64_t st_ctimeX;
306  uint64_t st_ctime_nsec;
307  uint64_t st_size;
308  uint64_t st_blocks;
309  uint32_t st_blksize;
310  uint32_t st_flags;
311  uint32_t st_gen;
312  uint32_t st_lspare;
313  uint64_t st_birthtimX;
314  uint64_t st_birthtim;
315  };
316 
317  struct tgt_stat64
318  {
319  uint32_t st_dev;
320  uint32_t st_ino;
321  uint16_t st_mode;
322  uint16_t st_nlink;
323  uint32_t st_uid;
324  uint32_t st_gid;
325  uint32_t st_rdev;
326  uint64_t st_atimeX;
327  uint64_t st_atime_nsec;
328  uint64_t st_mtimeX;
329  uint64_t st_mtime_nsec;
330  uint64_t st_ctimeX;
331  uint64_t st_ctime_nsec;
332  uint64_t st_size;
333  uint64_t st_blocks;
334  uint32_t st_blksize;
335  uint32_t st_flags;
336  uint32_t st_gen;
337  uint32_t st_lspare;
338  uint64_t st_birthtimX;
339  uint64_t st_birthtim;
340  };
341 
343  struct rusage
344  {
345  struct timeval ru_utime;
346  struct timeval ru_stime;
347  int64_t ru_maxrss;
348  int64_t ru_ixrss;
349  int64_t ru_idrss;
350  int64_t ru_isrss;
351  int64_t ru_minflt;
352  int64_t ru_majflt;
353  int64_t ru_nswap;
354  int64_t ru_inblock;
355  int64_t ru_oublock;
356  int64_t ru_msgsnd;
357  int64_t ru_msgrcv;
358  int64_t ru_nsignals;
359  int64_t ru_nvcsw;
360  int64_t ru_nivcsw;
361  };
362 
364  struct tms
365  {
366  int64_t tms_utime;
367  int64_t tms_stime;
368  int64_t tms_cutime;
369  int64_t tms_cstime;
370  };
371 };
372 
373 } // namespace gem5
374 
375 #endif
static constexpr int TGT_O_CLOEXEC
O_CLOEXEC.
Definition: freebsd.hh:78
static constexpr int TGT_O_NONBLOCK
O_NONBLOCK.
Definition: freebsd.hh:72
static constexpr int TGT_O_DIRECTORY
O_DIRECTORY.
Definition: freebsd.hh:76
static constexpr int TGT_O_NOFOLLOW
O_NOFOLLOW.
Definition: freebsd.hh:77
static constexpr int TGT_O_TRUNC
O_TRUNC.
Definition: freebsd.hh:70
static constexpr unsigned TGT_MAP_FIXED
Definition: freebsd.hh:85
uint32_t off_t
Definition: freebsd.hh:57
static constexpr int TGT_O_DIRECT
O_DIRECT.
Definition: freebsd.hh:75
static constexpr int TGT_O_EXCL
O_EXCL.
Definition: freebsd.hh:68
int32_t time_t
Definition: freebsd.hh:58
static constexpr unsigned TGT_MAP_SHARED
For mmap().
Definition: freebsd.hh:82
static constexpr int TGT_O_APPEND
O_APPEND.
Definition: freebsd.hh:71
static constexpr unsigned TGT_MAP_PRIVATE
Definition: freebsd.hh:83
uint32_t size_t
Basic ARM FreeBSD types.
Definition: freebsd.hh:56
int32_t clock_t
Definition: freebsd.hh:59
static constexpr int TGT_O_RDONLY
open(2) flag values.
Definition: freebsd.hh:64
static constexpr int TGT_O_NOCTTY
O_NOCTTY.
Definition: freebsd.hh:69
static constexpr unsigned TGT_MAP_ANONYMOUS
Definition: freebsd.hh:84
static constexpr int TGT_FASYNC
FASYNC.
Definition: freebsd.hh:74
static constexpr int TGT_O_CREAT
O_CREAT.
Definition: freebsd.hh:67
static constexpr int TGT_O_WRONLY
O_WRONLY.
Definition: freebsd.hh:65
static constexpr int TGT_O_SYNC
O_SYNC.
Definition: freebsd.hh:73
static constexpr int TGT_O_RDWR
O_RDWR.
Definition: freebsd.hh:66
static constexpr int TGT_O_RDWR
O_RDWR.
Definition: freebsd.hh:223
static constexpr int TGT_O_DIRECT
O_DIRECT.
Definition: freebsd.hh:232
static constexpr unsigned TGT_MAP_PRIVATE
Definition: freebsd.hh:240
static constexpr int TGT_O_DIRECTORY
O_DIRECTORY.
Definition: freebsd.hh:233
static const int TGT_RUSAGE_THREAD
Definition: freebsd.hh:248
static constexpr unsigned TGT_MAP_ANONYMOUS
Definition: freebsd.hh:241
static constexpr int TGT_O_NOCTTY
O_NOCTTY.
Definition: freebsd.hh:226
static constexpr int TGT_O_CLOEXEC
O_CLOEXEC.
Definition: freebsd.hh:235
static constexpr int TGT_O_APPEND
O_APPEND.
Definition: freebsd.hh:228
static constexpr unsigned TGT_MAP_FIXED
Definition: freebsd.hh:242
static const int TGT_RUSAGE_SELF
For getrusage().
Definition: freebsd.hh:246
static constexpr int TGT_O_NONBLOCK
O_NONBLOCK.
Definition: freebsd.hh:229
rlimit_resources
Resource enumeration for getrlimit().
Definition: freebsd.hh:253
static constexpr int TGT_O_SYNC
O_SYNC.
Definition: freebsd.hh:230
static constexpr int TGT_O_EXCL
O_EXCL.
Definition: freebsd.hh:225
uint64_t off_t
Definition: freebsd.hh:214
static constexpr int TGT_O_RDONLY
open(2) flag values.
Definition: freebsd.hh:221
static constexpr int TGT_O_WRONLY
O_WRONLY.
Definition: freebsd.hh:222
static const int TGT_RUSAGE_CHILDREN
Definition: freebsd.hh:247
uint64_t size_t
Basic ARM FreeBSD types.
Definition: freebsd.hh:213
static constexpr int TGT_O_CREAT
O_CREAT.
Definition: freebsd.hh:224
static constexpr int TGT_O_NOFOLLOW
O_NOFOLLOW.
Definition: freebsd.hh:234
static constexpr int TGT_O_TRUNC
O_TRUNC.
Definition: freebsd.hh:227
static constexpr unsigned TGT_MAP_SHARED
For mmap().
Definition: freebsd.hh:239
static constexpr int TGT_FASYNC
FASYNC.
Definition: freebsd.hh:231
static const ByteOrder byteOrder
Definition: freebsd.hh:48
This class encapsulates the types, structures, constants, functions, and syscall-number mappings spec...
Definition: freebsd.hh:65
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Limit struct for getrlimit/setrlimit.
Definition: freebsd.hh:89
uint32_t rlim_cur
soft limit
Definition: freebsd.hh:90
uint32_t rlim_max
hard limit
Definition: freebsd.hh:91
For getrusage().
Definition: freebsd.hh:178
struct timeval ru_utime
user time used
Definition: freebsd.hh:179
int32_t ru_msgrcv
messages received
Definition: freebsd.hh:191
int32_t ru_oublock
block output operations
Definition: freebsd.hh:189
int32_t ru_majflt
page faults
Definition: freebsd.hh:186
int32_t ru_idrss
integral unshared data "
Definition: freebsd.hh:183
int32_t ru_isrss
integral unshared stack "
Definition: freebsd.hh:184
int32_t ru_nsignals
signals received
Definition: freebsd.hh:192
int32_t ru_nvcsw
voluntary context switches
Definition: freebsd.hh:193
int32_t ru_ixrss
integral shared memory size
Definition: freebsd.hh:182
struct timeval ru_stime
system time used
Definition: freebsd.hh:180
int32_t ru_inblock
block input operations
Definition: freebsd.hh:188
int32_t ru_nivcsw
involuntary "
Definition: freebsd.hh:194
int32_t ru_minflt
page reclaims - total vmfaults
Definition: freebsd.hh:185
int32_t ru_msgsnd
messages sent
Definition: freebsd.hh:190
int32_t ru_maxrss
max rss
Definition: freebsd.hh:181
For gettimeofday().
Definition: freebsd.hh:96
int32_t tv_usec
microseconds
Definition: freebsd.hh:98
int32_t tv_sec
seconds
Definition: freebsd.hh:97
int32_t tms_cutime
user time of children
Definition: freebsd.hh:202
int32_t tms_cstime
system time of children
Definition: freebsd.hh:203
int32_t tms_stime
system time
Definition: freebsd.hh:201
int32_t tms_utime
user time
Definition: freebsd.hh:200
Limit struct for getrlimit/setrlimit.
Definition: freebsd.hh:273
uint64_t rlim_cur
soft limit
Definition: freebsd.hh:274
uint64_t rlim_max
hard limit
Definition: freebsd.hh:275
For getrusage().
Definition: freebsd.hh:344
int64_t ru_majflt
page faults
Definition: freebsd.hh:352
struct timeval ru_stime
system time used
Definition: freebsd.hh:346
int64_t ru_idrss
integral unshared data "
Definition: freebsd.hh:349
struct timeval ru_utime
user time used
Definition: freebsd.hh:345
int64_t ru_nvcsw
voluntary context switches
Definition: freebsd.hh:359
int64_t ru_inblock
block input operations
Definition: freebsd.hh:354
int64_t ru_isrss
integral unshared stack "
Definition: freebsd.hh:350
int64_t ru_msgsnd
messages sent
Definition: freebsd.hh:356
int64_t ru_oublock
block output operations
Definition: freebsd.hh:355
int64_t ru_msgrcv
messages received
Definition: freebsd.hh:357
int64_t ru_minflt
page reclaims - total vmfaults
Definition: freebsd.hh:351
int64_t ru_nivcsw
involuntary "
Definition: freebsd.hh:360
int64_t ru_maxrss
max rss
Definition: freebsd.hh:347
int64_t ru_nsignals
signals received
Definition: freebsd.hh:358
int64_t ru_ixrss
integral shared memory size
Definition: freebsd.hh:348
For gettimeofday().
Definition: freebsd.hh:280
int64_t tv_sec
seconds
Definition: freebsd.hh:281
int64_t tv_usec
microseconds
Definition: freebsd.hh:282
int64_t tms_cstime
system time of children
Definition: freebsd.hh:369
int64_t tms_cutime
user time of children
Definition: freebsd.hh:368
int64_t tms_utime
user time
Definition: freebsd.hh:366
int64_t tms_stime
system time
Definition: freebsd.hh:367

Generated on Wed Dec 21 2022 10:22:25 for gem5 by doxygen 1.9.1