process.cc revision 4434
12207SN/A/*
22207SN/A * Copyright (c) 2003-2004 The Regents of The University of Michigan
32207SN/A * All rights reserved.
42207SN/A *
52207SN/A * Redistribution and use in source and binary forms, with or without
62207SN/A * modification, are permitted provided that the following conditions are
72207SN/A * met: redistributions of source code must retain the above copyright
82207SN/A * notice, this list of conditions and the following disclaimer;
92207SN/A * redistributions in binary form must reproduce the above copyright
102207SN/A * notice, this list of conditions and the following disclaimer in the
112207SN/A * documentation and/or other materials provided with the distribution;
122207SN/A * neither the name of the copyright holders nor the names of its
132207SN/A * contributors may be used to endorse or promote products derived from
142207SN/A * this software without specific prior written permission.
152207SN/A *
162207SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172207SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182207SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192207SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202207SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212207SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222207SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232207SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242207SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252207SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262207SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Gabe Black
292665Ssaidi@eecs.umich.edu *          Ali Saidi
302207SN/A */
312207SN/A
323589Sgblack@eecs.umich.edu#include "arch/sparc/asi.hh"
334111Sgblack@eecs.umich.edu#include "arch/sparc/handlers.hh"
342474SN/A#include "arch/sparc/isa_traits.hh"
352207SN/A#include "arch/sparc/process.hh"
363760Sgblack@eecs.umich.edu#include "arch/sparc/types.hh"
372454SN/A#include "base/loader/object_file.hh"
382976Sgblack@eecs.umich.edu#include "base/loader/elf_object.hh"
392454SN/A#include "base/misc.hh"
402680Sktlim@umich.edu#include "cpu/thread_context.hh"
412561SN/A#include "mem/page_table.hh"
424434Ssaidi@eecs.umich.edu#include "sim/process_impl.hh"
432561SN/A#include "mem/translating_port.hh"
442474SN/A#include "sim/system.hh"
452207SN/A
462458SN/Ausing namespace std;
472474SN/Ausing namespace SparcISA;
482458SN/A
492207SN/A
502474SN/ASparcLiveProcess::SparcLiveProcess(const std::string &nm, ObjectFile *objFile,
512474SN/A        System *_system, int stdin_fd, int stdout_fd, int stderr_fd,
523114Sgblack@eecs.umich.edu        std::vector<std::string> &argv, std::vector<std::string> &envp,
533669Sbinkertn@umich.edu        const std::string &cwd,
543114Sgblack@eecs.umich.edu        uint64_t _uid, uint64_t _euid, uint64_t _gid, uint64_t _egid,
553114Sgblack@eecs.umich.edu        uint64_t _pid, uint64_t _ppid)
562474SN/A    : LiveProcess(nm, objFile, _system, stdin_fd, stdout_fd, stderr_fd,
573669Sbinkertn@umich.edu        argv, envp, cwd, _uid, _euid, _gid, _egid, _pid, _ppid)
582474SN/A{
592474SN/A
602474SN/A    // XXX all the below need to be updated for SPARC - Ali
612474SN/A    brk_point = objFile->dataBase() + objFile->dataSize() + objFile->bssSize();
622474SN/A    brk_point = roundUp(brk_point, VMPageSize);
632474SN/A
642474SN/A    // Set pointer for next thread stack.  Reserve 8M for main stack.
652474SN/A    next_thread_stack_base = stack_base - (8 * 1024 * 1024);
663415Sgblack@eecs.umich.edu
673415Sgblack@eecs.umich.edu    //Initialize these to 0s
683415Sgblack@eecs.umich.edu    fillStart = 0;
693415Sgblack@eecs.umich.edu    spillStart = 0;
702474SN/A}
712474SN/A
724111Sgblack@eecs.umich.eduvoid SparcLiveProcess::handleTrap(int trapNum, ThreadContext *tc)
734111Sgblack@eecs.umich.edu{
744111Sgblack@eecs.umich.edu    switch(trapNum)
754111Sgblack@eecs.umich.edu    {
764111Sgblack@eecs.umich.edu      case 0x03: //Flush window trap
774111Sgblack@eecs.umich.edu        warn("Ignoring request to flush register windows.\n");
784111Sgblack@eecs.umich.edu        break;
794111Sgblack@eecs.umich.edu      default:
804111Sgblack@eecs.umich.edu        panic("Unimplemented trap to operating system: trap number %#x.\n", trapNum);
814111Sgblack@eecs.umich.edu    }
824111Sgblack@eecs.umich.edu}
834111Sgblack@eecs.umich.edu
842474SN/Avoid
854111Sgblack@eecs.umich.eduSparc32LiveProcess::startup()
864111Sgblack@eecs.umich.edu{
874111Sgblack@eecs.umich.edu    argsInit(32 / 8, VMPageSize);
884111Sgblack@eecs.umich.edu
894111Sgblack@eecs.umich.edu    //From the SPARC ABI
904111Sgblack@eecs.umich.edu
914111Sgblack@eecs.umich.edu    //The process runs in user mode
924172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscReg(MISCREG_PSTATE, 0x02);
934111Sgblack@eecs.umich.edu
944111Sgblack@eecs.umich.edu    //Setup default FP state
954172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_FSR, 0);
964111Sgblack@eecs.umich.edu
974172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_TICK, 0);
984111Sgblack@eecs.umich.edu    //
994111Sgblack@eecs.umich.edu    /*
1004111Sgblack@eecs.umich.edu     * Register window management registers
1014111Sgblack@eecs.umich.edu     */
1024111Sgblack@eecs.umich.edu
1034111Sgblack@eecs.umich.edu    //No windows contain info from other programs
1044172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_OTHERWIN, 0);
1054111Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 6, 0);
1064111Sgblack@eecs.umich.edu    //There are no windows to pop
1074172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_CANRESTORE, 0);
1084111Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 4, 0);
1094111Sgblack@eecs.umich.edu    //All windows are available to save into
1104172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_CANSAVE, NWindows - 2);
1114111Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 3, NWindows - 2);
1124111Sgblack@eecs.umich.edu    //All windows are "clean"
1134172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_CLEANWIN, NWindows);
1144111Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 5, NWindows);
1154111Sgblack@eecs.umich.edu    //Start with register window 0
1164172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_CWP, 0);
1174111Sgblack@eecs.umich.edu    //Always use spill and fill traps 0
1184172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_WSTATE, 0);
1194111Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 7, 0);
1204111Sgblack@eecs.umich.edu    //Set the trap level to 0
1214172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_TL, 0);
1224111Sgblack@eecs.umich.edu    //Set the ASI register to something fixed
1234172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_ASI, ASI_PRIMARY);
1244111Sgblack@eecs.umich.edu}
1254111Sgblack@eecs.umich.edu
1264111Sgblack@eecs.umich.eduvoid
1274111Sgblack@eecs.umich.eduSparc64LiveProcess::startup()
1282474SN/A{
1293760Sgblack@eecs.umich.edu    argsInit(sizeof(IntReg), VMPageSize);
1302561SN/A
1312561SN/A    //From the SPARC ABI
1322561SN/A
1332561SN/A    //The process runs in user mode
1344172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscReg(MISCREG_PSTATE, 0x02);
1352561SN/A
1362646Ssaidi@eecs.umich.edu    //Setup default FP state
1374172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_FSR, 0);
1382646Ssaidi@eecs.umich.edu
1394172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_TICK, 0);
1402646Ssaidi@eecs.umich.edu    //
1412561SN/A    /*
1422561SN/A     * Register window management registers
1432561SN/A     */
1442561SN/A
1452561SN/A    //No windows contain info from other programs
1464172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_OTHERWIN, 0);
1473761Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 6, 0);
1482561SN/A    //There are no windows to pop
1494172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_CANRESTORE, 0);
1503761Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 4, 0);
1512561SN/A    //All windows are available to save into
1524172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_CANSAVE, NWindows - 2);
1533761Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 3, NWindows - 2);
1542561SN/A    //All windows are "clean"
1554172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_CLEANWIN, NWindows);
1563761Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 5, NWindows);
1572561SN/A    //Start with register window 0
1584172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_CWP, 0);
1593415Sgblack@eecs.umich.edu    //Always use spill and fill traps 0
1604172Ssaidi@eecs.umich.edu    //threadContexts[0]->setMiscRegNoEffect(MISCREG_WSTATE, 0);
1613761Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(NumIntArchRegs + 7, 0);
1623415Sgblack@eecs.umich.edu    //Set the trap level to 0
1634172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_TL, 0);
1643589Sgblack@eecs.umich.edu    //Set the ASI register to something fixed
1654172Ssaidi@eecs.umich.edu    threadContexts[0]->setMiscRegNoEffect(MISCREG_ASI, ASI_PRIMARY);
1662474SN/A}
1672474SN/A
1684111Sgblack@eecs.umich.eduM5_32_auxv_t::M5_32_auxv_t(int32_t type, int32_t val)
1692585SN/A{
1704111Sgblack@eecs.umich.edu    a_type = TheISA::htog(type);
1714111Sgblack@eecs.umich.edu    a_val = TheISA::htog(val);
1722585SN/A}
1732585SN/A
1744111Sgblack@eecs.umich.eduM5_64_auxv_t::M5_64_auxv_t(int64_t type, int64_t val)
1753415Sgblack@eecs.umich.edu{
1764111Sgblack@eecs.umich.edu    a_type = TheISA::htog(type);
1774111Sgblack@eecs.umich.edu    a_val = TheISA::htog(val);
1784111Sgblack@eecs.umich.edu}
1793415Sgblack@eecs.umich.edu
1802561SN/Avoid
1814111Sgblack@eecs.umich.eduSparc64LiveProcess::argsInit(int intSize, int pageSize)
1822561SN/A{
1834111Sgblack@eecs.umich.edu    typedef M5_64_auxv_t auxv_t;
1842561SN/A    Process::startup();
1852474SN/A
1863044Sgblack@eecs.umich.edu    string filename;
1873044Sgblack@eecs.umich.edu    if(argv.size() < 1)
1883044Sgblack@eecs.umich.edu        filename = "";
1893044Sgblack@eecs.umich.edu    else
1903044Sgblack@eecs.umich.edu        filename = argv[0];
1913044Sgblack@eecs.umich.edu
1922561SN/A    Addr alignmentMask = ~(intSize - 1);
1932561SN/A
1942561SN/A    // load object file into target memory
1952561SN/A    objFile->loadSections(initVirtMem);
1962561SN/A
1972585SN/A    //These are the auxilliary vector types
1982585SN/A    enum auxTypes
1992585SN/A    {
2002585SN/A        SPARC_AT_HWCAP = 16,
2012585SN/A        SPARC_AT_PAGESZ = 6,
2022585SN/A        SPARC_AT_CLKTCK = 17,
2032585SN/A        SPARC_AT_PHDR = 3,
2042585SN/A        SPARC_AT_PHENT = 4,
2052585SN/A        SPARC_AT_PHNUM = 5,
2062585SN/A        SPARC_AT_BASE = 7,
2072585SN/A        SPARC_AT_FLAGS = 8,
2082585SN/A        SPARC_AT_ENTRY = 9,
2092585SN/A        SPARC_AT_UID = 11,
2102585SN/A        SPARC_AT_EUID = 12,
2112585SN/A        SPARC_AT_GID = 13,
2122976Sgblack@eecs.umich.edu        SPARC_AT_EGID = 14,
2132976Sgblack@eecs.umich.edu        SPARC_AT_SECURE = 23
2142585SN/A    };
2152585SN/A
2162585SN/A    enum hardwareCaps
2172585SN/A    {
2182585SN/A        M5_HWCAP_SPARC_FLUSH = 1,
2192585SN/A        M5_HWCAP_SPARC_STBAR = 2,
2202585SN/A        M5_HWCAP_SPARC_SWAP = 4,
2212585SN/A        M5_HWCAP_SPARC_MULDIV = 8,
2222585SN/A        M5_HWCAP_SPARC_V9 = 16,
2232585SN/A        //This one should technically only be set
2242585SN/A        //if there is a cheetah or cheetah_plus tlb,
2252585SN/A        //but we'll use it all the time
2262585SN/A        M5_HWCAP_SPARC_ULTRA3 = 32
2272585SN/A    };
2282585SN/A
2292585SN/A    const int64_t hwcap =
2302585SN/A        M5_HWCAP_SPARC_FLUSH |
2312585SN/A        M5_HWCAP_SPARC_STBAR |
2322585SN/A        M5_HWCAP_SPARC_SWAP |
2332585SN/A        M5_HWCAP_SPARC_MULDIV |
2342585SN/A        M5_HWCAP_SPARC_V9 |
2352585SN/A        M5_HWCAP_SPARC_ULTRA3;
2362585SN/A
2372976Sgblack@eecs.umich.edu
2382976Sgblack@eecs.umich.edu    //Setup the auxilliary vectors. These will already have endian conversion.
2392976Sgblack@eecs.umich.edu    //Auxilliary vectors are loaded only for elf formatted executables.
2402976Sgblack@eecs.umich.edu    ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
2412976Sgblack@eecs.umich.edu    if(elfObject)
2422976Sgblack@eecs.umich.edu    {
2432976Sgblack@eecs.umich.edu        //Bits which describe the system hardware capabilities
2444111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_HWCAP, hwcap));
2452976Sgblack@eecs.umich.edu        //The system page size
2464111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_PAGESZ, SparcISA::VMPageSize));
2472976Sgblack@eecs.umich.edu        //Defined to be 100 in the kernel source.
2482976Sgblack@eecs.umich.edu        //Frequency at which times() increments
2494111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_CLKTCK, 100));
2502976Sgblack@eecs.umich.edu        // For statically linked executables, this is the virtual address of the
2512976Sgblack@eecs.umich.edu        // program header tables if they appear in the executable image
2524111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_PHDR, elfObject->programHeaderTable()));
2532976Sgblack@eecs.umich.edu        // This is the size of a program header entry from the elf file.
2544111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_PHENT, elfObject->programHeaderSize()));
2552976Sgblack@eecs.umich.edu        // This is the number of program headers from the original elf file.
2564111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_PHNUM, elfObject->programHeaderCount()));
2572976Sgblack@eecs.umich.edu        //This is the address of the elf "interpreter", It should be set
2582976Sgblack@eecs.umich.edu        //to 0 for regular executables. It should be something else
2592976Sgblack@eecs.umich.edu        //(not sure what) for dynamic libraries.
2604111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_BASE, 0));
2612976Sgblack@eecs.umich.edu        //This is hardwired to 0 in the elf loading code in the kernel
2624111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_FLAGS, 0));
2632976Sgblack@eecs.umich.edu        //The entry point to the program
2644111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_ENTRY, objFile->entryPoint()));
2652976Sgblack@eecs.umich.edu        //Different user and group IDs
2664111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_UID, uid()));
2674111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_EUID, euid()));
2684111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_GID, gid()));
2694111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_EGID, egid()));
2702976Sgblack@eecs.umich.edu        //Whether to enable "secure mode" in the executable
2714111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_SECURE, 0));
2722976Sgblack@eecs.umich.edu    }
2732585SN/A
2742561SN/A    //Figure out how big the initial stack needs to be
2752561SN/A
2763044Sgblack@eecs.umich.edu    // The unaccounted for 0 at the top of the stack
2773044Sgblack@eecs.umich.edu    int mysterious_size = intSize;
2783044Sgblack@eecs.umich.edu
2793044Sgblack@eecs.umich.edu    //This is the name of the file which is present on the initial stack
2803044Sgblack@eecs.umich.edu    //It's purpose is to let the user space linker examine the original file.
2813044Sgblack@eecs.umich.edu    int file_name_size = filename.size() + 1;
2823044Sgblack@eecs.umich.edu
2832561SN/A    int env_data_size = 0;
2842561SN/A    for (int i = 0; i < envp.size(); ++i) {
2852561SN/A        env_data_size += envp[i].size() + 1;
2862561SN/A    }
2872561SN/A    int arg_data_size = 0;
2882561SN/A    for (int i = 0; i < argv.size(); ++i) {
2892561SN/A        arg_data_size += argv[i].size() + 1;
2902561SN/A    }
2912561SN/A
2923044Sgblack@eecs.umich.edu    //The info_block needs to be padded so it's size is a multiple of the
2933044Sgblack@eecs.umich.edu    //alignment mask. Also, it appears that there needs to be at least some
2943044Sgblack@eecs.umich.edu    //padding, so if the size is already a multiple, we need to increase it
2953044Sgblack@eecs.umich.edu    //anyway.
2963044Sgblack@eecs.umich.edu    int info_block_size =
2973044Sgblack@eecs.umich.edu        (file_name_size +
2983044Sgblack@eecs.umich.edu        env_data_size +
2993044Sgblack@eecs.umich.edu        arg_data_size +
3003044Sgblack@eecs.umich.edu        intSize) & alignmentMask;
3013044Sgblack@eecs.umich.edu
3023044Sgblack@eecs.umich.edu    int info_block_padding =
3033044Sgblack@eecs.umich.edu        info_block_size -
3043044Sgblack@eecs.umich.edu        file_name_size -
3053044Sgblack@eecs.umich.edu        env_data_size -
3063044Sgblack@eecs.umich.edu        arg_data_size;
3073044Sgblack@eecs.umich.edu
3083044Sgblack@eecs.umich.edu    //Each auxilliary vector is two 8 byte words
3092561SN/A    int aux_array_size = intSize * 2 * (auxv.size() + 1);
3102561SN/A
3113044Sgblack@eecs.umich.edu    int envp_array_size = intSize * (envp.size() + 1);
3122561SN/A    int argv_array_size = intSize * (argv.size() + 1);
3132561SN/A
3142561SN/A    int argc_size = intSize;
3152561SN/A    int window_save_size = intSize * 16;
3162561SN/A
3172561SN/A    int space_needed =
3183044Sgblack@eecs.umich.edu        mysterious_size +
3192561SN/A        info_block_size +
3202561SN/A        aux_array_size +
3212561SN/A        envp_array_size +
3222561SN/A        argv_array_size +
3232561SN/A        argc_size +
3242561SN/A        window_save_size;
3252561SN/A
3262561SN/A    stack_min = stack_base - space_needed;
3272561SN/A    stack_min &= alignmentMask;
3282561SN/A    stack_size = stack_base - stack_min;
3292561SN/A
3302561SN/A    // map memory
3312561SN/A    pTable->allocate(roundDown(stack_min, pageSize),
3322561SN/A                     roundUp(stack_size, pageSize));
3332561SN/A
3342561SN/A    // map out initial stack contents
3353044Sgblack@eecs.umich.edu    Addr mysterious_base = stack_base - mysterious_size;
3363044Sgblack@eecs.umich.edu    Addr file_name_base = mysterious_base - file_name_size;
3373044Sgblack@eecs.umich.edu    Addr env_data_base = file_name_base - env_data_size;
3382561SN/A    Addr arg_data_base = env_data_base - arg_data_size;
3393044Sgblack@eecs.umich.edu    Addr auxv_array_base = arg_data_base - aux_array_size - info_block_padding;
3402585SN/A    Addr envp_array_base = auxv_array_base - envp_array_size;
3412561SN/A    Addr argv_array_base = envp_array_base - argv_array_size;
3422561SN/A    Addr argc_base = argv_array_base - argc_size;
3433039Sstever@eecs.umich.edu#ifndef NDEBUG
3443039Sstever@eecs.umich.edu    // only used in DPRINTF
3452561SN/A    Addr window_save_base = argc_base - window_save_size;
3463039Sstever@eecs.umich.edu#endif
3472561SN/A
3482561SN/A    DPRINTF(Sparc, "The addresses of items on the initial stack:\n");
3493044Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - file name\n", file_name_base);
3502561SN/A    DPRINTF(Sparc, "0x%x - env data\n", env_data_base);
3512561SN/A    DPRINTF(Sparc, "0x%x - arg data\n", arg_data_base);
3522585SN/A    DPRINTF(Sparc, "0x%x - auxv array\n", auxv_array_base);
3532585SN/A    DPRINTF(Sparc, "0x%x - envp array\n", envp_array_base);
3542585SN/A    DPRINTF(Sparc, "0x%x - argv array\n", argv_array_base);
3552561SN/A    DPRINTF(Sparc, "0x%x - argc \n", argc_base);
3562561SN/A    DPRINTF(Sparc, "0x%x - window save\n", window_save_base);
3572561SN/A    DPRINTF(Sparc, "0x%x - stack min\n", stack_min);
3582561SN/A
3592561SN/A    // write contents to stack
3603044Sgblack@eecs.umich.edu
3613044Sgblack@eecs.umich.edu    // figure out argc
3622561SN/A    uint64_t argc = argv.size();
3632585SN/A    uint64_t guestArgc = TheISA::htog(argc);
3642561SN/A
3653044Sgblack@eecs.umich.edu    //Write out the mysterious 0
3663044Sgblack@eecs.umich.edu    uint64_t mysterious_zero = 0;
3673044Sgblack@eecs.umich.edu    initVirtMem->writeBlob(mysterious_base,
3683044Sgblack@eecs.umich.edu            (uint8_t*)&mysterious_zero, mysterious_size);
3693044Sgblack@eecs.umich.edu
3703044Sgblack@eecs.umich.edu    //Write the file name
3713044Sgblack@eecs.umich.edu    initVirtMem->writeString(file_name_base, filename.c_str());
3723044Sgblack@eecs.umich.edu
3732585SN/A    //Copy the aux stuff
3742585SN/A    for(int x = 0; x < auxv.size(); x++)
3752585SN/A    {
3762585SN/A        initVirtMem->writeBlob(auxv_array_base + x * 2 * intSize,
3772585SN/A                (uint8_t*)&(auxv[x].a_type), intSize);
3782585SN/A        initVirtMem->writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
3792585SN/A                (uint8_t*)&(auxv[x].a_val), intSize);
3802585SN/A    }
3812585SN/A    //Write out the terminating zeroed auxilliary vector
3822561SN/A    const uint64_t zero = 0;
3832585SN/A    initVirtMem->writeBlob(auxv_array_base + 2 * intSize * auxv.size(),
3842585SN/A            (uint8_t*)&zero, 2 * intSize);
3852561SN/A
3862561SN/A    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
3872561SN/A    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
3882561SN/A
3892585SN/A    initVirtMem->writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
3902561SN/A
3913415Sgblack@eecs.umich.edu    //Stuff the trap handlers into the processes address space.
3923415Sgblack@eecs.umich.edu    //Since the stack grows down and is the highest area in the processes
3933415Sgblack@eecs.umich.edu    //address space, we can put stuff above it and stay out of the way.
3943415Sgblack@eecs.umich.edu    int fillSize = sizeof(MachInst) * numFillInsts;
3953415Sgblack@eecs.umich.edu    int spillSize = sizeof(MachInst) * numSpillInsts;
3963415Sgblack@eecs.umich.edu    fillStart = stack_base;
3973415Sgblack@eecs.umich.edu    spillStart = fillStart + fillSize;
3984111Sgblack@eecs.umich.edu    initVirtMem->writeBlob(fillStart, (uint8_t*)fillHandler64, fillSize);
3994111Sgblack@eecs.umich.edu    initVirtMem->writeBlob(spillStart, (uint8_t*)spillHandler64, spillSize);
4003415Sgblack@eecs.umich.edu
4013415Sgblack@eecs.umich.edu    //Set up the thread context to start running the process
4022680Sktlim@umich.edu    threadContexts[0]->setIntReg(ArgumentReg0, argc);
4032680Sktlim@umich.edu    threadContexts[0]->setIntReg(ArgumentReg1, argv_array_base);
4042680Sktlim@umich.edu    threadContexts[0]->setIntReg(StackPointerReg, stack_min - StackBias);
4052561SN/A
4062561SN/A    Addr prog_entry = objFile->entryPoint();
4072680Sktlim@umich.edu    threadContexts[0]->setPC(prog_entry);
4082680Sktlim@umich.edu    threadContexts[0]->setNextPC(prog_entry + sizeof(MachInst));
4092680Sktlim@umich.edu    threadContexts[0]->setNextNPC(prog_entry + (2 * sizeof(MachInst)));
4102561SN/A
4113959Sgblack@eecs.umich.edu    //Align the "stack_min" to a page boundary.
4123959Sgblack@eecs.umich.edu    stack_min = roundDown(stack_min, pageSize);
4133959Sgblack@eecs.umich.edu
4142561SN/A//    num_processes++;
4152561SN/A}
4164111Sgblack@eecs.umich.edu
4174111Sgblack@eecs.umich.eduvoid
4184111Sgblack@eecs.umich.eduSparc32LiveProcess::argsInit(int intSize, int pageSize)
4194111Sgblack@eecs.umich.edu{
4204111Sgblack@eecs.umich.edu    typedef M5_32_auxv_t auxv_t;
4214111Sgblack@eecs.umich.edu    Process::startup();
4224111Sgblack@eecs.umich.edu
4234111Sgblack@eecs.umich.edu    string filename;
4244111Sgblack@eecs.umich.edu    if(argv.size() < 1)
4254111Sgblack@eecs.umich.edu        filename = "";
4264111Sgblack@eecs.umich.edu    else
4274111Sgblack@eecs.umich.edu        filename = argv[0];
4284111Sgblack@eecs.umich.edu
4294117Sgblack@eecs.umich.edu    //Even though this is a 32 bit process, the ABI says we still need to
4304117Sgblack@eecs.umich.edu    //maintain double word alignment of the stack pointer.
4314117Sgblack@eecs.umich.edu    Addr alignmentMask = ~(8 - 1);
4324111Sgblack@eecs.umich.edu
4334111Sgblack@eecs.umich.edu    // load object file into target memory
4344111Sgblack@eecs.umich.edu    objFile->loadSections(initVirtMem);
4354111Sgblack@eecs.umich.edu
4364111Sgblack@eecs.umich.edu    //These are the auxilliary vector types
4374111Sgblack@eecs.umich.edu    enum auxTypes
4384111Sgblack@eecs.umich.edu    {
4394111Sgblack@eecs.umich.edu        SPARC_AT_HWCAP = 16,
4404111Sgblack@eecs.umich.edu        SPARC_AT_PAGESZ = 6,
4414111Sgblack@eecs.umich.edu        SPARC_AT_CLKTCK = 17,
4424111Sgblack@eecs.umich.edu        SPARC_AT_PHDR = 3,
4434111Sgblack@eecs.umich.edu        SPARC_AT_PHENT = 4,
4444111Sgblack@eecs.umich.edu        SPARC_AT_PHNUM = 5,
4454111Sgblack@eecs.umich.edu        SPARC_AT_BASE = 7,
4464111Sgblack@eecs.umich.edu        SPARC_AT_FLAGS = 8,
4474111Sgblack@eecs.umich.edu        SPARC_AT_ENTRY = 9,
4484111Sgblack@eecs.umich.edu        SPARC_AT_UID = 11,
4494111Sgblack@eecs.umich.edu        SPARC_AT_EUID = 12,
4504111Sgblack@eecs.umich.edu        SPARC_AT_GID = 13,
4514111Sgblack@eecs.umich.edu        SPARC_AT_EGID = 14,
4524111Sgblack@eecs.umich.edu        SPARC_AT_SECURE = 23
4534111Sgblack@eecs.umich.edu    };
4544111Sgblack@eecs.umich.edu
4554111Sgblack@eecs.umich.edu    enum hardwareCaps
4564111Sgblack@eecs.umich.edu    {
4574111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_FLUSH = 1,
4584111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_STBAR = 2,
4594111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_SWAP = 4,
4604111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_MULDIV = 8,
4614111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_V9 = 16,
4624111Sgblack@eecs.umich.edu        //This one should technically only be set
4634111Sgblack@eecs.umich.edu        //if there is a cheetah or cheetah_plus tlb,
4644111Sgblack@eecs.umich.edu        //but we'll use it all the time
4654111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_ULTRA3 = 32
4664111Sgblack@eecs.umich.edu    };
4674111Sgblack@eecs.umich.edu
4684111Sgblack@eecs.umich.edu    const int64_t hwcap =
4694111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_FLUSH |
4704111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_STBAR |
4714111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_SWAP |
4724111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_MULDIV |
4734111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_V9 |
4744111Sgblack@eecs.umich.edu        M5_HWCAP_SPARC_ULTRA3;
4754111Sgblack@eecs.umich.edu
4764111Sgblack@eecs.umich.edu
4774111Sgblack@eecs.umich.edu    //Setup the auxilliary vectors. These will already have endian conversion.
4784111Sgblack@eecs.umich.edu    //Auxilliary vectors are loaded only for elf formatted executables.
4794111Sgblack@eecs.umich.edu    ElfObject * elfObject = dynamic_cast<ElfObject *>(objFile);
4804111Sgblack@eecs.umich.edu    if(elfObject)
4814111Sgblack@eecs.umich.edu    {
4824111Sgblack@eecs.umich.edu        //Bits which describe the system hardware capabilities
4834111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_HWCAP, hwcap));
4844111Sgblack@eecs.umich.edu        //The system page size
4854111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_PAGESZ, SparcISA::VMPageSize));
4864111Sgblack@eecs.umich.edu        //Defined to be 100 in the kernel source.
4874111Sgblack@eecs.umich.edu        //Frequency at which times() increments
4884111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_CLKTCK, 100));
4894111Sgblack@eecs.umich.edu        // For statically linked executables, this is the virtual address of the
4904111Sgblack@eecs.umich.edu        // program header tables if they appear in the executable image
4914111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_PHDR, elfObject->programHeaderTable()));
4924111Sgblack@eecs.umich.edu        // This is the size of a program header entry from the elf file.
4934111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_PHENT, elfObject->programHeaderSize()));
4944111Sgblack@eecs.umich.edu        // This is the number of program headers from the original elf file.
4954111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_PHNUM, elfObject->programHeaderCount()));
4964111Sgblack@eecs.umich.edu        //This is the address of the elf "interpreter", It should be set
4974111Sgblack@eecs.umich.edu        //to 0 for regular executables. It should be something else
4984111Sgblack@eecs.umich.edu        //(not sure what) for dynamic libraries.
4994111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_BASE, 0));
5004111Sgblack@eecs.umich.edu        //This is hardwired to 0 in the elf loading code in the kernel
5014111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_FLAGS, 0));
5024111Sgblack@eecs.umich.edu        //The entry point to the program
5034111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_ENTRY, objFile->entryPoint()));
5044111Sgblack@eecs.umich.edu        //Different user and group IDs
5054111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_UID, uid()));
5064111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_EUID, euid()));
5074111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_GID, gid()));
5084111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_EGID, egid()));
5094111Sgblack@eecs.umich.edu        //Whether to enable "secure mode" in the executable
5104111Sgblack@eecs.umich.edu        auxv.push_back(auxv_t(SPARC_AT_SECURE, 0));
5114111Sgblack@eecs.umich.edu    }
5124111Sgblack@eecs.umich.edu
5134111Sgblack@eecs.umich.edu    //Figure out how big the initial stack needs to be
5144111Sgblack@eecs.umich.edu
5154164Sgblack@eecs.umich.edu    // The unaccounted for 8 byte 0 at the top of the stack
5164164Sgblack@eecs.umich.edu    int mysterious_size = 8;
5174111Sgblack@eecs.umich.edu
5184111Sgblack@eecs.umich.edu    //This is the name of the file which is present on the initial stack
5194111Sgblack@eecs.umich.edu    //It's purpose is to let the user space linker examine the original file.
5204111Sgblack@eecs.umich.edu    int file_name_size = filename.size() + 1;
5214111Sgblack@eecs.umich.edu
5224111Sgblack@eecs.umich.edu    int env_data_size = 0;
5234111Sgblack@eecs.umich.edu    for (int i = 0; i < envp.size(); ++i) {
5244111Sgblack@eecs.umich.edu        env_data_size += envp[i].size() + 1;
5254111Sgblack@eecs.umich.edu    }
5264111Sgblack@eecs.umich.edu    int arg_data_size = 0;
5274111Sgblack@eecs.umich.edu    for (int i = 0; i < argv.size(); ++i) {
5284111Sgblack@eecs.umich.edu        arg_data_size += argv[i].size() + 1;
5294111Sgblack@eecs.umich.edu    }
5304111Sgblack@eecs.umich.edu
5314164Sgblack@eecs.umich.edu    //The info_block - This seems to need an pad for some reason.
5324111Sgblack@eecs.umich.edu    int info_block_size =
5334164Sgblack@eecs.umich.edu        (mysterious_size +
5344164Sgblack@eecs.umich.edu        file_name_size +
5354111Sgblack@eecs.umich.edu        env_data_size +
5364164Sgblack@eecs.umich.edu        arg_data_size + intSize);
5374111Sgblack@eecs.umich.edu
5384164Sgblack@eecs.umich.edu    //Each auxilliary vector is two 4 byte words
5394111Sgblack@eecs.umich.edu    int aux_array_size = intSize * 2 * (auxv.size() + 1);
5404111Sgblack@eecs.umich.edu
5414111Sgblack@eecs.umich.edu    int envp_array_size = intSize * (envp.size() + 1);
5424111Sgblack@eecs.umich.edu    int argv_array_size = intSize * (argv.size() + 1);
5434111Sgblack@eecs.umich.edu
5444111Sgblack@eecs.umich.edu    int argc_size = intSize;
5454111Sgblack@eecs.umich.edu    int window_save_size = intSize * 16;
5464111Sgblack@eecs.umich.edu
5474111Sgblack@eecs.umich.edu    int space_needed =
5484164Sgblack@eecs.umich.edu        info_block_size +
5494111Sgblack@eecs.umich.edu        aux_array_size +
5504111Sgblack@eecs.umich.edu        envp_array_size +
5514111Sgblack@eecs.umich.edu        argv_array_size +
5524111Sgblack@eecs.umich.edu        argc_size +
5534111Sgblack@eecs.umich.edu        window_save_size;
5544111Sgblack@eecs.umich.edu
5554111Sgblack@eecs.umich.edu    stack_min = stack_base - space_needed;
5564111Sgblack@eecs.umich.edu    stack_min &= alignmentMask;
5574111Sgblack@eecs.umich.edu    stack_size = stack_base - stack_min;
5584111Sgblack@eecs.umich.edu
5594111Sgblack@eecs.umich.edu    // map memory
5604111Sgblack@eecs.umich.edu    pTable->allocate(roundDown(stack_min, pageSize),
5614111Sgblack@eecs.umich.edu                     roundUp(stack_size, pageSize));
5624111Sgblack@eecs.umich.edu
5634111Sgblack@eecs.umich.edu    // map out initial stack contents
5644117Sgblack@eecs.umich.edu    uint32_t window_save_base = stack_min;
5654117Sgblack@eecs.umich.edu    uint32_t argc_base = window_save_base + window_save_size;
5664117Sgblack@eecs.umich.edu    uint32_t argv_array_base = argc_base + argc_size;
5674117Sgblack@eecs.umich.edu    uint32_t envp_array_base = argv_array_base + argv_array_size;
5684117Sgblack@eecs.umich.edu    uint32_t auxv_array_base = envp_array_base + envp_array_size;
5694117Sgblack@eecs.umich.edu    //The info block is pushed up against the top of the stack, while
5704117Sgblack@eecs.umich.edu    //the rest of the initial stack frame is aligned to an 8 byte boudary.
5714164Sgblack@eecs.umich.edu    uint32_t arg_data_base = stack_base - info_block_size + intSize;
5724117Sgblack@eecs.umich.edu    uint32_t env_data_base = arg_data_base + arg_data_size;
5734117Sgblack@eecs.umich.edu    uint32_t file_name_base = env_data_base + env_data_size;
5744117Sgblack@eecs.umich.edu    uint32_t mysterious_base = file_name_base + file_name_size;
5754111Sgblack@eecs.umich.edu
5764111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "The addresses of items on the initial stack:\n");
5774111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - file name\n", file_name_base);
5784111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - env data\n", env_data_base);
5794111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - arg data\n", arg_data_base);
5804111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - auxv array\n", auxv_array_base);
5814111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - envp array\n", envp_array_base);
5824111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - argv array\n", argv_array_base);
5834111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - argc \n", argc_base);
5844111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - window save\n", window_save_base);
5854111Sgblack@eecs.umich.edu    DPRINTF(Sparc, "0x%x - stack min\n", stack_min);
5864111Sgblack@eecs.umich.edu
5874111Sgblack@eecs.umich.edu    // write contents to stack
5884111Sgblack@eecs.umich.edu
5894111Sgblack@eecs.umich.edu    // figure out argc
5904111Sgblack@eecs.umich.edu    uint32_t argc = argv.size();
5914111Sgblack@eecs.umich.edu    uint32_t guestArgc = TheISA::htog(argc);
5924111Sgblack@eecs.umich.edu
5934111Sgblack@eecs.umich.edu    //Write out the mysterious 0
5944111Sgblack@eecs.umich.edu    uint64_t mysterious_zero = 0;
5954111Sgblack@eecs.umich.edu    initVirtMem->writeBlob(mysterious_base,
5964111Sgblack@eecs.umich.edu            (uint8_t*)&mysterious_zero, mysterious_size);
5974111Sgblack@eecs.umich.edu
5984111Sgblack@eecs.umich.edu    //Write the file name
5994111Sgblack@eecs.umich.edu    initVirtMem->writeString(file_name_base, filename.c_str());
6004111Sgblack@eecs.umich.edu
6014111Sgblack@eecs.umich.edu    //Copy the aux stuff
6024111Sgblack@eecs.umich.edu    for(int x = 0; x < auxv.size(); x++)
6034111Sgblack@eecs.umich.edu    {
6044111Sgblack@eecs.umich.edu        initVirtMem->writeBlob(auxv_array_base + x * 2 * intSize,
6054111Sgblack@eecs.umich.edu                (uint8_t*)&(auxv[x].a_type), intSize);
6064111Sgblack@eecs.umich.edu        initVirtMem->writeBlob(auxv_array_base + (x * 2 + 1) * intSize,
6074111Sgblack@eecs.umich.edu                (uint8_t*)&(auxv[x].a_val), intSize);
6084111Sgblack@eecs.umich.edu    }
6094111Sgblack@eecs.umich.edu    //Write out the terminating zeroed auxilliary vector
6104111Sgblack@eecs.umich.edu    const uint64_t zero = 0;
6114111Sgblack@eecs.umich.edu    initVirtMem->writeBlob(auxv_array_base + 2 * intSize * auxv.size(),
6124111Sgblack@eecs.umich.edu            (uint8_t*)&zero, 2 * intSize);
6134111Sgblack@eecs.umich.edu
6144117Sgblack@eecs.umich.edu    copyStringArray(envp, envp_array_base, env_data_base, initVirtMem);
6154117Sgblack@eecs.umich.edu    copyStringArray(argv, argv_array_base, arg_data_base, initVirtMem);
6164111Sgblack@eecs.umich.edu
6174111Sgblack@eecs.umich.edu    initVirtMem->writeBlob(argc_base, (uint8_t*)&guestArgc, intSize);
6184111Sgblack@eecs.umich.edu
6194111Sgblack@eecs.umich.edu    //Stuff the trap handlers into the processes address space.
6204111Sgblack@eecs.umich.edu    //Since the stack grows down and is the highest area in the processes
6214111Sgblack@eecs.umich.edu    //address space, we can put stuff above it and stay out of the way.
6224111Sgblack@eecs.umich.edu    int fillSize = sizeof(MachInst) * numFillInsts;
6234111Sgblack@eecs.umich.edu    int spillSize = sizeof(MachInst) * numSpillInsts;
6244111Sgblack@eecs.umich.edu    fillStart = stack_base;
6254111Sgblack@eecs.umich.edu    spillStart = fillStart + fillSize;
6264111Sgblack@eecs.umich.edu    initVirtMem->writeBlob(fillStart, (uint8_t*)fillHandler32, fillSize);
6274111Sgblack@eecs.umich.edu    initVirtMem->writeBlob(spillStart, (uint8_t*)spillHandler32, spillSize);
6284111Sgblack@eecs.umich.edu
6294111Sgblack@eecs.umich.edu    //Set up the thread context to start running the process
6304164Sgblack@eecs.umich.edu    //threadContexts[0]->setIntReg(ArgumentReg0, argc);
6314164Sgblack@eecs.umich.edu    //threadContexts[0]->setIntReg(ArgumentReg1, argv_array_base);
6324111Sgblack@eecs.umich.edu    threadContexts[0]->setIntReg(StackPointerReg, stack_min);
6334111Sgblack@eecs.umich.edu
6344117Sgblack@eecs.umich.edu    uint32_t prog_entry = objFile->entryPoint();
6354111Sgblack@eecs.umich.edu    threadContexts[0]->setPC(prog_entry);
6364111Sgblack@eecs.umich.edu    threadContexts[0]->setNextPC(prog_entry + sizeof(MachInst));
6374111Sgblack@eecs.umich.edu    threadContexts[0]->setNextNPC(prog_entry + (2 * sizeof(MachInst)));
6384111Sgblack@eecs.umich.edu
6394111Sgblack@eecs.umich.edu    //Align the "stack_min" to a page boundary.
6404111Sgblack@eecs.umich.edu    stack_min = roundDown(stack_min, pageSize);
6414111Sgblack@eecs.umich.edu
6424111Sgblack@eecs.umich.edu//    num_processes++;
6434111Sgblack@eecs.umich.edu}
644