diff options
author | Brandon Potter <Brandon.Potter@amd.com> | 2017-03-01 13:07:43 -0600 |
---|---|---|
committer | Brandon Potter <Brandon.Potter@amd.com> | 2017-03-09 19:19:38 +0000 |
commit | 43418e7f81099072fb7d56dae11110ae1d858162 (patch) | |
tree | 0d624abfdd331b0edffcafc274c08695d0cca97b /src/arch/sparc | |
parent | 71dd6c2c17a465b7705f53469cd2c89f16ede4b7 (diff) | |
download | gem5-43418e7f81099072fb7d56dae11110ae1d858162.tar.xz |
syscall-emul: Move memState into its own file
The Process class is full of implementation details and
structures related to SE Mode. This changeset factors out an
internal class from Process and moves it into a separate file.
The purpose behind doing this is to clean up the code and make
it a bit more modular.
Change-Id: Ic6941a1657751e8d51d5b6b1dcc04f1195884280
Reviewed-on: https://gem5-review.googlesource.com/2263
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/arch/sparc')
-rw-r--r-- | src/arch/sparc/process.cc | 31 | ||||
-rw-r--r-- | src/arch/sparc/process.hh | 42 |
2 files changed, 47 insertions, 26 deletions
diff --git a/src/arch/sparc/process.cc b/src/arch/sparc/process.cc index a64bc587f..d8384b470 100644 --- a/src/arch/sparc/process.cc +++ b/src/arch/sparc/process.cc @@ -57,15 +57,6 @@ SparcProcess::SparcProcess(ProcessParams * params, ObjectFile *objFile, Addr _StackBias) : Process(params, objFile), StackBias(_StackBias) { - - // XXX all the below need to be updated for SPARC - Ali - memState->brkPoint = objFile->dataBase() + objFile->dataSize() + - objFile->bssSize(); - memState->brkPoint = roundUp(memState->brkPoint, PageBytes); - - // Set pointer for next thread stack. Reserve 8M for main stack. - memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024); - // Initialize these to 0s fillStart = 0; spillStart = 0; @@ -325,16 +316,16 @@ SparcProcess::argsInit(int pageSize) aux_padding + frame_size; - memState->stackMin = memState->stackBase - space_needed; - memState->stackMin = roundDown(memState->stackMin, align); - memState->stackSize = memState->stackBase - memState->stackMin; + memState->setStackMin(memState->getStackBase() - space_needed); + memState->setStackMin(roundDown(memState->getStackMin(), align)); + memState->setStackSize(memState->getStackBase() - memState->getStackMin()); // Allocate space for the stack - allocateMem(roundDown(memState->stackMin, pageSize), - roundUp(memState->stackSize, pageSize)); + allocateMem(roundDown(memState->getStackMin(), pageSize), + roundUp(memState->getStackSize(), pageSize)); // map out initial stack contents - IntType sentry_base = memState->stackBase - sentry_size; + IntType sentry_base = memState->getStackBase() - sentry_size; IntType file_name_base = sentry_base - file_name_size; IntType env_data_base = file_name_base - env_data_size; IntType arg_data_base = env_data_base - arg_data_size; @@ -358,9 +349,9 @@ SparcProcess::argsInit(int pageSize) DPRINTF(Stack, "%#x - argv array\n", argv_array_base); DPRINTF(Stack, "%#x - argc \n", argc_base); DPRINTF(Stack, "%#x - window save\n", window_save_base); - DPRINTF(Stack, "%#x - stack min\n", memState->stackMin); + DPRINTF(Stack, "%#x - stack min\n", memState->getStackMin()); - assert(window_save_base == memState->stackMin); + assert(window_save_base == memState->getStackMin()); // write contents to stack @@ -399,7 +390,7 @@ SparcProcess::argsInit(int pageSize) // Set up space for the trap handlers into the processes address space. // Since the stack grows down and there is reserved address space abov // it, we can put stuff above it and stay out of the way. - fillStart = memState->stackBase; + fillStart = memState->getStackBase(); spillStart = fillStart + sizeof(MachInst) * numFillInsts; ThreadContext *tc = system->getThreadContext(contextIds[0]); @@ -407,7 +398,7 @@ SparcProcess::argsInit(int pageSize) // assert(NumArgumentRegs >= 2); // tc->setIntReg(ArgumentReg[0], argc); // tc->setIntReg(ArgumentReg[1], argv_array_base); - tc->setIntReg(StackPointerReg, memState->stackMin - StackBias); + tc->setIntReg(StackPointerReg, memState->getStackMin() - StackBias); // %g1 is a pointer to a function that should be run at exit. Since we // don't have anything like that, it should be set to 0. @@ -416,7 +407,7 @@ SparcProcess::argsInit(int pageSize) tc->pcState(getStartPC()); // Align the "stack_min" to a page boundary. - memState->stackMin = roundDown(memState->stackMin, pageSize); + memState->setStackMin(roundDown(memState->getStackMin(), pageSize)); } void diff --git a/src/arch/sparc/process.hh b/src/arch/sparc/process.hh index 96901fde3..6a203a400 100644 --- a/src/arch/sparc/process.hh +++ b/src/arch/sparc/process.hh @@ -32,15 +32,16 @@ #ifndef __SPARC_PROCESS_HH__ #define __SPARC_PROCESS_HH__ +#include <memory> #include <string> #include <vector> +#include "arch/sparc/isa_traits.hh" +#include "base/loader/object_file.hh" #include "mem/page_table.hh" #include "sim/byteswap.hh" #include "sim/process.hh" -class ObjectFile; - class SparcProcess : public Process { protected: @@ -77,12 +78,27 @@ class Sparc32Process : public SparcProcess Sparc32Process(ProcessParams * params, ObjectFile *objFile) : SparcProcess(params, objFile, 0) { + Addr brk_point = objFile->dataBase() + objFile->dataSize() + + objFile->bssSize(); + brk_point = roundUp(brk_point, SparcISA::PageBytes); + + // Reserve 8M for main stack. + Addr max_stack_size = 8 * 1024 * 1024; + // Set up stack. On SPARC Linux, stack goes from the top of memory // downward, less the hole for the kernel address space. - memState->stackBase = (Addr)0xf0000000ULL; + Addr stack_base = 0xf0000000ULL; + + // Set pointer for next thread stack. + Addr next_thread_stack_base = stack_base - max_stack_size; // Set up region for mmaps. - memState->mmapEnd = 0x70000000; + Addr mmap_end = 0x70000000; + + memState = std::make_shared<MemState>(brk_point, stack_base, + max_stack_size, + next_thread_stack_base, + mmap_end); } void initState(); @@ -107,12 +123,26 @@ class Sparc64Process : public SparcProcess Sparc64Process(ProcessParams * params, ObjectFile *objFile) : SparcProcess(params, objFile, 2047) { + Addr brk_point = objFile->dataBase() + objFile->dataSize() + + objFile->bssSize(); + brk_point = roundUp(brk_point, SparcISA::PageBytes); + + Addr max_stack_size = 8 * 1024 * 1024; + // Set up stack. On SPARC Linux, stack goes from the top of memory // downward, less the hole for the kernel address space. - memState->stackBase = (Addr)0x80000000000ULL; + Addr stack_base = 0x80000000000ULL; + + // Set pointer for next thread stack. Reserve 8M for main stack. + Addr next_thread_stack_base = stack_base - max_stack_size; // Set up region for mmaps. - memState->mmapEnd = 0xfffff80000000000ULL; + Addr mmap_end = 0xfffff80000000000ULL; + + memState = std::make_shared<MemState>(brk_point, stack_base, + max_stack_size, + next_thread_stack_base, + mmap_end); } void initState(); |