process.hh (11801:cd7f3a1dbf55) process.hh (11851:824055fe6b30)
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
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;
50struct ProcessParams;
51
52class EmulatedDriver;
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
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
176 // generate new target fd for sim_fd
177 int allocFD(int sim_fd, const std::string& filename, int flags, int mode,
178 bool pipe);
179
180 // disassociate target fd with simulator fd and cleanup subsidiary fields
181 void resetFDEntry(int tgt_fd);
182
183 // look up simulator fd for given target fd

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

197 void fixFileOffsets();
198
199 // find all offsets for currently open files and save them
200 void findFileOffsets();
201
202 // set the source of this read pipe for a checkpoint resume
203 void setReadPipeSource(int read_pipe_fd, int source_fd);
204
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;
206
207 void allocateMem(Addr vaddr, int64_t size, bool clobber = false);
208
209 /// Attempt to fix up a fault at vaddr by allocating a page on the stack.
210 /// @return Whether the fault has been fixed.
211 bool fixupStackFault(Addr vaddr);
212
213 /**

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

223 * @return True if the map operation was successful. (At this
224 * point in time, the map operation always succeeds.)
225 */
226 bool map(Addr vaddr, Addr paddr, int size, bool cacheable = true);
227
228 void serialize(CheckpointOut &cp) const override;
229 void unserialize(CheckpointIn &cp) override;
230
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
231 public:
232 // Id of the owner of the process
233 uint64_t _uid;
234 uint64_t _euid;
235 uint64_t _gid;
236 uint64_t _egid;
237
238 // pid of the process and it's parent
239 uint64_t _pid;
240 uint64_t _ppid;
241
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
259 // Emulated drivers available to this process
260 std::vector<EmulatedDriver *> drivers;
261
247 // Emulated drivers available to this process
248 std::vector<EmulatedDriver *> drivers;
249
262 public:
263
264 enum AuxiliaryVectorType {
265 M5_AT_NULL = 0,
266 M5_AT_IGNORE = 1,
267 M5_AT_EXECFD = 2,
268 M5_AT_PHDR = 3,
269 M5_AT_PHENT = 4,
270 M5_AT_PHNUM = 5,
271 M5_AT_PAGESZ = 6,

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

294 inline uint64_t uid() { return _uid; }
295 inline uint64_t euid() { return _euid; }
296 inline uint64_t gid() { return _gid; }
297 inline uint64_t egid() { return _egid; }
298 inline uint64_t pid() { return _pid; }
299 inline uint64_t ppid() { return _ppid; }
300
301 // provide program name for debug messages
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(); }
303
304 std::string
305 fullPath(const std::string &filename)
306 {
307 if (filename[0] == '/' || cwd.empty())
308 return filename;
309
310 std::string full = cwd;
311
312 if (cwd[cwd.size() - 1] != '/')
313 full += '/';
314
315 return full + filename;
316 }
317
318 std::string getcwd() const { return cwd; }
319
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);
321
322 virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i) = 0;
323 virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width);
324 virtual void setSyscallArg(ThreadContext *tc,
325 int i, TheISA::IntReg val) = 0;
326 virtual void setSyscallReturn(ThreadContext *tc,
327 SyscallReturn return_value) = 0;
328

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

340 // the object file because the parameters needed to calculate the
341 // bias are not available when the object file is created.
342 void updateBias();
343
344 ObjectFile *getInterpreter();
345
346 Addr getBias();
347 Addr getStartPC();
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);
353};
354
334};
335
355
356#endif // __PROCESS_HH__
336#endif // __PROCESS_HH__