process.cc revision 11723
12SN/A/*
210298Salexandru.dutu@amd.com * Copyright (c) 2014 Advanced Micro Devices, Inc.
38852Sandreas.hansson@arm.com * Copyright (c) 2012 ARM Limited
48852Sandreas.hansson@arm.com * All rights reserved
58852Sandreas.hansson@arm.com *
68852Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall
78852Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual
88852Sandreas.hansson@arm.com * property including but not limited to intellectual property relating
98852Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software
108852Sandreas.hansson@arm.com * licensed hereunder.  You may use the software subject to the license
118852Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated
128852Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software,
138852Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form.
148852Sandreas.hansson@arm.com *
151762SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan
162SN/A * All rights reserved.
172SN/A *
182SN/A * Redistribution and use in source and binary forms, with or without
192SN/A * modification, are permitted provided that the following conditions are
202SN/A * met: redistributions of source code must retain the above copyright
212SN/A * notice, this list of conditions and the following disclaimer;
222SN/A * redistributions in binary form must reproduce the above copyright
232SN/A * notice, this list of conditions and the following disclaimer in the
242SN/A * documentation and/or other materials provided with the distribution;
252SN/A * neither the name of the copyright holders nor the names of its
262SN/A * contributors may be used to endorse or promote products derived from
272SN/A * this software without specific prior written permission.
282SN/A *
292SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
302SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
312SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
322SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
332SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
342SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
352SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
362SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
372SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
382SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
392SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
402665Ssaidi@eecs.umich.edu *
412665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert
422665Ssaidi@eecs.umich.edu *          Steve Reinhardt
432665Ssaidi@eecs.umich.edu *          Ali Saidi
442SN/A */
452SN/A
468229Snate@binkert.org#include <fcntl.h>
472SN/A#include <unistd.h>
486712Snate@binkert.org
496712Snate@binkert.org#include <cstdio>
5010930Sbrandon.potter@amd.com#include <map>
512SN/A#include <string>
522SN/A
5356SN/A#include "base/loader/object_file.hh"
541158SN/A#include "base/loader/symtab.hh"
558229Snate@binkert.org#include "base/intmath.hh"
56146SN/A#include "base/statistics.hh"
576658Snate@binkert.org#include "config/the_isa.hh"
582680Sktlim@umich.edu#include "cpu/thread_context.hh"
592378SN/A#include "mem/page_table.hh"
6010298Salexandru.dutu@amd.com#include "mem/multi_level_page_table.hh"
618706Sandreas.hansson@arm.com#include "mem/se_translating_port_proxy.hh"
628229Snate@binkert.org#include "params/LiveProcess.hh"
635154Sgblack@eecs.umich.edu#include "params/Process.hh"
645512SMichael.Adler@intel.com#include "sim/debug.hh"
65360SN/A#include "sim/process.hh"
664434Ssaidi@eecs.umich.edu#include "sim/process_impl.hh"
67695SN/A#include "sim/stats.hh"
682093SN/A#include "sim/syscall_emul.hh"
692378SN/A#include "sim/system.hh"
702SN/A
712715Sstever@eecs.umich.edu#if THE_ISA == ALPHA_ISA
722715Sstever@eecs.umich.edu#include "arch/alpha/linux/process.hh"
732715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA
742715Sstever@eecs.umich.edu#include "arch/sparc/linux/process.hh"
752715Sstever@eecs.umich.edu#include "arch/sparc/solaris/process.hh"
762715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA
772715Sstever@eecs.umich.edu#include "arch/mips/linux/process.hh"
785335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA
795335Shines@cs.fsu.edu#include "arch/arm/linux/process.hh"
8010810Sbr@bsdpad.com#include "arch/arm/freebsd/process.hh"
814157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA
824166Sgblack@eecs.umich.edu#include "arch/x86/linux/process.hh"
836691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA
846691Stjones1@inf.ed.ac.uk#include "arch/power/linux/process.hh"
8511723Sar4jc@virginia.edu#elif THE_ISA == RISCV_ISA
8611723Sar4jc@virginia.edu#include "arch/riscv/linux/process.hh"
872715Sstever@eecs.umich.edu#else
882715Sstever@eecs.umich.edu#error "THE_ISA not set"
892715Sstever@eecs.umich.edu#endif
902715Sstever@eecs.umich.edu
912715Sstever@eecs.umich.edu
922SN/Ausing namespace std;
932107SN/Ausing namespace TheISA;
942SN/A
952SN/A// current number of allocated processes
962SN/Aint num_processes = 0;
972SN/A
985758Shsul@eecs.umich.edutemplate<class IntType>
9910932Sbrandon.potter@amd.com
1005771Shsul@eecs.umich.eduAuxVector<IntType>::AuxVector(IntType type, IntType val)
1015758Shsul@eecs.umich.edu{
1025758Shsul@eecs.umich.edu    a_type = TheISA::htog(type);
1035758Shsul@eecs.umich.edu    a_val = TheISA::htog(val);
1045758Shsul@eecs.umich.edu}
1055758Shsul@eecs.umich.edu
1068737Skoansin.tan@gmail.comtemplate struct AuxVector<uint32_t>;
1078737Skoansin.tan@gmail.comtemplate struct AuxVector<uint64_t>;
1085758Shsul@eecs.umich.edu
10910930Sbrandon.potter@amd.comstatic int
11010930Sbrandon.potter@amd.comopenFile(const string& filename, int flags, mode_t mode)
11110930Sbrandon.potter@amd.com{
11210930Sbrandon.potter@amd.com    int sim_fd = open(filename.c_str(), flags, mode);
11310930Sbrandon.potter@amd.com    if (sim_fd != -1)
11410930Sbrandon.potter@amd.com        return sim_fd;
11510930Sbrandon.potter@amd.com    fatal("Unable to open %s with mode %O", filename, mode);
11610930Sbrandon.potter@amd.com}
11710930Sbrandon.potter@amd.com
11810930Sbrandon.potter@amd.comstatic int
11910930Sbrandon.potter@amd.comopenInputFile(const string &filename)
12010930Sbrandon.potter@amd.com{
12110930Sbrandon.potter@amd.com    return openFile(filename, O_RDONLY, 0);
12210930Sbrandon.potter@amd.com}
12310930Sbrandon.potter@amd.com
12410930Sbrandon.potter@amd.comstatic int
12510930Sbrandon.potter@amd.comopenOutputFile(const string &filename)
12610930Sbrandon.potter@amd.com{
12710930Sbrandon.potter@amd.com    return openFile(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664);
12810930Sbrandon.potter@amd.com}
12910930Sbrandon.potter@amd.com
1305154Sgblack@eecs.umich.eduProcess::Process(ProcessParams * params)
1317532Ssteve.reinhardt@amd.com    : SimObject(params), system(params->system),
13210559Sandreas.hansson@arm.com      brk_point(0), stack_base(0), stack_size(0), stack_min(0),
1338852Sandreas.hansson@arm.com      max_stack_size(params->max_stack_size),
13410559Sandreas.hansson@arm.com      next_thread_stack_base(0),
1358852Sandreas.hansson@arm.com      M5_pid(system->allocatePID()),
13610299Salexandru.dutu@amd.com      useArchPT(params->useArchPT),
13710554Salexandru.dutu@amd.com      kvmInSE(params->kvmInSE),
13810299Salexandru.dutu@amd.com      pTable(useArchPT ?
13910299Salexandru.dutu@amd.com        static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) :
14010299Salexandru.dutu@amd.com        static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ),
1418852Sandreas.hansson@arm.com      initVirtMem(system->getSystemPort(), this,
14210929Sbrandon.potter@amd.com                  SETranslatingPortProxy::Always),
14310930Sbrandon.potter@amd.com      fd_array(make_shared<array<FDEntry, NUM_FDS>>()),
14410930Sbrandon.potter@amd.com      imap {{"",       -1},
14510930Sbrandon.potter@amd.com            {"cin",    STDIN_FILENO},
14610930Sbrandon.potter@amd.com            {"stdin",  STDIN_FILENO}},
14710930Sbrandon.potter@amd.com      oemap{{"",       -1},
14810930Sbrandon.potter@amd.com            {"cout",   STDOUT_FILENO},
14910930Sbrandon.potter@amd.com            {"stdout", STDOUT_FILENO},
15010930Sbrandon.potter@amd.com            {"cerr",   STDERR_FILENO},
15110930Sbrandon.potter@amd.com            {"stderr", STDERR_FILENO}}
1522SN/A{
15310930Sbrandon.potter@amd.com    int sim_fd;
15410930Sbrandon.potter@amd.com    std::map<string,int>::iterator it;
1555154Sgblack@eecs.umich.edu
15610930Sbrandon.potter@amd.com    // Search through the input options and set fd if match is found;
15710930Sbrandon.potter@amd.com    // otherwise, open an input file and seek to location.
15810932Sbrandon.potter@amd.com    FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
15910930Sbrandon.potter@amd.com    if ((it = imap.find(params->input)) != imap.end())
16010930Sbrandon.potter@amd.com        sim_fd = it->second;
16110930Sbrandon.potter@amd.com    else
16210930Sbrandon.potter@amd.com        sim_fd = openInputFile(params->input);
16310930Sbrandon.potter@amd.com    fde_stdin->set(sim_fd, params->input, O_RDONLY, -1, false);
1645154Sgblack@eecs.umich.edu
16510930Sbrandon.potter@amd.com    // Search through the output/error options and set fd if match is found;
16610930Sbrandon.potter@amd.com    // otherwise, open an output file and seek to location.
16710932Sbrandon.potter@amd.com    FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
16810930Sbrandon.potter@amd.com    if ((it = oemap.find(params->output)) != oemap.end())
16910930Sbrandon.potter@amd.com        sim_fd = it->second;
1705154Sgblack@eecs.umich.edu    else
17110930Sbrandon.potter@amd.com        sim_fd = openOutputFile(params->output);
17210930Sbrandon.potter@amd.com    fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC,
17310930Sbrandon.potter@amd.com                    0664, false);
1745154Sgblack@eecs.umich.edu
17510932Sbrandon.potter@amd.com    FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
17610930Sbrandon.potter@amd.com    if (params->output == params->errout)
17710930Sbrandon.potter@amd.com        // Reuse the same file descriptor if these match.
17810930Sbrandon.potter@amd.com        sim_fd = fde_stdout->fd;
17910930Sbrandon.potter@amd.com    else if ((it = oemap.find(params->errout)) != oemap.end())
18010930Sbrandon.potter@amd.com        sim_fd = it->second;
1815154Sgblack@eecs.umich.edu    else
18210930Sbrandon.potter@amd.com        sim_fd = openOutputFile(params->errout);
18310930Sbrandon.potter@amd.com    fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC,
18410930Sbrandon.potter@amd.com                    0664, false);
1852SN/A
18611386Ssteve.reinhardt@amd.com    mmap_end = 0;
1871514SN/A    nxm_start = nxm_end = 0;
1882SN/A    // other parameters will be initialized when the program is loaded
1892SN/A}
1902SN/A
1912378SN/A
1922SN/Avoid
1932SN/AProcess::regStats()
1942SN/A{
19511522Sstephan.diestelhorst@arm.com    SimObject::regStats();
19611522Sstephan.diestelhorst@arm.com
197729SN/A    using namespace Stats;
1982SN/A
1992SN/A    num_syscalls
2008240Snate@binkert.org        .name(name() + ".num_syscalls")
2012SN/A        .desc("Number of system calls")
2022SN/A        ;
2032SN/A}
2042SN/A
20510930Sbrandon.potter@amd.comvoid
20610932Sbrandon.potter@amd.comProcess::inheritFDArray(Process *p)
2072SN/A{
20810930Sbrandon.potter@amd.com    fd_array = p->fd_array;
2092SN/A}
2102SN/A
2115713Shsul@eecs.umich.eduThreadContext *
2125713Shsul@eecs.umich.eduProcess::findFreeContext()
2132SN/A{
21410929Sbrandon.potter@amd.com    for (int id : contextIds) {
21510929Sbrandon.potter@amd.com        ThreadContext *tc = system->getThreadContext(id);
21610929Sbrandon.potter@amd.com        if (tc->status() == ThreadContext::Halted)
2175713Shsul@eecs.umich.edu            return tc;
2185512SMichael.Adler@intel.com    }
2195713Shsul@eecs.umich.edu    return NULL;
2202SN/A}
2212SN/A
2221395SN/Avoid
2237532Ssteve.reinhardt@amd.comProcess::initState()
2241395SN/A{
2255713Shsul@eecs.umich.edu    if (contextIds.empty())
2265713Shsul@eecs.umich.edu        fatal("Process %s is not associated with any HW contexts!\n", name());
2272378SN/A
2282680Sktlim@umich.edu    // first thread context for this process... initialize & enable
2295713Shsul@eecs.umich.edu    ThreadContext *tc = system->getThreadContext(contextIds[0]);
2301395SN/A
2311634SN/A    // mark this context as active so it will start ticking.
23210407Smitch.hayenga@arm.com    tc->activate();
23310298Salexandru.dutu@amd.com
23410298Salexandru.dutu@amd.com    pTable->initState(tc);
2351395SN/A}
2362SN/A
23710913Sandreas.sandberg@arm.comDrainState
23810913Sandreas.sandberg@arm.comProcess::drain()
23910905Sandreas.sandberg@arm.com{
24010932Sbrandon.potter@amd.com    findFileOffsets();
24110913Sandreas.sandberg@arm.com    return DrainState::Drained;
24210905Sandreas.sandberg@arm.com}
24310905Sandreas.sandberg@arm.com
2442SN/Aint
24510932Sbrandon.potter@amd.comProcess::allocFD(int sim_fd, const string& filename, int flags, int mode,
24610932Sbrandon.potter@amd.com                 bool pipe)
2472SN/A{
24810930Sbrandon.potter@amd.com    for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) {
24910932Sbrandon.potter@amd.com        FDEntry *fde = getFDEntry(free_fd);
25010930Sbrandon.potter@amd.com        if (fde->isFree()) {
25110930Sbrandon.potter@amd.com            fde->set(sim_fd, filename, flags, mode, pipe);
2521970SN/A            return free_fd;
2531970SN/A        }
2542SN/A    }
2552SN/A
25610930Sbrandon.potter@amd.com    fatal("Out of target file descriptors");
2571970SN/A}
2582SN/A
2591970SN/Avoid
26010932Sbrandon.potter@amd.comProcess::resetFDEntry(int tgt_fd)
2611970SN/A{
26210932Sbrandon.potter@amd.com    FDEntry *fde = getFDEntry(tgt_fd);
26310930Sbrandon.potter@amd.com    assert(fde->fd > -1);
2641970SN/A
26510930Sbrandon.potter@amd.com    fde->reset();
2662SN/A}
2672SN/A
2682SN/Aint
26910932Sbrandon.potter@amd.comProcess::getSimFD(int tgt_fd)
2702SN/A{
27110932Sbrandon.potter@amd.com    FDEntry *entry = getFDEntry(tgt_fd);
27210930Sbrandon.potter@amd.com    return entry ? entry->fd : -1;
2732SN/A}
2742SN/A
27510930Sbrandon.potter@amd.comFDEntry *
27610932Sbrandon.potter@amd.comProcess::getFDEntry(int tgt_fd)
2775282Srstrong@cs.ucsd.edu{
27810930Sbrandon.potter@amd.com    assert(0 <= tgt_fd && tgt_fd < fd_array->size());
27910930Sbrandon.potter@amd.com    return &(*fd_array)[tgt_fd];
28010929Sbrandon.potter@amd.com}
2815282Srstrong@cs.ucsd.edu
28210929Sbrandon.potter@amd.comint
28310932Sbrandon.potter@amd.comProcess::getTgtFD(int sim_fd)
28410929Sbrandon.potter@amd.com{
28510930Sbrandon.potter@amd.com    for (int index = 0; index < fd_array->size(); index++)
28610930Sbrandon.potter@amd.com        if ((*fd_array)[index].fd == sim_fd)
28710929Sbrandon.potter@amd.com            return index;
28810929Sbrandon.potter@amd.com    return -1;
2895282Srstrong@cs.ucsd.edu}
2907487Ssteve.reinhardt@amd.com
2918601Ssteve.reinhardt@amd.comvoid
2928601Ssteve.reinhardt@amd.comProcess::allocateMem(Addr vaddr, int64_t size, bool clobber)
2938601Ssteve.reinhardt@amd.com{
29410318Sandreas.hansson@arm.com    int npages = divCeil(size, (int64_t)PageBytes);
2958601Ssteve.reinhardt@amd.com    Addr paddr = system->allocPhysPages(npages);
29611294Sandreas.hansson@arm.com    pTable->map(vaddr, paddr, size,
29711294Sandreas.hansson@arm.com                clobber ? PageTableBase::Clobber : PageTableBase::Zero);
2988601Ssteve.reinhardt@amd.com}
2998601Ssteve.reinhardt@amd.com
3004434Ssaidi@eecs.umich.edubool
3018539Sgblack@eecs.umich.eduProcess::fixupStackFault(Addr vaddr)
3024434Ssaidi@eecs.umich.edu{
3038539Sgblack@eecs.umich.edu    // Check if this is already on the stack and there's just no page there
3048539Sgblack@eecs.umich.edu    // yet.
3054434Ssaidi@eecs.umich.edu    if (vaddr >= stack_min && vaddr < stack_base) {
30610318Sandreas.hansson@arm.com        allocateMem(roundDown(vaddr, PageBytes), PageBytes);
3074434Ssaidi@eecs.umich.edu        return true;
3084434Ssaidi@eecs.umich.edu    }
3094434Ssaidi@eecs.umich.edu
3108539Sgblack@eecs.umich.edu    // We've accessed the next page of the stack, so extend it to include
3118539Sgblack@eecs.umich.edu    // this address.
3125154Sgblack@eecs.umich.edu    if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
3135154Sgblack@eecs.umich.edu        while (vaddr < stack_min) {
3145154Sgblack@eecs.umich.edu            stack_min -= TheISA::PageBytes;
3158539Sgblack@eecs.umich.edu            if (stack_base - stack_min > max_stack_size)
3165154Sgblack@eecs.umich.edu                fatal("Maximum stack size exceeded\n");
3178601Ssteve.reinhardt@amd.com            allocateMem(stack_min, TheISA::PageBytes);
3185823Ssaidi@eecs.umich.edu            inform("Increasing stack size by one page.");
3195154Sgblack@eecs.umich.edu        };
3204434Ssaidi@eecs.umich.edu        return true;
3214434Ssaidi@eecs.umich.edu    }
3224434Ssaidi@eecs.umich.edu    return false;
3234434Ssaidi@eecs.umich.edu}
3244434Ssaidi@eecs.umich.edu
3255282Srstrong@cs.ucsd.eduvoid
32610932Sbrandon.potter@amd.comProcess::fixFileOffsets()
3277487Ssteve.reinhardt@amd.com{
32810930Sbrandon.potter@amd.com    auto seek = [] (FDEntry *fde)
32910930Sbrandon.potter@amd.com    {
33010930Sbrandon.potter@amd.com        if (lseek(fde->fd, fde->fileOffset, SEEK_SET) < 0)
33110930Sbrandon.potter@amd.com            fatal("Unable to see to location in %s", fde->filename);
33210930Sbrandon.potter@amd.com    };
3335282Srstrong@cs.ucsd.edu
33410930Sbrandon.potter@amd.com    std::map<string,int>::iterator it;
3355282Srstrong@cs.ucsd.edu
33610930Sbrandon.potter@amd.com    // Search through the input options and set fd if match is found;
33710930Sbrandon.potter@amd.com    // otherwise, open an input file and seek to location.
33810932Sbrandon.potter@amd.com    FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
33910930Sbrandon.potter@amd.com    if ((it = imap.find(fde_stdin->filename)) != imap.end()) {
34010930Sbrandon.potter@amd.com        fde_stdin->fd = it->second;
34110930Sbrandon.potter@amd.com    } else {
34210930Sbrandon.potter@amd.com        fde_stdin->fd = openInputFile(fde_stdin->filename);
34310930Sbrandon.potter@amd.com        seek(fde_stdin);
3445282Srstrong@cs.ucsd.edu    }
3455282Srstrong@cs.ucsd.edu
34610930Sbrandon.potter@amd.com    // Search through the output/error options and set fd if match is found;
34710930Sbrandon.potter@amd.com    // otherwise, open an output file and seek to location.
34810932Sbrandon.potter@amd.com    FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
34910930Sbrandon.potter@amd.com    if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) {
35010930Sbrandon.potter@amd.com        fde_stdout->fd = it->second;
35110930Sbrandon.potter@amd.com    } else {
35210930Sbrandon.potter@amd.com        fde_stdout->fd = openOutputFile(fde_stdout->filename);
35310930Sbrandon.potter@amd.com        seek(fde_stdout);
3545282Srstrong@cs.ucsd.edu    }
3555282Srstrong@cs.ucsd.edu
35610932Sbrandon.potter@amd.com    FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
35710930Sbrandon.potter@amd.com    if (fde_stdout->filename == fde_stderr->filename) {
35810930Sbrandon.potter@amd.com        // Reuse the same file descriptor if these match.
35910930Sbrandon.potter@amd.com        fde_stderr->fd = fde_stdout->fd;
36010930Sbrandon.potter@amd.com    } else if ((it = oemap.find(fde_stderr->filename)) != oemap.end()) {
36110930Sbrandon.potter@amd.com        fde_stderr->fd = it->second;
36210930Sbrandon.potter@amd.com    } else {
36310930Sbrandon.potter@amd.com        fde_stderr->fd = openOutputFile(fde_stderr->filename);
36410930Sbrandon.potter@amd.com        seek(fde_stderr);
3655514SMichael.Adler@intel.com    }
3665282Srstrong@cs.ucsd.edu
36710930Sbrandon.potter@amd.com    for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) {
36810932Sbrandon.potter@amd.com        FDEntry *fde = getFDEntry(tgt_fd);
36910930Sbrandon.potter@amd.com        if (fde->fd == -1)
37010930Sbrandon.potter@amd.com            continue;
3715282Srstrong@cs.ucsd.edu
37210930Sbrandon.potter@amd.com        if (fde->isPipe) {
37310930Sbrandon.potter@amd.com            if (fde->filename == "PIPE-WRITE")
37410930Sbrandon.potter@amd.com                continue;
37510930Sbrandon.potter@amd.com            assert(fde->filename == "PIPE-READ");
3765282Srstrong@cs.ucsd.edu
37710930Sbrandon.potter@amd.com            int fds[2];
37810930Sbrandon.potter@amd.com            if (pipe(fds) < 0)
37910930Sbrandon.potter@amd.com                fatal("Unable to create new pipe");
3805282Srstrong@cs.ucsd.edu
38110930Sbrandon.potter@amd.com            fde->fd = fds[0];
3825282Srstrong@cs.ucsd.edu
38310932Sbrandon.potter@amd.com            FDEntry *fde_write = getFDEntry(fde->readPipeSource);
38411378Sbrandon.potter@amd.com            assert(fde_write->filename == "PIPE-WRITE");
38510930Sbrandon.potter@amd.com            fde_write->fd = fds[1];
38610930Sbrandon.potter@amd.com        } else {
38710930Sbrandon.potter@amd.com            fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode);
38810930Sbrandon.potter@amd.com            seek(fde);
3895282Srstrong@cs.ucsd.edu        }
3905282Srstrong@cs.ucsd.edu    }
3915282Srstrong@cs.ucsd.edu}
3927487Ssteve.reinhardt@amd.com
3935282Srstrong@cs.ucsd.eduvoid
39410932Sbrandon.potter@amd.comProcess::findFileOffsets()
3957487Ssteve.reinhardt@amd.com{
39610930Sbrandon.potter@amd.com    for (auto& fde : *fd_array) {
39710930Sbrandon.potter@amd.com        if (fde.fd != -1)
39810930Sbrandon.potter@amd.com            fde.fileOffset = lseek(fde.fd, 0, SEEK_CUR);
3995282Srstrong@cs.ucsd.edu    }
4005282Srstrong@cs.ucsd.edu}
4015282Srstrong@cs.ucsd.edu
4025282Srstrong@cs.ucsd.eduvoid
4037487Ssteve.reinhardt@amd.comProcess::setReadPipeSource(int read_pipe_fd, int source_fd)
4047487Ssteve.reinhardt@amd.com{
40510932Sbrandon.potter@amd.com    FDEntry *fde = getFDEntry(read_pipe_fd);
40610930Sbrandon.potter@amd.com    assert(source_fd >= -1);
40710930Sbrandon.potter@amd.com    fde->readPipeSource = source_fd;
4085282Srstrong@cs.ucsd.edu}
4095282Srstrong@cs.ucsd.edu
4103311Ssaidi@eecs.umich.eduvoid
41110905Sandreas.sandberg@arm.comProcess::serialize(CheckpointOut &cp) const
4123311Ssaidi@eecs.umich.edu{
4133311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(brk_point);
4143311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_base);
4153311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_size);
4163311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_min);
4173311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(next_thread_stack_base);
4183311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(mmap_end);
4193311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(nxm_start);
4203311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(nxm_end);
42110905Sandreas.sandberg@arm.com    pTable->serialize(cp);
42210930Sbrandon.potter@amd.com    for (int x = 0; x < fd_array->size(); x++) {
42310930Sbrandon.potter@amd.com        (*fd_array)[x].serializeSection(cp, csprintf("FDEntry%d", x));
4245282Srstrong@cs.ucsd.edu    }
4256820SLisa.Hsu@amd.com    SERIALIZE_SCALAR(M5_pid);
4263311Ssaidi@eecs.umich.edu
4273311Ssaidi@eecs.umich.edu}
4283311Ssaidi@eecs.umich.edu
4293311Ssaidi@eecs.umich.eduvoid
43010905Sandreas.sandberg@arm.comProcess::unserialize(CheckpointIn &cp)
4313311Ssaidi@eecs.umich.edu{
4323311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(brk_point);
4333311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_base);
4343311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_size);
4353311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_min);
4363311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(next_thread_stack_base);
4373311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(mmap_end);
4383311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(nxm_start);
4393311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(nxm_end);
44010905Sandreas.sandberg@arm.com    pTable->unserialize(cp);
44110930Sbrandon.potter@amd.com    for (int x = 0; x < fd_array->size(); x++) {
44210932Sbrandon.potter@amd.com        FDEntry *fde = getFDEntry(x);
44310930Sbrandon.potter@amd.com        fde->unserializeSection(cp, csprintf("FDEntry%d", x));
4447487Ssteve.reinhardt@amd.com    }
44510932Sbrandon.potter@amd.com    fixFileOffsets();
4466820SLisa.Hsu@amd.com    UNSERIALIZE_OPT_SCALAR(M5_pid);
4476820SLisa.Hsu@amd.com    // The above returns a bool so that you could do something if you don't
4486820SLisa.Hsu@amd.com    // find the param in the checkpoint if you wanted to, like set a default
44910930Sbrandon.potter@amd.com    // but in this case we'll just stick with the instantiated value if not
45010929Sbrandon.potter@amd.com    // found.
4513311Ssaidi@eecs.umich.edu}
4522SN/A
4532SN/A
4549110Ssteve.reinhardt@amd.combool
45510558Salexandru.dutu@amd.comProcess::map(Addr vaddr, Addr paddr, int size, bool cacheable)
4569110Ssteve.reinhardt@amd.com{
45710558Salexandru.dutu@amd.com    pTable->map(vaddr, paddr, size,
45811294Sandreas.hansson@arm.com                cacheable ? PageTableBase::Zero : PageTableBase::Uncacheable);
4599110Ssteve.reinhardt@amd.com    return true;
4609110Ssteve.reinhardt@amd.com}
4619110Ssteve.reinhardt@amd.com
4629110Ssteve.reinhardt@amd.com
4632SN/A////////////////////////////////////////////////////////////////////////
4642SN/A//
4652SN/A// LiveProcess member definitions
4662SN/A//
4672SN/A////////////////////////////////////////////////////////////////////////
4682SN/A
46912SN/A
47010499Ssteve.reinhardt@amd.comLiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile)
4715154Sgblack@eecs.umich.edu    : Process(params), objFile(_objFile),
47210496Ssteve.reinhardt@amd.com      argv(params->cmd), envp(params->env), cwd(params->cwd),
47311140Sjthestness@gmail.com      executable(params->executable),
47410499Ssteve.reinhardt@amd.com      __uid(params->uid), __euid(params->euid),
47510499Ssteve.reinhardt@amd.com      __gid(params->gid), __egid(params->egid),
47610499Ssteve.reinhardt@amd.com      __pid(params->pid), __ppid(params->ppid),
47710496Ssteve.reinhardt@amd.com      drivers(params->drivers)
4782SN/A{
4793114Sgblack@eecs.umich.edu
4801158SN/A    // load up symbols, if any... these may be used for debugging or
4811158SN/A    // profiling.
4821158SN/A    if (!debugSymbolTable) {
4831158SN/A        debugSymbolTable = new SymbolTable();
4841158SN/A        if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
4859641Sguodeyuan@tsinghua.org.cn            !objFile->loadLocalSymbols(debugSymbolTable) ||
4869641Sguodeyuan@tsinghua.org.cn            !objFile->loadWeakSymbols(debugSymbolTable)) {
4871158SN/A            // didn't load any symbols
4881158SN/A            delete debugSymbolTable;
4891158SN/A            debugSymbolTable = NULL;
4901158SN/A        }
4911158SN/A    }
4922378SN/A}
4931158SN/A
4942378SN/Avoid
4952680Sktlim@umich.eduLiveProcess::syscall(int64_t callnum, ThreadContext *tc)
4962093SN/A{
4972093SN/A    num_syscalls++;
4982093SN/A
4992093SN/A    SyscallDesc *desc = getDesc(callnum);
5002093SN/A    if (desc == NULL)
5012093SN/A        fatal("Syscall %d out of range", callnum);
5022093SN/A
5032680Sktlim@umich.edu    desc->doSyscall(callnum, this, tc);
5042093SN/A}
5052SN/A
5066701Sgblack@eecs.umich.eduIntReg
5076701Sgblack@eecs.umich.eduLiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
5086701Sgblack@eecs.umich.edu{
5096701Sgblack@eecs.umich.edu    return getSyscallArg(tc, i);
5106701Sgblack@eecs.umich.edu}
5116701Sgblack@eecs.umich.edu
51210496Ssteve.reinhardt@amd.com
51310496Ssteve.reinhardt@amd.comEmulatedDriver *
51410496Ssteve.reinhardt@amd.comLiveProcess::findDriver(std::string filename)
51510496Ssteve.reinhardt@amd.com{
51610496Ssteve.reinhardt@amd.com    for (EmulatedDriver *d : drivers) {
51710496Ssteve.reinhardt@amd.com        if (d->match(filename))
51810496Ssteve.reinhardt@amd.com            return d;
51910496Ssteve.reinhardt@amd.com    }
52010496Ssteve.reinhardt@amd.com
52110496Ssteve.reinhardt@amd.com    return NULL;
52210496Ssteve.reinhardt@amd.com}
52310496Ssteve.reinhardt@amd.com
52411389Sbrandon.potter@amd.comvoid
52511389Sbrandon.potter@amd.comLiveProcess::updateBias()
52611389Sbrandon.potter@amd.com{
52711389Sbrandon.potter@amd.com    ObjectFile *interp = objFile->getInterpreter();
52811389Sbrandon.potter@amd.com
52911389Sbrandon.potter@amd.com    if (!interp || !interp->relocatable())
53011389Sbrandon.potter@amd.com        return;
53111389Sbrandon.potter@amd.com
53211389Sbrandon.potter@amd.com    // Determine how large the interpreters footprint will be in the process
53311389Sbrandon.potter@amd.com    // address space.
53411389Sbrandon.potter@amd.com    Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes);
53511389Sbrandon.potter@amd.com
53611389Sbrandon.potter@amd.com    // We are allocating the memory area; set the bias to the lowest address
53711389Sbrandon.potter@amd.com    // in the allocated memory region.
53811389Sbrandon.potter@amd.com    Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end;
53911389Sbrandon.potter@amd.com
54011389Sbrandon.potter@amd.com    // Adjust the process mmap area to give the interpreter room; the real
54111389Sbrandon.potter@amd.com    // execve system call would just invoke the kernel's internal mmap
54211389Sbrandon.potter@amd.com    // functions to make these adjustments.
54311389Sbrandon.potter@amd.com    mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize;
54411389Sbrandon.potter@amd.com
54511389Sbrandon.potter@amd.com    interp->updateBias(ld_bias);
54611389Sbrandon.potter@amd.com}
54711389Sbrandon.potter@amd.com
54811389Sbrandon.potter@amd.com
54911392Sbrandon.potter@amd.comObjectFile *
55011392Sbrandon.potter@amd.comLiveProcess::getInterpreter()
55111392Sbrandon.potter@amd.com{
55211392Sbrandon.potter@amd.com    return objFile->getInterpreter();
55311392Sbrandon.potter@amd.com}
55411392Sbrandon.potter@amd.com
55511392Sbrandon.potter@amd.com
55611389Sbrandon.potter@amd.comAddr
55711389Sbrandon.potter@amd.comLiveProcess::getBias()
55811389Sbrandon.potter@amd.com{
55911392Sbrandon.potter@amd.com    ObjectFile *interp = getInterpreter();
56011389Sbrandon.potter@amd.com
56111389Sbrandon.potter@amd.com    return interp ? interp->bias() : objFile->bias();
56211389Sbrandon.potter@amd.com}
56311389Sbrandon.potter@amd.com
56411389Sbrandon.potter@amd.com
56511389Sbrandon.potter@amd.comAddr
56611389Sbrandon.potter@amd.comLiveProcess::getStartPC()
56711389Sbrandon.potter@amd.com{
56811392Sbrandon.potter@amd.com    ObjectFile *interp = getInterpreter();
56911389Sbrandon.potter@amd.com
57011389Sbrandon.potter@amd.com    return interp ? interp->entryPoint() : objFile->entryPoint();
57111389Sbrandon.potter@amd.com}
57211389Sbrandon.potter@amd.com
57310496Ssteve.reinhardt@amd.com
5742715Sstever@eecs.umich.eduLiveProcess *
5755154Sgblack@eecs.umich.eduLiveProcess::create(LiveProcessParams * params)
5762715Sstever@eecs.umich.edu{
5772715Sstever@eecs.umich.edu    LiveProcess *process = NULL;
5782715Sstever@eecs.umich.edu
57911140Sjthestness@gmail.com    // If not specified, set the executable parameter equal to the
58011140Sjthestness@gmail.com    // simulated system's zeroth command line parameter
58111140Sjthestness@gmail.com    if (params->executable == "") {
58211140Sjthestness@gmail.com        params->executable = params->cmd[0];
58311140Sjthestness@gmail.com    }
58411140Sjthestness@gmail.com
58511140Sjthestness@gmail.com    ObjectFile *objFile = createObjectFile(params->executable);
5862715Sstever@eecs.umich.edu    if (objFile == NULL) {
58711140Sjthestness@gmail.com        fatal("Can't load object file %s", params->executable);
5882715Sstever@eecs.umich.edu    }
5892715Sstever@eecs.umich.edu
5905089Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA
5915753Ssteve.reinhardt@amd.com    if (objFile->getArch() != ObjectFile::Alpha)
5925753Ssteve.reinhardt@amd.com        fatal("Object file architecture does not match compiled ISA (Alpha).");
5935753Ssteve.reinhardt@amd.com
5942715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
5955753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
5965753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
5975753Ssteve.reinhardt@amd.com        // fall through
5982715Sstever@eecs.umich.edu      case ObjectFile::Linux:
5995154Sgblack@eecs.umich.edu        process = new AlphaLinuxProcess(params, objFile);
6002715Sstever@eecs.umich.edu        break;
6012715Sstever@eecs.umich.edu
6022715Sstever@eecs.umich.edu      default:
6032715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6042715Sstever@eecs.umich.edu    }
6052715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA
6065753Ssteve.reinhardt@amd.com    if (objFile->getArch() != ObjectFile::SPARC64 &&
6075753Ssteve.reinhardt@amd.com        objFile->getArch() != ObjectFile::SPARC32)
6082715Sstever@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (SPARC).");
6092715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
6105753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6115753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6125753Ssteve.reinhardt@amd.com        // fall through
6132715Sstever@eecs.umich.edu      case ObjectFile::Linux:
6144111Sgblack@eecs.umich.edu        if (objFile->getArch() == ObjectFile::SPARC64) {
6155154Sgblack@eecs.umich.edu            process = new Sparc64LinuxProcess(params, objFile);
6164111Sgblack@eecs.umich.edu        } else {
6175154Sgblack@eecs.umich.edu            process = new Sparc32LinuxProcess(params, objFile);
6184111Sgblack@eecs.umich.edu        }
6192715Sstever@eecs.umich.edu        break;
6202715Sstever@eecs.umich.edu
6212715Sstever@eecs.umich.edu
6222715Sstever@eecs.umich.edu      case ObjectFile::Solaris:
6235154Sgblack@eecs.umich.edu        process = new SparcSolarisProcess(params, objFile);
6242715Sstever@eecs.umich.edu        break;
6255753Ssteve.reinhardt@amd.com
6262715Sstever@eecs.umich.edu      default:
6272715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6282715Sstever@eecs.umich.edu    }
6294157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA
6305874Sgblack@eecs.umich.edu    if (objFile->getArch() != ObjectFile::X86_64 &&
6315874Sgblack@eecs.umich.edu        objFile->getArch() != ObjectFile::I386)
6324166Sgblack@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (x86).");
6334157Sgblack@eecs.umich.edu    switch (objFile->getOpSys()) {
6345753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6355753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6365753Ssteve.reinhardt@amd.com        // fall through
6374166Sgblack@eecs.umich.edu      case ObjectFile::Linux:
6385874Sgblack@eecs.umich.edu        if (objFile->getArch() == ObjectFile::X86_64) {
6395955Sgblack@eecs.umich.edu            process = new X86_64LinuxProcess(params, objFile);
6405874Sgblack@eecs.umich.edu        } else {
6415955Sgblack@eecs.umich.edu            process = new I386LinuxProcess(params, objFile);
6425874Sgblack@eecs.umich.edu        }
6434166Sgblack@eecs.umich.edu        break;
6445753Ssteve.reinhardt@amd.com
6454157Sgblack@eecs.umich.edu      default:
6464157Sgblack@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6474157Sgblack@eecs.umich.edu    }
6482715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA
6492715Sstever@eecs.umich.edu    if (objFile->getArch() != ObjectFile::Mips)
6502715Sstever@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (MIPS).");
6512715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
6525753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6535753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6545753Ssteve.reinhardt@amd.com        // fall through
6552715Sstever@eecs.umich.edu      case ObjectFile::Linux:
6565154Sgblack@eecs.umich.edu        process = new MipsLinuxProcess(params, objFile);
6572715Sstever@eecs.umich.edu        break;
6582715Sstever@eecs.umich.edu
6592715Sstever@eecs.umich.edu      default:
6602715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6612715Sstever@eecs.umich.edu    }
6625335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA
66310037SARM gem5 Developers    ObjectFile::Arch arch = objFile->getArch();
66410037SARM gem5 Developers    if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
66510037SARM gem5 Developers        arch != ObjectFile::Arm64)
6665335Shines@cs.fsu.edu        fatal("Object file architecture does not match compiled ISA (ARM).");
6675335Shines@cs.fsu.edu    switch (objFile->getOpSys()) {
6685753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6695753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6705753Ssteve.reinhardt@amd.com        // fall through
6715335Shines@cs.fsu.edu      case ObjectFile::Linux:
67210037SARM gem5 Developers        if (arch == ObjectFile::Arm64) {
67310037SARM gem5 Developers            process = new ArmLinuxProcess64(params, objFile,
67410037SARM gem5 Developers                                            objFile->getArch());
67510037SARM gem5 Developers        } else {
67610037SARM gem5 Developers            process = new ArmLinuxProcess32(params, objFile,
67710037SARM gem5 Developers                                            objFile->getArch());
67810037SARM gem5 Developers        }
6795335Shines@cs.fsu.edu        break;
68010810Sbr@bsdpad.com      case ObjectFile::FreeBSD:
68110810Sbr@bsdpad.com        if (arch == ObjectFile::Arm64) {
68210810Sbr@bsdpad.com            process = new ArmFreebsdProcess64(params, objFile,
68310810Sbr@bsdpad.com                                              objFile->getArch());
68410810Sbr@bsdpad.com        } else {
68510810Sbr@bsdpad.com            process = new ArmFreebsdProcess32(params, objFile,
68610810Sbr@bsdpad.com                                              objFile->getArch());
68710810Sbr@bsdpad.com        }
68810810Sbr@bsdpad.com        break;
6896392Ssaidi@eecs.umich.edu      case ObjectFile::LinuxArmOABI:
6906392Ssaidi@eecs.umich.edu        fatal("M5 does not support ARM OABI binaries. Please recompile with an"
6916392Ssaidi@eecs.umich.edu              " EABI compiler.");
6925335Shines@cs.fsu.edu      default:
6935335Shines@cs.fsu.edu        fatal("Unknown/unsupported operating system.");
6945335Shines@cs.fsu.edu    }
6956691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA
6966691Stjones1@inf.ed.ac.uk    if (objFile->getArch() != ObjectFile::Power)
6976691Stjones1@inf.ed.ac.uk        fatal("Object file architecture does not match compiled ISA (Power).");
6986691Stjones1@inf.ed.ac.uk    switch (objFile->getOpSys()) {
6996691Stjones1@inf.ed.ac.uk      case ObjectFile::UnknownOpSys:
7006691Stjones1@inf.ed.ac.uk        warn("Unknown operating system; assuming Linux.");
7016691Stjones1@inf.ed.ac.uk        // fall through
7026691Stjones1@inf.ed.ac.uk      case ObjectFile::Linux:
7036691Stjones1@inf.ed.ac.uk        process = new PowerLinuxProcess(params, objFile);
7046691Stjones1@inf.ed.ac.uk        break;
7056691Stjones1@inf.ed.ac.uk
7066691Stjones1@inf.ed.ac.uk      default:
7076691Stjones1@inf.ed.ac.uk        fatal("Unknown/unsupported operating system.");
7086691Stjones1@inf.ed.ac.uk    }
70911723Sar4jc@virginia.edu#elif THE_ISA == RISCV_ISA
71011723Sar4jc@virginia.edu    if (objFile->getArch() != ObjectFile::Riscv)
71111723Sar4jc@virginia.edu        fatal("Object file architecture does not match compiled ISA (RISCV).");
71211723Sar4jc@virginia.edu    switch (objFile->getOpSys()) {
71311723Sar4jc@virginia.edu      case ObjectFile::UnknownOpSys:
71411723Sar4jc@virginia.edu        warn("Unknown operating system; assuming Linux.");
71511723Sar4jc@virginia.edu        // fall through
71611723Sar4jc@virginia.edu      case ObjectFile::Linux:
71711723Sar4jc@virginia.edu        process = new RiscvLinuxProcess(params, objFile);
71811723Sar4jc@virginia.edu        break;
71911723Sar4jc@virginia.edu      default:
72011723Sar4jc@virginia.edu        fatal("Unknown/unsupported operating system.");
72111723Sar4jc@virginia.edu    }
7222715Sstever@eecs.umich.edu#else
7232715Sstever@eecs.umich.edu#error "THE_ISA not set"
7242715Sstever@eecs.umich.edu#endif
7252715Sstever@eecs.umich.edu
7262715Sstever@eecs.umich.edu    if (process == NULL)
7272715Sstever@eecs.umich.edu        fatal("Unknown error creating process object.");
7282715Sstever@eecs.umich.edu    return process;
7292715Sstever@eecs.umich.edu}
7302715Sstever@eecs.umich.edu
7314762Snate@binkert.orgLiveProcess *
7324762Snate@binkert.orgLiveProcessParams::create()
7332715Sstever@eecs.umich.edu{
7345154Sgblack@eecs.umich.edu    return LiveProcess::create(this);
7352715Sstever@eecs.umich.edu}
736