syscall_emul: move mmapGrowsDown() to LiveProcess
[gem5.git] / src / arch / sparc / process.hh
index 1cf7ec2245755f2869b9296dac57052d106d0162..e9d81367b7ff05d08f352ce0f8da0a5b5bc72f84 100644 (file)
 
 #include <string>
 #include <vector>
+
+#include "sim/byteswap.hh"
 #include "sim/process.hh"
 
 class ObjectFile;
 class System;
 
-typedef struct
-{
-    int64_t a_type;
-    union {
-        int64_t a_val;
-        Addr    a_ptr;
-        Addr    a_fcn;
-    };
-} m5_auxv_t;
-
 class SparcLiveProcess : public LiveProcess
 {
   protected:
 
-    static const Addr StackBias = 2047;
+    const Addr StackBias;
 
-    //The locations of the fill and spill handlers
+    // The locations of the fill and spill handlers
     Addr fillStart, spillStart;
 
-    std::vector<m5_auxv_t> auxv;
+    SparcLiveProcess(LiveProcessParams * params,
+            ObjectFile *objFile, Addr _StackBias);
+
+    void initState();
+
+    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;
+    void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
+};
+
+class Sparc32LiveProcess : public SparcLiveProcess
+{
+  protected:
+
+    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;
 
-    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,
-                const std::string &cwd,
-                uint64_t _uid, uint64_t _euid,
-                uint64_t _gid, uint64_t _egid,
-                uint64_t _pid, uint64_t _ppid);
+        // Set up region for mmaps.
+        mmap_end = 0x70000000;
+    }
 
-    void startup();
+    void initState();
 
   public:
 
     void argsInit(int intSize, int pageSize);
 
-    Addr readFillStart()
-    { return fillStart; }
+    void flushWindows(ThreadContext *tc);
 
-    Addr readSpillStart()
-    { return spillStart; }
+    SparcISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
+    /// Explicitly import the otherwise hidden getSyscallArg
+    using LiveProcess::getSyscallArg;
 
+    void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
 };
 
+class Sparc64LiveProcess : public SparcLiveProcess
+{
+  protected:
+
+    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;
+
+        // Set up region for mmaps.
+        mmap_end = 0xfffff80000000000ULL;
+    }
+
+    void initState();
+
+  public:
+
+    void argsInit(int intSize, int pageSize);
+
+    void flushWindows(ThreadContext *tc);
+
+    SparcISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
+    /// Explicitly import the otherwise hidden getSyscallArg
+    using LiveProcess::getSyscallArg;
+
+    void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
+};
+
+/* No architectural page table defined for this ISA */
+typedef NoArchPageTable ArchPageTable;
+
 #endif // __SPARC_PROCESS_HH__