Deleted Added
sdiff udiff text old ( 11886:43b882cada33 ) new ( 11905:4a771f8756ad )
full compact
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 memState->stackBase = 0xbf000000L;
55
56 // Set pointer for next thread stack. Reserve 8M for main stack.
57 memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024);
58
59 // Set up break point (Top of Heap)
60 memState->brkPoint = objFile->dataBase() + objFile->dataSize() +
61 objFile->bssSize();
62 memState->brkPoint = roundUp(memState->brkPoint, PageBytes);
63
64 // Set up region for mmaps. For now, start at bottom of kuseg space.
65 memState->mmapEnd = 0x70000000L;
66}
67
68void
69PowerProcess::initState()
70{
71 Process::initState();
72
73 argsInit(MachineBytes, PageBytes);

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

181 //There needs to be padding after the auxiliary vector data so that the
182 //very bottom of the stack is aligned properly.
183 int partial_size = frame_size;
184 int aligned_partial_size = roundUp(partial_size, align);
185 int aux_padding = aligned_partial_size - partial_size;
186
187 int space_needed = frame_size + aux_padding;
188
189 memState->stackMin = memState->stackBase - space_needed;
190 memState->stackMin = roundDown(memState->stackMin, align);
191 memState->stackSize = memState->stackBase - memState->stackMin;
192
193 // map memory
194 allocateMem(roundDown(memState->stackMin, pageSize),
195 roundUp(memState->stackSize, pageSize));
196
197 // map out initial stack contents
198 uint32_t sentry_base = memState->stackBase - sentry_size;
199 uint32_t aux_data_base = sentry_base - aux_data_size;
200 uint32_t env_data_base = aux_data_base - env_data_size;
201 uint32_t arg_data_base = env_data_base - arg_data_size;
202 uint32_t platform_base = arg_data_base - platform_size;
203 uint32_t auxv_array_base = platform_base - aux_array_size - aux_padding;
204 uint32_t envp_array_base = auxv_array_base - envp_array_size;
205 uint32_t argv_array_base = envp_array_base - argv_array_size;
206 uint32_t argc_base = argv_array_base - argc_size;
207
208 DPRINTF(Stack, "The addresses of items on the initial stack:\n");
209 DPRINTF(Stack, "0x%x - aux data\n", aux_data_base);
210 DPRINTF(Stack, "0x%x - env data\n", env_data_base);
211 DPRINTF(Stack, "0x%x - arg data\n", arg_data_base);
212 DPRINTF(Stack, "0x%x - platform base\n", platform_base);
213 DPRINTF(Stack, "0x%x - auxv array\n", auxv_array_base);
214 DPRINTF(Stack, "0x%x - envp array\n", envp_array_base);
215 DPRINTF(Stack, "0x%x - argv array\n", argv_array_base);
216 DPRINTF(Stack, "0x%x - argc \n", argc_base);
217 DPRINTF(Stack, "0x%x - stack min\n", memState->stackMin);
218
219 // write contents to stack
220
221 // figure out argc
222 uint32_t argc = argv.size();
223 uint32_t guestArgc = PowerISA::htog(argc);
224
225 //Write out the sentry void *

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

254 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
255 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
256
257 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
258
259 ThreadContext *tc = system->getThreadContext(contextIds[0]);
260
261 //Set the stack pointer register
262 tc->setIntReg(StackPointerReg, memState->stackMin);
263
264 tc->pcState(getStartPC());
265
266 //Align the "stack_min" to a page boundary.
267 memState->stackMin = roundDown(memState->stackMin, pageSize);
268}
269
270PowerISA::IntReg
271PowerProcess::getSyscallArg(ThreadContext *tc, int &i)
272{
273 assert(i < 5);
274 return tc->readIntReg(ArgumentReg0 + i++);
275}

--- 20 unchanged lines hidden ---