gem5 v24.1.0.1
Loading...
Searching...
No Matches
linux.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Arm Limited
3 *
4 * The license below extends only to copyright in the software and shall
5 * not be construed as granting a license to any other intellectual
6 * property including but not limited to intellectual property relating
7 * to a hardware implementation of the functionality of the software
8 * licensed hereunder. You may use the software subject to the license
9 * terms below provided that you ensure that this notice is replicated
10 * unmodified and in its entirety in all distributions of the software,
11 * modified or unmodified, in source code or in binary form.
12 *
13 * Copyright (c) 2003-2005 The Regents of The University of Michigan
14 * All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are
18 * met: redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer;
20 * redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution;
23 * neither the name of the copyright holders nor the names of its
24 * contributors may be used to endorse or promote products derived from
25 * this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#ifndef __ARCH_SPARC_LINUX_LINUX_HH__
41#define __ARCH_SPARC_LINUX_LINUX_HH__
42
43#include <map>
44
45#include "arch/sparc/asi.hh"
48#include "cpu/thread_context.hh"
50#include "kern/linux/linux.hh"
51
52namespace gem5
53{
54
55class SparcLinux : public Linux, public OpenFlagTable<SparcLinux>
56{
57 public:
58
59 static const ByteOrder byteOrder = ByteOrder::big;
60
61 struct tgt_stat
62 {
63 uint32_t st_dev;
64 char __pad1[4];
65 uint64_t st_ino;
66 uint32_t st_mode;
67 uint16_t st_nlink;
68 uint32_t st_uid;
69 uint32_t st_gid;
70 uint32_t st_rdev;
71 char __pad2[4];
72 int64_t st_size;
73 int64_t st_atimeX;
74 int64_t st_mtimeX;
75 int64_t st_ctimeX;
76 int64_t st_blksize;
77 int64_t st_blocks;
78 uint64_t __unused4[2];
79 };
80
82 {
83 uint64_t st_dev;
84 uint64_t st_ino;
85 uint64_t st_nlink;
86
87 uint32_t st_mode;
88 uint32_t st_uid;
89 uint32_t st_gid;
90 uint32_t __pad0;
91
92 uint64_t st_rdev;
93 int64_t st_size;
94 int64_t st_blksize;
95 int64_t st_blocks;
96
97 uint64_t st_atimeX;
98 uint64_t st_atime_nsec;
99 uint64_t st_mtimeX;
101 uint64_t st_ctimeX;
103 int64_t __unused4[3];
104 };
105
106 // SPARC receives weird subsignals for several of its signals. If you
107 // find yourself needing to implement these in detail, look at the
108 // Linux source.
109 static const int TGT_SIGHUP = 0x000001;
110 static const int TGT_SIGINT = 0x000002;
111 static const int TGT_SIGQUIT = 0x000003;
112 static const int TGT_SIGILL = 0x000004;
113 static const int TGT_SIGTRAP = 0x000005;
114 static const int TGT_SIGABRT = 0x000006;
115 static const int TGT_SIGIOT = 0x000006;
116 static const int TGT_SIGEMT = 0x000007;
117 static const int TGT_SIGFPE = 0x000008;
118 static const int TGT_SIGKILL = 0x000009;
119 static const int TGT_SIGBUS = 0x00000a;
120 static const int TGT_SIGSEGV = 0x00000b;
121 static const int TGT_SIGSYS = 0x00000c;
122 static const int TGT_SIGPIPE = 0x00000d;
123 static const int TGT_SIGALRM = 0x00000e;
124 static const int TGT_SIGTERM = 0x00000f;
125 static const int TGT_SIGURG = 0x000010;
126 static const int TGT_SIGSTOP = 0x000011;
127 static const int TGT_SIGTSTP = 0x000012;
128 static const int TGT_SIGCONT = 0x000013;
129 static const int TGT_SIGCHLD = 0x000014;
130 static const int TGT_SIGTTIN = 0x000015;
131 static const int TGT_SIGTTOU = 0x000016;
132 static const int TGT_SIGIO = 0x000017;
133 static const int TGT_SIGPOLL = 0x000017;
134 static const int TGT_SIGXCPU = 0x000018;
135 static const int TGT_SIGXFSZ = 0x000019;
136 static const int TGT_SIGVTALRM = 0x00001a;
137 static const int TGT_SIGPROF = 0x00001b;
138 static const int TGT_SIGWINCH = 0x00001c;
139 static const int TGT_SIGLOST = 0x00001d;
140 static const int TGT_SIGPWR = 0x00001d;
141 static const int TGT_SIGUSR1 = 0x00001e;
142 static const int TGT_SIGUSR2 = 0x00001f;
143
144 static constexpr int TGT_O_RDONLY = 0x00000000;
145 static constexpr int TGT_O_WRONLY = 0x00000001;
146 static constexpr int TGT_O_RDWR = 0x00000002;
147 static constexpr int TGT_O_NONBLOCK = 0x00004000;
148 static constexpr int TGT_O_APPEND = 0x00000008;
149 static constexpr int TGT_FASYNC = 0x00000040;
150 static constexpr int TGT_O_CREAT = 0x00000200;
151 static constexpr int TGT_O_TRUNC = 0x00000400;
152 static constexpr int TGT_O_EXCL = 0x00000800;
153 static constexpr int TGT_O_NOCTTY = 0x00008000;
154 static constexpr int TGT_O_DSYNC = 0x00002000;
155 static constexpr int TGT_O_LARGEFILE = 0x00040000;
156 static constexpr int TGT_O_DIRECT = 0x00100000;
157 static constexpr int TGT_O_NOATIME = 0x00200000;
158 static constexpr int TGT_O_CLOEXEC = 0x00400000;
159 static constexpr int TGT_O_SYNC = 0x00802000;
160 static constexpr int TGT_O_PATH = 0x01000000;
161
162 static constexpr int TGT_O_DIRECTORY = 000200000;
163 static constexpr int TGT_O_NOFOLLOW = 000400000;
164
165 static constexpr unsigned TGT_MAP_SHARED = 0x00001;
166 static constexpr unsigned TGT_MAP_PRIVATE = 0x00002;
167 static constexpr unsigned TGT_MAP_ANON = 0x00020;
168 static constexpr unsigned TGT_MAP_DENYWRITE = 0x00800;
169 static constexpr unsigned TGT_MAP_EXECUTABLE = 0x01000;
170 static constexpr unsigned TGT_MAP_FILE = 0x00000;
171 static constexpr unsigned TGT_MAP_GROWSDOWN = 0x00200;
172 static constexpr unsigned TGT_MAP_HUGETLB = 0x40000;
173 static constexpr unsigned TGT_MAP_LOCKED = 0x00100;
174 static constexpr unsigned TGT_MAP_NONBLOCK = 0x10000;
175 static constexpr unsigned TGT_MAP_NORESERVE = 0x00040;
176 static constexpr unsigned TGT_MAP_POPULATE = 0x08000;
177 static constexpr unsigned TGT_MAP_STACK = 0x20000;
178 static constexpr unsigned TGT_MAP_ANONYMOUS = 0x00020;
179 static constexpr unsigned TGT_MAP_FIXED = 0x00010;
180 static constexpr unsigned TGT_MAP_INHERIT = 0x00080;
181
183 {
184 int64_t uptime; /* Seconds since boot */
185 uint64_t loads[3]; /* 1, 5, and 15 minute load averages */
186 uint64_t totalram; /* Total usable main memory size */
187 uint64_t freeram; /* Available memory size */
188 uint64_t sharedram; /* Amount of shared memory */
189 uint64_t bufferram; /* Memory used by buffers */
190 uint64_t totalswap; /* Total swap space size */
191 uint64_t freeswap; /* swap space still available */
192 uint16_t procs; /* Number of current processes */
193 uint64_t totalhigh; /* Total high memory size */
194 uint64_t freehigh; /* Available high memory size */
195 uint64_t mem_unit; /* Memory unit size in bytes */
196 };
197
199
203 static const unsigned TGT_TCGETA = 0x40125401;
204 static const unsigned TGT_TCSETAW = 0x80125403;
205 static const unsigned TGT_TCGETS = 0x40385408;
206 static const unsigned TGT_FIONREAD = 0x4004667f;
207 static const unsigned TGT_TIOCGETP = 0x40067408;
208 static const unsigned TGT_TIOCSETP = 0x80067409;
209 static const unsigned TGT_TIOCSETN = 0x8006740a;
211
212 static bool
213 isTtyReq(unsigned req)
214 {
215 switch (req) {
216 case TGT_TIOCGETP:
217 case TGT_TIOCSETP:
218 case TGT_TIOCSETN:
219 case TGT_TCGETS:
220 case TGT_TCGETA:
221 case TGT_TCSETAW:
222 return true;
223 default:
224 return false;
225 }
226 }
227
228 static void
229 archClone(uint64_t flags,
230 Process *pp, Process *cp,
232 uint64_t stack, uint64_t tls)
233 {
234 ctc->getIsaPtr()->copyRegsFrom(ptc);
243 for (int y = 8; y < 32; y++) {
245 ctc->setReg(reg, ptc->getReg(reg));
246 }
247
248 if (stack)
250
251 // Set these extra values. Since "clone" doesn't return two values,
252 // we can set these and they won't be clobbered by the syscall ABI.
255 }
256
257 typedef uint64_t size_t;
258 typedef int64_t off_t;
259};
260
262{
263 public:
264
266 {
267 uint64_t st_dev;
268 uint64_t st_ino;
269 uint32_t st_mode;
270 uint32_t st_nlink;
271 uint32_t st_uid;
272 uint32_t st_gid;
273 uint64_t st_rdev;
274 uint8_t __pad3[8];
275 int64_t st_size;
276 int32_t st_blksize;
277 uint8_t __pad4[8];
278 int64_t st_blocks;
279 uint64_t st_atimeX;
281 uint64_t st_mtimeX;
283 uint64_t st_ctimeX;
285 uint32_t __unused4;
286 uint32_t __unused5;
287 };
288
290 {
291 int32_t uptime; /* Seconds since boot */
292 uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
293 uint32_t totalram; /* Total usable main memory size */
294 uint32_t freeram; /* Available memory size */
295 uint32_t sharedram; /* Amount of shared memory */
296 uint32_t bufferram; /* Memory used by buffers */
297 uint32_t totalswap; /* Total swap space size */
298 uint32_t freeswap; /* swap space still available */
299 uint16_t procs; /* Number of current processes */
300 uint32_t totalhigh; /* Total high memory size */
301 uint32_t freehigh; /* Available high memory size */
302 uint32_t mem_unit; /* Memory unit size in bytes */
303 };
304
305 typedef uint32_t size_t;
306 typedef int32_t off_t;
307
309 static const unsigned TGT_RLIMIT_NPROC = 7;
310 static const unsigned TGT_RLIMIT_NOFILE = 6;
311};
312
313} // namespace gem5
314
315#endif
virtual void copyRegsFrom(ThreadContext *src)=0
This class encapsulates the types, structures, constants, functions, and syscall-number mappings spec...
Definition linux.hh:62
Register ID: describe an architectural register with its class and index.
Definition reg_class.hh:94
static const unsigned TGT_RLIMIT_NPROC
Resource constants for getrlimit() (overide some generics).
Definition linux.hh:309
static const unsigned TGT_RLIMIT_NOFILE
Definition linux.hh:310
uint32_t size_t
Definition linux.hh:305
static const int TGT_SIGXCPU
Definition linux.hh:134
static const int TGT_SIGSEGV
Definition linux.hh:120
static const unsigned TGT_TCGETS
Definition linux.hh:205
static const int TGT_SIGSTOP
Definition linux.hh:126
static const int TGT_SIGLOST
Definition linux.hh:139
static const int TGT_SIGHUP
Definition linux.hh:109
static constexpr int TGT_O_RDWR
O_RDWR.
Definition linux.hh:146
static const int TGT_SIGBUS
Definition linux.hh:119
static constexpr unsigned TGT_MAP_FIXED
Definition linux.hh:179
static const int TGT_SIGABRT
Definition linux.hh:114
static constexpr int TGT_O_NOATIME
O_NOATIME.
Definition linux.hh:157
static constexpr int TGT_O_CLOEXEC
O_CLOEXEC.
Definition linux.hh:158
static const int TGT_SIGPOLL
Definition linux.hh:133
static constexpr int TGT_FASYNC
FASYNC.
Definition linux.hh:149
static const int TGT_SIGXFSZ
Definition linux.hh:135
static const int TGT_SIGSYS
Definition linux.hh:121
static const int TGT_SIGINT
Definition linux.hh:110
static constexpr unsigned TGT_MAP_GROWSDOWN
Definition linux.hh:171
static const int TGT_SIGFPE
Definition linux.hh:117
static const int TGT_SIGKILL
Definition linux.hh:118
static constexpr unsigned TGT_MAP_LOCKED
Definition linux.hh:173
static const int TGT_SIGTERM
Definition linux.hh:124
static constexpr int TGT_O_PATH
O_PATH.
Definition linux.hh:160
static const int TGT_SIGQUIT
Definition linux.hh:111
static const int TGT_SIGIO
Definition linux.hh:132
static constexpr unsigned TGT_MAP_ANON
Definition linux.hh:167
static const unsigned TGT_TIOCGETP
Definition linux.hh:207
static constexpr int TGT_O_NOFOLLOW
O_NOFOLLOW.
Definition linux.hh:163
static constexpr unsigned TGT_MAP_STACK
Definition linux.hh:177
static constexpr int TGT_O_WRONLY
O_WRONLY.
Definition linux.hh:145
static const int TGT_SIGUSR1
Definition linux.hh:141
static constexpr int TGT_O_SYNC
O_SYNC.
Definition linux.hh:159
static constexpr unsigned TGT_MAP_ANONYMOUS
Definition linux.hh:178
static const unsigned TGT_TCGETA
ioctl() command codes.
Definition linux.hh:203
static constexpr int TGT_O_NOCTTY
O_NOCTTY.
Definition linux.hh:153
static constexpr int TGT_O_DSYNC
O_DSYNC.
Definition linux.hh:154
static bool isTtyReq(unsigned req)
Definition linux.hh:213
static constexpr unsigned TGT_MAP_NONBLOCK
Definition linux.hh:174
static const ByteOrder byteOrder
Definition linux.hh:59
static constexpr unsigned TGT_MAP_SHARED
Definition linux.hh:165
static const int TGT_SIGTSTP
Definition linux.hh:127
static const unsigned TGT_FIONREAD
Definition linux.hh:206
static const unsigned TGT_TCSETAW
Definition linux.hh:204
static constexpr int TGT_O_CREAT
O_CREAT.
Definition linux.hh:150
static const int TGT_SIGCHLD
Definition linux.hh:129
int64_t off_t
Definition linux.hh:258
static constexpr int TGT_O_EXCL
O_EXCL.
Definition linux.hh:152
static constexpr unsigned TGT_MAP_DENYWRITE
Definition linux.hh:168
static const int TGT_SIGTRAP
Definition linux.hh:113
static constexpr int TGT_O_RDONLY
O_RDONLY.
Definition linux.hh:144
static const int TGT_SIGCONT
Definition linux.hh:128
static const unsigned TGT_TIOCSETP
Definition linux.hh:208
static const int TGT_SIGURG
Definition linux.hh:125
static constexpr unsigned TGT_MAP_INHERIT
Definition linux.hh:180
static const int TGT_SIGPROF
Definition linux.hh:137
static constexpr int TGT_O_NONBLOCK
O_NONBLOCK.
Definition linux.hh:147
static constexpr int TGT_O_DIRECT
O_DIRECT.
Definition linux.hh:156
static const unsigned TGT_TIOCSETN
Definition linux.hh:209
static const int TGT_SIGILL
Definition linux.hh:112
static void archClone(uint64_t flags, Process *pp, Process *cp, ThreadContext *ptc, ThreadContext *ctc, uint64_t stack, uint64_t tls)
Definition linux.hh:229
static constexpr int TGT_O_TRUNC
O_TRUNC.
Definition linux.hh:151
static const int TGT_SIGTTIN
Definition linux.hh:130
static constexpr unsigned TGT_MAP_POPULATE
Definition linux.hh:176
static constexpr unsigned TGT_MAP_EXECUTABLE
Definition linux.hh:169
static const int TGT_SIGTTOU
Definition linux.hh:131
static const int TGT_SIGIOT
Definition linux.hh:115
static constexpr unsigned TGT_MAP_NORESERVE
Definition linux.hh:175
static const int TGT_SIGWINCH
Definition linux.hh:138
static constexpr unsigned TGT_MAP_HUGETLB
Definition linux.hh:172
static const int TGT_SIGPIPE
Definition linux.hh:122
static const int TGT_SIGUSR2
Definition linux.hh:142
uint64_t size_t
Definition linux.hh:257
static constexpr unsigned TGT_MAP_FILE
Definition linux.hh:170
static constexpr int TGT_O_DIRECTORY
O_DIRECTORY.
Definition linux.hh:162
static constexpr int TGT_O_APPEND
O_APPEND.
Definition linux.hh:148
static const int TGT_SIGVTALRM
Definition linux.hh:136
static constexpr int TGT_O_LARGEFILE
O_LARGEFILE.
Definition linux.hh:155
static constexpr unsigned TGT_MAP_PRIVATE
Definition linux.hh:166
static const int TGT_SIGEMT
Definition linux.hh:116
static const int TGT_SIGPWR
Definition linux.hh:140
static const int TGT_SIGALRM
Definition linux.hh:123
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
virtual BaseISA * getIsaPtr() const =0
virtual void setReg(const RegId &reg, RegVal val)
uint8_t flags
Definition helpers.cc:87
Bitfield< 7, 0 > ptc
constexpr RegId Cleanwin
Definition int.hh:135
constexpr RegId Wstate
Definition int.hh:137
constexpr RegId Cansave
Definition int.hh:133
constexpr RegId Otherwin
Definition int.hh:136
constexpr RegId Canrestore
Definition int.hh:134
@ MISCREG_ASI
Ancillary State Registers.
Definition misc.hh:47
constexpr RegClass intRegClass
Definition int.hh:78
constexpr auto & StackPointerReg
Definition int.hh:170
const int NWindows
constexpr auto & SyscallPseudoReturnReg
Definition int.hh:174
Bitfield< 5, 3 > reg
Definition types.hh:92
Bitfield< 17, 16 > stack
Definition misc.hh:602
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
uint64_t RegVal
Definition types.hh:173
uint64_t __unused4[2]
Definition linux.hh:78

Generated on Mon Jan 13 2025 04:28:22 for gem5 by doxygen 1.9.8