Deleted Added
sdiff udiff text old ( 11854:0e94e16e26ea ) new ( 11886:43b882cada33 )
full compact
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 stack_base = 0xbf000000L;
74
75 // Set pointer for next thread stack. Reserve 8M for main stack.
76 next_thread_stack_base = stack_base - (8 * 1024 * 1024);
77
78 // Set up break point (Top of Heap)
79 brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
80 brk_point = roundUp(brk_point, PageBytes);
81
82 // Set up region for mmaps. For now, start at bottom of kuseg space.
83 mmap_end = 0x40000000L;
84}
85
86ArmProcess64::ArmProcess64(ProcessParams *params, ObjectFile *objFile,
87 ObjectFile::Arch _arch)
88 : ArmProcess(params, objFile, _arch)
89{
90 stack_base = 0x7fffff0000L;
91
92 // Set pointer for next thread stack. Reserve 8M for main stack.
93 next_thread_stack_base = stack_base - (8 * 1024 * 1024);
94
95 // Set up break point (Top of Heap)
96 brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
97 brk_point = roundUp(brk_point, PageBytes);
98
99 // Set up region for mmaps. For now, start at bottom of kuseg space.
100 mmap_end = 0x4000000000L;
101}
102
103void
104ArmProcess32::initState()
105{
106 Process::initState();
107 argsInit<uint32_t>(PageBytes, INTREG_SP);
108 for (int i = 0; i < contextIds.size(); i++) {

--- 186 unchanged lines hidden (view full) ---

295 //There needs to be padding after the auxiliary vector data so that the
296 //very bottom of the stack is aligned properly.
297 int partial_size = frame_size;
298 int aligned_partial_size = roundUp(partial_size, align);
299 int aux_padding = aligned_partial_size - partial_size;
300
301 int space_needed = frame_size + aux_padding;
302
303 stack_min = stack_base - space_needed;
304 stack_min = roundDown(stack_min, align);
305 stack_size = stack_base - stack_min;
306
307 // map memory
308 allocateMem(roundDown(stack_min, pageSize), roundUp(stack_size, pageSize));
309
310 // map out initial stack contents
311 IntType sentry_base = stack_base - sentry_size;
312 IntType aux_data_base = sentry_base - aux_data_size;
313 IntType env_data_base = aux_data_base - env_data_size;
314 IntType arg_data_base = env_data_base - arg_data_size;
315 IntType platform_base = arg_data_base - platform_size;
316 IntType aux_random_base = platform_base - aux_random_size;
317 IntType auxv_array_base = aux_random_base - aux_array_size - aux_padding;
318 IntType envp_array_base = auxv_array_base - envp_array_size;
319 IntType argv_array_base = envp_array_base - argv_array_size;

--- 4 unchanged lines hidden (view full) ---

324 DPRINTF(Stack, "0x%x - env data\n", env_data_base);
325 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base);
326 DPRINTF(Stack, "0x%x - random data\n", aux_random_base);
327 DPRINTF(Stack, "0x%x - platform base\n", platform_base);
328 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base);
329 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
330 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
331 DPRINTF(Stack, "0x%x - argc \n", argc_base);
332 DPRINTF(Stack, "0x%x - stack min\n", stack_min);
333
334 // write contents to stack
335
336 // figure out argc
337 IntType argc = argv.size();
338 IntType guestArgc = ArmISA::htog(argc);
339
340 //Write out the sentry void *

--- 29 unchanged lines hidden (view full) ---

370
371 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
372 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
373
374 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
375
376 ThreadContext *tc = system->getThreadContext(contextIds[0]);
377 //Set the stack pointer register
378 tc->setIntReg(spIndex, stack_min);
379 //A pointer to a function to run when the program exits. We'll set this
380 //to zero explicitly to make sure this isn't used.
381 tc->setIntReg(ArgumentReg0, 0);
382 //Set argument regs 1 and 2 to argv[0] and envp[0] respectively
383 if (argv.size() > 0) {
384 tc->setIntReg(ArgumentReg1, arg_data_base + arg_data_size -
385 argv[argv.size() - 1].size() - 1);
386 } else {

--- 9 unchanged lines hidden (view full) ---

396 PCState pc;
397 pc.thumb(arch == ObjectFile::Thumb);
398 pc.nextThumb(pc.thumb());
399 pc.aarch64(arch == ObjectFile::Arm64);
400 pc.nextAArch64(pc.aarch64());
401 pc.set(getStartPC() & ~mask(1));
402 tc->pcState(pc);
403
404 //Align the "stack_min" to a page boundary.
405 stack_min = roundDown(stack_min, pageSize);
406}
407
408ArmISA::IntReg
409ArmProcess32::getSyscallArg(ThreadContext *tc, int &i)
410{
411 assert(i < 6);
412 return tc->readIntReg(ArgumentReg0 + i++);
413}

--- 81 unchanged lines hidden ---