X86: Fix the expected size of the immediate offset in MOV_MI.
[gem5.git] / src / sim / system.hh
index a1b53c2eb04c40b5f323cd35c6537fdbada17488..aa89866bd591d5e0d836502818481432cf3635d9 100644 (file)
 #include "base/loader/symtab.hh"
 #include "base/misc.hh"
 #include "base/statistics.hh"
+#include "config/full_system.hh"
 #include "cpu/pc_event.hh"
+#include "enums/MemoryMode.hh"
 #include "mem/port.hh"
+#include "params/System.hh"
 #include "sim/sim_object.hh"
 #if FULL_SYSTEM
 #include "kern/system_events.hh"
@@ -54,44 +57,53 @@ class PhysicalMemory;
 
 #if FULL_SYSTEM
 class Platform;
-class GDBListener;
-class RemoteGDB;
 #endif
+class GDBListener;
+namespace TheISA
+{
+    class RemoteGDB;
+}
 
 class System : public SimObject
 {
   public:
-    enum MemoryMode {
-        Invalid=0,
-        Atomic,
-        Timing
-    };
 
     static const char *MemoryModeStrings[3];
 
-
-    MemoryMode getMemoryMode() { assert(memoryMode); return memoryMode; }
+    Enums::MemoryMode
+    getMemoryMode()
+    {
+        assert(memoryMode);
+        return memoryMode;
+    }
 
     /** Change the memory mode of the system. This should only be called by the
      * python!!
      * @param mode Mode to change to (atomic/timing)
      */
-    void setMemoryMode(MemoryMode mode);
+    void setMemoryMode(Enums::MemoryMode mode);
 
     PhysicalMemory *physmem;
     PCEventQueue pcEventQueue;
 
     std::vector<ThreadContext *> threadContexts;
-    int numcpus;
+    int _numContexts;
 
-    int getNumCPUs()
+    ThreadContext *getThreadContext(ThreadID tid)
     {
-        if (numcpus != threadContexts.size())
-            panic("cpu array not fully populated!");
+        return threadContexts[tid];
+    }
 
-        return numcpus;
+    int numContexts()
+    {
+        assert(_numContexts == (int)threadContexts.size());
+        return _numContexts;
     }
 
+    /** Return number of running (non-halted) thread contexts in
+     * system.  These threads could be Active or Suspended. */
+    int numRunningContexts();
+
 #if FULL_SYSTEM
     Platform *platform;
     uint64_t init_param;
@@ -120,12 +132,26 @@ class System : public SimObject
 
     int page_ptr;
 
+  protected:
+    uint64_t next_PID;
+
+  public:
+    uint64_t allocatePID()
+    {
+        return next_PID++;
+    }
+
+    /** Amount of physical memory that is still free */
+    Addr freeMemSize();
+
+    /** Amount of physical memory that exists */
+    Addr memSize();
+
 
 #endif // FULL_SYSTEM
 
   protected:
-
-    MemoryMode memoryMode;
+    Enums::MemoryMode memoryMode;
 
 #if FULL_SYSTEM
     /**
@@ -140,7 +166,7 @@ class System : public SimObject
      * up in the specified symbol table.
      */
     template <class T>
-    T *System::addFuncEvent(SymbolTable *symtab, const char *lbl)
+    T *addFuncEvent(SymbolTable *symtab, const char *lbl)
     {
         Addr addr = 0; // initialize only to avoid compiler warning
 
@@ -154,35 +180,19 @@ class System : public SimObject
 
     /** Add a function-based event to kernel code. */
     template <class T>
-    T *System::addKernelFuncEvent(const char *lbl)
+    T *addKernelFuncEvent(const char *lbl)
     {
         return addFuncEvent<T>(kernelSymtab, lbl);
     }
 
 #endif
   public:
-#if FULL_SYSTEM
-    std::vector<RemoteGDB *> remoteGDB;
+    std::vector<TheISA::RemoteGDB *> remoteGDB;
     std::vector<GDBListener *> gdbListen;
-    virtual bool breakpoint() = 0;
-#endif // FULL_SYSTEM
+    bool breakpoint();
 
   public:
-    struct Params
-    {
-        std::string name;
-        PhysicalMemory *physmem;
-        MemoryMode mem_mode;
-
-#if FULL_SYSTEM
-        Tick boot_cpu_frequency;
-        std::string boot_osflags;
-        uint64_t init_param;
-
-        std::string kernel_path;
-        std::string readfile;
-#endif
-    };
+    typedef SystemParams Params;
 
   protected:
     Params *_params;
@@ -222,8 +232,8 @@ class System : public SimObject
 
 #endif // FULL_SYSTEM
 
-    int registerThreadContext(ThreadContext *tc, int tcIndex);
-    void replaceThreadContext(ThreadContext *tc, int tcIndex);
+    int registerThreadContext(ThreadContext *tc, int assigned=-1);
+    void replaceThreadContext(ThreadContext *tc, int context_id);
 
     void serialize(std::ostream &os);
     void unserialize(Checkpoint *cp, const std::string &section);