1/* 2 * Copyright (c) 2010, 2012 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 56 unchanged lines hidden (view full) --- 65 : Process(params, objFile), arch(_arch) 66{ 67} 68 69ArmProcess32::ArmProcess32(ProcessParams *params, ObjectFile *objFile, 70 ObjectFile::Arch _arch) 71 : ArmProcess(params, objFile, _arch) 72{ |
73 memState->stackBase = 0xbf000000L; |
74 75 // Set pointer for next thread stack. Reserve 8M for main stack. |
76 memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024); |
77 78 // Set up break point (Top of Heap) |
79 memState->brkPoint = objFile->dataBase() + objFile->dataSize() + 80 objFile->bssSize(); 81 memState->brkPoint = roundUp(memState->brkPoint, PageBytes); |
82 83 // Set up region for mmaps. For now, start at bottom of kuseg space. |
84 memState->mmapEnd = 0x40000000L; |
85} 86 87ArmProcess64::ArmProcess64(ProcessParams *params, ObjectFile *objFile, 88 ObjectFile::Arch _arch) 89 : ArmProcess(params, objFile, _arch) 90{ |
91 memState->stackBase = 0x7fffff0000L; |
92 93 // Set pointer for next thread stack. Reserve 8M for main stack. |
94 memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024); |
95 96 // Set up break point (Top of Heap) |
97 memState->brkPoint = objFile->dataBase() + objFile->dataSize() + 98 objFile->bssSize(); 99 memState->brkPoint = roundUp(memState->brkPoint, PageBytes); |
100 101 // Set up region for mmaps. For now, start at bottom of kuseg space. |
102 memState->mmapEnd = 0x4000000000L; |
103} 104 105void 106ArmProcess32::initState() 107{ 108 Process::initState(); 109 argsInit<uint32_t>(PageBytes, INTREG_SP); 110 for (int i = 0; i < contextIds.size(); i++) { --- 186 unchanged lines hidden (view full) --- 297 //There needs to be padding after the auxiliary vector data so that the 298 //very bottom of the stack is aligned properly. 299 int partial_size = frame_size; 300 int aligned_partial_size = roundUp(partial_size, align); 301 int aux_padding = aligned_partial_size - partial_size; 302 303 int space_needed = frame_size + aux_padding; 304 |
305 memState->stackMin = memState->stackBase - space_needed; 306 memState->stackMin = roundDown(memState->stackMin, align); 307 memState->stackSize = memState->stackBase - memState->stackMin; |
308 309 // map memory |
310 allocateMem(roundDown(memState->stackMin, pageSize), 311 roundUp(memState->stackSize, pageSize)); |
312 313 // map out initial stack contents |
314 IntType sentry_base = memState->stackBase - sentry_size; |
315 IntType aux_data_base = sentry_base - aux_data_size; 316 IntType env_data_base = aux_data_base - env_data_size; 317 IntType arg_data_base = env_data_base - arg_data_size; 318 IntType platform_base = arg_data_base - platform_size; 319 IntType aux_random_base = platform_base - aux_random_size; 320 IntType auxv_array_base = aux_random_base - aux_array_size - aux_padding; 321 IntType envp_array_base = auxv_array_base - envp_array_size; 322 IntType argv_array_base = envp_array_base - argv_array_size; --- 4 unchanged lines hidden (view full) --- 327 DPRINTF(Stack, "0x%x - env data\n", env_data_base); 328 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base); 329 DPRINTF(Stack, "0x%x - random data\n", aux_random_base); 330 DPRINTF(Stack, "0x%x - platform base\n", platform_base); 331 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base); 332 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base); 333 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base); 334 DPRINTF(Stack, "0x%x - argc \n", argc_base); |
335 DPRINTF(Stack, "0x%x - stack min\n", memState->stackMin); |
336 337 // write contents to stack 338 339 // figure out argc 340 IntType argc = argv.size(); 341 IntType guestArgc = ArmISA::htog(argc); 342 343 //Write out the sentry void * --- 29 unchanged lines hidden (view full) --- 373 374 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem); 375 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem); 376 377 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize); 378 379 ThreadContext *tc = system->getThreadContext(contextIds[0]); 380 //Set the stack pointer register |
381 tc->setIntReg(spIndex, memState->stackMin); |
382 //A pointer to a function to run when the program exits. We'll set this 383 //to zero explicitly to make sure this isn't used. 384 tc->setIntReg(ArgumentReg0, 0); 385 //Set argument regs 1 and 2 to argv[0] and envp[0] respectively 386 if (argv.size() > 0) { 387 tc->setIntReg(ArgumentReg1, arg_data_base + arg_data_size - 388 argv[argv.size() - 1].size() - 1); 389 } else { --- 9 unchanged lines hidden (view full) --- 399 PCState pc; 400 pc.thumb(arch == ObjectFile::Thumb); 401 pc.nextThumb(pc.thumb()); 402 pc.aarch64(arch == ObjectFile::Arm64); 403 pc.nextAArch64(pc.aarch64()); 404 pc.set(getStartPC() & ~mask(1)); 405 tc->pcState(pc); 406 |
407 //Align the "stackMin" to a page boundary. 408 memState->stackMin = roundDown(memState->stackMin, pageSize); |
409} 410 411ArmISA::IntReg 412ArmProcess32::getSyscallArg(ThreadContext *tc, int &i) 413{ 414 assert(i < 6); 415 return tc->readIntReg(ArgumentReg0 + i++); 416} --- 81 unchanged lines hidden --- |