diff options
Diffstat (limited to 'src/arch/riscv')
-rw-r--r-- | src/arch/riscv/process.cc | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/arch/riscv/process.cc b/src/arch/riscv/process.cc index 6bc328325..8b168cb35 100644 --- a/src/arch/riscv/process.cc +++ b/src/arch/riscv/process.cc @@ -56,16 +56,16 @@ RiscvProcess::RiscvProcess(ProcessParams * params, { // Set up stack. On RISC-V, stack starts at the top of kuseg // user address space. RISC-V stack grows down from here - stack_base = 0x7FFFFFFF; + memState->stackBase = (Addr)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->bssBase() + objFile->bssSize(); + memState->brkPoint = objFile->bssBase() + objFile->bssSize(); // 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 @@ -124,18 +124,19 @@ RiscvProcess::argsInit(int pageSize) env_data_size += env.size() + 1; int auxv_array_size = 2 * sizeof(IntType)*auxv.size(); - stack_size = sizeof(IntType) + argv_array_size + 2 * sizeof(Addr) + - arg_data_size + 2 * sizeof(Addr); + memState->stackSize = sizeof(IntType) + argv_array_size + 2 * + sizeof(Addr) + arg_data_size + 2 * sizeof(Addr); if (!envp.empty()) { - stack_size += 2 * sizeof(Addr) + envp_array_size + 2 * sizeof(Addr) + - env_data_size; + memState->stackSize += 2 * sizeof(Addr) + envp_array_size + 2 * + sizeof(Addr) + env_data_size; } if (!auxv.empty()) - stack_size += 2 * sizeof(Addr) + auxv_array_size; - stack_min = roundDown(stack_base - stack_size, pageSize); - allocateMem(stack_min, roundUp(stack_size, pageSize)); + memState->stackSize += 2 * sizeof(Addr) + auxv_array_size; + memState->stackMin = roundDown(memState->stackBase - memState->stackSize, + pageSize); + allocateMem(memState->stackMin, roundUp(memState->stackSize, pageSize)); - Addr argv_array_base = stack_min + sizeof(IntType); + Addr argv_array_base = memState->stackMin + sizeof(IntType); Addr arg_data_base = argv_array_base + argv_array_size + 2 * sizeof(Addr); Addr envp_array_base = arg_data_base + arg_data_size; if (!envp.empty()) @@ -160,7 +161,7 @@ RiscvProcess::argsInit(int pageSize) } } - Addr sp = stack_min; + Addr sp = memState->stackMin; initVirtMem.writeBlob(sp, (uint8_t *)&argc, sizeof(IntType)); sp += sizeof(IntType); for (Addr arg_pointer: arg_pointers) { @@ -211,7 +212,7 @@ RiscvProcess::argsInit(int pageSize) } ThreadContext *tc = system->getThreadContext(contextIds[0]); - tc->setIntReg(StackPointerReg, stack_min); + tc->setIntReg(StackPointerReg, memState->stackMin); tc->pcState(getStartPC()); } |