process.cc revision 10554
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>
502SN/A#include <string>
512SN/A
5256SN/A#include "base/loader/object_file.hh"
531158SN/A#include "base/loader/symtab.hh"
548229Snate@binkert.org#include "base/intmath.hh"
55146SN/A#include "base/statistics.hh"
566658Snate@binkert.org#include "config/the_isa.hh"
572680Sktlim@umich.edu#include "cpu/thread_context.hh"
582378SN/A#include "mem/page_table.hh"
5910298Salexandru.dutu@amd.com#include "mem/multi_level_page_table.hh"
608706Sandreas.hansson@arm.com#include "mem/se_translating_port_proxy.hh"
618229Snate@binkert.org#include "params/LiveProcess.hh"
625154Sgblack@eecs.umich.edu#include "params/Process.hh"
635512SMichael.Adler@intel.com#include "sim/debug.hh"
64360SN/A#include "sim/process.hh"
654434Ssaidi@eecs.umich.edu#include "sim/process_impl.hh"
66695SN/A#include "sim/stats.hh"
672093SN/A#include "sim/syscall_emul.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#include "arch/alpha/tru64/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"
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"
842715Sstever@eecs.umich.edu#else
852715Sstever@eecs.umich.edu#error "THE_ISA not set"
862715Sstever@eecs.umich.edu#endif
872715Sstever@eecs.umich.edu
882715Sstever@eecs.umich.edu
892SN/Ausing namespace std;
902107SN/Ausing namespace TheISA;
912SN/A
922SN/A// current number of allocated processes
932SN/Aint num_processes = 0;
942SN/A
955758Shsul@eecs.umich.edutemplate<class IntType>
965771Shsul@eecs.umich.eduAuxVector<IntType>::AuxVector(IntType type, IntType val)
975758Shsul@eecs.umich.edu{
985758Shsul@eecs.umich.edu    a_type = TheISA::htog(type);
995758Shsul@eecs.umich.edu    a_val = TheISA::htog(val);
1005758Shsul@eecs.umich.edu}
1015758Shsul@eecs.umich.edu
1028737Skoansin.tan@gmail.comtemplate struct AuxVector<uint32_t>;
1038737Skoansin.tan@gmail.comtemplate struct AuxVector<uint64_t>;
1045758Shsul@eecs.umich.edu
1055154Sgblack@eecs.umich.eduProcess::Process(ProcessParams * params)
1067532Ssteve.reinhardt@amd.com    : SimObject(params), system(params->system),
1078852Sandreas.hansson@arm.com      max_stack_size(params->max_stack_size),
1088852Sandreas.hansson@arm.com      M5_pid(system->allocatePID()),
10910299Salexandru.dutu@amd.com      useArchPT(params->useArchPT),
11010554Salexandru.dutu@amd.com      kvmInSE(params->kvmInSE),
11110299Salexandru.dutu@amd.com      pTable(useArchPT ?
11210299Salexandru.dutu@amd.com        static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) :
11310299Salexandru.dutu@amd.com        static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ),
1148852Sandreas.hansson@arm.com      initVirtMem(system->getSystemPort(), this,
1158852Sandreas.hansson@arm.com                  SETranslatingPortProxy::Always)
1162SN/A{
1175154Sgblack@eecs.umich.edu    string in = params->input;
1185154Sgblack@eecs.umich.edu    string out = params->output;
1195514SMichael.Adler@intel.com    string err = params->errout;
1205154Sgblack@eecs.umich.edu
1215154Sgblack@eecs.umich.edu    // initialize file descriptors to default: same as simulator
1225154Sgblack@eecs.umich.edu    int stdin_fd, stdout_fd, stderr_fd;
1235154Sgblack@eecs.umich.edu
1245154Sgblack@eecs.umich.edu    if (in == "stdin" || in == "cin")
1255154Sgblack@eecs.umich.edu        stdin_fd = STDIN_FILENO;
1265154Sgblack@eecs.umich.edu    else if (in == "None")
1275154Sgblack@eecs.umich.edu        stdin_fd = -1;
1285154Sgblack@eecs.umich.edu    else
1295154Sgblack@eecs.umich.edu        stdin_fd = Process::openInputFile(in);
1305154Sgblack@eecs.umich.edu
1315154Sgblack@eecs.umich.edu    if (out == "stdout" || out == "cout")
1325154Sgblack@eecs.umich.edu        stdout_fd = STDOUT_FILENO;
1335154Sgblack@eecs.umich.edu    else if (out == "stderr" || out == "cerr")
1345154Sgblack@eecs.umich.edu        stdout_fd = STDERR_FILENO;
1355154Sgblack@eecs.umich.edu    else if (out == "None")
1365154Sgblack@eecs.umich.edu        stdout_fd = -1;
1375154Sgblack@eecs.umich.edu    else
1385154Sgblack@eecs.umich.edu        stdout_fd = Process::openOutputFile(out);
1395154Sgblack@eecs.umich.edu
1405514SMichael.Adler@intel.com    if (err == "stdout" || err == "cout")
1415514SMichael.Adler@intel.com        stderr_fd = STDOUT_FILENO;
1425514SMichael.Adler@intel.com    else if (err == "stderr" || err == "cerr")
1435514SMichael.Adler@intel.com        stderr_fd = STDERR_FILENO;
1445514SMichael.Adler@intel.com    else if (err == "None")
1455514SMichael.Adler@intel.com        stderr_fd = -1;
1465514SMichael.Adler@intel.com    else if (err == out)
1475514SMichael.Adler@intel.com        stderr_fd = stdout_fd;
1485514SMichael.Adler@intel.com    else
1495514SMichael.Adler@intel.com        stderr_fd = Process::openOutputFile(err);
1505154Sgblack@eecs.umich.edu
1512SN/A    // initialize first 3 fds (stdin, stdout, stderr)
1525282Srstrong@cs.ucsd.edu    Process::FdMap *fdo = &fd_map[STDIN_FILENO];
1535282Srstrong@cs.ucsd.edu    fdo->fd = stdin_fd;
1545282Srstrong@cs.ucsd.edu    fdo->filename = in;
1555282Srstrong@cs.ucsd.edu    fdo->flags = O_RDONLY;
1565282Srstrong@cs.ucsd.edu    fdo->mode = -1;
1575282Srstrong@cs.ucsd.edu    fdo->fileOffset = 0;
1585282Srstrong@cs.ucsd.edu
1595282Srstrong@cs.ucsd.edu    fdo =  &fd_map[STDOUT_FILENO];
1605282Srstrong@cs.ucsd.edu    fdo->fd = stdout_fd;
1615282Srstrong@cs.ucsd.edu    fdo->filename = out;
1625282Srstrong@cs.ucsd.edu    fdo->flags =  O_WRONLY | O_CREAT | O_TRUNC;
1635282Srstrong@cs.ucsd.edu    fdo->mode = 0774;
1645282Srstrong@cs.ucsd.edu    fdo->fileOffset = 0;
1655282Srstrong@cs.ucsd.edu
1665282Srstrong@cs.ucsd.edu    fdo = &fd_map[STDERR_FILENO];
1675282Srstrong@cs.ucsd.edu    fdo->fd = stderr_fd;
1685514SMichael.Adler@intel.com    fdo->filename = err;
1695282Srstrong@cs.ucsd.edu    fdo->flags = O_WRONLY;
1705282Srstrong@cs.ucsd.edu    fdo->mode = -1;
1715282Srstrong@cs.ucsd.edu    fdo->fileOffset = 0;
1725282Srstrong@cs.ucsd.edu
1732SN/A
1742SN/A    // mark remaining fds as free
1752SN/A    for (int i = 3; i <= MAX_FD; ++i) {
1769550Sandreas.hansson@arm.com        fdo = &fd_map[i];
1775282Srstrong@cs.ucsd.edu        fdo->fd = -1;
1782SN/A    }
1792SN/A
1801450SN/A    mmap_start = mmap_end = 0;
1811514SN/A    nxm_start = nxm_end = 0;
1822SN/A    // other parameters will be initialized when the program is loaded
1832SN/A}
1842SN/A
1852378SN/A
1862SN/Avoid
1872SN/AProcess::regStats()
1882SN/A{
189729SN/A    using namespace Stats;
1902SN/A
1912SN/A    num_syscalls
1928240Snate@binkert.org        .name(name() + ".num_syscalls")
1932SN/A        .desc("Number of system calls")
1942SN/A        ;
1952SN/A}
1962SN/A
1972SN/A//
1982SN/A// static helper functions
1992SN/A//
2002SN/Aint
2012SN/AProcess::openInputFile(const string &filename)
2022SN/A{
2032SN/A    int fd = open(filename.c_str(), O_RDONLY);
2042SN/A
2052SN/A    if (fd == -1) {
2062SN/A        perror(NULL);
2072SN/A        cerr << "unable to open \"" << filename << "\" for reading\n";
2082SN/A        fatal("can't open input file");
2092SN/A    }
2102SN/A
2112SN/A    return fd;
2122SN/A}
2132SN/A
2142SN/A
2152SN/Aint
2162SN/AProcess::openOutputFile(const string &filename)
2172SN/A{
2185514SMichael.Adler@intel.com    int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664);
2192SN/A
2202SN/A    if (fd == -1) {
2212SN/A        perror(NULL);
2222SN/A        cerr << "unable to open \"" << filename << "\" for writing\n";
2232SN/A        fatal("can't open output file");
2242SN/A    }
2252SN/A
2262SN/A    return fd;
2272SN/A}
2282SN/A
2295713Shsul@eecs.umich.eduThreadContext *
2305713Shsul@eecs.umich.eduProcess::findFreeContext()
2312SN/A{
2325713Shsul@eecs.umich.edu    int size = contextIds.size();
2335713Shsul@eecs.umich.edu    ThreadContext *tc;
2345713Shsul@eecs.umich.edu    for (int i = 0; i < size; ++i) {
2355713Shsul@eecs.umich.edu        tc = system->getThreadContext(contextIds[i]);
2366029Ssteve.reinhardt@amd.com        if (tc->status() == ThreadContext::Halted) {
2375713Shsul@eecs.umich.edu            // inactive context, free to use
2385713Shsul@eecs.umich.edu            return tc;
2395713Shsul@eecs.umich.edu        }
2405512SMichael.Adler@intel.com    }
2415713Shsul@eecs.umich.edu    return NULL;
2422SN/A}
2432SN/A
2441395SN/Avoid
2457532Ssteve.reinhardt@amd.comProcess::initState()
2461395SN/A{
2475713Shsul@eecs.umich.edu    if (contextIds.empty())
2485713Shsul@eecs.umich.edu        fatal("Process %s is not associated with any HW contexts!\n", name());
2492378SN/A
2502680Sktlim@umich.edu    // first thread context for this process... initialize & enable
2515713Shsul@eecs.umich.edu    ThreadContext *tc = system->getThreadContext(contextIds[0]);
2521395SN/A
2531634SN/A    // mark this context as active so it will start ticking.
25410407Smitch.hayenga@arm.com    tc->activate();
25510298Salexandru.dutu@amd.com
25610298Salexandru.dutu@amd.com    pTable->initState(tc);
2571395SN/A}
2582SN/A
2592SN/A// map simulator fd sim_fd to target fd tgt_fd
2602SN/Avoid
2612SN/AProcess::dup_fd(int sim_fd, int tgt_fd)
2622SN/A{
2632SN/A    if (tgt_fd < 0 || tgt_fd > MAX_FD)
2642SN/A        panic("Process::dup_fd tried to dup past MAX_FD (%d)", tgt_fd);
2652SN/A
2665282Srstrong@cs.ucsd.edu    Process::FdMap *fdo = &fd_map[tgt_fd];
2675282Srstrong@cs.ucsd.edu    fdo->fd = sim_fd;
2682SN/A}
2692SN/A
2702SN/A
2712SN/A// generate new target fd for sim_fd
2722SN/Aint
2735282Srstrong@cs.ucsd.eduProcess::alloc_fd(int sim_fd, string filename, int flags, int mode, bool pipe)
2742SN/A{
2752SN/A    // in case open() returns an error, don't allocate a new fd
2762SN/A    if (sim_fd == -1)
2772SN/A        return -1;
2782SN/A
2792SN/A    // find first free target fd
2805282Srstrong@cs.ucsd.edu    for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
2815282Srstrong@cs.ucsd.edu        Process::FdMap *fdo = &fd_map[free_fd];
28210496Ssteve.reinhardt@amd.com        if (fdo->fd == -1 && fdo->driver == NULL) {
2835282Srstrong@cs.ucsd.edu            fdo->fd = sim_fd;
2845282Srstrong@cs.ucsd.edu            fdo->filename = filename;
2855282Srstrong@cs.ucsd.edu            fdo->mode = mode;
2865282Srstrong@cs.ucsd.edu            fdo->fileOffset = 0;
2875282Srstrong@cs.ucsd.edu            fdo->flags = flags;
2885282Srstrong@cs.ucsd.edu            fdo->isPipe = pipe;
2895282Srstrong@cs.ucsd.edu            fdo->readPipeSource = 0;
2901970SN/A            return free_fd;
2911970SN/A        }
2922SN/A    }
2932SN/A
2941970SN/A    panic("Process::alloc_fd: out of file descriptors!");
2951970SN/A}
2962SN/A
2971970SN/A
2981970SN/A// free target fd (e.g., after close)
2991970SN/Avoid
3001970SN/AProcess::free_fd(int tgt_fd)
3011970SN/A{
3025282Srstrong@cs.ucsd.edu    Process::FdMap *fdo = &fd_map[tgt_fd];
3035282Srstrong@cs.ucsd.edu    if (fdo->fd == -1)
3041970SN/A        warn("Process::free_fd: request to free unused fd %d", tgt_fd);
3051970SN/A
3065282Srstrong@cs.ucsd.edu    fdo->fd = -1;
3075282Srstrong@cs.ucsd.edu    fdo->filename = "NULL";
3085282Srstrong@cs.ucsd.edu    fdo->mode = 0;
3095282Srstrong@cs.ucsd.edu    fdo->fileOffset = 0;
3105282Srstrong@cs.ucsd.edu    fdo->flags = 0;
3115282Srstrong@cs.ucsd.edu    fdo->isPipe = false;
3125282Srstrong@cs.ucsd.edu    fdo->readPipeSource = 0;
31310496Ssteve.reinhardt@amd.com    fdo->driver = NULL;
3142SN/A}
3152SN/A
3162SN/A
3172SN/A// look up simulator fd for given target fd
3182SN/Aint
3192SN/AProcess::sim_fd(int tgt_fd)
3202SN/A{
3218324Ssteve.reinhardt@amd.com    if (tgt_fd < 0 || tgt_fd > MAX_FD)
3222SN/A        return -1;
3232SN/A
3245282Srstrong@cs.ucsd.edu    return fd_map[tgt_fd].fd;
3252SN/A}
3262SN/A
3275282Srstrong@cs.ucsd.eduProcess::FdMap *
3285282Srstrong@cs.ucsd.eduProcess::sim_fd_obj(int tgt_fd)
3295282Srstrong@cs.ucsd.edu{
3308324Ssteve.reinhardt@amd.com    if (tgt_fd < 0 || tgt_fd > MAX_FD)
3318324Ssteve.reinhardt@amd.com        return NULL;
3325282Srstrong@cs.ucsd.edu
3335282Srstrong@cs.ucsd.edu    return &fd_map[tgt_fd];
3345282Srstrong@cs.ucsd.edu}
3357487Ssteve.reinhardt@amd.com
3368601Ssteve.reinhardt@amd.comvoid
3378601Ssteve.reinhardt@amd.comProcess::allocateMem(Addr vaddr, int64_t size, bool clobber)
3388601Ssteve.reinhardt@amd.com{
33910318Sandreas.hansson@arm.com    int npages = divCeil(size, (int64_t)PageBytes);
3408601Ssteve.reinhardt@amd.com    Addr paddr = system->allocPhysPages(npages);
3418601Ssteve.reinhardt@amd.com    pTable->map(vaddr, paddr, size, clobber);
3428601Ssteve.reinhardt@amd.com}
3438601Ssteve.reinhardt@amd.com
3444434Ssaidi@eecs.umich.edubool
3458539Sgblack@eecs.umich.eduProcess::fixupStackFault(Addr vaddr)
3464434Ssaidi@eecs.umich.edu{
3478539Sgblack@eecs.umich.edu    // Check if this is already on the stack and there's just no page there
3488539Sgblack@eecs.umich.edu    // yet.
3494434Ssaidi@eecs.umich.edu    if (vaddr >= stack_min && vaddr < stack_base) {
35010318Sandreas.hansson@arm.com        allocateMem(roundDown(vaddr, PageBytes), PageBytes);
3514434Ssaidi@eecs.umich.edu        return true;
3524434Ssaidi@eecs.umich.edu    }
3534434Ssaidi@eecs.umich.edu
3548539Sgblack@eecs.umich.edu    // We've accessed the next page of the stack, so extend it to include
3558539Sgblack@eecs.umich.edu    // this address.
3565154Sgblack@eecs.umich.edu    if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
3575154Sgblack@eecs.umich.edu        while (vaddr < stack_min) {
3585154Sgblack@eecs.umich.edu            stack_min -= TheISA::PageBytes;
3598539Sgblack@eecs.umich.edu            if (stack_base - stack_min > max_stack_size)
3605154Sgblack@eecs.umich.edu                fatal("Maximum stack size exceeded\n");
3618601Ssteve.reinhardt@amd.com            allocateMem(stack_min, TheISA::PageBytes);
3625823Ssaidi@eecs.umich.edu            inform("Increasing stack size by one page.");
3635154Sgblack@eecs.umich.edu        };
3644434Ssaidi@eecs.umich.edu        return true;
3654434Ssaidi@eecs.umich.edu    }
3664434Ssaidi@eecs.umich.edu    return false;
3674434Ssaidi@eecs.umich.edu}
3684434Ssaidi@eecs.umich.edu
3697487Ssteve.reinhardt@amd.com// find all offsets for currently open files and save them
3705282Srstrong@cs.ucsd.eduvoid
3717487Ssteve.reinhardt@amd.comProcess::fix_file_offsets()
3727487Ssteve.reinhardt@amd.com{
3735282Srstrong@cs.ucsd.edu    Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO];
3745282Srstrong@cs.ucsd.edu    Process::FdMap *fdo_stdout = &fd_map[STDOUT_FILENO];
3755282Srstrong@cs.ucsd.edu    Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO];
3765282Srstrong@cs.ucsd.edu    string in = fdo_stdin->filename;
3775282Srstrong@cs.ucsd.edu    string out = fdo_stdout->filename;
3785514SMichael.Adler@intel.com    string err = fdo_stderr->filename;
3795282Srstrong@cs.ucsd.edu
3805282Srstrong@cs.ucsd.edu    // initialize file descriptors to default: same as simulator
3815282Srstrong@cs.ucsd.edu    int stdin_fd, stdout_fd, stderr_fd;
3825282Srstrong@cs.ucsd.edu
3835282Srstrong@cs.ucsd.edu    if (in == "stdin" || in == "cin")
3845282Srstrong@cs.ucsd.edu        stdin_fd = STDIN_FILENO;
3855282Srstrong@cs.ucsd.edu    else if (in == "None")
3865282Srstrong@cs.ucsd.edu        stdin_fd = -1;
3877487Ssteve.reinhardt@amd.com    else {
3887487Ssteve.reinhardt@amd.com        // open standard in and seek to the right location
3895282Srstrong@cs.ucsd.edu        stdin_fd = Process::openInputFile(in);
3905282Srstrong@cs.ucsd.edu        if (lseek(stdin_fd, fdo_stdin->fileOffset, SEEK_SET) < 0)
3915282Srstrong@cs.ucsd.edu            panic("Unable to seek to correct location in file: %s", in);
3925282Srstrong@cs.ucsd.edu    }
3935282Srstrong@cs.ucsd.edu
3945282Srstrong@cs.ucsd.edu    if (out == "stdout" || out == "cout")
3955282Srstrong@cs.ucsd.edu        stdout_fd = STDOUT_FILENO;
3965282Srstrong@cs.ucsd.edu    else if (out == "stderr" || out == "cerr")
3975282Srstrong@cs.ucsd.edu        stdout_fd = STDERR_FILENO;
3985282Srstrong@cs.ucsd.edu    else if (out == "None")
3995282Srstrong@cs.ucsd.edu        stdout_fd = -1;
4007487Ssteve.reinhardt@amd.com    else {
4015282Srstrong@cs.ucsd.edu        stdout_fd = Process::openOutputFile(out);
4025514SMichael.Adler@intel.com        if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0)
4035514SMichael.Adler@intel.com            panic("Unable to seek to correct location in file: %s", out);
4045282Srstrong@cs.ucsd.edu    }
4055282Srstrong@cs.ucsd.edu
4065514SMichael.Adler@intel.com    if (err == "stdout" || err == "cout")
4075514SMichael.Adler@intel.com        stderr_fd = STDOUT_FILENO;
4085514SMichael.Adler@intel.com    else if (err == "stderr" || err == "cerr")
4095514SMichael.Adler@intel.com        stderr_fd = STDERR_FILENO;
4105514SMichael.Adler@intel.com    else if (err == "None")
4115514SMichael.Adler@intel.com        stderr_fd = -1;
4125514SMichael.Adler@intel.com    else if (err == out)
4135514SMichael.Adler@intel.com        stderr_fd = stdout_fd;
4145514SMichael.Adler@intel.com    else {
4155514SMichael.Adler@intel.com        stderr_fd = Process::openOutputFile(err);
4165514SMichael.Adler@intel.com        if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0)
4175514SMichael.Adler@intel.com            panic("Unable to seek to correct location in file: %s", err);
4185514SMichael.Adler@intel.com    }
4195282Srstrong@cs.ucsd.edu
4205282Srstrong@cs.ucsd.edu    fdo_stdin->fd = stdin_fd;
4215282Srstrong@cs.ucsd.edu    fdo_stdout->fd = stdout_fd;
4225282Srstrong@cs.ucsd.edu    fdo_stderr->fd = stderr_fd;
4235282Srstrong@cs.ucsd.edu
4245282Srstrong@cs.ucsd.edu
4255282Srstrong@cs.ucsd.edu    for (int free_fd = 3; free_fd <= MAX_FD; ++free_fd) {
4265282Srstrong@cs.ucsd.edu        Process::FdMap *fdo = &fd_map[free_fd];
4275282Srstrong@cs.ucsd.edu        if (fdo->fd != -1) {
4285282Srstrong@cs.ucsd.edu            if (fdo->isPipe){
4295282Srstrong@cs.ucsd.edu                if (fdo->filename == "PIPE-WRITE")
4305282Srstrong@cs.ucsd.edu                    continue;
4315282Srstrong@cs.ucsd.edu                else {
4325282Srstrong@cs.ucsd.edu                    assert (fdo->filename == "PIPE-READ");
4335282Srstrong@cs.ucsd.edu                    //create a new pipe
4345282Srstrong@cs.ucsd.edu                    int fds[2];
4355282Srstrong@cs.ucsd.edu                    int pipe_retval = pipe(fds);
4365282Srstrong@cs.ucsd.edu
4375282Srstrong@cs.ucsd.edu                    if (pipe_retval < 0) {
4385282Srstrong@cs.ucsd.edu                        // error
4395282Srstrong@cs.ucsd.edu                        panic("Unable to create new pipe.");
4405282Srstrong@cs.ucsd.edu                    }
4415282Srstrong@cs.ucsd.edu                    fdo->fd = fds[0]; //set read pipe
4425282Srstrong@cs.ucsd.edu                    Process::FdMap *fdo_write = &fd_map[fdo->readPipeSource];
4435282Srstrong@cs.ucsd.edu                    if (fdo_write->filename != "PIPE-WRITE")
4445282Srstrong@cs.ucsd.edu                        panic ("Couldn't find write end of the pipe");
4455282Srstrong@cs.ucsd.edu
4465282Srstrong@cs.ucsd.edu                    fdo_write->fd = fds[1];//set write pipe
4475282Srstrong@cs.ucsd.edu               }
4485282Srstrong@cs.ucsd.edu            } else {
4495282Srstrong@cs.ucsd.edu                //Open file
4505282Srstrong@cs.ucsd.edu                int fd = open(fdo->filename.c_str(), fdo->flags, fdo->mode);
4515282Srstrong@cs.ucsd.edu
4525282Srstrong@cs.ucsd.edu                if (fd == -1)
4535282Srstrong@cs.ucsd.edu                    panic("Unable to open file: %s", fdo->filename);
4545282Srstrong@cs.ucsd.edu                fdo->fd = fd;
4555282Srstrong@cs.ucsd.edu
4565282Srstrong@cs.ucsd.edu                //Seek to correct location before checkpoint
4575282Srstrong@cs.ucsd.edu                if (lseek(fd,fdo->fileOffset, SEEK_SET) < 0)
4587487Ssteve.reinhardt@amd.com                    panic("Unable to seek to correct location in file: %s",
4597487Ssteve.reinhardt@amd.com                          fdo->filename);
4605282Srstrong@cs.ucsd.edu            }
4615282Srstrong@cs.ucsd.edu        }
4625282Srstrong@cs.ucsd.edu    }
4635282Srstrong@cs.ucsd.edu}
4647487Ssteve.reinhardt@amd.com
4655282Srstrong@cs.ucsd.eduvoid
4667487Ssteve.reinhardt@amd.comProcess::find_file_offsets()
4677487Ssteve.reinhardt@amd.com{
4685282Srstrong@cs.ucsd.edu    for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
4695282Srstrong@cs.ucsd.edu        Process::FdMap *fdo = &fd_map[free_fd];
4705282Srstrong@cs.ucsd.edu        if (fdo->fd != -1) {
4715282Srstrong@cs.ucsd.edu            fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR);
4727487Ssteve.reinhardt@amd.com        } else {
4735282Srstrong@cs.ucsd.edu                fdo->filename = "NULL";
4745282Srstrong@cs.ucsd.edu                fdo->fileOffset = 0;
4755282Srstrong@cs.ucsd.edu        }
4765282Srstrong@cs.ucsd.edu    }
4775282Srstrong@cs.ucsd.edu}
4785282Srstrong@cs.ucsd.edu
4795282Srstrong@cs.ucsd.eduvoid
4807487Ssteve.reinhardt@amd.comProcess::setReadPipeSource(int read_pipe_fd, int source_fd)
4817487Ssteve.reinhardt@amd.com{
4825282Srstrong@cs.ucsd.edu    Process::FdMap *fdo = &fd_map[read_pipe_fd];
4835282Srstrong@cs.ucsd.edu    fdo->readPipeSource = source_fd;
4845282Srstrong@cs.ucsd.edu}
4855282Srstrong@cs.ucsd.edu
4865282Srstrong@cs.ucsd.eduvoid
4875282Srstrong@cs.ucsd.eduProcess::FdMap::serialize(std::ostream &os)
4885282Srstrong@cs.ucsd.edu{
4895282Srstrong@cs.ucsd.edu    SERIALIZE_SCALAR(fd);
4905282Srstrong@cs.ucsd.edu    SERIALIZE_SCALAR(isPipe);
4915282Srstrong@cs.ucsd.edu    SERIALIZE_SCALAR(filename);
4925282Srstrong@cs.ucsd.edu    SERIALIZE_SCALAR(flags);
4935282Srstrong@cs.ucsd.edu    SERIALIZE_SCALAR(readPipeSource);
4945282Srstrong@cs.ucsd.edu    SERIALIZE_SCALAR(fileOffset);
4955282Srstrong@cs.ucsd.edu}
4965282Srstrong@cs.ucsd.edu
4975282Srstrong@cs.ucsd.eduvoid
4985282Srstrong@cs.ucsd.eduProcess::FdMap::unserialize(Checkpoint *cp, const std::string &section)
4995282Srstrong@cs.ucsd.edu{
5005282Srstrong@cs.ucsd.edu    UNSERIALIZE_SCALAR(fd);
5015282Srstrong@cs.ucsd.edu    UNSERIALIZE_SCALAR(isPipe);
5025282Srstrong@cs.ucsd.edu    UNSERIALIZE_SCALAR(filename);
5035282Srstrong@cs.ucsd.edu    UNSERIALIZE_SCALAR(flags);
5045282Srstrong@cs.ucsd.edu    UNSERIALIZE_SCALAR(readPipeSource);
5055282Srstrong@cs.ucsd.edu    UNSERIALIZE_SCALAR(fileOffset);
5065282Srstrong@cs.ucsd.edu}
5075282Srstrong@cs.ucsd.edu
5083311Ssaidi@eecs.umich.eduvoid
5093311Ssaidi@eecs.umich.eduProcess::serialize(std::ostream &os)
5103311Ssaidi@eecs.umich.edu{
5113311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(brk_point);
5123311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_base);
5133311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_size);
5143311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(stack_min);
5153311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(next_thread_stack_base);
5163311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(mmap_start);
5173311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(mmap_end);
5183311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(nxm_start);
5193311Ssaidi@eecs.umich.edu    SERIALIZE_SCALAR(nxm_end);
5205282Srstrong@cs.ucsd.edu    find_file_offsets();
5215282Srstrong@cs.ucsd.edu    pTable->serialize(os);
5225282Srstrong@cs.ucsd.edu    for (int x = 0; x <= MAX_FD; x++) {
5235282Srstrong@cs.ucsd.edu        nameOut(os, csprintf("%s.FdMap%d", name(), x));
5245282Srstrong@cs.ucsd.edu        fd_map[x].serialize(os);
5255282Srstrong@cs.ucsd.edu    }
5266820SLisa.Hsu@amd.com    SERIALIZE_SCALAR(M5_pid);
5273311Ssaidi@eecs.umich.edu
5283311Ssaidi@eecs.umich.edu}
5293311Ssaidi@eecs.umich.edu
5303311Ssaidi@eecs.umich.eduvoid
5313311Ssaidi@eecs.umich.eduProcess::unserialize(Checkpoint *cp, const std::string &section)
5323311Ssaidi@eecs.umich.edu{
5333311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(brk_point);
5343311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_base);
5353311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_size);
5363311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(stack_min);
5373311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(next_thread_stack_base);
5383311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(mmap_start);
5393311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(mmap_end);
5403311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(nxm_start);
5413311Ssaidi@eecs.umich.edu    UNSERIALIZE_SCALAR(nxm_end);
5423311Ssaidi@eecs.umich.edu    pTable->unserialize(cp, section);
5435282Srstrong@cs.ucsd.edu    for (int x = 0; x <= MAX_FD; x++) {
5445282Srstrong@cs.ucsd.edu        fd_map[x].unserialize(cp, csprintf("%s.FdMap%d", section, x));
5457487Ssteve.reinhardt@amd.com    }
5465282Srstrong@cs.ucsd.edu    fix_file_offsets();
5476820SLisa.Hsu@amd.com    UNSERIALIZE_OPT_SCALAR(M5_pid);
5486820SLisa.Hsu@amd.com    // The above returns a bool so that you could do something if you don't
5496820SLisa.Hsu@amd.com    // find the param in the checkpoint if you wanted to, like set a default
5506820SLisa.Hsu@amd.com    // but in this case we'll just stick with the instantianted value if not
5516820SLisa.Hsu@amd.com    // found.
5523311Ssaidi@eecs.umich.edu}
5532SN/A
5542SN/A
5559110Ssteve.reinhardt@amd.combool
5569110Ssteve.reinhardt@amd.comProcess::map(Addr vaddr, Addr paddr, int size)
5579110Ssteve.reinhardt@amd.com{
5589110Ssteve.reinhardt@amd.com    pTable->map(vaddr, paddr, size);
5599110Ssteve.reinhardt@amd.com    return true;
5609110Ssteve.reinhardt@amd.com}
5619110Ssteve.reinhardt@amd.com
5629110Ssteve.reinhardt@amd.com
5632SN/A////////////////////////////////////////////////////////////////////////
5642SN/A//
5652SN/A// LiveProcess member definitions
5662SN/A//
5672SN/A////////////////////////////////////////////////////////////////////////
5682SN/A
56912SN/A
57010499Ssteve.reinhardt@amd.comLiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile)
5715154Sgblack@eecs.umich.edu    : Process(params), objFile(_objFile),
57210496Ssteve.reinhardt@amd.com      argv(params->cmd), envp(params->env), cwd(params->cwd),
57310499Ssteve.reinhardt@amd.com      __uid(params->uid), __euid(params->euid),
57410499Ssteve.reinhardt@amd.com      __gid(params->gid), __egid(params->egid),
57510499Ssteve.reinhardt@amd.com      __pid(params->pid), __ppid(params->ppid),
57610496Ssteve.reinhardt@amd.com      drivers(params->drivers)
5772SN/A{
5783114Sgblack@eecs.umich.edu
5791158SN/A    // load up symbols, if any... these may be used for debugging or
5801158SN/A    // profiling.
5811158SN/A    if (!debugSymbolTable) {
5821158SN/A        debugSymbolTable = new SymbolTable();
5831158SN/A        if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
5849641Sguodeyuan@tsinghua.org.cn            !objFile->loadLocalSymbols(debugSymbolTable) ||
5859641Sguodeyuan@tsinghua.org.cn            !objFile->loadWeakSymbols(debugSymbolTable)) {
5861158SN/A            // didn't load any symbols
5871158SN/A            delete debugSymbolTable;
5881158SN/A            debugSymbolTable = NULL;
5891158SN/A        }
5901158SN/A    }
5912378SN/A}
5921158SN/A
5932378SN/Avoid
5942680Sktlim@umich.eduLiveProcess::syscall(int64_t callnum, ThreadContext *tc)
5952093SN/A{
5962093SN/A    num_syscalls++;
5972093SN/A
5982093SN/A    SyscallDesc *desc = getDesc(callnum);
5992093SN/A    if (desc == NULL)
6002093SN/A        fatal("Syscall %d out of range", callnum);
6012093SN/A
6022680Sktlim@umich.edu    desc->doSyscall(callnum, this, tc);
6032093SN/A}
6042SN/A
6056701Sgblack@eecs.umich.eduIntReg
6066701Sgblack@eecs.umich.eduLiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
6076701Sgblack@eecs.umich.edu{
6086701Sgblack@eecs.umich.edu    return getSyscallArg(tc, i);
6096701Sgblack@eecs.umich.edu}
6106701Sgblack@eecs.umich.edu
61110496Ssteve.reinhardt@amd.com
61210496Ssteve.reinhardt@amd.comEmulatedDriver *
61310496Ssteve.reinhardt@amd.comLiveProcess::findDriver(std::string filename)
61410496Ssteve.reinhardt@amd.com{
61510496Ssteve.reinhardt@amd.com    for (EmulatedDriver *d : drivers) {
61610496Ssteve.reinhardt@amd.com        if (d->match(filename))
61710496Ssteve.reinhardt@amd.com            return d;
61810496Ssteve.reinhardt@amd.com    }
61910496Ssteve.reinhardt@amd.com
62010496Ssteve.reinhardt@amd.com    return NULL;
62110496Ssteve.reinhardt@amd.com}
62210496Ssteve.reinhardt@amd.com
62310496Ssteve.reinhardt@amd.com
6242715Sstever@eecs.umich.eduLiveProcess *
6255154Sgblack@eecs.umich.eduLiveProcess::create(LiveProcessParams * params)
6262715Sstever@eecs.umich.edu{
6272715Sstever@eecs.umich.edu    LiveProcess *process = NULL;
6282715Sstever@eecs.umich.edu
6295154Sgblack@eecs.umich.edu    string executable =
6305154Sgblack@eecs.umich.edu        params->executable == "" ? params->cmd[0] : params->executable;
6312715Sstever@eecs.umich.edu    ObjectFile *objFile = createObjectFile(executable);
6322715Sstever@eecs.umich.edu    if (objFile == NULL) {
6332715Sstever@eecs.umich.edu        fatal("Can't load object file %s", executable);
6342715Sstever@eecs.umich.edu    }
6352715Sstever@eecs.umich.edu
6363917Ssaidi@eecs.umich.edu    if (objFile->isDynamic())
6373917Ssaidi@eecs.umich.edu       fatal("Object file is a dynamic executable however only static "
6385070Ssaidi@eecs.umich.edu             "executables are supported!\n       Please recompile your "
6393917Ssaidi@eecs.umich.edu             "executable as a static binary and try again.\n");
6403917Ssaidi@eecs.umich.edu
6415089Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA
6425753Ssteve.reinhardt@amd.com    if (objFile->getArch() != ObjectFile::Alpha)
6435753Ssteve.reinhardt@amd.com        fatal("Object file architecture does not match compiled ISA (Alpha).");
6445753Ssteve.reinhardt@amd.com
6452715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
6462715Sstever@eecs.umich.edu      case ObjectFile::Tru64:
6475154Sgblack@eecs.umich.edu        process = new AlphaTru64Process(params, objFile);
6482715Sstever@eecs.umich.edu        break;
6492715Sstever@eecs.umich.edu
6505753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6515753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6525753Ssteve.reinhardt@amd.com        // fall through
6532715Sstever@eecs.umich.edu      case ObjectFile::Linux:
6545154Sgblack@eecs.umich.edu        process = new AlphaLinuxProcess(params, objFile);
6552715Sstever@eecs.umich.edu        break;
6562715Sstever@eecs.umich.edu
6572715Sstever@eecs.umich.edu      default:
6582715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6592715Sstever@eecs.umich.edu    }
6602715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA
6615753Ssteve.reinhardt@amd.com    if (objFile->getArch() != ObjectFile::SPARC64 &&
6625753Ssteve.reinhardt@amd.com        objFile->getArch() != ObjectFile::SPARC32)
6632715Sstever@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (SPARC).");
6642715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
6655753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6665753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6675753Ssteve.reinhardt@amd.com        // fall through
6682715Sstever@eecs.umich.edu      case ObjectFile::Linux:
6694111Sgblack@eecs.umich.edu        if (objFile->getArch() == ObjectFile::SPARC64) {
6705154Sgblack@eecs.umich.edu            process = new Sparc64LinuxProcess(params, objFile);
6714111Sgblack@eecs.umich.edu        } else {
6725154Sgblack@eecs.umich.edu            process = new Sparc32LinuxProcess(params, objFile);
6734111Sgblack@eecs.umich.edu        }
6742715Sstever@eecs.umich.edu        break;
6752715Sstever@eecs.umich.edu
6762715Sstever@eecs.umich.edu
6772715Sstever@eecs.umich.edu      case ObjectFile::Solaris:
6785154Sgblack@eecs.umich.edu        process = new SparcSolarisProcess(params, objFile);
6792715Sstever@eecs.umich.edu        break;
6805753Ssteve.reinhardt@amd.com
6812715Sstever@eecs.umich.edu      default:
6822715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
6832715Sstever@eecs.umich.edu    }
6844157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA
6855874Sgblack@eecs.umich.edu    if (objFile->getArch() != ObjectFile::X86_64 &&
6865874Sgblack@eecs.umich.edu        objFile->getArch() != ObjectFile::I386)
6874166Sgblack@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (x86).");
6884157Sgblack@eecs.umich.edu    switch (objFile->getOpSys()) {
6895753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
6905753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
6915753Ssteve.reinhardt@amd.com        // fall through
6924166Sgblack@eecs.umich.edu      case ObjectFile::Linux:
6935874Sgblack@eecs.umich.edu        if (objFile->getArch() == ObjectFile::X86_64) {
6945955Sgblack@eecs.umich.edu            process = new X86_64LinuxProcess(params, objFile);
6955874Sgblack@eecs.umich.edu        } else {
6965955Sgblack@eecs.umich.edu            process = new I386LinuxProcess(params, objFile);
6975874Sgblack@eecs.umich.edu        }
6984166Sgblack@eecs.umich.edu        break;
6995753Ssteve.reinhardt@amd.com
7004157Sgblack@eecs.umich.edu      default:
7014157Sgblack@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
7024157Sgblack@eecs.umich.edu    }
7032715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA
7042715Sstever@eecs.umich.edu    if (objFile->getArch() != ObjectFile::Mips)
7052715Sstever@eecs.umich.edu        fatal("Object file architecture does not match compiled ISA (MIPS).");
7062715Sstever@eecs.umich.edu    switch (objFile->getOpSys()) {
7075753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
7085753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
7095753Ssteve.reinhardt@amd.com        // fall through
7102715Sstever@eecs.umich.edu      case ObjectFile::Linux:
7115154Sgblack@eecs.umich.edu        process = new MipsLinuxProcess(params, objFile);
7122715Sstever@eecs.umich.edu        break;
7132715Sstever@eecs.umich.edu
7142715Sstever@eecs.umich.edu      default:
7152715Sstever@eecs.umich.edu        fatal("Unknown/unsupported operating system.");
7162715Sstever@eecs.umich.edu    }
7175335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA
71810037SARM gem5 Developers    ObjectFile::Arch arch = objFile->getArch();
71910037SARM gem5 Developers    if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
72010037SARM gem5 Developers        arch != ObjectFile::Arm64)
7215335Shines@cs.fsu.edu        fatal("Object file architecture does not match compiled ISA (ARM).");
7225335Shines@cs.fsu.edu    switch (objFile->getOpSys()) {
7235753Ssteve.reinhardt@amd.com      case ObjectFile::UnknownOpSys:
7245753Ssteve.reinhardt@amd.com        warn("Unknown operating system; assuming Linux.");
7255753Ssteve.reinhardt@amd.com        // fall through
7265335Shines@cs.fsu.edu      case ObjectFile::Linux:
72710037SARM gem5 Developers        if (arch == ObjectFile::Arm64) {
72810037SARM gem5 Developers            process = new ArmLinuxProcess64(params, objFile,
72910037SARM gem5 Developers                                            objFile->getArch());
73010037SARM gem5 Developers        } else {
73110037SARM gem5 Developers            process = new ArmLinuxProcess32(params, objFile,
73210037SARM gem5 Developers                                            objFile->getArch());
73310037SARM gem5 Developers        }
7345335Shines@cs.fsu.edu        break;
7356392Ssaidi@eecs.umich.edu      case ObjectFile::LinuxArmOABI:
7366392Ssaidi@eecs.umich.edu        fatal("M5 does not support ARM OABI binaries. Please recompile with an"
7376392Ssaidi@eecs.umich.edu              " EABI compiler.");
7385335Shines@cs.fsu.edu      default:
7395335Shines@cs.fsu.edu        fatal("Unknown/unsupported operating system.");
7405335Shines@cs.fsu.edu    }
7416691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA
7426691Stjones1@inf.ed.ac.uk    if (objFile->getArch() != ObjectFile::Power)
7436691Stjones1@inf.ed.ac.uk        fatal("Object file architecture does not match compiled ISA (Power).");
7446691Stjones1@inf.ed.ac.uk    switch (objFile->getOpSys()) {
7456691Stjones1@inf.ed.ac.uk      case ObjectFile::UnknownOpSys:
7466691Stjones1@inf.ed.ac.uk        warn("Unknown operating system; assuming Linux.");
7476691Stjones1@inf.ed.ac.uk        // fall through
7486691Stjones1@inf.ed.ac.uk      case ObjectFile::Linux:
7496691Stjones1@inf.ed.ac.uk        process = new PowerLinuxProcess(params, objFile);
7506691Stjones1@inf.ed.ac.uk        break;
7516691Stjones1@inf.ed.ac.uk
7526691Stjones1@inf.ed.ac.uk      default:
7536691Stjones1@inf.ed.ac.uk        fatal("Unknown/unsupported operating system.");
7546691Stjones1@inf.ed.ac.uk    }
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