process.cc revision 4111
110447Snilay@cs.wisc.edu/*
210447Snilay@cs.wisc.edu * Copyright (c) 2003-2004 The Regents of The University of Michigan
310447Snilay@cs.wisc.edu * All rights reserved.
410447Snilay@cs.wisc.edu *
510447Snilay@cs.wisc.edu * Redistribution and use in source and binary forms, with or without
610447Snilay@cs.wisc.edu * modification, are permitted provided that the following conditions are
710447Snilay@cs.wisc.edu * met: redistributions of source code must retain the above copyright
810447Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer;
910447Snilay@cs.wisc.edu * redistributions in binary form must reproduce the above copyright
1010447Snilay@cs.wisc.edu * notice, this list of conditions and the following disclaimer in the
1110447Snilay@cs.wisc.edu * documentation and/or other materials provided with the distribution;
1210447Snilay@cs.wisc.edu * neither the name of the copyright holders nor the names of its
1310447Snilay@cs.wisc.edu * contributors may be used to endorse or promote products derived from
1410447Snilay@cs.wisc.edu * this software without specific prior written permission.
1510447Snilay@cs.wisc.edu *
1610447Snilay@cs.wisc.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1710447Snilay@cs.wisc.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1810447Snilay@cs.wisc.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1910447Snilay@cs.wisc.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2010447Snilay@cs.wisc.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2110447Snilay@cs.wisc.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2210447Snilay@cs.wisc.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2310447Snilay@cs.wisc.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2410447Snilay@cs.wisc.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2510447Snilay@cs.wisc.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2610447Snilay@cs.wisc.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2710447Snilay@cs.wisc.edu *
2810447Snilay@cs.wisc.edu * Authors: Gabe Black
2910447Snilay@cs.wisc.edu *          Ali Saidi
3010447Snilay@cs.wisc.edu */
3110447Snilay@cs.wisc.edu
3210447Snilay@cs.wisc.edu#include "arch/alpha/isa_traits.hh"
3310447Snilay@cs.wisc.edu#include "arch/alpha/process.hh"
3410447Snilay@cs.wisc.edu#include "base/loader/object_file.hh"
3510447Snilay@cs.wisc.edu#include "base/misc.hh"
3610447Snilay@cs.wisc.edu#include "cpu/thread_context.hh"
3710447Snilay@cs.wisc.edu#include "sim/system.hh"
3810447Snilay@cs.wisc.edu
3910447Snilay@cs.wisc.edu
4010447Snilay@cs.wisc.eduusing namespace AlphaISA;
4110447Snilay@cs.wisc.eduusing namespace std;
4210447Snilay@cs.wisc.edu
4310447Snilay@cs.wisc.eduAlphaLiveProcess::AlphaLiveProcess(const std::string &nm, ObjectFile *objFile,
4410447Snilay@cs.wisc.edu        System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
4510447Snilay@cs.wisc.edu        std::vector<std::string> &argv, std::vector<std::string> &envp,
4610447Snilay@cs.wisc.edu        const std::string &cwd,
4710447Snilay@cs.wisc.edu        uint64_t _uid, uint64_t _euid, uint64_t _gid, uint64_t _egid,
4810447Snilay@cs.wisc.edu        uint64_t _pid, uint64_t _ppid)
4910447Snilay@cs.wisc.edu    : LiveProcess(nm, objFile, _system, stdin_fd, stdout_fd, stderr_fd,
5010447Snilay@cs.wisc.edu        argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid)
5110447Snilay@cs.wisc.edu{
5210447Snilay@cs.wisc.edu    brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
5310447Snilay@cs.wisc.edu    brk_point = roundUp(brk_point, VMPageSize);
5410447Snilay@cs.wisc.edu
5510447Snilay@cs.wisc.edu    // Set up stack.  On Alpha, stack goes below text section.  This
5610447Snilay@cs.wisc.edu    // code should get moved to some architecture-specific spot.
5710447Snilay@cs.wisc.edu    stack_base = objFile->textBase() - (409600+4096);
5810447Snilay@cs.wisc.edu
5910447Snilay@cs.wisc.edu    // Set up region for mmaps.  Tru64 seems to start just above 0 and
6010447Snilay@cs.wisc.edu    // grow up from there.
6110447Snilay@cs.wisc.edu    mmap_start = mmap_end = 0x10000;
6210447Snilay@cs.wisc.edu
6310447Snilay@cs.wisc.edu    // Set pointer for next thread stack.  Reserve 8M for main stack.
6410447Snilay@cs.wisc.edu    next_thread_stack_base = stack_base - (8 * 1024 * 1024);
6510447Snilay@cs.wisc.edu
6610447Snilay@cs.wisc.edu}
6710447Snilay@cs.wisc.edu
6810447Snilay@cs.wisc.eduvoid
6910447Snilay@cs.wisc.eduAlphaLiveProcess::startup()
7010447Snilay@cs.wisc.edu{
7110447Snilay@cs.wisc.edu    argsInit(MachineBytes, VMPageSize);
7210447Snilay@cs.wisc.edu
7310447Snilay@cs.wisc.edu    threadContexts[0]->setIntReg(GlobalPointerReg, objFile->globalPointer());
7410447Snilay@cs.wisc.edu}
7510447Snilay@cs.wisc.edu
7610447Snilay@cs.wisc.edu
7710447Snilay@cs.wisc.edu