process.cc revision 11813
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
4611793Sbrandon.potter@amd.com#include "sim/process.hh"
4711793Sbrandon.potter@amd.com
488229Snate@binkert.org#include <fcntl.h>
492SN/A#include <unistd.h>
506712Snate@binkert.org
5111800Sbrandon.potter@amd.com#include <array>
5210930Sbrandon.potter@amd.com#include <map>
532SN/A#include <string>
5411800Sbrandon.potter@amd.com#include <vector>
552SN/A
5611793Sbrandon.potter@amd.com#include "base/intmath.hh"
5756SN/A#include "base/loader/object_file.hh"
581158SN/A#include "base/loader/symtab.hh"
59146SN/A#include "base/statistics.hh"
606658Snate@binkert.org#include "config/the_isa.hh"
612680Sktlim@umich.edu#include "cpu/thread_context.hh"
622378SN/A#include "mem/page_table.hh"
638706Sandreas.hansson@arm.com#include "mem/se_translating_port_proxy.hh"
648229Snate@binkert.org#include "params/LiveProcess.hh"
655154Sgblack@eecs.umich.edu#include "params/Process.hh"
6611800Sbrandon.potter@amd.com#include "sim/emul_driver.hh"
6711794Sbrandon.potter@amd.com#include "sim/syscall_desc.hh"
682378SN/A#include "sim/system.hh"
692SN/A
702715Sstever@eecs.umich.edu#if THE_ISA == ALPHA_ISA
712715Sstever@eecs.umich.edu#include "arch/alpha/linux/process.hh"
722715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA
732715Sstever@eecs.umich.edu#include "arch/sparc/linux/process.hh"
742715Sstever@eecs.umich.edu#include "arch/sparc/solaris/process.hh"
752715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA
762715Sstever@eecs.umich.edu#include "arch/mips/linux/process.hh"
775335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA
785335Shines@cs.fsu.edu#include "arch/arm/linux/process.hh"
7910810Sbr@bsdpad.com#include "arch/arm/freebsd/process.hh"
804157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA
814166Sgblack@eecs.umich.edu#include "arch/x86/linux/process.hh"
826691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA
836691Stjones1@inf.ed.ac.uk#include "arch/power/linux/process.hh"
8411723Sar4jc@virginia.edu#elif THE_ISA == RISCV_ISA
8511723Sar4jc@virginia.edu#include "arch/riscv/linux/process.hh"
862715Sstever@eecs.umich.edu#else
872715Sstever@eecs.umich.edu#error "THE_ISA not set"
882715Sstever@eecs.umich.edu#endif
892715Sstever@eecs.umich.edu
902715Sstever@eecs.umich.edu
912SN/Ausing namespace std;
922107SN/Ausing namespace TheISA;
932SN/A
942SN/A// current number of allocated processes
952SN/Aint num_processes = 0;
962SN/A
975758Shsul@eecs.umich.edutemplate<class IntType>
9810932Sbrandon.potter@amd.com
995771Shsul@eecs.umich.eduAuxVector<IntType>::AuxVector(IntType type, IntType val)
1005758Shsul@eecs.umich.edu{
1015758Shsul@eecs.umich.edu    a_type = TheISA::htog(type);
1025758Shsul@eecs.umich.edu    a_val = TheISA::htog(val);
1035758Shsul@eecs.umich.edu}
1045758Shsul@eecs.umich.edu
1058737Skoansin.tan@gmail.comtemplate struct AuxVector<uint32_t>;
1068737Skoansin.tan@gmail.comtemplate struct AuxVector<uint64_t>;
1075758Shsul@eecs.umich.edu
10810930Sbrandon.potter@amd.comstatic int
10910930Sbrandon.potter@amd.comopenFile(const string& filename, int flags, mode_t mode)
11010930Sbrandon.potter@amd.com{
11110930Sbrandon.potter@amd.com    int sim_fd = open(filename.c_str(), flags, mode);
11210930Sbrandon.potter@amd.com    if (sim_fd != -1)
11310930Sbrandon.potter@amd.com        return sim_fd;
11410930Sbrandon.potter@amd.com    fatal("Unable to open %s with mode %O", filename, mode);
11510930Sbrandon.potter@amd.com}
11610930Sbrandon.potter@amd.com
11710930Sbrandon.potter@amd.comstatic int
11810930Sbrandon.potter@amd.comopenInputFile(const string &filename)
11910930Sbrandon.potter@amd.com{
12010930Sbrandon.potter@amd.com    return openFile(filename, O_RDONLY, 0);
12110930Sbrandon.potter@amd.com}
12210930Sbrandon.potter@amd.com
12310930Sbrandon.potter@amd.comstatic int
12410930Sbrandon.potter@amd.comopenOutputFile(const string &filename)
12510930Sbrandon.potter@amd.com{
12610930Sbrandon.potter@amd.com    return openFile(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664);
12710930Sbrandon.potter@amd.com}
12810930Sbrandon.potter@amd.com
1295154Sgblack@eecs.umich.eduProcess::Process(ProcessParams * params)
1307532Ssteve.reinhardt@amd.com    : SimObject(params), system(params->system),
13110559Sandreas.hansson@arm.com      brk_point(0), stack_base(0), stack_size(0), stack_min(0),
1328852Sandreas.hansson@arm.com      max_stack_size(params->max_stack_size),
13310559Sandreas.hansson@arm.com      next_thread_stack_base(0),
13410299Salexandru.dutu@amd.com      useArchPT(params->useArchPT),
13510554Salexandru.dutu@amd.com      kvmInSE(params->kvmInSE),
13610299Salexandru.dutu@amd.com      pTable(useArchPT ?
13711813Sbaz21@cam.ac.uk        static_cast<PageTableBase *>(new ArchPageTable(name(), params->pid,
13811813Sbaz21@cam.ac.uk            system)) :
13911813Sbaz21@cam.ac.uk        static_cast<PageTableBase *>(new FuncPageTable(name(), params->pid))),
1408852Sandreas.hansson@arm.com      initVirtMem(system->getSystemPort(), this,
14110929Sbrandon.potter@amd.com                  SETranslatingPortProxy::Always),
14210930Sbrandon.potter@amd.com      fd_array(make_shared<array<FDEntry, NUM_FDS>>()),
14310930Sbrandon.potter@amd.com      imap {{"",       -1},
14410930Sbrandon.potter@amd.com            {"cin",    STDIN_FILENO},
14510930Sbrandon.potter@amd.com            {"stdin",  STDIN_FILENO}},
14610930Sbrandon.potter@amd.com      oemap{{"",       -1},
14710930Sbrandon.potter@amd.com            {"cout",   STDOUT_FILENO},
14810930Sbrandon.potter@amd.com            {"stdout", STDOUT_FILENO},
14910930Sbrandon.potter@amd.com            {"cerr",   STDERR_FILENO},
15011801Sbrandon.potter@amd.com            {"stderr", STDERR_FILENO}},
15111801Sbrandon.potter@amd.com      _uid(params->uid), _euid(params->euid),
15211801Sbrandon.potter@amd.com      _gid(params->gid), _egid(params->egid),
15311801Sbrandon.potter@amd.com      _pid(params->pid), _ppid(params->ppid)
1542SN/A{
15510930Sbrandon.potter@amd.com    int sim_fd;
15610930Sbrandon.potter@amd.com    std::map<string,int>::iterator it;
1575154Sgblack@eecs.umich.edu
15810930Sbrandon.potter@amd.com    // Search through the input options and set fd if match is found;
15910930Sbrandon.potter@amd.com    // otherwise, open an input file and seek to location.
16010932Sbrandon.potter@amd.com    FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
16110930Sbrandon.potter@amd.com    if ((it = imap.find(params->input)) != imap.end())
16210930Sbrandon.potter@amd.com        sim_fd = it->second;
16310930Sbrandon.potter@amd.com    else
16410930Sbrandon.potter@amd.com        sim_fd = openInputFile(params->input);
16510930Sbrandon.potter@amd.com    fde_stdin->set(sim_fd, params->input, O_RDONLY, -1, false);
1665154Sgblack@eecs.umich.edu
16710930Sbrandon.potter@amd.com    // Search through the output/error options and set fd if match is found;
16810930Sbrandon.potter@amd.com    // otherwise, open an output file and seek to location.
16910932Sbrandon.potter@amd.com    FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
17010930Sbrandon.potter@amd.com    if ((it = oemap.find(params->output)) != oemap.end())
17110930Sbrandon.potter@amd.com        sim_fd = it->second;
1725154Sgblack@eecs.umich.edu    else
17310930Sbrandon.potter@amd.com        sim_fd = openOutputFile(params->output);
17410930Sbrandon.potter@amd.com    fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC,
17510930Sbrandon.potter@amd.com                    0664, false);
1765154Sgblack@eecs.umich.edu
17710932Sbrandon.potter@amd.com    FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
17810930Sbrandon.potter@amd.com    if (params->output == params->errout)
17910930Sbrandon.potter@amd.com        // Reuse the same file descriptor if these match.
18010930Sbrandon.potter@amd.com        sim_fd = fde_stdout->fd;
18110930Sbrandon.potter@amd.com    else if ((it = oemap.find(params->errout)) != oemap.end())
18210930Sbrandon.potter@amd.com        sim_fd = it->second;
1835154Sgblack@eecs.umich.edu    else
18410930Sbrandon.potter@amd.com        sim_fd = openOutputFile(params->errout);
18510930Sbrandon.potter@amd.com    fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC,
18610930Sbrandon.potter@amd.com                    0664, false);
1872SN/A
18811386Ssteve.reinhardt@amd.com    mmap_end = 0;
1891514SN/A    nxm_start = nxm_end = 0;
1902SN/A    // other parameters will be initialized when the program is loaded
1912SN/A}
1922SN/A
1932378SN/A
1942SN/Avoid
1952SN/AProcess::regStats()
1962SN/A{
19711522Sstephan.diestelhorst@arm.com    SimObject::regStats();
19811522Sstephan.diestelhorst@arm.com
199729SN/A    using namespace Stats;
2002SN/A
2012SN/A    num_syscalls
2028240Snate@binkert.org        .name(name() + ".num_syscalls")
2032SN/A        .desc("Number of system calls")
2042SN/A        ;
2052SN/A}
2062SN/A
20710930Sbrandon.potter@amd.comvoid
20810932Sbrandon.potter@amd.comProcess::inheritFDArray(Process *p)
2092SN/A{
21010930Sbrandon.potter@amd.com    fd_array = p->fd_array;
2112SN/A}
2122SN/A
2135713Shsul@eecs.umich.eduThreadContext *
2145713Shsul@eecs.umich.eduProcess::findFreeContext()
2152SN/A{
21610929Sbrandon.potter@amd.com    for (int id : contextIds) {
21710929Sbrandon.potter@amd.com        ThreadContext *tc = system->getThreadContext(id);
21810929Sbrandon.potter@amd.com        if (tc->status() == ThreadContext::Halted)
2195713Shsul@eecs.umich.edu            return tc;
2205512SMichael.Adler@intel.com    }
2215713Shsul@eecs.umich.edu    return NULL;
2222SN/A}
2232SN/A
2241395SN/Avoid
2257532Ssteve.reinhardt@amd.comProcess::initState()
2261395SN/A{
2275713Shsul@eecs.umich.edu    if (contextIds.empty())
2285713Shsul@eecs.umich.edu        fatal("Process %s is not associated with any HW contexts!\n", name());
2292378SN/A
2302680Sktlim@umich.edu    // first thread context for this process... initialize & enable
2315713Shsul@eecs.umich.edu    ThreadContext *tc = system->getThreadContext(contextIds[0]);
2321395SN/A
2331634SN/A    // mark this context as active so it will start ticking.
23410407Smitch.hayenga@arm.com    tc->activate();
23510298Salexandru.dutu@amd.com
23610298Salexandru.dutu@amd.com    pTable->initState(tc);
2371395SN/A}
2382SN/A
23910913Sandreas.sandberg@arm.comDrainState
24010913Sandreas.sandberg@arm.comProcess::drain()
24110905Sandreas.sandberg@arm.com{
24210932Sbrandon.potter@amd.com    findFileOffsets();
24310913Sandreas.sandberg@arm.com    return DrainState::Drained;
24410905Sandreas.sandberg@arm.com}
24510905Sandreas.sandberg@arm.com
2462SN/Aint
24710932Sbrandon.potter@amd.comProcess::allocFD(int sim_fd, const string& filename, int flags, int mode,
24810932Sbrandon.potter@amd.com                 bool pipe)
2492SN/A{
25010930Sbrandon.potter@amd.com    for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) {
25110932Sbrandon.potter@amd.com        FDEntry *fde = getFDEntry(free_fd);
25210930Sbrandon.potter@amd.com        if (fde->isFree()) {
25310930Sbrandon.potter@amd.com            fde->set(sim_fd, filename, flags, mode, pipe);
2541970SN/A            return free_fd;
2551970SN/A        }
2562SN/A    }
2572SN/A
25810930Sbrandon.potter@amd.com    fatal("Out of target file descriptors");
2591970SN/A}
2602SN/A
2611970SN/Avoid
26210932Sbrandon.potter@amd.comProcess::resetFDEntry(int tgt_fd)
2631970SN/A{
26410932Sbrandon.potter@amd.com    FDEntry *fde = getFDEntry(tgt_fd);
26510930Sbrandon.potter@amd.com    assert(fde->fd > -1);
2661970SN/A
26710930Sbrandon.potter@amd.com    fde->reset();
2682SN/A}
2692SN/A
2702SN/Aint
27110932Sbrandon.potter@amd.comProcess::getSimFD(int tgt_fd)
2722SN/A{
27310932Sbrandon.potter@amd.com    FDEntry *entry = getFDEntry(tgt_fd);
27410930Sbrandon.potter@amd.com    return entry ? entry->fd : -1;
2752SN/A}
2762SN/A
27710930Sbrandon.potter@amd.comFDEntry *
27810932Sbrandon.potter@amd.comProcess::getFDEntry(int tgt_fd)
2795282Srstrong@cs.ucsd.edu{
28010930Sbrandon.potter@amd.com    assert(0 <= tgt_fd && tgt_fd < fd_array->size());
28110930Sbrandon.potter@amd.com    return &(*fd_array)[tgt_fd];
28210929Sbrandon.potter@amd.com}
2835282Srstrong@cs.ucsd.edu
28410929Sbrandon.potter@amd.comint
28510932Sbrandon.potter@amd.comProcess::getTgtFD(int sim_fd)
28610929Sbrandon.potter@amd.com{
28710930Sbrandon.potter@amd.com    for (int index = 0; index < fd_array->size(); index++)
28810930Sbrandon.potter@amd.com        if ((*fd_array)[index].fd == sim_fd)
28910929Sbrandon.potter@amd.com            return index;
29010929Sbrandon.potter@amd.com    return -1;
2915282Srstrong@cs.ucsd.edu}
2927487Ssteve.reinhardt@amd.com
2938601Ssteve.reinhardt@amd.comvoid
2948601Ssteve.reinhardt@amd.comProcess::allocateMem(Addr vaddr, int64_t size, bool clobber)
2958601Ssteve.reinhardt@amd.com{
29610318Sandreas.hansson@arm.com    int npages = divCeil(size, (int64_t)PageBytes);
2978601Ssteve.reinhardt@amd.com    Addr paddr = system->allocPhysPages(npages);
29811294Sandreas.hansson@arm.com    pTable->map(vaddr, paddr, size,
29911294Sandreas.hansson@arm.com                clobber ? PageTableBase::Clobber : PageTableBase::Zero);
3008601Ssteve.reinhardt@amd.com}
3018601Ssteve.reinhardt@amd.com
3024434Ssaidi@eecs.umich.edubool
3038539Sgblack@eecs.umich.eduProcess::fixupStackFault(Addr vaddr)
3044434Ssaidi@eecs.umich.edu{
3058539Sgblack@eecs.umich.edu    // Check if this is already on the stack and there's just no page there
3068539Sgblack@eecs.umich.edu    // yet.
3074434Ssaidi@eecs.umich.edu    if (vaddr >= stack_min && vaddr < stack_base) {
30810318Sandreas.hansson@arm.com        allocateMem(roundDown(vaddr, PageBytes), PageBytes);
3094434Ssaidi@eecs.umich.edu        return true;
3104434Ssaidi@eecs.umich.edu    }
3114434Ssaidi@eecs.umich.edu
3128539Sgblack@eecs.umich.edu    // We've accessed the next page of the stack, so extend it to include
3138539Sgblack@eecs.umich.edu    // this address.
3145154Sgblack@eecs.umich.edu    if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
3155154Sgblack@eecs.umich.edu        while (vaddr < stack_min) {
3165154Sgblack@eecs.umich.edu            stack_min -= TheISA::PageBytes;
3178539Sgblack@eecs.umich.edu            if (stack_base - stack_min > max_stack_size)
3185154Sgblack@eecs.umich.edu                fatal("Maximum stack size exceeded\n");
3198601Ssteve.reinhardt@amd.com            allocateMem(stack_min, TheISA::PageBytes);
3205823Ssaidi@eecs.umich.edu            inform("Increasing stack size by one page.");
3215154Sgblack@eecs.umich.edu        };
3224434Ssaidi@eecs.umich.edu        return true;
3234434Ssaidi@eecs.umich.edu    }
3244434Ssaidi@eecs.umich.edu    return false;
3254434Ssaidi@eecs.umich.edu}
3264434Ssaidi@eecs.umich.edu
3275282Srstrong@cs.ucsd.eduvoid
32810932Sbrandon.potter@amd.comProcess::fixFileOffsets()
3297487Ssteve.reinhardt@amd.com{
33010930Sbrandon.potter@amd.com    auto seek = [] (FDEntry *fde)
33110930Sbrandon.potter@amd.com    {
33210930Sbrandon.potter@amd.com        if (lseek(fde->fd, fde->fileOffset, SEEK_SET) < 0)
33310930Sbrandon.potter@amd.com            fatal("Unable to see to location in %s", fde->filename);
33410930Sbrandon.potter@amd.com    };
3355282Srstrong@cs.ucsd.edu
33610930Sbrandon.potter@amd.com    std::map<string,int>::iterator it;
3375282Srstrong@cs.ucsd.edu
33810930Sbrandon.potter@amd.com    // Search through the input options and set fd if match is found;
33910930Sbrandon.potter@amd.com    // otherwise, open an input file and seek to location.
34010932Sbrandon.potter@amd.com    FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
34111785Sjthestness@gmail.com
34211785Sjthestness@gmail.com    // Check if user has specified a different input file, and if so, use it
34311785Sjthestness@gmail.com    // instead of the file specified in the checkpoint. This also resets the
34411785Sjthestness@gmail.com    // file offset from the checkpointed value
34511785Sjthestness@gmail.com    string new_in = ((ProcessParams*)params())->input;
34611785Sjthestness@gmail.com    if (new_in != fde_stdin->filename) {
34711785Sjthestness@gmail.com        warn("Using new input file (%s) rather than checkpointed (%s)\n",
34811785Sjthestness@gmail.com             new_in, fde_stdin->filename);
34911785Sjthestness@gmail.com        fde_stdin->filename = new_in;
35011785Sjthestness@gmail.com        fde_stdin->fileOffset = 0;
35111785Sjthestness@gmail.com    }
35211785Sjthestness@gmail.com
35310930Sbrandon.potter@amd.com    if ((it = imap.find(fde_stdin->filename)) != imap.end()) {
35410930Sbrandon.potter@amd.com        fde_stdin->fd = it->second;
35510930Sbrandon.potter@amd.com    } else {
35610930Sbrandon.potter@amd.com        fde_stdin->fd = openInputFile(fde_stdin->filename);
35710930Sbrandon.potter@amd.com        seek(fde_stdin);
3585282Srstrong@cs.ucsd.edu    }
3595282Srstrong@cs.ucsd.edu
36010930Sbrandon.potter@amd.com    // Search through the output/error options and set fd if match is found;
36110930Sbrandon.potter@amd.com    // otherwise, open an output file and seek to location.
36210932Sbrandon.potter@amd.com    FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
36311785Sjthestness@gmail.com
36411785Sjthestness@gmail.com    // Check if user has specified a different output file, and if so, use it
36511785Sjthestness@gmail.com    // instead of the file specified in the checkpoint. This also resets the
36611785Sjthestness@gmail.com    // file offset from the checkpointed value
36711785Sjthestness@gmail.com    string new_out = ((ProcessParams*)params())->output;
36811785Sjthestness@gmail.com    if (new_out != fde_stdout->filename) {
36911785Sjthestness@gmail.com        warn("Using new output file (%s) rather than checkpointed (%s)\n",
37011785Sjthestness@gmail.com             new_out, fde_stdout->filename);
37111785Sjthestness@gmail.com        fde_stdout->filename = new_out;
37211785Sjthestness@gmail.com        fde_stdout->fileOffset = 0;
37311785Sjthestness@gmail.com    }
37411785Sjthestness@gmail.com
37510930Sbrandon.potter@amd.com    if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) {
37610930Sbrandon.potter@amd.com        fde_stdout->fd = it->second;
37710930Sbrandon.potter@amd.com    } else {
37810930Sbrandon.potter@amd.com        fde_stdout->fd = openOutputFile(fde_stdout->filename);
37910930Sbrandon.potter@amd.com        seek(fde_stdout);
3805282Srstrong@cs.ucsd.edu    }
3815282Srstrong@cs.ucsd.edu
38210932Sbrandon.potter@amd.com    FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
38311785Sjthestness@gmail.com
38411785Sjthestness@gmail.com    // Check if user has specified a different error file, and if so, use it
38511785Sjthestness@gmail.com    // instead of the file specified in the checkpoint. This also resets the
38611785Sjthestness@gmail.com    // file offset from the checkpointed value
38711785Sjthestness@gmail.com    string new_err = ((ProcessParams*)params())->errout;
38811785Sjthestness@gmail.com    if (new_err != fde_stderr->filename) {
38911785Sjthestness@gmail.com        warn("Using new error file (%s) rather than checkpointed (%s)\n",
39011785Sjthestness@gmail.com             new_err, fde_stderr->filename);
39111785Sjthestness@gmail.com        fde_stderr->filename = new_err;
39211785Sjthestness@gmail.com        fde_stderr->fileOffset = 0;
39311785Sjthestness@gmail.com    }
39411785Sjthestness@gmail.com
39510930Sbrandon.potter@amd.com    if (fde_stdout->filename == fde_stderr->filename) {
39610930Sbrandon.potter@amd.com        // Reuse the same file descriptor if these match.
39710930Sbrandon.potter@amd.com        fde_stderr->fd = fde_stdout->fd;
39810930Sbrandon.potter@amd.com    } else if ((it = oemap.find(fde_stderr->filename)) != oemap.end()) {
39910930Sbrandon.potter@amd.com        fde_stderr->fd = it->second;
40010930Sbrandon.potter@amd.com    } else {
40110930Sbrandon.potter@amd.com        fde_stderr->fd = openOutputFile(fde_stderr->filename);
40210930Sbrandon.potter@amd.com        seek(fde_stderr);
4035514SMichael.Adler@intel.com    }
4045282Srstrong@cs.ucsd.edu
40510930Sbrandon.potter@amd.com    for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) {
40610932Sbrandon.potter@amd.com        FDEntry *fde = getFDEntry(tgt_fd);
40710930Sbrandon.potter@amd.com        if (fde->fd == -1)
40810930Sbrandon.potter@amd.com            continue;
4095282Srstrong@cs.ucsd.edu
41010930Sbrandon.potter@amd.com        if (fde->isPipe) {
41110930Sbrandon.potter@amd.com            if (fde->filename == "PIPE-WRITE")
41210930Sbrandon.potter@amd.com                continue;
41310930Sbrandon.potter@amd.com            assert(fde->filename == "PIPE-READ");
4145282Srstrong@cs.ucsd.edu
41510930Sbrandon.potter@amd.com            int fds[2];
41610930Sbrandon.potter@amd.com            if (pipe(fds) < 0)
41710930Sbrandon.potter@amd.com                fatal("Unable to create new pipe");
4185282Srstrong@cs.ucsd.edu
41910930Sbrandon.potter@amd.com            fde->fd = fds[0];
4205282Srstrong@cs.ucsd.edu
42110932Sbrandon.potter@amd.com            FDEntry *fde_write = getFDEntry(fde->readPipeSource);
42211378Sbrandon.potter@amd.com            assert(fde_write->filename == "PIPE-WRITE");
42310930Sbrandon.potter@amd.com            fde_write->fd = fds[1];
42410930Sbrandon.potter@amd.com        } else {
42510930Sbrandon.potter@amd.com            fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode);
42610930Sbrandon.potter@amd.com            seek(fde);
4275282Srstrong@cs.ucsd.edu        }
4285282Srstrong@cs.ucsd.edu    }
4295282Srstrong@cs.ucsd.edu}
4307487Ssteve.reinhardt@amd.com
4315282Srstrong@cs.ucsd.eduvoid
43210932Sbrandon.potter@amd.comProcess::findFileOffsets()
4337487Ssteve.reinhardt@amd.com{
43410930Sbrandon.potter@amd.com    for (auto& fde : *fd_array) {
43510930Sbrandon.potter@amd.com        if (fde.fd != -1)
43610930Sbrandon.potter@amd.com            fde.fileOffset = lseek(fde.fd, 0, SEEK_CUR);
4375282Srstrong@cs.ucsd.edu    }
4385282Srstrong@cs.ucsd.edu}
4395282Srstrong@cs.ucsd.edu
4405282Srstrong@cs.ucsd.eduvoid
4417487Ssteve.reinhardt@amd.comProcess::setReadPipeSource(int read_pipe_fd, int source_fd)
4427487Ssteve.reinhardt@amd.com{
44310932Sbrandon.potter@amd.com    FDEntry *fde = getFDEntry(read_pipe_fd);
44410930Sbrandon.potter@amd.com    assert(source_fd >= -1);
44510930Sbrandon.potter@amd.com    fde->readPipeSource = source_fd;
4465282Srstrong@cs.ucsd.edu}
4475282Srstrong@cs.ucsd.edu
4483311Ssaidi@eecs.umich.eduvoid
44910905Sandreas.sandberg@arm.comProcess::serialize(CheckpointOut &cp) const
4503311Ssaidi@eecs.umich.edu{
4513311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(brk_point);
4523311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_base);
4533311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_size);
4543311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_min);
4553311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(next_thread_stack_base);
4563311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(mmap_end);
4573311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(nxm_start);
4583311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(nxm_end);
45910905Sandreas.sandberg@arm.com    pTable->serialize(cp);
46010930Sbrandon.potter@amd.com    for (int x = 0; x < fd_array->size(); x++) {
46110930Sbrandon.potter@amd.com        (*fd_array)[x].serializeSection(cp, csprintf("FDEntry%d", x));
4625282Srstrong@cs.ucsd.edu    }
4633311Ssaidi@eecs.umich.edu
4643311Ssaidi@eecs.umich.edu}
4653311Ssaidi@eecs.umich.edu
4663311Ssaidi@eecs.umich.eduvoid
46710905Sandreas.sandberg@arm.comProcess::unserialize(CheckpointIn &cp)
4683311Ssaidi@eecs.umich.edu{
4693311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(brk_point);
4703311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_base);
4713311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_size);
4723311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_min);
4733311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(next_thread_stack_base);
4743311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(mmap_end);
4753311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(nxm_start);
4763311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(nxm_end);
47710905Sandreas.sandberg@arm.com    pTable->unserialize(cp);
47810930Sbrandon.potter@amd.com    for (int x = 0; x < fd_array->size(); x++) {
47910932Sbrandon.potter@amd.com        FDEntry *fde = getFDEntry(x);
48010930Sbrandon.potter@amd.com        fde->unserializeSection(cp, csprintf("FDEntry%d", x));
4817487Ssteve.reinhardt@amd.com    }
48210932Sbrandon.potter@amd.com    fixFileOffsets();
4836820SLisa.Hsu@amd.com    // The above returns a bool so that you could do something if you don't
4846820SLisa.Hsu@amd.com    // find the param in the checkpoint if you wanted to, like set a default
48510930Sbrandon.potter@amd.com    // but in this case we'll just stick with the instantiated value if not
48610929Sbrandon.potter@amd.com    // found.
4873311Ssaidi@eecs.umich.edu}
4882SN/A
4892SN/A
4909110Ssteve.reinhardt@amd.combool
49110558Salexandru.dutu@amd.comProcess::map(Addr vaddr, Addr paddr, int size, bool cacheable)
4929110Ssteve.reinhardt@amd.com{
49310558Salexandru.dutu@amd.com    pTable->map(vaddr, paddr, size,
49411294Sandreas.hansson@arm.com                cacheable ? PageTableBase::Zero : PageTableBase::Uncacheable);
4959110Ssteve.reinhardt@amd.com    return true;
4969110Ssteve.reinhardt@amd.com}
4979110Ssteve.reinhardt@amd.com
4989110Ssteve.reinhardt@amd.com
4992SN/A////////////////////////////////////////////////////////////////////////
5002SN/A//
5012SN/A// LiveProcess member definitions
5022SN/A//
5032SN/A////////////////////////////////////////////////////////////////////////
5042SN/A
50512SN/A
50610499Ssteve.reinhardt@amd.comLiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile)
5075154Sgblack@eecs.umich.edu    : Process(params), objFile(_objFile),
50810496Ssteve.reinhardt@amd.com      argv(params->cmd), envp(params->env), cwd(params->cwd),
50911140Sjthestness@gmail.com      executable(params->executable),
51010496Ssteve.reinhardt@amd.com      drivers(params->drivers)
5112SN/A{
5123114Sgblack@eecs.umich.edu
5131158SN/A    // load up symbols, if any... these may be used for debugging or
5141158SN/A    // profiling.
5151158SN/A    if (!debugSymbolTable) {
5161158SN/A        debugSymbolTable = new SymbolTable();
5171158SN/A        if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
5189641Sguodeyuan@tsinghua.org.cn            !objFile->loadLocalSymbols(debugSymbolTable) ||
5199641Sguodeyuan@tsinghua.org.cn            !objFile->loadWeakSymbols(debugSymbolTable)) {
5201158SN/A            // didn't load any symbols
5211158SN/A            delete debugSymbolTable;
5221158SN/A            debugSymbolTable = NULL;
5231158SN/A        }
5241158SN/A    }
5252378SN/A}
5261158SN/A
5272378SN/Avoid
5282680Sktlim@umich.eduLiveProcess::syscall(int64_t callnum, ThreadContext *tc)
5292093SN/A{
5302093SN/A    num_syscalls++;
5312093SN/A
5322093SN/A    SyscallDesc *desc = getDesc(callnum);
5332093SN/A    if (desc == NULL)
5342093SN/A        fatal("Syscall %d out of range", callnum);
5352093SN/A
5362680Sktlim@umich.edu    desc->doSyscall(callnum, this, tc);
5372093SN/A}
5382SN/A
5396701Sgblack@eecs.umich.eduIntReg
5406701Sgblack@eecs.umich.eduLiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
5416701Sgblack@eecs.umich.edu{
5426701Sgblack@eecs.umich.edu    return getSyscallArg(tc, i);
5436701Sgblack@eecs.umich.edu}
5446701Sgblack@eecs.umich.edu
54510496Ssteve.reinhardt@amd.com
54610496Ssteve.reinhardt@amd.comEmulatedDriver *
54710496Ssteve.reinhardt@amd.comLiveProcess::findDriver(std::string filename)
54810496Ssteve.reinhardt@amd.com{
54910496Ssteve.reinhardt@amd.com    for (EmulatedDriver *d : drivers) {
55010496Ssteve.reinhardt@amd.com        if (d->match(filename))
55110496Ssteve.reinhardt@amd.com            return d;
55210496Ssteve.reinhardt@amd.com    }
55310496Ssteve.reinhardt@amd.com
55410496Ssteve.reinhardt@amd.com    return NULL;
55510496Ssteve.reinhardt@amd.com}
55610496Ssteve.reinhardt@amd.com
55711389Sbrandon.potter@amd.comvoid
55811389Sbrandon.potter@amd.comLiveProcess::updateBias()
55911389Sbrandon.potter@amd.com{
56011389Sbrandon.potter@amd.com    ObjectFile *interp = objFile->getInterpreter();
56111389Sbrandon.potter@amd.com
56211389Sbrandon.potter@amd.com    if (!interp || !interp->relocatable())
56311389Sbrandon.potter@amd.com        return;
56411389Sbrandon.potter@amd.com
56511389Sbrandon.potter@amd.com    // Determine how large the interpreters footprint will be in the process
56611389Sbrandon.potter@amd.com    // address space.
56711389Sbrandon.potter@amd.com    Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes);
56811389Sbrandon.potter@amd.com
56911389Sbrandon.potter@amd.com    // We are allocating the memory area; set the bias to the lowest address
57011389Sbrandon.potter@amd.com    // in the allocated memory region.
57111389Sbrandon.potter@amd.com    Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end;
57211389Sbrandon.potter@amd.com
57311389Sbrandon.potter@amd.com    // Adjust the process mmap area to give the interpreter room; the real
57411389Sbrandon.potter@amd.com    // execve system call would just invoke the kernel's internal mmap
57511389Sbrandon.potter@amd.com    // functions to make these adjustments.
57611389Sbrandon.potter@amd.com    mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize;
57711389Sbrandon.potter@amd.com
57811389Sbrandon.potter@amd.com    interp->updateBias(ld_bias);
57911389Sbrandon.potter@amd.com}
58011389Sbrandon.potter@amd.com
58111389Sbrandon.potter@amd.com
58211392Sbrandon.potter@amd.comObjectFile *
58311392Sbrandon.potter@amd.comLiveProcess::getInterpreter()
58411392Sbrandon.potter@amd.com{
58511392Sbrandon.potter@amd.com    return objFile->getInterpreter();
58611392Sbrandon.potter@amd.com}
58711392Sbrandon.potter@amd.com
58811392Sbrandon.potter@amd.com
58911389Sbrandon.potter@amd.comAddr
59011389Sbrandon.potter@amd.comLiveProcess::getBias()
59111389Sbrandon.potter@amd.com{
59211392Sbrandon.potter@amd.com    ObjectFile *interp = getInterpreter();
59311389Sbrandon.potter@amd.com
59411389Sbrandon.potter@amd.com    return interp ? interp->bias() : objFile->bias();
59511389Sbrandon.potter@amd.com}
59611389Sbrandon.potter@amd.com
59711389Sbrandon.potter@amd.com
59811389Sbrandon.potter@amd.comAddr
59911389Sbrandon.potter@amd.comLiveProcess::getStartPC()
60011389Sbrandon.potter@amd.com{
60111392Sbrandon.potter@amd.com    ObjectFile *interp = getInterpreter();
60211389Sbrandon.potter@amd.com
60311389Sbrandon.potter@amd.com    return interp ? interp->entryPoint() : objFile->entryPoint();
60411389Sbrandon.potter@amd.com}
60511389Sbrandon.potter@amd.com
60610496Ssteve.reinhardt@amd.com
6072715Sstever@eecs.umich.eduLiveProcess *
6085154Sgblack@eecs.umich.eduLiveProcess::create(LiveProcessParams * params)
6092715Sstever@eecs.umich.edu{
6102715Sstever@eecs.umich.edu    LiveProcess *process = NULL;
6112715Sstever@eecs.umich.edu
61211140Sjthestness@gmail.com    // If not specified, set the executable parameter equal to the
61311140Sjthestness@gmail.com    // simulated system's zeroth command line parameter
61411140Sjthestness@gmail.com    if (params->executable == "") {
61511140Sjthestness@gmail.com        params->executable = params->cmd[0];
61611140Sjthestness@gmail.com    }
61711140Sjthestness@gmail.com
61811140Sjthestness@gmail.com    ObjectFile *objFile = createObjectFile(params->executable);
6192715Sstever@eecs.umich.edu    if (objFile == NULL) {
62011140Sjthestness@gmail.com        fatal("Can't load object file %s", params->executable);
6212715Sstever@eecs.umich.edu    }
6222715Sstever@eecs.umich.edu
6235089Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA
6245753Ssteve.reinhardt@amd.com    if (objFile->getArch() != ObjectFile::Alpha)
6255753Ssteve.reinhardt@amd.com        fatal("Object file architecture does not match compiled ISA (Alpha).");
6265753Ssteve.reinhardt@amd.com
6272715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
6285753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6295753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6305753Ssteve.reinhardt@amd.com        // fall through
6312715Sstever@eecs.umich.edu      case ObjectFile::Linux:
6325154Sgblack@eecs.umich.edu        process = new AlphaLinuxProcess(params, objFile);
6332715Sstever@eecs.umich.edu        break;
6342715Sstever@eecs.umich.edu
6352715Sstever@eecs.umich.edu      default:
6362715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6372715Sstever@eecs.umich.edu    }
6382715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA
6395753Ssteve.reinhardt@amd.com    if (objFile->getArch() != ObjectFile::SPARC64 &&
6405753Ssteve.reinhardt@amd.com        objFile->getArch() != ObjectFile::SPARC32)
6412715Sstever@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (SPARC).");
6422715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
6435753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6445753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6455753Ssteve.reinhardt@amd.com        // fall through
6462715Sstever@eecs.umich.edu      case ObjectFile::Linux:
6474111Sgblack@eecs.umich.edu        if (objFile->getArch() == ObjectFile::SPARC64) {
6485154Sgblack@eecs.umich.edu            process = new Sparc64LinuxProcess(params, objFile);
6494111Sgblack@eecs.umich.edu        } else {
6505154Sgblack@eecs.umich.edu            process = new Sparc32LinuxProcess(params, objFile);
6514111Sgblack@eecs.umich.edu        }
6522715Sstever@eecs.umich.edu        break;
6532715Sstever@eecs.umich.edu
6542715Sstever@eecs.umich.edu
6552715Sstever@eecs.umich.edu      case ObjectFile::Solaris:
6565154Sgblack@eecs.umich.edu        process = new SparcSolarisProcess(params, objFile);
6572715Sstever@eecs.umich.edu        break;
6585753Ssteve.reinhardt@amd.com
6592715Sstever@eecs.umich.edu      default:
6602715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6612715Sstever@eecs.umich.edu    }
6624157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA
6635874Sgblack@eecs.umich.edu    if (objFile->getArch() != ObjectFile::X86_64 &&
6645874Sgblack@eecs.umich.edu        objFile->getArch() != ObjectFile::I386)
6654166Sgblack@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (x86).");
6664157Sgblack@eecs.umich.edu    switch (objFile->getOpSys()) {
6675753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6685753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6695753Ssteve.reinhardt@amd.com        // fall through
6704166Sgblack@eecs.umich.edu      case ObjectFile::Linux:
6715874Sgblack@eecs.umich.edu        if (objFile->getArch() == ObjectFile::X86_64) {
6725955Sgblack@eecs.umich.edu            process = new X86_64LinuxProcess(params, objFile);
6735874Sgblack@eecs.umich.edu        } else {
6745955Sgblack@eecs.umich.edu            process = new I386LinuxProcess(params, objFile);
6755874Sgblack@eecs.umich.edu        }
6764166Sgblack@eecs.umich.edu        break;
6775753Ssteve.reinhardt@amd.com
6784157Sgblack@eecs.umich.edu      default:
6794157Sgblack@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6804157Sgblack@eecs.umich.edu    }
6812715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA
6822715Sstever@eecs.umich.edu    if (objFile->getArch() != ObjectFile::Mips)
6832715Sstever@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (MIPS).");
6842715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
6855753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6865753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6875753Ssteve.reinhardt@amd.com        // fall through
6882715Sstever@eecs.umich.edu      case ObjectFile::Linux:
6895154Sgblack@eecs.umich.edu        process = new MipsLinuxProcess(params, objFile);
6902715Sstever@eecs.umich.edu        break;
6912715Sstever@eecs.umich.edu
6922715Sstever@eecs.umich.edu      default:
6932715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6942715Sstever@eecs.umich.edu    }
6955335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA
69610037SARM gem5 Developers    ObjectFile::Arch arch = objFile->getArch();
69710037SARM gem5 Developers    if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
69810037SARM gem5 Developers        arch != ObjectFile::Arm64)
6995335Shines@cs.fsu.edu        fatal("Object file architecture does not match compiled ISA (ARM).");
7005335Shines@cs.fsu.edu    switch (objFile->getOpSys()) {
7015753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
7025753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
7035753Ssteve.reinhardt@amd.com        // fall through
7045335Shines@cs.fsu.edu      case ObjectFile::Linux:
70510037SARM gem5 Developers        if (arch == ObjectFile::Arm64) {
70610037SARM gem5 Developers            process = new ArmLinuxProcess64(params, objFile,
70710037SARM gem5 Developers                                            objFile->getArch());
70810037SARM gem5 Developers        } else {
70910037SARM gem5 Developers            process = new ArmLinuxProcess32(params, objFile,
71010037SARM gem5 Developers                                            objFile->getArch());
71110037SARM gem5 Developers        }
7125335Shines@cs.fsu.edu        break;
71310810Sbr@bsdpad.com      case ObjectFile::FreeBSD:
71410810Sbr@bsdpad.com        if (arch == ObjectFile::Arm64) {
71510810Sbr@bsdpad.com            process = new ArmFreebsdProcess64(params, objFile,
71610810Sbr@bsdpad.com                                              objFile->getArch());
71710810Sbr@bsdpad.com        } else {
71810810Sbr@bsdpad.com            process = new ArmFreebsdProcess32(params, objFile,
71910810Sbr@bsdpad.com                                              objFile->getArch());
72010810Sbr@bsdpad.com        }
72110810Sbr@bsdpad.com        break;
7226392Ssaidi@eecs.umich.edu      case ObjectFile::LinuxArmOABI:
7236392Ssaidi@eecs.umich.edu        fatal("M5 does not support ARM OABI binaries. Please recompile with an"
7246392Ssaidi@eecs.umich.edu              " EABI compiler.");
7255335Shines@cs.fsu.edu      default:
7265335Shines@cs.fsu.edu        fatal("Unknown/unsupported operating system.");
7275335Shines@cs.fsu.edu    }
7286691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA
7296691Stjones1@inf.ed.ac.uk    if (objFile->getArch() != ObjectFile::Power)
7306691Stjones1@inf.ed.ac.uk        fatal("Object file architecture does not match compiled ISA (Power).");
7316691Stjones1@inf.ed.ac.uk    switch (objFile->getOpSys()) {
7326691Stjones1@inf.ed.ac.uk      case ObjectFile::UnknownOpSys:
7336691Stjones1@inf.ed.ac.uk        warn("Unknown operating system; assuming Linux.");
7346691Stjones1@inf.ed.ac.uk        // fall through
7356691Stjones1@inf.ed.ac.uk      case ObjectFile::Linux:
7366691Stjones1@inf.ed.ac.uk        process = new PowerLinuxProcess(params, objFile);
7376691Stjones1@inf.ed.ac.uk        break;
7386691Stjones1@inf.ed.ac.uk
7396691Stjones1@inf.ed.ac.uk      default:
7406691Stjones1@inf.ed.ac.uk        fatal("Unknown/unsupported operating system.");
7416691Stjones1@inf.ed.ac.uk    }
74211723Sar4jc@virginia.edu#elif THE_ISA == RISCV_ISA
74311723Sar4jc@virginia.edu    if (objFile->getArch() != ObjectFile::Riscv)
74411723Sar4jc@virginia.edu        fatal("Object file architecture does not match compiled ISA (RISCV).");
74511723Sar4jc@virginia.edu    switch (objFile->getOpSys()) {
74611723Sar4jc@virginia.edu      case ObjectFile::UnknownOpSys:
74711723Sar4jc@virginia.edu        warn("Unknown operating system; assuming Linux.");
74811723Sar4jc@virginia.edu        // fall through
74911723Sar4jc@virginia.edu      case ObjectFile::Linux:
75011723Sar4jc@virginia.edu        process = new RiscvLinuxProcess(params, objFile);
75111723Sar4jc@virginia.edu        break;
75211723Sar4jc@virginia.edu      default:
75311723Sar4jc@virginia.edu        fatal("Unknown/unsupported operating system.");
75411723Sar4jc@virginia.edu    }
7552715Sstever@eecs.umich.edu#else
7562715Sstever@eecs.umich.edu#error "THE_ISA not set"
7572715Sstever@eecs.umich.edu#endif
7582715Sstever@eecs.umich.edu
7592715Sstever@eecs.umich.edu    if (process == NULL)
7602715Sstever@eecs.umich.edu        fatal("Unknown error creating process object.");
7612715Sstever@eecs.umich.edu    return process;
7622715Sstever@eecs.umich.edu}
7632715Sstever@eecs.umich.edu
7644762Snate@binkert.orgLiveProcess *
7654762Snate@binkert.orgLiveProcessParams::create()
7662715Sstever@eecs.umich.edu{
7675154Sgblack@eecs.umich.edu    return LiveProcess::create(this);
7682715Sstever@eecs.umich.edu}
769