Deleted Added
sdiff udiff text old ( 3039:9cec9533b941 ) new ( 3044:66cc2a38662e )
full compact
1/*
2 * Copyright (c) 2003-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

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

51{
52
53 // XXX all the below need to be updated for SPARC - Ali
54 brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
55 brk_point = roundUp(brk_point, VMPageSize);
56
57 // Set up stack. On SPARC Linux, stack goes from the top of memory
58 // downward, less the hole for the kernel address space.
59 stack_base = ((Addr)0x80000000000ULL);
60
61 // Set up region for mmaps. Tru64 seems to start just above 0 and
62 // grow up from there.
63 mmap_start = mmap_end = 0x800000;
64
65 // Set pointer for next thread stack. Reserve 8M for main stack.
66 next_thread_stack_base = stack_base - (8 * 1024 * 1024);
67}
68
69void
70SparcLiveProcess::startup()
71{

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

105 return result;
106}
107
108void
109SparcLiveProcess::argsInit(int intSize, int pageSize)
110{
111 Process::startup();
112
113 Addr alignmentMask = ~(intSize - 1);
114
115 // load object file into target memory
116 objFile->loadSections(initVirtMem);
117
118 //These are the auxilliary vector types
119 enum auxTypes
120 {

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

189 auxv.push_back(buildAuxVect(SPARC_AT_GID, 100));
190 auxv.push_back(buildAuxVect(SPARC_AT_EGID, 100));
191 //Whether to enable "secure mode" in the executable
192 auxv.push_back(buildAuxVect(SPARC_AT_SECURE, 0));
193 }
194
195 //Figure out how big the initial stack needs to be
196
197 //Each auxilliary vector is two 8 byte words
198 int aux_data_size = 2 * intSize * auxv.size();
199 int env_data_size = 0;
200 for (int i = 0; i < envp.size(); ++i) {
201 env_data_size += envp[i].size() + 1;
202 }
203 int arg_data_size = 0;
204 for (int i = 0; i < argv.size(); ++i) {
205 arg_data_size += argv[i].size() + 1;
206 }
207
208 int aux_array_size = intSize * 2 * (auxv.size() + 1);
209
210 int argv_array_size = intSize * (argv.size() + 1);
211 int envp_array_size = intSize * (envp.size() + 1);
212
213 int argc_size = intSize;
214 int window_save_size = intSize * 16;
215
216 int info_block_size =
217 (aux_data_size +
218 env_data_size +
219 arg_data_size +
220 ~alignmentMask) & alignmentMask;
221
222 int info_block_padding =
223 info_block_size -
224 aux_data_size -
225 env_data_size -
226 arg_data_size;
227
228 int space_needed =
229 info_block_size +
230 aux_array_size +
231 envp_array_size +
232 argv_array_size +
233 argc_size +
234 window_save_size;
235
236 stack_min = stack_base - space_needed;
237 stack_min &= alignmentMask;
238 stack_size = stack_base - stack_min;
239
240 // map memory
241 pTable->allocate(roundDown(stack_min, pageSize),
242 roundUp(stack_size, pageSize));
243
244 // map out initial stack contents
245 Addr aux_data_base = stack_base - aux_data_size - info_block_padding;
246 Addr env_data_base = aux_data_base - env_data_size;
247 Addr arg_data_base = env_data_base - arg_data_size;
248 Addr auxv_array_base = arg_data_base - aux_array_size;
249 Addr envp_array_base = auxv_array_base - envp_array_size;
250 Addr argv_array_base = envp_array_base - argv_array_size;
251 Addr argc_base = argv_array_base - argc_size;
252#ifndef NDEBUG
253 // only used in DPRINTF
254 Addr window_save_base = argc_base - window_save_size;
255#endif
256
257 DPRINTF(Sparc, "The addresses of items on the initial stack:\n");
258 DPRINTF(Sparc, "0x%x - aux data\n", aux_data_base);
259 DPRINTF(Sparc, "0x%x - env data\n", env_data_base);
260 DPRINTF(Sparc, "0x%x - arg data\n", arg_data_base);
261 DPRINTF(Sparc, "0x%x - auxv array\n", auxv_array_base);
262 DPRINTF(Sparc, "0x%x - envp array\n", envp_array_base);
263 DPRINTF(Sparc, "0x%x - argv array\n", argv_array_base);
264 DPRINTF(Sparc, "0x%x - argc \n", argc_base);
265 DPRINTF(Sparc, "0x%x - window save\n", window_save_base);
266 DPRINTF(Sparc, "0x%x - stack min\n", stack_min);
267
268 // write contents to stack
269 uint64_t argc = argv.size();
270 uint64_t guestArgc = TheISA::htog(argc);
271
272 //Copy the aux stuff
273 for(int x = 0; x < auxv.size(); x++)
274 {
275 initVirtMem->writeBlob(auxv_array_base + x * 2 * intSize,
276 (uint8_t*)&(auxv[x].a_type), intSize);
277 initVirtMem->writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
278 (uint8_t*)&(auxv[x].a_val), intSize);
279 }

--- 21 unchanged lines hidden ---