gem5  v19.0.0.0
linux.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007 The Hewlett-Packard Development Company
3  * All rights reserved.
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Authors: Gabe Black
38  */
39 
40 #ifndef __ARCH_X86_LINUX_LINUX_HH__
41 #define __ARCH_X86_LINUX_LINUX_HH__
42 
43 #include "arch/x86/utility.hh"
44 #include "kern/linux/linux.hh"
45 
46 class X86Linux : public Linux
47 {
48  public:
50 
51  static void
52  archClone(uint64_t flags,
53  Process *pp, Process *cp,
55  uint64_t stack, uint64_t tls)
56  {
57  X86ISA::copyRegs(ptc, ctc);
58 
59  if (flags & TGT_CLONE_SETTLS) {
62  }
63 
64  if (stack)
66  }
67 };
68 
69 class X86Linux64 : public X86Linux
70 {
71  public:
72 
73  typedef struct {
74  uint64_t st_dev;
75  uint64_t st_ino;
76  uint64_t st_nlink;
77  uint32_t st_mode;
78  uint32_t st_uid;
79  uint32_t st_gid;
80  uint32_t __pad0;
81  uint64_t st_rdev;
82  int64_t st_size;
83  int64_t st_blksize;
84  int64_t st_blocks;
85  uint64_t st_atimeX;
86  uint64_t st_atime_nsec;
87  uint64_t st_mtimeX;
88  uint64_t st_mtime_nsec;
89  uint64_t st_ctimeX;
90  uint64_t st_ctime_nsec;
91  int64_t unused0[3];
92  } tgt_stat64;
93 
94  typedef struct {
95  long val[2];
96  } tgt_fsid;
97 
98  typedef struct {
99  long f_type;
100  long f_bsize;
101  long f_blocks;
102  long f_bfree;
103  long f_bavail;
104  long f_files;
105  long f_ffree;
107  long f_namelen;
108  long f_frsize;
109  long f_spare[5];
110  } tgt_statfs;
111 
112  static const int TGT_SIGHUP = 0x000001;
113  static const int TGT_SIGINT = 0x000002;
114  static const int TGT_SIGQUIT = 0x000003;
115  static const int TGT_SIGILL = 0x000004;
116  static const int TGT_SIGTRAP = 0x000005;
117  static const int TGT_SIGABRT = 0x000006;
118  static const int TGT_SIGIOT = 0x000006;
119  static const int TGT_SIGBUS = 0x000007;
120  static const int TGT_SIGFPE = 0x000008;
121  static const int TGT_SIGKILL = 0x000009;
122  static const int TGT_SIGUSR1 = 0x00000a;
123  static const int TGT_SIGSEGV = 0x00000b;
124  static const int TGT_SIGUSR2 = 0x00000c;
125  static const int TGT_SIGPIPE = 0x00000d;
126  static const int TGT_SIGALRM = 0x00000e;
127  static const int TGT_SIGTERM = 0x00000f;
128  static const int TGT_SIGSTKFLT = 0x000010;
129  static const int TGT_SIGCHLD = 0x000011;
130  static const int TGT_SIGCONT = 0x000012;
131  static const int TGT_SIGSTOP = 0x000013;
132  static const int TGT_SIGTSTP = 0x000014;
133  static const int TGT_SIGTTIN = 0x000015;
134  static const int TGT_SIGTTOU = 0x000016;
135  static const int TGT_SIGURG = 0x000017;
136  static const int TGT_SIGXCPU = 0x000018;
137  static const int TGT_SIGXFSZ = 0x000019;
138  static const int TGT_SIGVTALRM = 0x00001a;
139  static const int TGT_SIGPROF = 0x00001b;
140  static const int TGT_SIGWINCH = 0x00001c;
141  static const int TGT_SIGIO = 0x00001d;
142  static const int TGT_SIGPOLL = 0x00001d;
143  static const int TGT_SIGPWR = 0x00001e;
144  static const int TGT_SIGSYS = 0x00001f;
145  static const int TGT_SIGUNUSED = 0x00001f;
146 
147  static SyscallFlagTransTable openFlagTable[];
148 
149  static const int TGT_O_RDONLY = 000000000;
150  static const int TGT_O_WRONLY = 000000001;
151  static const int TGT_O_RDWR = 000000002;
152  static const int TGT_O_CREAT = 000000100;
153  static const int TGT_O_EXCL = 000000200;
154  static const int TGT_O_NOCTTY = 000000400;
155  static const int TGT_O_TRUNC = 000001000;
156  static const int TGT_O_APPEND = 000002000;
157  static const int TGT_O_NONBLOCK = 000004000;
158  static const int TGT_O_DSYNC = 000010000;
159  static const int TGT_FASYNC = 000020000;
160  static const int TGT_O_DIRECT = 000040000;
161  static const int TGT_O_LARGEFILE = 000100000;
162  static const int TGT_O_DIRECTORY = 000200000;
163  static const int TGT_O_NOFOLLOW = 000400000;
164  static const int TGT_O_NOATIME = 001000000;
165  static const int TGT_O_CLOEXEC = 002000000;
166  static const int TGT_O_SYNC = 004010000;
167  static const int TGT_O_PATH = 010000000;
168 
169  static const int NUM_OPEN_FLAGS;
170 
171  static const unsigned TGT_MAP_SHARED = 0x00001;
172  static const unsigned TGT_MAP_PRIVATE = 0x00002;
173  static const unsigned TGT_MAP_32BIT = 0x00040;
174  static const unsigned TGT_MAP_ANON = 0x00020;
175  static const unsigned TGT_MAP_DENYWRITE = 0x00800;
176  static const unsigned TGT_MAP_EXECUTABLE = 0x01000;
177  static const unsigned TGT_MAP_FILE = 0x00000;
178  static const unsigned TGT_MAP_GROWSDOWN = 0x00100;
179  static const unsigned TGT_MAP_HUGETLB = 0x40000;
180  static const unsigned TGT_MAP_LOCKED = 0x02000;
181  static const unsigned TGT_MAP_NONBLOCK = 0x10000;
182  static const unsigned TGT_MAP_NORESERVE = 0x04000;
183  static const unsigned TGT_MAP_POPULATE = 0x08000;
184  static const unsigned TGT_MAP_STACK = 0x20000;
185  static const unsigned TGT_MAP_ANONYMOUS = 0x00020;
186  static const unsigned TGT_MAP_FIXED = 0x00010;
187 
188  static const unsigned NUM_MMAP_FLAGS;
189 
190  typedef struct {
191  uint64_t iov_base; // void *
192  uint64_t iov_len; // size_t
193  } tgt_iovec;
194 
195  typedef struct {
196  int64_t uptime; /* Seconds since boot */
197  uint64_t loads[3]; /* 1, 5, and 15 minute load averages */
198  uint64_t totalram; /* Total usable main memory size */
199  uint64_t freeram; /* Available memory size */
200  uint64_t sharedram; /* Amount of shared memory */
201  uint64_t bufferram; /* Memory used by buffers */
202  uint64_t totalswap; /* Total swap space size */
203  uint64_t freeswap; /* swap space still available */
204  uint16_t procs; /* Number of current processes */
205  uint64_t totalhigh; /* Total high memory size */
206  uint64_t freehigh; /* Available high memory size */
207  uint64_t mem_unit; /* Memory unit size in bytes */
208  } tgt_sysinfo;
209 
210 };
211 
212 class X86Linux32 : public X86Linux
213 {
214  public:
215 
216  typedef struct {
217  uint64_t st_dev;
218  uint8_t __pad0[4];
219  uint32_t __st_ino;
220  uint32_t st_mode;
221  uint32_t st_nlink;
222  uint32_t st_uid;
223  uint32_t st_gid;
224  uint64_t st_rdev;
225  uint8_t __pad3[4];
226  int64_t st_size;
227  uint32_t st_blksize;
228  uint64_t st_blocks;
229  uint32_t st_atimeX;
230  uint32_t st_atime_nsec;
231  uint32_t st_mtimeX;
232  uint32_t st_mtime_nsec;
233  uint32_t st_ctimeX;
234  uint32_t st_ctime_nsec;
235  uint64_t st_ino;
236  } __attribute__((__packed__)) tgt_stat64;
237 
238  static const int TGT_SIGHUP = 0x000001;
239  static const int TGT_SIGINT = 0x000002;
240  static const int TGT_SIGQUIT = 0x000003;
241  static const int TGT_SIGILL = 0x000004;
242  static const int TGT_SIGTRAP = 0x000005;
243  static const int TGT_SIGABRT = 0x000006;
244  static const int TGT_SIGIOT = 0x000006;
245  static const int TGT_SIGBUS = 0x000007;
246  static const int TGT_SIGFPE = 0x000008;
247  static const int TGT_SIGKILL = 0x000009;
248  static const int TGT_SIGUSR1 = 0x00000a;
249  static const int TGT_SIGSEGV = 0x00000b;
250  static const int TGT_SIGUSR2 = 0x00000c;
251  static const int TGT_SIGPIPE = 0x00000d;
252  static const int TGT_SIGALRM = 0x00000e;
253  static const int TGT_SIGTERM = 0x00000f;
254  static const int TGT_SIGSTKFLT = 0x000010;
255  static const int TGT_SIGCHLD = 0x000011;
256  static const int TGT_SIGCONT = 0x000012;
257  static const int TGT_SIGSTOP = 0x000013;
258  static const int TGT_SIGTSTP = 0x000014;
259  static const int TGT_SIGTTIN = 0x000015;
260  static const int TGT_SIGTTOU = 0x000016;
261  static const int TGT_SIGURG = 0x000017;
262  static const int TGT_SIGXCPU = 0x000018;
263  static const int TGT_SIGXFSZ = 0x000019;
264  static const int TGT_SIGVTALRM = 0x00001a;
265  static const int TGT_SIGPROF = 0x00001b;
266  static const int TGT_SIGWINCH = 0x00001c;
267  static const int TGT_SIGIO = 0x00001d;
268  static const int TGT_SIGPOLL = 0x00001d;
269  static const int TGT_SIGPWR = 0x00001e;
270  static const int TGT_SIGSYS = 0x00001f;
271  static const int TGT_SIGUNUSED = 0x00001f;
272 
273  static SyscallFlagTransTable openFlagTable[];
274 
275  static const int TGT_O_RDONLY = 000000000;
276  static const int TGT_O_WRONLY = 000000001;
277  static const int TGT_O_RDWR = 000000002;
278  static const int TGT_O_CREAT = 000000100;
279  static const int TGT_O_EXCL = 000000200;
280  static const int TGT_O_NOCTTY = 000000400;
281  static const int TGT_O_TRUNC = 000001000;
282  static const int TGT_O_APPEND = 000002000;
283  static const int TGT_O_NONBLOCK = 000004000;
284  static const int TGT_O_DSYNC = 000010000;
285  static const int TGT_FASYNC = 000020000;
286  static const int TGT_O_DIRECT = 000040000;
287  static const int TGT_O_LARGEFILE = 000100000;
288  static const int TGT_O_DIRECTORY = 000200000;
289  static const int TGT_O_NOFOLLOW = 000400000;
290  static const int TGT_O_NOATIME = 001000000;
291  static const int TGT_O_CLOEXEC = 002000000;
292  static const int TGT_O_SYNC = 004010000;
293  static const int TGT_O_PATH = 010000000;
294 
295  static const int NUM_OPEN_FLAGS;
296 
297  static SyscallFlagTransTable mmapFlagTable[];
298 
299  static const unsigned TGT_MAP_SHARED = 0x00001;
300  static const unsigned TGT_MAP_PRIVATE = 0x00002;
301  static const unsigned TGT_MAP_32BIT = 0x00040;
302  static const unsigned TGT_MAP_ANON = 0x00020;
303  static const unsigned TGT_MAP_DENYWRITE = 0x00800;
304  static const unsigned TGT_MAP_EXECUTABLE = 0x01000;
305  static const unsigned TGT_MAP_FILE = 0x00000;
306  static const unsigned TGT_MAP_GROWSDOWN = 0x00100;
307  static const unsigned TGT_MAP_HUGETLB = 0x40000;
308  static const unsigned TGT_MAP_LOCKED = 0x02000;
309  static const unsigned TGT_MAP_NONBLOCK = 0x10000;
310  static const unsigned TGT_MAP_NORESERVE = 0x04000;
311  static const unsigned TGT_MAP_POPULATE = 0x08000;
312  static const unsigned TGT_MAP_STACK = 0x20000;
313  static const unsigned TGT_MAP_ANONYMOUS = 0x00020;
314  static const unsigned TGT_MAP_FIXED = 0x00010;
315 
316  static const unsigned NUM_MMAP_FLAGS;
317 
318  typedef struct {
319  int32_t uptime; /* Seconds since boot */
320  uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
321  uint32_t totalram; /* Total usable main memory size */
322  uint32_t freeram; /* Available memory size */
323  uint32_t sharedram; /* Amount of shared memory */
324  uint32_t bufferram; /* Memory used by buffers */
325  uint32_t totalswap; /* Total swap space size */
326  uint32_t freeswap; /* swap space still available */
327  uint16_t procs; /* Number of current processes */
328  uint32_t totalhigh; /* Total high memory size */
329  uint32_t freehigh; /* Available high memory size */
330  uint32_t mem_unit; /* Memory unit size in bytes */
331  } tgt_sysinfo;
332 };
333 
334 #endif
const char * __attribute__((weak)) m5MainCommands[]
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
uint64_t st_ctime_nsec
Definition: linux.hh:90
uint64_t iov_base
Definition: linux.hh:191
int64_t st_blksize
Definition: linux.hh:83
Definition: cprintf.cc:42
static const unsigned NUM_MMAP_FLAGS
Definition: linux.hh:188
ThreadContext is the external interface to all thread state for anything outside of the CPU...
const int StackPointerReg
Definition: registers.hh:87
Bitfield< 63 > val
Definition: misc.hh:771
static const ByteOrder byteOrder
Definition: linux.hh:49
uint64_t st_nlink
Definition: linux.hh:76
uint32_t st_mode
Definition: linux.hh:77
uint64_t st_atimeX
Definition: linux.hh:85
ByteOrder
Definition: types.hh:247
void copyRegs(ThreadContext *src, ThreadContext *dest)
Definition: utility.cc:96
static const unsigned TGT_CLONE_SETTLS
Definition: linux.hh:286
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
static void archClone(uint64_t flags, Process *pp, Process *cp, ThreadContext *ptc, ThreadContext *ctc, uint64_t stack, uint64_t tls)
Definition: linux.hh:52
uint64_t st_rdev
Definition: linux.hh:81
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 const unsigned NUM_MMAP_FLAGS
Definition: linux.hh:316
Bitfield< 7, 0 > ptc
Definition: mt_constants.hh:56
static const int NUM_OPEN_FLAGS
Definition: linux.hh:169
static const int NUM_OPEN_FLAGS
Definition: linux.hh:295
uint64_t st_mtimeX
Definition: linux.hh:87
uint64_t st_ctimeX
Definition: linux.hh:89
uint64_t iov_len
Definition: linux.hh:192
uint64_t st_mtime_nsec
Definition: linux.hh:88
uint64_t st_atime_nsec
Definition: linux.hh:86

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