1/* 2 * Copyright (c) 2007-2008 The Florida State University 3 * Copyright (c) 2009 The University of Edinburgh 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright --- 37 unchanged lines hidden (view full) --- 46#include "sim/system.hh" 47 48using namespace std; 49using namespace PowerISA; 50 51PowerProcess::PowerProcess(ProcessParams *params, ObjectFile *objFile) 52 : Process(params, objFile) 53{ |
54 // Set up break point (Top of Heap) 55 Addr brk_point = objFile->dataBase() + objFile->dataSize() + 56 objFile->bssSize(); 57 brk_point = roundUp(brk_point, PageBytes); |
58 |
59 Addr stack_base = 0xbf000000L; |
60 |
61 Addr max_stack_size = 8 * 1024 * 1024; |
62 |
63 // Set pointer for next thread stack. Reserve 8M for main stack. 64 Addr next_thread_stack_base = stack_base - max_stack_size; 65 |
66 // Set up region for mmaps. For now, start at bottom of kuseg space. |
67 Addr mmap_end = 0x70000000L; 68 69 memState = make_shared<MemState>(brk_point, stack_base, max_stack_size, 70 next_thread_stack_base, mmap_end); |
71} 72 73void 74PowerProcess::initState() 75{ 76 Process::initState(); 77 78 argsInit(MachineBytes, PageBytes); --- 107 unchanged lines hidden (view full) --- 186 //There needs to be padding after the auxiliary vector data so that the 187 //very bottom of the stack is aligned properly. 188 int partial_size = frame_size; 189 int aligned_partial_size = roundUp(partial_size, align); 190 int aux_padding = aligned_partial_size - partial_size; 191 192 int space_needed = frame_size + aux_padding; 193 |
194 Addr stack_min = memState->getStackBase() - space_needed; 195 stack_min = roundDown(stack_min, align); |
196 |
197 memState->setStackSize(memState->getStackBase() - stack_min); 198 |
199 // map memory |
200 allocateMem(roundDown(stack_min, pageSize), 201 roundUp(memState->getStackSize(), pageSize)); |
202 203 // map out initial stack contents |
204 uint32_t sentry_base = memState->getStackBase() - sentry_size; |
205 uint32_t aux_data_base = sentry_base - aux_data_size; 206 uint32_t env_data_base = aux_data_base - env_data_size; 207 uint32_t arg_data_base = env_data_base - arg_data_size; 208 uint32_t platform_base = arg_data_base - platform_size; 209 uint32_t auxv_array_base = platform_base - aux_array_size - aux_padding; 210 uint32_t envp_array_base = auxv_array_base - envp_array_size; 211 uint32_t argv_array_base = envp_array_base - argv_array_size; 212 uint32_t argc_base = argv_array_base - argc_size; 213 214 DPRINTF(Stack, "The addresses of items on the initial stack:\n"); 215 DPRINTF(Stack, "0x%x - aux data\n", aux_data_base); 216 DPRINTF(Stack, "0x%x - env data\n", env_data_base); 217 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base); 218 DPRINTF(Stack, "0x%x - platform base\n", platform_base); 219 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base); 220 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base); 221 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base); 222 DPRINTF(Stack, "0x%x - argc \n", argc_base); |
223 DPRINTF(Stack, "0x%x - stack min\n", stack_min); |
224 225 // write contents to stack 226 227 // figure out argc 228 uint32_t argc = argv.size(); 229 uint32_t guestArgc = PowerISA::htog(argc); 230 231 //Write out the sentry void * --- 28 unchanged lines hidden (view full) --- 260 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 261 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 262 263 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); 264 265 ThreadContext *tc = system->getThreadContext(contextIds[0]); 266 267 //Set the stack pointer register |
268 tc->setIntReg(StackPointerReg, stack_min); |
269 270 tc->pcState(getStartPC()); 271 272 //Align the "stack_min" to a page boundary. |
273 memState->setStackMin(roundDown(stack_min, pageSize)); |
274} 275 276PowerISA::IntReg 277PowerProcess::getSyscallArg(ThreadContext *tc, int &i) 278{ 279 assert(i < 5); 280 return tc->readIntReg(ArgumentReg0 + i++); 281} --- 20 unchanged lines hidden --- |