process.cc (11886:43b882cada33) process.cc (11905:4a771f8756ad)
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;

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

52
53static const int FirstArgumentReg = 8;
54
55
56SparcProcess::SparcProcess(ProcessParams * params, ObjectFile *objFile,
57 Addr _StackBias)
58 : Process(params, objFile), StackBias(_StackBias)
59{
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;

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

52
53static const int FirstArgumentReg = 8;
54
55
56SparcProcess::SparcProcess(ProcessParams * params, ObjectFile *objFile,
57 Addr _StackBias)
58 : Process(params, objFile), StackBias(_StackBias)
59{
60
61 // XXX all the below need to be updated for SPARC - Ali
62 memState->brkPoint = objFile->dataBase() + objFile->dataSize() +
63 objFile->bssSize();
64 memState->brkPoint = roundUp(memState->brkPoint, PageBytes);
65
66 // Set pointer for next thread stack. Reserve 8M for main stack.
67 memState->nextThreadStackBase = memState->stackBase - (8 * 1024 * 1024);
68
69 // Initialize these to 0s
70 fillStart = 0;
71 spillStart = 0;
72}
73
74void
75SparcProcess::handleTrap(int trapNum, ThreadContext *tc, Fault *fault)
76{

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

320 int aligned_partial_size = roundUp(frame_size, align);
321 int aux_padding = aligned_partial_size - frame_size;
322
323 int space_needed =
324 info_block_size +
325 aux_padding +
326 frame_size;
327
60 // Initialize these to 0s
61 fillStart = 0;
62 spillStart = 0;
63}
64
65void
66SparcProcess::handleTrap(int trapNum, ThreadContext *tc, Fault *fault)
67{

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

311 int aligned_partial_size = roundUp(frame_size, align);
312 int aux_padding = aligned_partial_size - frame_size;
313
314 int space_needed =
315 info_block_size +
316 aux_padding +
317 frame_size;
318
328 memState->stackMin = memState->stackBase - space_needed;
329 memState->stackMin = roundDown(memState->stackMin, align);
330 memState->stackSize = memState->stackBase - memState->stackMin;
319 memState->setStackMin(memState->getStackBase() - space_needed);
320 memState->setStackMin(roundDown(memState->getStackMin(), align));
321 memState->setStackSize(memState->getStackBase() - memState->getStackMin());
331
332 // Allocate space for the stack
322
323 // Allocate space for the stack
333 allocateMem(roundDown(memState->stackMin, pageSize),
334 roundUp(memState->stackSize, pageSize));
324 allocateMem(roundDown(memState->getStackMin(), pageSize),
325 roundUp(memState->getStackSize(), pageSize));
335
336 // map out initial stack contents
326
327 // map out initial stack contents
337 IntType sentry_base = memState->stackBase - sentry_size;
328 IntType sentry_base = memState->getStackBase() - sentry_size;
338 IntType file_name_base = sentry_base - file_name_size;
339 IntType env_data_base = file_name_base - env_data_size;
340 IntType arg_data_base = env_data_base - arg_data_size;
341 IntType auxv_array_base = arg_data_base -
342 info_block_padding - aux_array_size - aux_padding;
343 IntType envp_array_base = auxv_array_base - envp_array_size;
344 IntType argv_array_base = envp_array_base - argv_array_size;
345 IntType argc_base = argv_array_base - argc_size;

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

353 DPRINTF(Stack, "%#x - file name\n", file_name_base);
354 DPRINTF(Stack, "%#x - env data\n", env_data_base);
355 DPRINTF(Stack, "%#x - arg data\n", arg_data_base);
356 DPRINTF(Stack, "%#x - auxv array\n", auxv_array_base);
357 DPRINTF(Stack, "%#x - envp array\n", envp_array_base);
358 DPRINTF(Stack, "%#x - argv array\n", argv_array_base);
359 DPRINTF(Stack, "%#x - argc \n", argc_base);
360 DPRINTF(Stack, "%#x - window save\n", window_save_base);
329 IntType file_name_base = sentry_base - file_name_size;
330 IntType env_data_base = file_name_base - env_data_size;
331 IntType arg_data_base = env_data_base - arg_data_size;
332 IntType auxv_array_base = arg_data_base -
333 info_block_padding - aux_array_size - aux_padding;
334 IntType envp_array_base = auxv_array_base - envp_array_size;
335 IntType argv_array_base = envp_array_base - argv_array_size;
336 IntType argc_base = argv_array_base - argc_size;

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

344 DPRINTF(Stack, "%#x - file name\n", file_name_base);
345 DPRINTF(Stack, "%#x - env data\n", env_data_base);
346 DPRINTF(Stack, "%#x - arg data\n", arg_data_base);
347 DPRINTF(Stack, "%#x - auxv array\n", auxv_array_base);
348 DPRINTF(Stack, "%#x - envp array\n", envp_array_base);
349 DPRINTF(Stack, "%#x - argv array\n", argv_array_base);
350 DPRINTF(Stack, "%#x - argc \n", argc_base);
351 DPRINTF(Stack, "%#x - window save\n", window_save_base);
361 DPRINTF(Stack, "%#x - stack min\n", memState->stackMin);
352 DPRINTF(Stack, "%#x - stack min\n", memState->getStackMin());
362
353
363 assert(window_save_base == memState->stackMin);
354 assert(window_save_base == memState->getStackMin());
364
365 // write contents to stack
366
367 // figure out argc
368 IntType argc = argv.size();
369 IntType guestArgc = SparcISA::htog(argc);
370
371 // Write out the sentry void *

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

394 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
395 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
396
397 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
398
399 // Set up space for the trap handlers into the processes address space.
400 // Since the stack grows down and there is reserved address space abov
401 // it, we can put stuff above it and stay out of the way.
355
356 // write contents to stack
357
358 // figure out argc
359 IntType argc = argv.size();
360 IntType guestArgc = SparcISA::htog(argc);
361
362 // Write out the sentry void *

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

385 copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
386 copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
387
388 initVirtMem.writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
389
390 // Set up space for the trap handlers into the processes address space.
391 // Since the stack grows down and there is reserved address space abov
392 // it, we can put stuff above it and stay out of the way.
402 fillStart = memState->stackBase;
393 fillStart = memState->getStackBase();
403 spillStart = fillStart + sizeof(MachInst) * numFillInsts;
404
405 ThreadContext *tc = system->getThreadContext(contextIds[0]);
406 // Set up the thread context to start running the process
407 // assert(NumArgumentRegs >= 2);
408 // tc->setIntReg(ArgumentReg[0], argc);
409 // tc->setIntReg(ArgumentReg[1], argv_array_base);
394 spillStart = fillStart + sizeof(MachInst) * numFillInsts;
395
396 ThreadContext *tc = system->getThreadContext(contextIds[0]);
397 // Set up the thread context to start running the process
398 // assert(NumArgumentRegs >= 2);
399 // tc->setIntReg(ArgumentReg[0], argc);
400 // tc->setIntReg(ArgumentReg[1], argv_array_base);
410 tc->setIntReg(StackPointerReg, memState->stackMin - StackBias);
401 tc->setIntReg(StackPointerReg, memState->getStackMin() - StackBias);
411
412 // %g1 is a pointer to a function that should be run at exit. Since we
413 // don't have anything like that, it should be set to 0.
414 tc->setIntReg(1, 0);
415
416 tc->pcState(getStartPC());
417
418 // Align the "stack_min" to a page boundary.
402
403 // %g1 is a pointer to a function that should be run at exit. Since we
404 // don't have anything like that, it should be set to 0.
405 tc->setIntReg(1, 0);
406
407 tc->pcState(getStartPC());
408
409 // Align the "stack_min" to a page boundary.
419 memState->stackMin = roundDown(memState->stackMin, pageSize);
410 memState->setStackMin(roundDown(memState->getStackMin(), pageSize));
420}
421
422void
423Sparc64Process::argsInit(int intSize, int pageSize)
424{
425 SparcProcess::argsInit<uint64_t>(pageSize);
426
427 // Stuff the trap handlers into the process address space

--- 140 unchanged lines hidden ---
411}
412
413void
414Sparc64Process::argsInit(int intSize, int pageSize)
415{
416 SparcProcess::argsInit<uint64_t>(pageSize);
417
418 // Stuff the trap handlers into the process address space

--- 140 unchanged lines hidden ---