gem5  v20.1.0.0
process.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2005 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 
30 
31 #include "arch/sparc/isa_traits.hh"
32 #include "arch/sparc/registers.hh"
34 #include "base/trace.hh"
35 #include "cpu/thread_context.hh"
36 #include "kern/solaris/solaris.hh"
37 #include "sim/process.hh"
38 #include "sim/syscall_desc.hh"
39 #include "sim/syscall_emul.hh"
40 
41 using namespace std;
42 using namespace SparcISA;
43 
44 namespace
45 {
46 
47 class SparcSolarisObjectFileLoader : public Process::Loader
48 {
49  public:
50  Process *
51  load(ProcessParams *params, ::Loader::ObjectFile *obj_file) override
52  {
53  auto arch = obj_file->getArch();
54  auto opsys = obj_file->getOpSys();
55 
56  if (arch != ::Loader::SPARC64 && arch != ::Loader::SPARC32)
57  return nullptr;
58 
59  if (opsys != ::Loader::Solaris)
60  return nullptr;
61 
62  return new SparcSolarisProcess(params, obj_file);
63  }
64 };
65 
66 SparcSolarisObjectFileLoader loader;
67 
68 } // anonymous namespace
69 
70 
72 static SyscallReturn
74 {
75  auto process = tc->getProcessPtr();
76 
77  strcpy(name->sysname, "SunOS");
78  strcpy(name->nodename, "m5.eecs.umich.edu");
79  strcpy(name->release, process->release.c_str());
80  strcpy(name->version, "Generic_118558-21");
81  strcpy(name->machine, "sun4u");
82 
83  return 0;
84 }
85 
86 
88  SparcSolarisProcess::syscallDescs = {
89  { 0, "syscall" },
90  { 1, "exit", exitFunc },
91  { 2, "fork" },
92  { 3, "read", readFunc<SparcSolaris> },
93  { 4, "write", writeFunc<SparcSolaris> },
94  { 5, "open", openFunc<SparcSolaris> },
95  { 6, "close", closeFunc },
96  { 7, "wait" },
97  { 8, "creat" },
98  { 9, "link" },
99  { 10, "unlink", unlinkFunc },
100  { 11, "exec" },
101  { 12, "chdir" },
102  { 13, "time" },
103  { 14, "mknod" },
104  { 15, "chmod", chmodFunc<Solaris> },
105  { 16, "chown", chownFunc },
106  { 17, "brk", brkFunc },
107  { 18, "stat" },
108  { 19, "lseek", lseekFunc },
109  { 20, "getpid", getpidFunc },
110  { 21, "mount" },
111  { 22, "umount" },
112  { 23, "setuid", ignoreFunc },
113  { 24, "getuid", getuidFunc },
114  { 25, "stime" },
115  { 26, "pcsample" },
116  { 27, "alarm" },
117  { 28, "fstat", fstatFunc<SparcSolaris> },
118  { 29, "pause" },
119  { 30, "utime" },
120  { 31, "stty" },
121  { 32, "gtty" },
122  { 33, "access" },
123  { 34, "nice" },
124  { 35, "statfs" },
125  { 36, "sync" },
126  { 37, "kill" },
127  { 38, "fstatfs" },
128  { 39, "pgrpsys" },
129  { 40, "xenix" },
130  { 41, "dup" },
131  { 42, "pipe", pipePseudoFunc },
132  { 43, "times" },
133  { 44, "profil" },
134  { 45, "plock" },
135  { 46, "setgid" },
136  { 47, "getgid", getgidFunc },
137  { 48, "signal" },
138  { 49, "msgsys" },
139  { 50, "syssun" },
140  { 51, "acct" },
141  { 52, "shmsys" },
142  { 53, "semsys" },
143  { 54, "ioctl" },
144  { 55, "uadmin" },
145  { 56, "RESERVED" },
146  { 57, "utssys" },
147  { 58, "fdsync" },
148  { 59, "execve" },
149  { 60, "umask", umaskFunc },
150  { 61, "chroot" },
151  { 62, "fcntl" },
152  { 63, "ulimit" },
153  { 64, "reserved_64" },
154  { 65, "reserved_65" },
155  { 66, "reserved_66" },
156  { 67, "reserved_67" },
157  { 68, "reserved_68" },
158  { 69, "reserved_69" },
159  { 70, "tasksys" },
160  { 71, "acctctl" },
161  { 72, "reserved_72" },
162  { 73, "getpagesizes" },
163  { 74, "rctlsys" },
164  { 75, "issetugid" },
165  { 76, "fsat" },
166  { 77, "lwp_park" },
167  { 78, "sendfilev" },
168  { 79, "rmdir" },
169  { 80, "mkdir" },
170  { 81, "getdents" },
171  { 82, "reserved_82" },
172  { 83, "reserved_83" },
173  { 84, "sysfs" },
174  { 85, "getmsg" },
175  { 86, "putmsg" },
176  { 87, "poll" },
177  { 88, "lstat" },
178  { 89, "symlink" },
179  { 90, "readlink", readlinkFunc },
180  { 91, "setgroups" },
181  { 92, "getgroups" },
182  { 93, "fchmod" },
183  { 94, "fchown" },
184  { 95, "sigprocmask" },
185  { 96, "sigsuspend" },
186  { 97, "sigaltstack" },
187  { 98, "sigaction" },
188  { 99, "sigpending" },
189  { 100, "context" },
190  { 101, "evsys" },
191  { 102, "evtrapret" },
192  { 103, "statvfs" },
193  { 104, "fstatvfs" },
194  { 105, "getloadavg" },
195  { 106, "nfssys" },
196  { 107, "waitsys" },
197  { 108, "sigsendsys" },
198  { 109, "hrtsys" },
199  { 110, "acancel" },
200  { 111, "async" },
201  { 112, "priocntlsys" },
202  { 113, "pathconf" },
203  { 114, "mincore" },
204  { 115, "mmap", mmapFunc<SparcSolaris> },
205  { 116, "mprotect" },
206  { 117, "munmap", munmapFunc },
207  { 118, "fpathconf" },
208  { 119, "vfork" },
209  { 120, "fchdir" },
210  { 121, "readv" },
211  { 122, "writev" },
212  { 123, "xstat" },
213  { 124, "lxstat" },
214  { 125, "fxstat" },
215  { 126, "xmknod" },
216  { 127, "clocal" },
217  { 128, "setrlimit" },
218  { 129, "getrlimit" },
219  { 130, "lchown" },
220  { 131, "memcntl" },
221  { 132, "getpmsg" },
222  { 133, "putpmsg" },
223  { 134, "rename" },
224  { 135, "uname", unameFunc },
225  { 136, "setegid" },
226  { 137, "sysconfig" },
227  { 138, "adjtime" },
228  { 139, "systeminfo" },
229  { 140, "reserved_140" },
230  { 141, "seteuid" },
231  { 142, "vtrace" },
232  { 143, "fork1" },
233  { 144, "sigtimedwait" },
234  { 145, "lwp_info" },
235  { 146, "yield" },
236  { 147, "lwp_sema_wait" },
237  { 148, "lwp_sema_post" },
238  { 149, "lwp_sema_trywait" },
239  { 150, "lwp_detach" },
240  { 151, "corectl" },
241  { 152, "modctl" },
242  { 153, "fchroot" },
243  { 154, "utimes" },
244  { 155, "vhangup" },
245  { 156, "gettimeofday" },
246  { 157, "getitimer" },
247  { 158, "setitimer" },
248  { 159, "lwp_create" },
249  { 160, "lwp_exit" },
250  { 161, "lwp_suspend" },
251  { 162, "lwp_continue" },
252  { 163, "lwp_kill" },
253  { 164, "lwp_self" },
254  { 165, "lwp_setprivate" },
255  { 166, "lwp_getprivate" },
256  { 167, "lwp_wait" },
257  { 168, "lwp_mutex_wakeup" },
258  { 169, "lwp_mutex_lock" },
259  { 170, "lwp_cond_wait" },
260  { 171, "lwp_cond_signal" },
261  { 172, "lwp_cond_broadcast" },
262  { 173, "pread" },
263  { 174, "pwrite" },
264  { 175, "llseek" },
265  { 176, "inst_sync" },
266  { 177, "srmlimitsys" },
267  { 178, "kaio" },
268  { 179, "cpc" },
269  { 180, "lgrpsys_meminfosys" },
270  { 181, "rusagesys" },
271  { 182, "reserved_182" },
272  { 183, "reserved_183" },
273  { 184, "tsolsys" },
274  { 185, "acl" },
275  { 186, "auditsys" },
276  { 187, "processor_bind" },
277  { 188, "processor_info" },
278  { 189, "p_online" },
279  { 190, "sigqueue" },
280  { 191, "clock_gettime" },
281  { 192, "clock_settime" },
282  { 193, "clock_getres" },
283  { 194, "timer_create" },
284  { 195, "timer_delete" },
285  { 196, "timer_settime" },
286  { 197, "timer_gettime" },
287  { 198, "timer_getoverrun" },
288  { 199, "nanosleep" },
289  { 200, "facl" },
290  { 201, "door" },
291  { 202, "setreuid" },
292  { 203, "setregid" },
293  { 204, "install_utrap" },
294  { 205, "signotify" },
295  { 206, "schedctl" },
296  { 207, "pset" },
297  { 208, "sparc_utrap_install" },
298  { 209, "resolvepath" },
299  { 210, "signotifywait" },
300  { 211, "lwp_sigredirect" },
301  { 212, "lwp_alarm" },
302  { 213, "getdents64" },
303  { 214, "mmap64" },
304  { 215, "stat64" },
305  { 216, "lstat64" },
306  { 217, "fstat64" },
307  { 218, "statvfs64" },
308  { 219, "fstatvfs64" },
309  { 220, "setrlimit64" },
310  { 221, "getrlimit64" },
311  { 222, "pread64" },
312  { 223, "pwrite64" },
313  { 224, "creat64" },
314  { 225, "open64" },
315  { 226, "rpcsys" },
316  { 227, "reserved_227" },
317  { 228, "reserved_228" },
318  { 229, "reserved_229" },
319  { 230, "so_socket" },
320  { 231, "so_socketpair" },
321  { 232, "bind" },
322  { 233, "listen" },
323  { 234, "accept" },
324  { 235, "connect" },
325  { 236, "shutdown" },
326  { 237, "recv" },
327  { 238, "recvfrom" },
328  { 239, "recvmsg" },
329  { 240, "send" },
330  { 241, "sendmsg" },
331  { 242, "sendto" },
332  { 243, "getpeername" },
333  { 244, "getsockname" },
334  { 245, "getsockopt" },
335  { 246, "setsockopt" },
336  { 247, "sockconfig" },
337  { 248, "ntp_gettime" },
338  { 249, "ntp_adjtime" },
339  { 250, "lwp_mutex_unlock" },
340  { 251, "lwp_mutex_trylock" },
341  { 252, "lwp_mutex_init" },
342  { 253, "cladm" },
343  { 254, "lwp_sigtimedwait" },
344  { 255, "umount2" }
345 };
346 
347 SparcSolarisProcess::SparcSolarisProcess(ProcessParams *params,
348  ::Loader::ObjectFile *objFile) :
349  Sparc64Process(params, objFile)
350 {}
351 
352 void
354 {
356  syscallDescs.get(tc->readIntReg(1))->doSyscall(tc);
357 }
munmapFunc
SyscallReturn munmapFunc(SyscallDesc *desc, ThreadContext *tc, Addr start, size_t length)
Target munmap() handler.
Definition: syscall_emul.cc:331
Process::Loader
Each instance of a Loader subclass will have a chance to try to load an object file when tryLoaders i...
Definition: process.hh:185
ignoreFunc
SyscallReturn ignoreFunc(SyscallDesc *desc, ThreadContext *tc)
Handler for unimplemented syscalls that we never intend to implement (signal handling,...
Definition: syscall_emul.cc:73
SparcISA::SparcSolarisProcess::syscall
void syscall(ThreadContext *tc) override
Definition: process.cc:353
Loader::SPARC32
@ SPARC32
Definition: object_file.hh:47
SyscallDescTable< Sparc64Process::SyscallABI >
Process
Definition: process.hh:65
chownFunc
SyscallReturn chownFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, uint32_t owner, uint32_t group)
Target chown() handler.
Definition: syscall_emul.cc:625
ProxyPtr
Definition: proxy_ptr.hh:236
unlinkFunc
SyscallReturn unlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname)
Target unlink() handler.
Definition: syscall_emul.cc:452
SparcISA::SparcSolarisProcess
A process with emulated SPARC/Solaris syscalls.
Definition: process.hh:40
ThreadContext::getProcessPtr
virtual Process * getProcessPtr()=0
umaskFunc
SyscallReturn umaskFunc(SyscallDesc *desc, ThreadContext *tc)
Target umask() handler.
Definition: syscall_emul.cc:614
Loader::Solaris
@ Solaris
Definition: object_file.hh:63
Loader::SPARC64
@ SPARC64
Definition: object_file.hh:46
Process::syscall
virtual void syscall(ThreadContext *tc)
Definition: process.hh:78
solaris.hh
SparcISA::SparcSolarisProcess::syscallDescs
static SyscallDescTable< Sparc64Process::SyscallABI > syscallDescs
Array of syscall descriptors, indexed by call number.
Definition: process.hh:52
lseekFunc
SyscallReturn lseekFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offs, int whence)
Target lseek() handler.
Definition: syscall_emul.cc:287
exitFunc
SyscallReturn exitFunc(SyscallDesc *desc, ThreadContext *tc, int status)
Target exit() handler: terminate current context.
Definition: syscall_emul.cc:230
SparcISA
Definition: asi.cc:31
getpidFunc
SyscallReturn getpidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getpid() handler.
Definition: syscall_emul.cc:928
Loader::ObjectFile
Definition: object_file.hh:70
brkFunc
SyscallReturn brkFunc(SyscallDesc *desc, ThreadContext *tc, Addr new_brk)
Target brk() handler: set brk address.
Definition: syscall_emul.cc:249
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
readlinkFunc
SyscallReturn readlinkFunc(SyscallDesc *desc, ThreadContext *tc, Addr pathname, Addr buf_ptr, size_t bufsiz)
Target readlink() handler.
Definition: syscall_emul.cc:394
isa_traits.hh
process.hh
Sparc64Process
Definition: process.hh:181
SyscallReturn
This class represents the return value from an emulated system call, including any errno setting.
Definition: syscall_return.hh:52
unameFunc
static SyscallReturn unameFunc(SyscallDesc *desc, ThreadContext *tc, VPtr< Solaris::utsname > name)
Target uname() handler.
Definition: process.cc:73
name
const std::string & name()
Definition: trace.cc:50
SyscallDesc::doSyscall
void doSyscall(ThreadContext *tc)
Interface for invoking the system call funcion pointer.
Definition: syscall_desc.cc:38
process.hh
getuidFunc
SyscallReturn getuidFunc(SyscallDesc *desc, ThreadContext *tc)
Definition: syscall_emul.cc:949
syscall_emul.hh
Loader::ObjectFile::getArch
Arch getArch() const
Definition: object_file.hh:99
closeFunc
SyscallReturn closeFunc(SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
Target close() handler.
Definition: syscall_emul.cc:280
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
Loader::ObjectFile::getOpSys
OpSys getOpSys() const
Definition: object_file.hh:100
registers.hh
trace.hh
SyscallDescTable::get
SyscallDesc * get(int num, bool fatal_if_missing=true)
Definition: syscall_desc.hh:195
ThreadContext::readIntReg
virtual RegVal readIntReg(RegIndex reg_idx) const =0
getgidFunc
SyscallReturn getgidFunc(SyscallDesc *desc, ThreadContext *tc)
Target getgid() handler.
Definition: syscall_emul.cc:963
pipePseudoFunc
SyscallReturn pipePseudoFunc(SyscallDesc *desc, ThreadContext *tc)
Pseudo Funcs - These functions use a different return convension, returning a second value in a regis...
Definition: syscall_emul.cc:790
object_file.hh
thread_context.hh
SyscallDesc
This class provides the wrapper interface for the system call implementations which are defined in th...
Definition: syscall_desc.hh:66
syscall_desc.hh

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17