process.cc revision 4188
16242Sgblack@eecs.umich.edu/* 211575SDylan.Johnson@ARM.com * Copyright (c) 2003-2004 The Regents of The University of Michigan 37093Sgblack@eecs.umich.edu * All rights reserved. 47093Sgblack@eecs.umich.edu * 57093Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without 67093Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are 77093Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright 87093Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer; 97093Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright 107093Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 117093Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution; 127093Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 137093Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 146242Sgblack@eecs.umich.edu * this software without specific prior written permission. 156242Sgblack@eecs.umich.edu * 166242Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176242Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186242Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196242Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206242Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216242Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226242Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236242Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246242Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256242Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266242Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276242Sgblack@eecs.umich.edu * 286242Sgblack@eecs.umich.edu * Authors: Gabe Black 296242Sgblack@eecs.umich.edu * Ali Saidi 306242Sgblack@eecs.umich.edu */ 316242Sgblack@eecs.umich.edu 326242Sgblack@eecs.umich.edu#include "arch/alpha/isa_traits.hh" 336242Sgblack@eecs.umich.edu#include "arch/alpha/process.hh" 346242Sgblack@eecs.umich.edu#include "base/loader/object_file.hh" 356242Sgblack@eecs.umich.edu#include "base/misc.hh" 366242Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 376242Sgblack@eecs.umich.edu#include "sim/system.hh" 386242Sgblack@eecs.umich.edu 396242Sgblack@eecs.umich.edu 406242Sgblack@eecs.umich.eduusing namespace AlphaISA; 4110037SARM gem5 Developersusing namespace std; 426242Sgblack@eecs.umich.edu 436242Sgblack@eecs.umich.eduAlphaLiveProcess::AlphaLiveProcess(const std::string &nm, ObjectFile *objFile, 446242Sgblack@eecs.umich.edu System *_system, int stdin_fd, int stdout_fd, int stderr_fd, 456242Sgblack@eecs.umich.edu std::vector<std::string> &argv, std::vector<std::string> &envp, 4610037SARM gem5 Developers const std::string &cwd, 4710037SARM gem5 Developers uint64_t _uid, uint64_t _euid, uint64_t _gid, uint64_t _egid, 486242Sgblack@eecs.umich.edu uint64_t _pid, uint64_t _ppid) 499256SAndreas.Sandberg@arm.com : LiveProcess(nm, objFile, _system, stdin_fd, stdout_fd, stderr_fd, 506242Sgblack@eecs.umich.edu argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid) 5110037SARM gem5 Developers{ 5210037SARM gem5 Developers brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize(); 5310037SARM gem5 Developers brk_point = roundUp(brk_point, VMPageSize); 546242Sgblack@eecs.umich.edu 556242Sgblack@eecs.umich.edu // Set up stack. On Alpha, stack goes below text section. This 566242Sgblack@eecs.umich.edu // code should get moved to some architecture-specific spot. 5710037SARM gem5 Developers stack_base = objFile->textBase() - (409600+4096); 5810037SARM gem5 Developers 5910037SARM gem5 Developers // Set up region for mmaps. Tru64 seems to start just above 0 and 6010037SARM gem5 Developers // grow up from there. 6110037SARM gem5 Developers mmap_start = mmap_end = 0x10000; 6210037SARM gem5 Developers 6310037SARM gem5 Developers // Set pointer for next thread stack. Reserve 8M for main stack. 6410037SARM gem5 Developers next_thread_stack_base = stack_base - (8 * 1024 * 1024); 6510037SARM gem5 Developers 6610037SARM gem5 Developers} 6710037SARM gem5 Developers 6810037SARM gem5 Developersvoid 6910037SARM gem5 DevelopersAlphaLiveProcess::startup() 7010037SARM gem5 Developers{ 7110037SARM gem5 Developers argsInit(MachineBytes, VMPageSize); 727259Sgblack@eecs.umich.edu 7310037SARM gem5 Developers threadContexts[0]->setIntReg(GlobalPointerReg, objFile->globalPointer()); 7410037SARM gem5 Developers} 7510037SARM gem5 Developers 7610037SARM gem5 Developers 7710037SARM gem5 Developers