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 // 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 |
319 memState->setStackMin(memState->getStackBase() - space_needed); 320 memState->setStackMin(roundDown(memState->getStackMin(), align)); 321 memState->setStackSize(memState->getStackBase() - memState->getStackMin()); |
322 323 // Allocate space for the stack |
324 allocateMem(roundDown(memState->getStackMin(), pageSize), 325 roundUp(memState->getStackSize(), pageSize)); |
326 327 // map out initial stack contents |
328 IntType sentry_base = memState->getStackBase() - sentry_size; |
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); |
352 DPRINTF(Stack, "%#x - stack min\n", memState->getStackMin()); |
353 |
354 assert(window_save_base == memState->getStackMin()); |
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. |
393 fillStart = memState->getStackBase(); |
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); |
401 tc->setIntReg(StackPointerReg, memState->getStackMin() - StackBias); |
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. |
410 memState->setStackMin(roundDown(memState->getStackMin(), pageSize)); |
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 --- |