sim: Add an option to forward work items to Python
[gem5.git] / src / arch / mips / process.cc
index 7f1e9470962ed89d8961ded1d20853a44d7f36d6..404c84da6b925c2ebbdfaf87777cdd1c5eef2b63 100644 (file)
 
 #include "arch/mips/isa_traits.hh"
 #include "arch/mips/process.hh"
-
-#include "base/loader/object_file.hh"
 #include "base/loader/elf_object.hh"
+#include "base/loader/object_file.hh"
 #include "base/misc.hh"
 #include "cpu/thread_context.hh"
-
+#include "debug/Loader.hh"
 #include "mem/page_table.hh"
-
 #include "sim/process.hh"
 #include "sim/process_impl.hh"
 #include "sim/system.hh"
@@ -60,7 +58,7 @@ MipsLiveProcess::MipsLiveProcess(LiveProcessParams * params,
 
     // Set up break point (Top of Heap)
     brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
-    brk_point = roundUp(brk_point, VMPageSize);
+    brk_point = roundUp(brk_point, PageBytes);
 
     // Set up region for mmaps.  Start it 1GB above the top of the heap.
     mmap_start = mmap_end = brk_point + 0x40000000L;
@@ -71,7 +69,7 @@ MipsLiveProcess::initState()
 {
     LiveProcess::initState();
 
-    argsInit<uint32_t>(VMPageSize);
+    argsInit<uint32_t>(PageBytes);
 }
 
 template<class IntType>
@@ -90,7 +88,7 @@ MipsLiveProcess::argsInit(int pageSize)
     if (elfObject)
     {
         // Set the system page size
-        auxv.push_back(auxv_t(M5_AT_PAGESZ, MipsISA::VMPageSize));
+        auxv.push_back(auxv_t(M5_AT_PAGESZ, MipsISA::PageBytes));
         // Set the frequency at which time() increments
         auxv.push_back(auxv_t(M5_AT_CLKTCK, 100));
         // For statically linked executables, this is the virtual
@@ -138,7 +136,7 @@ MipsLiveProcess::argsInit(int pageSize)
     stack_min = roundDown(stack_min, pageSize);
     stack_size = stack_base - stack_min;
     // map memory
-    pTable->allocate(stack_min, roundUp(stack_size, pageSize));
+    allocateMem(stack_min, roundUp(stack_size, pageSize));
 
     // map out initial stack contents
     IntType argv_array_base = stack_min + intSize; // room for argc
@@ -152,7 +150,7 @@ MipsLiveProcess::argsInit(int pageSize)
 
     argc = htog((IntType)argc);
 
-    initVirtMem->writeBlob(stack_min, (uint8_t*)&argc, intSize);
+    initVirtMem.writeBlob(stack_min, (uint8_t*)&argc, intSize);
 
     copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
 
@@ -160,9 +158,9 @@ MipsLiveProcess::argsInit(int pageSize)
 
     // Copy the aux vector
     for (typename vector<auxv_t>::size_type x = 0; x < auxv.size(); x++) {
-        initVirtMem->writeBlob(auxv_array_base + x * 2 * intSize,
+        initVirtMem.writeBlob(auxv_array_base + x * 2 * intSize,
                 (uint8_t*)&(auxv[x].a_type), intSize);
-        initVirtMem->writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
+        initVirtMem.writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
                 (uint8_t*)&(auxv[x].a_val), intSize);
     }
 
@@ -170,7 +168,7 @@ MipsLiveProcess::argsInit(int pageSize)
     for (unsigned i = 0; i < 2; i++) {
         const IntType zero = 0;
         const Addr addr = auxv_array_base + 2 * intSize * (auxv.size() + i);
-        initVirtMem->writeBlob(addr, (uint8_t*)&zero, intSize);
+        initVirtMem.writeBlob(addr, (uint8_t*)&zero, intSize);
     }
 
     ThreadContext *tc = system->getThreadContext(contextIds[0]);
@@ -179,10 +177,7 @@ MipsLiveProcess::argsInit(int pageSize)
     setSyscallArg(tc, 1, argv_array_base);
     tc->setIntReg(StackPointerReg, stack_min);
 
-    Addr prog_entry = objFile->entryPoint();
-    tc->setPC(prog_entry);
-    tc->setNextPC(prog_entry + sizeof(MachInst));
-    tc->setNextNPC(prog_entry + (2 * sizeof(MachInst)));
+    tc->pcState(objFile->entryPoint());
 }
 
 
@@ -202,16 +197,15 @@ MipsLiveProcess::setSyscallArg(ThreadContext *tc,
 }
 
 void
-MipsLiveProcess::setSyscallReturn(ThreadContext *tc,
-        SyscallReturn return_value)
+MipsLiveProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
 {
-    if (return_value.successful()) {
+    if (sysret.successful()) {
         // no error
         tc->setIntReg(SyscallSuccessReg, 0);
-        tc->setIntReg(ReturnValueReg, return_value.value());
+        tc->setIntReg(ReturnValueReg, sysret.returnValue());
     } else {
         // got an error, return details
         tc->setIntReg(SyscallSuccessReg, (IntReg) -1);
-        tc->setIntReg(ReturnValueReg, -return_value.value());
+        tc->setIntReg(ReturnValueReg, sysret.errnoValue());
     }
 }