1/*
2 * Copyright (c) 2014 Advanced Micro Devices, Inc.
3 * Copyright (c) 2001-2005 The Regents of The University of Michigan
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 32 unchanged lines hidden (view full) ---

41#include "arch/registers.hh"
42#include "base/statistics.hh"
43#include "base/types.hh"
44#include "config/the_isa.hh"
45#include "mem/se_translating_port_proxy.hh"
46#include "sim/fd_entry.hh"
47#include "sim/sim_object.hh"
48
49struct LiveProcessParams;
49struct ProcessParams;
50
51class EmulatedDriver;
52class ObjectFile;
53class PageTableBase;
54class SyscallDesc;
55class SyscallReturn;
56class System;
57class ThreadContext;
58
59template<class IntType>
60struct AuxVector

--- 104 unchanged lines hidden (view full) ---

165 void assignThreadContext(ContextID context_id)
166 {
167 contextIds.push_back(context_id);
168 }
169
170 // Find a free context to use
171 ThreadContext *findFreeContext();
172
173 // provide program name for debug messages
174 virtual const char *progName() const { return "<unknown>"; }
175
173 // generate new target fd for sim_fd
174 int allocFD(int sim_fd, const std::string& filename, int flags, int mode,
175 bool pipe);
176
177 // disassociate target fd with simulator fd and cleanup subsidiary fields
178 void resetFDEntry(int tgt_fd);
179
180 // look up simulator fd for given target fd

--- 13 unchanged lines hidden (view full) ---

194 void fixFileOffsets();
195
196 // find all offsets for currently open files and save them
197 void findFileOffsets();
198
199 // set the source of this read pipe for a checkpoint resume
200 void setReadPipeSource(int read_pipe_fd, int source_fd);
201
205 virtual void syscall(int64_t callnum, ThreadContext *tc) = 0;
202
203 void allocateMem(Addr vaddr, int64_t size, bool clobber = false);
204
205 /// Attempt to fix up a fault at vaddr by allocating a page on the stack.
206 /// @return Whether the fault has been fixed.
207 bool fixupStackFault(Addr vaddr);
208
209 /**

--- 9 unchanged lines hidden (view full) ---

219 * @return True if the map operation was successful. (At this
220 * point in time, the map operation always succeeds.)
221 */
222 bool map(Addr vaddr, Addr paddr, int size, bool cacheable = true);
223
224 void serialize(CheckpointOut &cp) const override;
225 void unserialize(CheckpointIn &cp) override;
226
227 protected:
228 ObjectFile *objFile;
229 std::vector<std::string> argv;
230 std::vector<std::string> envp;
231 std::string cwd;
232 std::string executable;
233
234 Process(ProcessParams *params, ObjectFile *obj_file);
235
236 public:
237 // Id of the owner of the process
238 uint64_t _uid;
239 uint64_t _euid;
240 uint64_t _gid;
241 uint64_t _egid;
242
243 // pid of the process and it's parent
244 uint64_t _pid;
245 uint64_t _ppid;
246
242};
243
244//
245// "Live" process with system calls redirected to host system
246//
247class ObjectFile;
248class LiveProcess : public Process
249{
250 protected:
251 ObjectFile *objFile;
252 std::vector<std::string> argv;
253 std::vector<std::string> envp;
254 std::string cwd;
255 std::string executable;
256
257 LiveProcess(LiveProcessParams *params, ObjectFile *objFile);
258
247 // Emulated drivers available to this process
248 std::vector<EmulatedDriver *> drivers;
249
262 public:
263
250 enum AuxiliaryVectorType {
251 M5_AT_NULL = 0,
252 M5_AT_IGNORE = 1,
253 M5_AT_EXECFD = 2,
254 M5_AT_PHDR = 3,
255 M5_AT_PHENT = 4,
256 M5_AT_PHNUM = 5,
257 M5_AT_PAGESZ = 6,

--- 22 unchanged lines hidden (view full) ---

280 inline uint64_t uid() { return _uid; }
281 inline uint64_t euid() { return _euid; }
282 inline uint64_t gid() { return _gid; }
283 inline uint64_t egid() { return _egid; }
284 inline uint64_t pid() { return _pid; }
285 inline uint64_t ppid() { return _ppid; }
286
287 // provide program name for debug messages
302 virtual const char *progName() const { return executable.c_str(); }
288 const char *progName() const { return executable.c_str(); }
289
290 std::string
291 fullPath(const std::string &filename)
292 {
293 if (filename[0] == '/' || cwd.empty())
294 return filename;
295
296 std::string full = cwd;
297
298 if (cwd[cwd.size() - 1] != '/')
299 full += '/';
300
301 return full + filename;
302 }
303
304 std::string getcwd() const { return cwd; }
305
320 virtual void syscall(int64_t callnum, ThreadContext *tc);
306 void syscall(int64_t callnum, ThreadContext *tc);
307
308 virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i) = 0;
309 virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width);
310 virtual void setSyscallArg(ThreadContext *tc,
311 int i, TheISA::IntReg val) = 0;
312 virtual void setSyscallReturn(ThreadContext *tc,
313 SyscallReturn return_value) = 0;
314

--- 11 unchanged lines hidden (view full) ---

326 // the object file because the parameters needed to calculate the
327 // bias are not available when the object file is created.
328 void updateBias();
329
330 ObjectFile *getInterpreter();
331
332 Addr getBias();
333 Addr getStartPC();
348
349 // this function is used to create the LiveProcess object, since
350 // we can't tell which subclass of LiveProcess to use until we
351 // open and look at the object file.
352 static LiveProcess *create(LiveProcessParams *params);
334};
335
355
336#endif // __PROCESS_HH__