sim, arch, base: Refactor the base remote GDB class.
[gem5.git] / src / sim / process.hh
index 9dc29dcb09765f08e62844be5b176c1648762fc7..cb2a3e2beb3d17ea8cffd5f5137a730b86bb6287 100644 (file)
 #include "mem/se_translating_port_proxy.hh"
 #include "sim/fd_array.hh"
 #include "sim/fd_entry.hh"
+#include "sim/mem_state.hh"
 #include "sim/sim_object.hh"
 
 struct ProcessParams;
 
 class EmulatedDriver;
 class ObjectFile;
-class PageTableBase;
+class EmulationPageTable;
 class SyscallDesc;
 class SyscallReturn;
 class System;
@@ -62,50 +63,8 @@ class ThreadContext;
 class Process : public SimObject
 {
   public:
-    struct WaitRec
-    {
-        Addr waitChan;
-        ThreadContext *waitingContext;
-
-        WaitRec(Addr chan, ThreadContext *ctx)
-            : waitChan(chan), waitingContext(ctx)
-        { }
-    };
-
-    struct MemState
-    {
-        Addr brkPoint;
-        Addr stackBase;
-        unsigned stackSize;
-        Addr stackMin;
-        Addr nextThreadStackBase;
-        Addr mmapEnd;
-
-        MemState()
-            : brkPoint(0), stackBase(0), stackSize(0), stackMin(0),
-              nextThreadStackBase(0), mmapEnd(0)
-        { }
-
-        MemState&
-        operator=(const MemState &in)
-        {
-            if (this == &in)
-                return *this;
-
-            brkPoint = in.brkPoint;
-            stackBase = in.stackBase;
-            stackSize = in.stackSize;
-            stackMin = in.stackMin;
-            nextThreadStackBase = in.nextThreadStackBase;
-            mmapEnd = in.mmapEnd;
-            return *this;
-        }
-
-        void serialize(CheckpointOut &cp) const;
-        void unserialize(CheckpointIn &cp);
-    };
-
-    Process(ProcessParams *params, ObjectFile *obj_file);
+    Process(ProcessParams *params, EmulationPageTable *pTable,
+            ObjectFile *obj_file);
 
     void serialize(CheckpointOut &cp) const override;
     void unserialize(CheckpointIn &cp) override;
@@ -113,7 +72,7 @@ class Process : public SimObject
     void initState() override;
     DrainState drain() override;
 
-    void syscall(int64_t callnum, ThreadContext *tc, Fault *fault);
+    virtual void syscall(int64_t callnum, ThreadContext *tc, Fault *fault);
     virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i) = 0;
     virtual TheISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width);
     virtual void setSyscallArg(ThreadContext *tc, int i,
@@ -140,7 +99,7 @@ class Process : public SimObject
      * Find an emulated device driver.
      *
      * @param filename Name of the device (under /dev)
-     * @return Pointer to driver object if found, else NULL
+     * @return Pointer to driver object if found, else nullptr
      */
     EmulatedDriver *findDriver(std::string filename);
 
@@ -203,11 +162,8 @@ class Process : public SimObject
     void replicatePage(Addr vaddr, Addr new_paddr, ThreadContext *old_tc,
                        ThreadContext *new_tc, bool alloc_page);
 
-    void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *new_p,
-               TheISA::IntReg flags);
-
-    // list of all blocked contexts
-    std::list<WaitRec> waitList;
+    virtual void clone(ThreadContext *old_tc, ThreadContext *new_tc,
+                       Process *new_p, TheISA::IntReg flags);
 
     // thread contexts associated with this process
     std::vector<ContextID> contextIds;
@@ -220,7 +176,7 @@ class Process : public SimObject
     bool useArchPT; // flag for using architecture specific page table
     bool kvmInSE;   // running KVM requires special initialization
 
-    PageTableBase* pTable;
+    EmulationPageTable *pTable;
 
     SETranslatingPortProxy initVirtMem; // memory proxy for initial image load
 
@@ -248,9 +204,7 @@ class Process : public SimObject
     std::shared_ptr<FDArray> fds;
 
     bool *exitGroup;
-
-    Addr maxStackSize;
-    MemState *memState;
+    std::shared_ptr<MemState> memState;
 
     /**
      * Calls a futex wakeup at the address specified by this pointer when