Automated merge with ssh://m5sim.org//repo/m5
[gem5.git] / src / arch / sparc / process.hh
index db5e64352b18ea1e6154552332d678dec01ae93b..a37760139e89b3d7fabf7e10bd0f4ae1b014a219 100644 (file)
 
 #include <string>
 #include <vector>
+#include "sim/byteswap.hh"
 #include "sim/process.hh"
 
 class ObjectFile;
 class System;
 
-typedef struct
+class SparcLiveProcess : public LiveProcess
+{
+  protected:
+
+    const Addr StackBias;
+
+    //The locations of the fill and spill handlers
+    Addr fillStart, spillStart;
+
+    SparcLiveProcess(LiveProcessParams * params,
+            ObjectFile *objFile, Addr _StackBias);
+
+    void startup();
+
+    template<class IntType>
+    void argsInit(int pageSize);
+
+  public:
+
+    //Handles traps which request services from the operating system
+    virtual void handleTrap(int trapNum, ThreadContext *tc);
+
+    Addr readFillStart()
+    { return fillStart; }
+
+    Addr readSpillStart()
+    { return spillStart; }
+
+    virtual void flushWindows(ThreadContext *tc) = 0;
+};
+
+template<class IntType>
+struct M5_auxv_t
 {
-    int64_t a_type;
+    IntType a_type;
     union {
-        int64_t a_val;
-        Addr    a_ptr;
-        Addr    a_fcn;
+        IntType a_val;
+        IntType a_ptr;
+        IntType a_fcn;
     };
-} m5_auxv_t;
 
-class SparcLiveProcess : public LiveProcess
+    M5_auxv_t()
+    {}
+
+    M5_auxv_t(IntType type, IntType val)
+    {
+        a_type = SparcISA::htog(type);
+        a_val = SparcISA::htog(val);
+    }
+};
+
+class Sparc32LiveProcess : public SparcLiveProcess
 {
   protected:
 
-    static const Addr StackBias = 2047;
+    Sparc32LiveProcess(LiveProcessParams * params, ObjectFile *objFile) :
+            SparcLiveProcess(params, objFile, 0)
+    {
+        // Set up stack. On SPARC Linux, stack goes from the top of memory
+        // downward, less the hole for the kernel address space.
+        stack_base = (Addr)0xf0000000ULL;
+
+        // Set up region for mmaps.
+        mmap_start = mmap_end = 0x70000000;
+    }
+
+    void startup();
+
+  public:
+
+    void argsInit(int intSize, int pageSize);
+
+    void flushWindows(ThreadContext *tc);
+};
+
+class Sparc64LiveProcess : public SparcLiveProcess
+{
+  protected:
 
-    std::vector<m5_auxv_t> auxv;
+    Sparc64LiveProcess(LiveProcessParams * params, ObjectFile *objFile) :
+            SparcLiveProcess(params, objFile, 2047)
+    {
+        // Set up stack. On SPARC Linux, stack goes from the top of memory
+        // downward, less the hole for the kernel address space.
+        stack_base = (Addr)0x80000000000ULL;
 
-    SparcLiveProcess(const std::string &nm, ObjectFile *objFile,
-                System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
-                std::vector<std::string> &argv,
-                std::vector<std::string> &envp);
+        // Set up region for mmaps.  Tru64 seems to start just above 0 and
+        // grow up from there.
+        mmap_start = mmap_end = 0xfffff80000000000ULL;
+    }
 
     void startup();
 
   public:
-    // this function is used to create the LiveProcess object, since
-    // we can't tell which subclass of LiveProcess to use until we
-    // open and look at the object file.
-    static SparcLiveProcess *create(const std::string &nm,
-                               System *_system,
-                               int stdin_fd, int stdout_fd, int stderr_fd,
-                               std::string executable,
-                               std::vector<std::string> &argv,
-                               std::vector<std::string> &envp);
 
     void argsInit(int intSize, int pageSize);
 
+    void flushWindows(ThreadContext *tc);
 };
 
 #endif // __SPARC_PROCESS_HH__