mem-cache: Add multiple eviction stats
[gem5.git] / src / arch / arm / freebsd / freebsd.hh
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 "kern/freebsd/freebsd.hh"
37
38 class ArmFreebsd : public FreeBSD
39 {
40 public:
41 static const ByteOrder byteOrder = LittleEndianByteOrder;
42 };
43
44 class ArmFreebsd32 : public ArmFreebsd
45 {
46 public:
47 /// This table maps the target open() flags to the corresponding
48 /// host open() flags.
49 static SyscallFlagTransTable openFlagTable[];
50
51 /// Number of entries in openFlagTable[].
52 static const int NUM_OPEN_FLAGS;
53
54 //@{
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;
60 //@}
61
62 //@{
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
79 //@}
80
81 /// For mmap().
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;
86
87 /// Limit struct for getrlimit/setrlimit.
88 struct rlimit {
89 uint32_t rlim_cur; //!< soft limit
90 uint32_t rlim_max; //!< hard limit
91 };
92
93 /// For gettimeofday().
94 struct timeval {
95 int32_t tv_sec; //!< seconds
96 int32_t tv_usec; //!< microseconds
97 };
98
99 // For writev/readv
100 struct tgt_iovec {
101 uint32_t iov_base; // void *
102 uint32_t iov_len;
103 };
104
105 /*
106 * sizeof st 120
107 * sizeof st_dev 4
108 * sizeof st_ino 4
109 * sizeof st_mode 2
110 * sizeof st_nlink 2
111 * sizeof st_uid 4
112 * sizeof st_gid 4
113 * sizeof st_rdev 4
114 * sizeof st_atim 16
115 * sizeof st_size 8
116 * sizeof st_blocks 8
117 * sizeof st_blksize 4
118 * sizeof st_flags 4
119 * sizeof st_gen 4
120 * sizeof st_lspare 4
121 */
122
123 typedef struct {
124 uint32_t st_dev;
125 uint32_t st_ino;
126 uint16_t st_mode;
127 uint16_t st_nlink;
128 uint32_t st_uid;
129 uint32_t st_gid;
130 uint32_t st_rdev;
131 uint64_t st_atimeX;
132 uint64_t st_atime_nsec;
133 uint64_t st_mtimeX;
134 uint64_t st_mtime_nsec;
135 uint64_t st_ctimeX;
136 uint64_t st_ctime_nsec;
137 uint64_t st_size;
138 uint64_t st_blocks;
139 uint32_t st_blksize;
140 uint32_t st_flags;
141 uint32_t st_gen;
142 uint32_t st_lspare;
143 uint64_t st_birthtimX;
144 uint64_t st_birthtim;
145 } tgt_stat;
146
147 typedef struct {
148 uint32_t st_dev;
149 uint32_t st_ino;
150 uint16_t st_mode;
151 uint16_t st_nlink;
152 uint32_t st_uid;
153 uint32_t st_gid;
154 uint32_t st_rdev;
155 uint64_t st_atimeX;
156 uint64_t st_atime_nsec;
157 uint64_t st_mtimeX;
158 uint64_t st_mtime_nsec;
159 uint64_t st_ctimeX;
160 uint64_t st_ctime_nsec;
161 uint64_t st_size;
162 uint64_t st_blocks;
163 uint32_t st_blksize;
164 uint32_t st_flags;
165 uint32_t st_gen;
166 uint32_t st_lspare;
167 uint64_t st_birthtimX;
168 uint64_t st_birthtim;
169 } tgt_stat64;
170
171 /// For getrusage().
172 struct rusage {
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 "
189 };
190
191 /// For times().
192 struct tms {
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
197 };
198 };
199
200 class ArmFreebsd64 : public ArmFreebsd
201 {
202 public:
203
204 /// This table maps the target open() flags to the corresponding
205 /// host open() flags.
206 static SyscallFlagTransTable openFlagTable[];
207
208 /// Number of entries in openFlagTable[].
209 static const int NUM_OPEN_FLAGS;
210
211 //@{
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;
217 //@}
218
219 //@{
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
236 //@}
237
238 /// For mmap().
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;
243
244 //@{
245 /// For getrusage().
246 static const int TGT_RUSAGE_SELF = 0;
247 static const int TGT_RUSAGE_CHILDREN = -1;
248 static const int TGT_RUSAGE_THREAD = 1;
249 //@}
250
251 /// Resource enumeration for getrlimit().
252 enum rlimit_resources {
253 TGT_RLIMIT_CPU = 0,
254 TGT_RLIMIT_FSIZE = 1,
255 TGT_RLIMIT_DATA = 2,
256 TGT_RLIMIT_STACK = 3,
257 TGT_RLIMIT_CORE = 4,
258 TGT_RLIMIT_RSS = 5,
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
268 };
269
270 /// Limit struct for getrlimit/setrlimit.
271 struct rlimit {
272 uint64_t rlim_cur; //!< soft limit
273 uint64_t rlim_max; //!< hard limit
274 };
275
276 /// For gettimeofday().
277 struct timeval {
278 int64_t tv_sec; //!< seconds
279 int64_t tv_usec; //!< microseconds
280 };
281
282 // For writev/readv
283 struct tgt_iovec {
284 uint64_t iov_base; // void *
285 uint64_t iov_len;
286 };
287
288 typedef struct {
289 uint32_t st_dev;
290 uint32_t st_ino;
291 uint16_t st_mode;
292 uint16_t st_nlink;
293 uint32_t st_uid;
294 uint32_t st_gid;
295 uint32_t st_rdev;
296 uint64_t st_atimeX;
297 uint64_t st_atime_nsec;
298 uint64_t st_mtimeX;
299 uint64_t st_mtime_nsec;
300 uint64_t st_ctimeX;
301 uint64_t st_ctime_nsec;
302 uint64_t st_size;
303 uint64_t st_blocks;
304 uint32_t st_blksize;
305 uint32_t st_flags;
306 uint32_t st_gen;
307 uint32_t st_lspare;
308 uint64_t st_birthtimX;
309 uint64_t st_birthtim;
310 } tgt_stat;
311
312 typedef struct {
313 uint32_t st_dev;
314 uint32_t st_ino;
315 uint16_t st_mode;
316 uint16_t st_nlink;
317 uint32_t st_uid;
318 uint32_t st_gid;
319 uint32_t st_rdev;
320 uint64_t st_atimeX;
321 uint64_t st_atime_nsec;
322 uint64_t st_mtimeX;
323 uint64_t st_mtime_nsec;
324 uint64_t st_ctimeX;
325 uint64_t st_ctime_nsec;
326 uint64_t st_size;
327 uint64_t st_blocks;
328 uint32_t st_blksize;
329 uint32_t st_flags;
330 uint32_t st_gen;
331 uint32_t st_lspare;
332 uint64_t st_birthtimX;
333 uint64_t st_birthtim;
334 } tgt_stat64;
335
336 /// For getrusage().
337 struct rusage {
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 "
354 };
355
356 /// For times().
357 struct tms {
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
362 };
363 };
364
365 #endif