summaryrefslogtreecommitdiff
path: root/src/arch/arm/process.cc
diff options
context:
space:
mode:
authorBrandon Potter <Brandon.Potter@amd.com>2017-03-01 13:07:43 -0600
committerBrandon Potter <Brandon.Potter@amd.com>2017-03-09 19:19:38 +0000
commit43418e7f81099072fb7d56dae11110ae1d858162 (patch)
tree0d624abfdd331b0edffcafc274c08695d0cca97b /src/arch/arm/process.cc
parent71dd6c2c17a465b7705f53469cd2c89f16ede4b7 (diff)
downloadgem5-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/arm/process.cc')
-rw-r--r--src/arch/arm/process.cc60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc
index fd0243c44..eb8abfb4d 100644
--- a/src/arch/arm/process.cc
+++ b/src/arch/arm/process.cc
@@ -70,36 +70,30 @@ ArmProcess32::ArmProcess32(ProcessParams *params, ObjectFile *objFile,
ObjectFile::Arch _arch)
: ArmProcess(params, objFile, _arch)
{
- memState->stackBase = 0xbf000000L;
-
- // Set pointer for next thread stack. Reserve 8M for main stack.
- memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024);
-
- // Set up break point (Top of Heap)
- memState->brkPoint = objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize();
- memState->brkPoint = roundUp(memState->brkPoint, PageBytes);
-
- // Set up region for mmaps. For now, start at bottom of kuseg space.
- memState->mmapEnd = 0x40000000L;
+ Addr brk_point = roundUp(objFile->dataBase() + objFile->dataSize() +
+ objFile->bssSize(), PageBytes);
+ Addr stack_base = 0xbf000000L;
+ Addr max_stack_size = 8 * 1024 * 1024;
+ Addr next_thread_stack_base = stack_base - max_stack_size;
+ Addr mmap_end = 0x40000000L;
+
+ memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
+ next_thread_stack_base, mmap_end);
}
ArmProcess64::ArmProcess64(ProcessParams *params, ObjectFile *objFile,
ObjectFile::Arch _arch)
: ArmProcess(params, objFile, _arch)
{
- memState->stackBase = 0x7fffff0000L;
-
- // Set pointer for next thread stack. Reserve 8M for main stack.
- memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024);
-
- // Set up break point (Top of Heap)
- memState->brkPoint = objFile->dataBase() + objFile->dataSize() +
- objFile->bssSize();
- memState->brkPoint = roundUp(memState->brkPoint, PageBytes);
-
- // Set up region for mmaps. For now, start at bottom of kuseg space.
- memState->mmapEnd = 0x4000000000L;
+ Addr brk_point = roundUp(objFile->dataBase() + objFile->dataSize() +
+ objFile->bssSize(), PageBytes);
+ Addr stack_base = 0x7fffff0000L;
+ Addr max_stack_size = 8 * 1024 * 1024;
+ Addr next_thread_stack_base = stack_base - max_stack_size;
+ Addr mmap_end = 0x4000000000L;
+
+ memState = make_shared<MemState>(brk_point, stack_base, max_stack_size,
+ next_thread_stack_base, mmap_end);
}
void
@@ -302,16 +296,16 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex)
int space_needed = frame_size + aux_padding;
- 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());
// map memory
- 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 aux_data_base = sentry_base - aux_data_size;
IntType env_data_base = aux_data_base - env_data_size;
IntType arg_data_base = env_data_base - arg_data_size;
@@ -332,7 +326,7 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex)
DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
DPRINTF(Stack, "0x%x - argc \n", argc_base);
- DPRINTF(Stack, "0x%x - stack min\n", memState->stackMin);
+ DPRINTF(Stack, "0x%x - stack min\n", memState->getStackMin());
// write contents to stack
@@ -378,7 +372,7 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex)
ThreadContext *tc = system->getThreadContext(contextIds[0]);
//Set the stack pointer register
- tc->setIntReg(spIndex, memState->stackMin);
+ tc->setIntReg(spIndex, memState->getStackMin());
//A pointer to a function to run when the program exits. We'll set this
//to zero explicitly to make sure this isn't used.
tc->setIntReg(ArgumentReg0, 0);
@@ -405,7 +399,7 @@ ArmProcess::argsInit(int pageSize, IntRegIndex spIndex)
tc->pcState(pc);
//Align the "stackMin" to a page boundary.
- memState->stackMin = roundDown(memState->stackMin, pageSize);
+ memState->setStackMin(roundDown(memState->getStackMin(), pageSize));
}
ArmISA::IntReg