summaryrefslogtreecommitdiff
path: root/src/arch/mips
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2017-02-27 14:10:15 -0500
committerBrandon Potter <brandon.potter@amd.com>2017-02-27 14:10:15 -0500
commit2367198921765848a4f5b3d020a7cc5776209f80 (patch)
tree00cff9357d9e5f2bec277cf937e8a73944ce1c98 /src/arch/mips
parent073cb266079edddec64ea8cd5169dd2cbef8f812 (diff)
downloadgem5-2367198921765848a4f5b3d020a7cc5776209f80.tar.xz
syscall_emul: [PATCH 15/22] add clone/execve for threading and multiprocess simulations
Modifies the clone system call and adds execve system call. Requires allowing processes to steal thread contexts from other processes in the same system object and the ability to detach pieces of process state (such as MemState) to allow dynamic sharing.
Diffstat (limited to 'src/arch/mips')
-rw-r--r--src/arch/mips/process.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc
index c1943bf39..4993b3c68 100644
--- a/src/arch/mips/process.cc
+++ b/src/arch/mips/process.cc
@@ -53,17 +53,18 @@ MipsProcess::MipsProcess(ProcessParams * params, ObjectFile *objFile)
{
// Set up stack. On MIPS, stack starts at the top of kuseg
// user address space. MIPS stack grows down from here
- stack_base = 0x7FFFFFFF;
+ memState->stackBase = 0x7FFFFFFF;
// Set pointer for next thread stack. Reserve 8M for main stack.
- next_thread_stack_base = stack_base - (8 * 1024 * 1024);
+ memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024);
// Set up break point (Top of Heap)
- brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
- brk_point = roundUp(brk_point, PageBytes);
+ memState->brkPoint = objFile->dataBase() + objFile->dataSize() +
+ objFile->bssSize();
+ memState->brkPoint = roundUp(memState->brkPoint, PageBytes);
// Set up region for mmaps. Start it 1GB above the top of the heap.
- mmap_end = brk_point + 0x40000000L;
+ memState->mmapEnd = memState->brkPoint + 0x40000000L;
}
void
@@ -140,15 +141,15 @@ MipsProcess::argsInit(int pageSize)
env_data_size;
// set bottom of stack
- stack_min = stack_base - space_needed;
+ memState->stackMin = memState->stackBase - space_needed;
// align it
- stack_min = roundDown(stack_min, pageSize);
- stack_size = stack_base - stack_min;
+ memState->stackMin = roundDown(memState->stackMin, pageSize);
+ memState->stackSize = memState->stackBase - memState->stackMin;
// map memory
- allocateMem(stack_min, roundUp(stack_size, pageSize));
+ allocateMem(memState->stackMin, roundUp(memState->stackSize, pageSize));
// map out initial stack contents
- IntType argv_array_base = stack_min + intSize; // room for argc
+ IntType argv_array_base = memState->stackMin + intSize; // room for argc
IntType envp_array_base = argv_array_base + argv_array_size;
IntType auxv_array_base = envp_array_base + envp_array_size;
IntType arg_data_base = auxv_array_base + auxv_array_size;
@@ -159,7 +160,7 @@ MipsProcess::argsInit(int pageSize)
argc = htog((IntType)argc);
- initVirtMem.writeBlob(stack_min, (uint8_t*)&argc, intSize);
+ initVirtMem.writeBlob(memState->stackMin, (uint8_t*)&argc, intSize);
copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
@@ -184,7 +185,7 @@ MipsProcess::argsInit(int pageSize)
setSyscallArg(tc, 0, argc);
setSyscallArg(tc, 1, argv_array_base);
- tc->setIntReg(StackPointerReg, stack_min);
+ tc->setIntReg(StackPointerReg, memState->stackMin);
tc->pcState(getStartPC());
}