Deleted Added
sdiff udiff text old ( 11886:43b882cada33 ) new ( 11905:4a771f8756ad )
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;

--- 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
328 memState->stackMin = memState->stackBase - space_needed;
329 memState->stackMin = roundDown(memState->stackMin, align);
330 memState->stackSize = memState->stackBase - memState->stackMin;
331
332 // Allocate space for the stack
333 allocateMem(roundDown(memState->stackMin, pageSize),
334 roundUp(memState->stackSize, pageSize));
335
336 // map out initial stack contents
337 IntType sentry_base = memState->stackBase - 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);
361 DPRINTF(Stack, "%#x - stack min\n", memState->stackMin);
362
363 assert(window_save_base == memState->stackMin);
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.
402 fillStart = memState->stackBase;
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);
410 tc->setIntReg(StackPointerReg, memState->stackMin - 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.
419 memState->stackMin = roundDown(memState->stackMin, 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 ---