-
- /// Pointer to object representing the system this process is
- /// running on.
- System *system;
-
- // have we initialized a thread context from this process? If
- // yes, subsequent contexts are assumed to be for dynamically
- // created threads and are not initialized.
- bool initialContextLoaded;
-
- bool checkpointRestored;
-
- // thread contexts associated with this process
- std::vector<int> contextIds;
-
- // remote gdb objects
- std::vector<TheISA::RemoteGDB *> remoteGDB;
- std::vector<GDBListener *> gdbListen;
- bool breakpoint();
-
- // number of CPUs (esxec contexts, really) assigned to this process.
- unsigned int numCpus() { return contextIds.size(); }
-
- // record of blocked context
- struct WaitRec
- {
- Addr waitChan;
- ThreadContext *waitingContext;
-
- WaitRec(Addr chan, ThreadContext *ctx)
- : waitChan(chan), waitingContext(ctx)
- { }
- };
-
- // list of all blocked contexts
- std::list<WaitRec> waitList;
-
- Addr brk_point; // top of the data segment
-
- Addr stack_base; // stack segment base (highest address)
- unsigned stack_size; // initial stack size
- Addr stack_min; // lowest address accessed on the stack
-
- // The maximum size allowed for the stack.
- Addr max_stack_size;
-
- // addr to use for next stack region (for multithreaded apps)
- Addr next_thread_stack_base;
-
- // Base of region for mmaps (when user doesn't specify an address).
- Addr mmap_start;
- Addr mmap_end;
-
- // Base of region for nxm data
- Addr nxm_start;
- Addr nxm_end;
-
- std::string prog_fname; // file name
-
- Stats::Scalar num_syscalls; // number of syscalls executed
-
-
- protected:
- // constructor
- Process(ProcessParams * params);
-
- // post initialization startup
- virtual void startup();
-
- protected:
- /// Memory object for initialization (image loading)
- TranslatingPort *initVirtMem;
-
- public:
- PageTable *pTable;
-
- //This id is assigned by m5 and is used to keep process' tlb entries
- //separated.
- uint64_t M5_pid;
-
- class FdMap
- {
- public:
- int fd;
- std::string filename;
- int mode;
- int flags;
- bool isPipe;
- int readPipeSource;
- uint64_t fileOffset;
-
-
- FdMap()
- {
- fd = -1;
- filename = "NULL";
- mode = 0;
- flags = 0;
- isPipe = false;
- readPipeSource = 0;
- fileOffset = 0;
-
- }
-
- void serialize(std::ostream &os);
- void unserialize(Checkpoint *cp, const std::string §ion);
-
- };
-
- private:
- // file descriptor remapping support
- static const int MAX_FD = 256; // max legal fd value
- FdMap fd_map[MAX_FD+1];
-
-
- public:
- // static helper functions to generate file descriptors for constructor
- static int openInputFile(const std::string &filename);
- static int openOutputFile(const std::string &filename);
-
- // override of virtual SimObject method: register statistics
- virtual void regStats();
+ Process(const ProcessParams ¶ms, EmulationPageTable *pTable,
+ ::Loader::ObjectFile *obj_file);
+
+ void serialize(CheckpointOut &cp) const override;
+ void unserialize(CheckpointIn &cp) override;
+
+ void init() override;
+ void initState() override;
+ DrainState drain() override;
+
+ virtual void syscall(ThreadContext *tc) { numSyscalls++; }
+
+ inline uint64_t uid() { return _uid; }
+ inline uint64_t euid() { return _euid; }
+ inline uint64_t gid() { return _gid; }
+ inline uint64_t egid() { return _egid; }
+ inline uint64_t pid() { return _pid; }
+ inline uint64_t ppid() { return _ppid; }
+ inline uint64_t pgid() { return _pgid; }
+ inline void pgid(uint64_t pgid) { _pgid = pgid; }
+ inline uint64_t tgid() { return _tgid; }
+
+ const char *progName() const { return executable.c_str(); }
+
+ /**
+ * Find an emulated device driver.
+ *
+ * @param filename Name of the device (under /dev)
+ * @return Pointer to driver object if found, else nullptr
+ */
+ EmulatedDriver *findDriver(std::string filename);
+
+ // This function acts as a callback to update the bias value in
+ // the object file because the parameters needed to calculate the
+ // bias are not available when the object file is created.
+ void updateBias();
+ Addr getBias();
+ Addr getStartPC();
+ ::Loader::ObjectFile *getInterpreter();
+
+ void allocateMem(Addr vaddr, int64_t size, bool clobber = false);
+
+ /// Attempt to fix up a fault at vaddr by allocating a page on the stack.
+ /// @return Whether the fault has been fixed.
+ bool fixupFault(Addr vaddr);