gem5  v19.0.0.0
linux.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * Authors: Korey Sewell
29  */
30 
31 #ifndef __ARCH_RISCV_LINUX_LINUX_HH__
32 #define __ARCH_RISCV_LINUX_LINUX_HH__
33 
34 #include "arch/riscv/utility.hh"
35 #include "kern/linux/linux.hh"
36 
37 class RiscvLinux : public Linux
38 {
39  public:
41 };
42 
43 class RiscvLinux64 : public RiscvLinux
44 {
45  public:
46  static const int TGT_SIGHUP = 1;
47  static const int TGT_SIGINT = 2;
48  static const int TGT_SIGQUIT = 3;
49  static const int TGT_SIGILL = 4;
50  static const int TGT_SIGTRAP = 5;
51  static const int TGT_SIGABRT = 6;
52  static const int TGT_SIGIOT = 6;
53  static const int TGT_SIGEMT = 7;
54  static const int TGT_SIGFPE = 8;
55  static const int TGT_SIGKILL = 9;
56  static const int TGT_SIGBUS = 10;
57  static const int TGT_SIGSEGV = 11;
58  static const int TGT_SIGSYS = 12;
59  static const int TGT_SIGPIPE = 13;
60  static const int TGT_SIGALRM = 14;
61  static const int TGT_SIGTERM = 15;
62  static const int TGT_SIGURG = 16;
63  static const int TGT_SIGSTOP = 17;
64  static const int TGT_SIGTSTP = 18;
65  static const int TGT_SIGCONT = 19;
66  static const int TGT_SIGCHLD = 20;
67  static const int TGT_SIGCLD = 20;
68  static const int TGT_SIGTTIN = 21;
69  static const int TGT_SIGTTOU = 22;
70  static const int TGT_SIGPOLL = 23;
71  static const int TGT_SIGIO = 23;
72  static const int TGT_SIGXCPU = 24;
73  static const int TGT_SIGXFSZ = 25;
74  static const int TGT_SIGVTALRM = 26;
75  static const int TGT_SIGPROF = 27;
76  static const int TGT_SIGWINCH = 28;
77  static const int TGT_SIGLOST = 29;
78  static const int TGT_SIGPWR = 29;
79  static const int TGT_SIGUSR1 = 30;
80  static const int TGT_SIGUSR2 = 31;
81 
84  static SyscallFlagTransTable openFlagTable[];
85 
87  static const int NUM_OPEN_FLAGS;
88 
90  static const int TGT_O_RDONLY = 0x000000;
92  static const int TGT_O_WRONLY = 0x000001;
93  static const int TGT_O_RDWR = 0x000002;
94  static const int TGT_O_CREAT = 0x000040;
95  static const int TGT_O_EXCL = 0x000080;
96  static const int TGT_O_NOCTTY = 0x000100;
97  static const int TGT_O_TRUNC = 0x000200;
98  static const int TGT_O_APPEND = 0x000400;
99  static const int TGT_O_NONBLOCK = 0x000800;
100  static const int TGT_O_SYNC = 0x001000;
101  static const int TGT_FSYNC = 0x001000;
102  static const int TGT_FASYNC = 0x008000;
103  // The following are not present in riscv64-unknown-elf <fcntl.h>
104  static const int TGT_O_DSYNC = 0x010000;
105  static const int TGT_O_CLOEXEC = 0x040000;
106  static const int TGT_O_NOINHERIT = 0x040000;
107  static const int TGT_O_DIRECT = 0x080000;
108  static const int TGT_O_NOFOLLOW = 0x100000;
109  static const int TGT_O_DIRECTORY = 0x200000;
110  // The following are not defined by riscv64-unknown-elf
111  static const int TGT_O_LARGEFILE = 0x020000;
112  static const int TGT_O_NOATIME = 0x800000;
113  static const int TGT_O_PATH = 0x400000;
114 
115 
116  // Only defined in riscv-unknown-elf for proxy kernel and not linux kernel
117  static const unsigned TGT_MAP_SHARED = 0x0001;
118  static const unsigned TGT_MAP_PRIVATE = 0x0002;
119  static const unsigned TGT_MAP_FIXED = 0x0010;
120  static const unsigned TGT_MAP_ANONYMOUS = 0x0020;
121  static const unsigned TGT_MAP_POPULATE = 0x1000;
122  static const unsigned TGT_MREMAP_FIXED = 0x0020;
123 
124  static const unsigned NUM_MMAP_FLAGS;
125 
126  typedef int64_t time_t;
127  typedef uint64_t dev_t;
128  typedef uint64_t ino_t;
129  typedef uint32_t mode_t;
130  typedef uint32_t nlink_t;
131  typedef uint32_t uid_t;
132  typedef uint32_t gid_t;
133  typedef int64_t off_t;
134  typedef uint64_t blksize_t;
135  typedef uint64_t blkcnt_t;
136 
137  struct timespec {
138  time_t tv_sec;
139  int64_t tv_nsec;
140  };
141 
142  typedef struct {
143  dev_t st_dev;
144  ino_t st_ino;
145  mode_t st_mode;
146  nlink_t st_nlink;
147  uid_t st_uid;
148  gid_t st_gid;
149  dev_t st_rdev;
150  dev_t __pad1;
151  off_t st_size;
152  blksize_t st_blksize;
153  blkcnt_t st_blocks;
154  uint64_t st_atimeX;
155  uint64_t st_atime_nsec;
156  uint64_t st_mtimeX;
157  uint64_t st_mtime_nsec;
158  uint64_t st_ctimeX;
159  uint64_t st_ctime_nsec;
160  int32_t ___glibc_reserved[2];
161  } tgt_stat64;
162 
163  typedef struct {
164  int32_t val[2];
165  } tgt_fsid_t;
166 
167  typedef struct {
168  uint64_t f_type;
169  uint64_t f_bsize;
170  uint64_t f_blocks;
171  uint64_t f_bfree;
172  uint64_t f_bavail;
173  uint64_t f_files;
174  uint64_t f_ffree;
176  uint64_t f_namelen;
177  uint64_t f_frsize;
178  uint64_t f_flags;
179  uint64_t f_spare[4];
180  } tgt_statfs;
181 
182  typedef struct {
183  int64_t uptime;
184  uint64_t loads[3];
185  uint64_t totalram;
186  uint64_t freeram;
187  uint64_t sharedram;
188  uint64_t bufferram;
189  uint64_t totalswap;
190  uint64_t freeswap;
191  uint16_t procs;
192  uint16_t pad;
193  uint64_t totalhigh;
194  uint64_t freehigh;
195  uint32_t mem_unit;
196  } tgt_sysinfo;
197 
198  static void
199  archClone(uint64_t flags,
200  Process *pp, Process *cp,
202  uint64_t stack, uint64_t tls)
203  {
204  RiscvISA::copyRegs(ptc, ctc);
205  if (flags & TGT_CLONE_SETTLS)
207  if (stack)
209  }
210 };
211 
212 class RiscvLinux32 : public RiscvLinux
213 {
214  public:
215  static const int TGT_SIGHUP = 1;
216  static const int TGT_SIGINT = 2;
217  static const int TGT_SIGQUIT = 3;
218  static const int TGT_SIGILL = 4;
219  static const int TGT_SIGTRAP = 5;
220  static const int TGT_SIGABRT = 6;
221  static const int TGT_SIGIOT = 6;
222  static const int TGT_SIGEMT = 7;
223  static const int TGT_SIGFPE = 8;
224  static const int TGT_SIGKILL = 9;
225  static const int TGT_SIGBUS = 10;
226  static const int TGT_SIGSEGV = 11;
227  static const int TGT_SIGSYS = 12;
228  static const int TGT_SIGPIPE = 13;
229  static const int TGT_SIGALRM = 14;
230  static const int TGT_SIGTERM = 15;
231  static const int TGT_SIGURG = 16;
232  static const int TGT_SIGSTOP = 17;
233  static const int TGT_SIGTSTP = 18;
234  static const int TGT_SIGCONT = 19;
235  static const int TGT_SIGCHLD = 20;
236  static const int TGT_SIGCLD = 20;
237  static const int TGT_SIGTTIN = 21;
238  static const int TGT_SIGTTOU = 22;
239  static const int TGT_SIGPOLL = 23;
240  static const int TGT_SIGIO = 23;
241  static const int TGT_SIGXCPU = 24;
242  static const int TGT_SIGXFSZ = 25;
243  static const int TGT_SIGVTALRM = 26;
244  static const int TGT_SIGPROF = 27;
245  static const int TGT_SIGWINCH = 28;
246  static const int TGT_SIGLOST = 29;
247  static const int TGT_SIGPWR = 29;
248  static const int TGT_SIGUSR1 = 30;
249  static const int TGT_SIGUSR2 = 31;
250 
253  static SyscallFlagTransTable openFlagTable[];
254 
256  static const int NUM_OPEN_FLAGS;
257 
259  // The following values match newlib 3.0.0.
261  // Note that glibc has different values.
262  static const int TGT_O_RDONLY = 0x000000;
263  static const int TGT_O_WRONLY = 0x000001;
264  static const int TGT_O_RDWR = 0x000002;
265  static const int TGT_O_CREAT = 0x000200;
266  static const int TGT_O_EXCL = 0x000800;
267  static const int TGT_O_NOCTTY = 0x008000;
268  static const int TGT_O_TRUNC = 0x000400;
269  static const int TGT_O_APPEND = 0x000008;
270  static const int TGT_O_NONBLOCK = 0x004000;
271  static const int TGT_O_SYNC = 0x002000;
272  static const int TGT_FSYNC = 0x002000;
273  static const int TGT_FASYNC = 0x000040;
274  // The following are not present in riscv32-unknown-elf <fcntl.h>
275  static const int TGT_O_DSYNC = 0x010000;
276  static const int TGT_O_CLOEXEC = 0x040000;
277  static const int TGT_O_NOINHERIT = 0x040000;
278  static const int TGT_O_DIRECT = 0x080000;
279  static const int TGT_O_NOFOLLOW = 0x100000;
280  static const int TGT_O_DIRECTORY = 0x200000;
281  // The following are not defined by riscv32-unknown-elf
282  static const int TGT_O_LARGEFILE = 0x020000;
283  static const int TGT_O_NOATIME = 0x800000;
284  static const int TGT_O_PATH = 0x400000;
285 
286 
287  // Only defined in riscv-unknown-elf for proxy kernel and not linux kernel
288  static const unsigned TGT_MAP_SHARED = 0x0001;
289  static const unsigned TGT_MAP_PRIVATE = 0x0002;
290  static const unsigned TGT_MAP_FIXED = 0x0010;
291  static const unsigned TGT_MAP_ANONYMOUS = 0x0020;
292  static const unsigned TGT_MAP_POPULATE = 0x1000;
293  static const unsigned TGT_MREMAP_FIXED = 0x0020;
294 
295  static const unsigned NUM_MMAP_FLAGS;
296 
297  // Newlib 3.0.0 defaults to 64-bits for time_t.
298  // Currently time_t in glibc for riscv32 is 32-bits, but will be changed.
299  typedef int64_t time_t;
300 
302  struct rlimit {
303  uint32_t rlim_cur;
304  uint32_t rlim_max;
305  };
306 
307  struct timespec {
308  time_t tv_sec;
309  int32_t tv_nsec;
310  };
311 
312  typedef struct {
313  int32_t val[2];
314  } tgt_fsid_t;
315 
316  typedef struct {
317  uint64_t st_dev;
318  uint64_t st_ino;
319  uint32_t st_mode;
320  uint32_t st_nlink;
321  uint32_t st_uid;
322  uint32_t st_gid;
323  uint64_t st_rdev;
324  uint64_t __pad1;
325  int64_t st_size;
326  int32_t st_blksize;
327  int32_t __pad2;
328  int64_t st_blocks;
329  time_t st_atimeX;
330  int32_t st_atime_nsec;
331  time_t st_mtimeX;
332  int32_t st_mtime_nsec;
333  time_t st_ctimeX;
334  int32_t st_ctime_nsec;
335  int32_t __unused4;
336  int32_t __unused5;
337  } tgt_stat;
338 
339  typedef struct {
340  uint32_t f_type;
341  uint32_t f_bsize;
342  uint32_t f_blocks;
343  uint32_t f_bfree;
344  uint32_t f_bavail;
345  uint32_t f_files;
346  uint32_t f_ffree;
348  uint32_t f_namelen;
349  uint32_t f_frsize;
350  uint32_t f_flags;
351  uint32_t f_spare[4];
352  } tgt_statfs;
353 
354  typedef struct {
355  int32_t uptime;
356  uint32_t loads[3];
357  uint32_t totalram;
358  uint32_t freeram;
359  uint32_t sharedram;
360  uint32_t bufferram;
361  uint32_t totalswap;
362  uint32_t freeswap;
363  uint16_t procs;
364  uint16_t pad;
365  uint32_t totalhigh;
366  uint32_t freehigh;
367  uint32_t mem_unit;
368  } tgt_sysinfo;
369 
370  static void
371  archClone(uint64_t flags,
372  Process *pp, Process *cp,
374  uint64_t stack, uint64_t tls)
375  {
376  RiscvISA::copyRegs(ptc, ctc);
377  if (stack)
379  }
380 };
381 
382 #endif
uint64_t st_atime_nsec
Definition: linux.hh:155
uint64_t blksize_t
Definition: linux.hh:134
int32_t st_ctime_nsec
Definition: linux.hh:334
static const int NUM_OPEN_FLAGS
Number of entries in openFlagTable[].
Definition: linux.hh:87
const int StackPointerReg
Definition: registers.hh:102
int64_t off_t
Definition: linux.hh:133
uint32_t nlink_t
Definition: linux.hh:130
const int ThreadPointerReg
Definition: registers.hh:104
uint64_t blkcnt_t
Definition: linux.hh:135
static const unsigned NUM_MMAP_FLAGS
Definition: linux.hh:124
Definition: cprintf.cc:42
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Bitfield< 63 > val
Definition: misc.hh:771
static void archClone(uint64_t flags, Process *pp, Process *cp, ThreadContext *ptc, ThreadContext *ctc, uint64_t stack, uint64_t tls)
Definition: linux.hh:199
blksize_t st_blksize
Definition: linux.hh:152
uint32_t rlim_max
hard limit
Definition: linux.hh:304
static const unsigned TGT_MREMAP_FIXED
Definition: linux.hh:274
static const unsigned NUM_MMAP_FLAGS
Definition: linux.hh:295
uint32_t mode_t
Definition: linux.hh:129
static const int NUM_OPEN_FLAGS
Number of entries in openFlagTable[].
Definition: linux.hh:256
uint64_t dev_t
Definition: linux.hh:127
ByteOrder
Definition: types.hh:247
static const unsigned TGT_CLONE_SETTLS
Definition: linux.hh:286
void tgt_stat
Stat buffer.
uint32_t gid_t
Definition: linux.hh:132
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
This struct is used to build target-OS-dependent tables that map the target&#39;s flags to the host&#39;s fla...
Bitfield< 17, 16 > stack
Definition: misc.hh:589
static void archClone(uint64_t flags, Process *pp, Process *cp, ThreadContext *ptc, ThreadContext *ctc, uint64_t stack, uint64_t tls)
Definition: linux.hh:371
static const ByteOrder byteOrder
Definition: linux.hh:40
uint64_t ino_t
Definition: linux.hh:128
Bitfield< 7, 0 > ptc
Definition: mt_constants.hh:56
Limit struct for getrlimit/setrlimit.
Definition: linux.hh:302
uint32_t rlim_cur
soft limit
Definition: linux.hh:303
int32_t st_atime_nsec
Definition: linux.hh:330
uint64_t st_ctime_nsec
Definition: linux.hh:159
uint32_t uid_t
Definition: linux.hh:131
int64_t time_t
Definition: linux.hh:126
void copyRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.hh:121
uint64_t st_mtime_nsec
Definition: linux.hh:157
int32_t st_mtime_nsec
Definition: linux.hh:332
int64_t time_t
Definition: linux.hh:299

Generated on Fri Feb 28 2020 16:26:56 for gem5 by doxygen 1.8.13