process.cc revision 10929
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" 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" 852715Sstever@eecs.umich.edu#else 862715Sstever@eecs.umich.edu#error "THE_ISA not set" 872715Sstever@eecs.umich.edu#endif 882715Sstever@eecs.umich.edu 892715Sstever@eecs.umich.edu 902SN/Ausing namespace std; 912107SN/Ausing namespace TheISA; 922SN/A 932SN/A// current number of allocated processes 942SN/Aint num_processes = 0; 952SN/A 965758Shsul@eecs.umich.edutemplate<class IntType> 975771Shsul@eecs.umich.eduAuxVector<IntType>::AuxVector(IntType type, IntType val) 985758Shsul@eecs.umich.edu{ 995758Shsul@eecs.umich.edu a_type = TheISA::htog(type); 1005758Shsul@eecs.umich.edu a_val = TheISA::htog(val); 1015758Shsul@eecs.umich.edu} 1025758Shsul@eecs.umich.edu 1038737Skoansin.tan@gmail.comtemplate struct AuxVector<uint32_t>; 1048737Skoansin.tan@gmail.comtemplate struct AuxVector<uint64_t>; 1055758Shsul@eecs.umich.edu 1065154Sgblack@eecs.umich.eduProcess::Process(ProcessParams * params) 1077532Ssteve.reinhardt@amd.com : SimObject(params), system(params->system), 10810559Sandreas.hansson@arm.com brk_point(0), stack_base(0), stack_size(0), stack_min(0), 1098852Sandreas.hansson@arm.com max_stack_size(params->max_stack_size), 11010559Sandreas.hansson@arm.com next_thread_stack_base(0), 1118852Sandreas.hansson@arm.com M5_pid(system->allocatePID()), 11210299Salexandru.dutu@amd.com useArchPT(params->useArchPT), 11310554Salexandru.dutu@amd.com kvmInSE(params->kvmInSE), 11410299Salexandru.dutu@amd.com pTable(useArchPT ? 11510299Salexandru.dutu@amd.com static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) : 11610299Salexandru.dutu@amd.com static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ), 1178852Sandreas.hansson@arm.com initVirtMem(system->getSystemPort(), this, 11810929Sbrandon.potter@amd.com SETranslatingPortProxy::Always), 11910929Sbrandon.potter@amd.com fd_map(new FdMap[NUM_FDS]) 1202SN/A{ 1215154Sgblack@eecs.umich.edu string in = params->input; 1225154Sgblack@eecs.umich.edu string out = params->output; 1235514SMichael.Adler@intel.com string err = params->errout; 1245154Sgblack@eecs.umich.edu 1255154Sgblack@eecs.umich.edu // initialize file descriptors to default: same as simulator 1265154Sgblack@eecs.umich.edu int stdin_fd, stdout_fd, stderr_fd; 1275154Sgblack@eecs.umich.edu 1285154Sgblack@eecs.umich.edu if (in == "stdin" || in == "cin") 1295154Sgblack@eecs.umich.edu stdin_fd = STDIN_FILENO; 1305154Sgblack@eecs.umich.edu else if (in == "None") 1315154Sgblack@eecs.umich.edu stdin_fd = -1; 1325154Sgblack@eecs.umich.edu else 1335154Sgblack@eecs.umich.edu stdin_fd = Process::openInputFile(in); 1345154Sgblack@eecs.umich.edu 1355154Sgblack@eecs.umich.edu if (out == "stdout" || out == "cout") 1365154Sgblack@eecs.umich.edu stdout_fd = STDOUT_FILENO; 1375154Sgblack@eecs.umich.edu else if (out == "stderr" || out == "cerr") 1385154Sgblack@eecs.umich.edu stdout_fd = STDERR_FILENO; 1395154Sgblack@eecs.umich.edu else if (out == "None") 1405154Sgblack@eecs.umich.edu stdout_fd = -1; 1415154Sgblack@eecs.umich.edu else 1425154Sgblack@eecs.umich.edu stdout_fd = Process::openOutputFile(out); 1435154Sgblack@eecs.umich.edu 1445514SMichael.Adler@intel.com if (err == "stdout" || err == "cout") 1455514SMichael.Adler@intel.com stderr_fd = STDOUT_FILENO; 1465514SMichael.Adler@intel.com else if (err == "stderr" || err == "cerr") 1475514SMichael.Adler@intel.com stderr_fd = STDERR_FILENO; 1485514SMichael.Adler@intel.com else if (err == "None") 1495514SMichael.Adler@intel.com stderr_fd = -1; 1505514SMichael.Adler@intel.com else if (err == out) 1515514SMichael.Adler@intel.com stderr_fd = stdout_fd; 1525514SMichael.Adler@intel.com else 1535514SMichael.Adler@intel.com stderr_fd = Process::openOutputFile(err); 1545154Sgblack@eecs.umich.edu 1552SN/A // initialize first 3 fds (stdin, stdout, stderr) 1565282Srstrong@cs.ucsd.edu Process::FdMap *fdo = &fd_map[STDIN_FILENO]; 1575282Srstrong@cs.ucsd.edu fdo->fd = stdin_fd; 1585282Srstrong@cs.ucsd.edu fdo->filename = in; 1595282Srstrong@cs.ucsd.edu fdo->flags = O_RDONLY; 1605282Srstrong@cs.ucsd.edu fdo->mode = -1; 1615282Srstrong@cs.ucsd.edu fdo->fileOffset = 0; 1625282Srstrong@cs.ucsd.edu 1635282Srstrong@cs.ucsd.edu fdo = &fd_map[STDOUT_FILENO]; 1645282Srstrong@cs.ucsd.edu fdo->fd = stdout_fd; 1655282Srstrong@cs.ucsd.edu fdo->filename = out; 1665282Srstrong@cs.ucsd.edu fdo->flags = O_WRONLY | O_CREAT | O_TRUNC; 1675282Srstrong@cs.ucsd.edu fdo->mode = 0774; 1685282Srstrong@cs.ucsd.edu fdo->fileOffset = 0; 1695282Srstrong@cs.ucsd.edu 1705282Srstrong@cs.ucsd.edu fdo = &fd_map[STDERR_FILENO]; 1715282Srstrong@cs.ucsd.edu fdo->fd = stderr_fd; 1725514SMichael.Adler@intel.com fdo->filename = err; 1735282Srstrong@cs.ucsd.edu fdo->flags = O_WRONLY; 1745282Srstrong@cs.ucsd.edu fdo->mode = -1; 1755282Srstrong@cs.ucsd.edu fdo->fileOffset = 0; 1765282Srstrong@cs.ucsd.edu 1772SN/A 1782SN/A // mark remaining fds as free 17910929Sbrandon.potter@amd.com for (int i = 3; i < NUM_FDS; ++i) { 1809550Sandreas.hansson@arm.com fdo = &fd_map[i]; 1815282Srstrong@cs.ucsd.edu fdo->fd = -1; 1822SN/A } 1832SN/A 1841450SN/A mmap_start = mmap_end = 0; 1851514SN/A nxm_start = nxm_end = 0; 1862SN/A // other parameters will be initialized when the program is loaded 1872SN/A} 1882SN/A 1892378SN/A 1902SN/Avoid 1912SN/AProcess::regStats() 1922SN/A{ 193729SN/A using namespace Stats; 1942SN/A 1952SN/A num_syscalls 1968240Snate@binkert.org .name(name() + ".num_syscalls") 1972SN/A .desc("Number of system calls") 1982SN/A ; 1992SN/A} 2002SN/A 2012SN/A// 2022SN/A// static helper functions 2032SN/A// 20410929Sbrandon.potter@amd.com 2052SN/Aint 2062SN/AProcess::openInputFile(const string &filename) 2072SN/A{ 2082SN/A int fd = open(filename.c_str(), O_RDONLY); 2092SN/A 2102SN/A if (fd == -1) { 2112SN/A perror(NULL); 2122SN/A cerr << "unable to open \"" << filename << "\" for reading\n"; 2132SN/A fatal("can't open input file"); 2142SN/A } 2152SN/A 2162SN/A return fd; 2172SN/A} 2182SN/A 2192SN/A 2202SN/Aint 2212SN/AProcess::openOutputFile(const string &filename) 2222SN/A{ 2235514SMichael.Adler@intel.com int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664); 2242SN/A 2252SN/A if (fd == -1) { 2262SN/A perror(NULL); 2272SN/A cerr << "unable to open \"" << filename << "\" for writing\n"; 2282SN/A fatal("can't open output file"); 2292SN/A } 2302SN/A 2312SN/A return fd; 2322SN/A} 2332SN/A 2345713Shsul@eecs.umich.eduThreadContext * 2355713Shsul@eecs.umich.eduProcess::findFreeContext() 2362SN/A{ 23710929Sbrandon.potter@amd.com for (int id : contextIds) { 23810929Sbrandon.potter@amd.com ThreadContext *tc = system->getThreadContext(id); 23910929Sbrandon.potter@amd.com if (tc->status() == ThreadContext::Halted) 2405713Shsul@eecs.umich.edu return tc; 2415512SMichael.Adler@intel.com } 2425713Shsul@eecs.umich.edu return NULL; 2432SN/A} 2442SN/A 2451395SN/Avoid 2467532Ssteve.reinhardt@amd.comProcess::initState() 2471395SN/A{ 2485713Shsul@eecs.umich.edu if (contextIds.empty()) 2495713Shsul@eecs.umich.edu fatal("Process %s is not associated with any HW contexts!\n", name()); 2502378SN/A 2512680Sktlim@umich.edu // first thread context for this process... initialize & enable 2525713Shsul@eecs.umich.edu ThreadContext *tc = system->getThreadContext(contextIds[0]); 2531395SN/A 2541634SN/A // mark this context as active so it will start ticking. 25510407Smitch.hayenga@arm.com tc->activate(); 25610298Salexandru.dutu@amd.com 25710298Salexandru.dutu@amd.com pTable->initState(tc); 2581395SN/A} 2592SN/A 26010913Sandreas.sandberg@arm.comDrainState 26110913Sandreas.sandberg@arm.comProcess::drain() 26210905Sandreas.sandberg@arm.com{ 26310905Sandreas.sandberg@arm.com find_file_offsets(); 26410913Sandreas.sandberg@arm.com return DrainState::Drained; 26510905Sandreas.sandberg@arm.com} 26610905Sandreas.sandberg@arm.com 2672SN/Aint 26810782Snilay@cs.wisc.eduProcess::alloc_fd(int sim_fd, const string& filename, int flags, int mode, 26910782Snilay@cs.wisc.edu bool pipe) 2702SN/A{ 2712SN/A // in case open() returns an error, don't allocate a new fd 2722SN/A if (sim_fd == -1) 2732SN/A return -1; 2742SN/A 2752SN/A // find first free target fd 27610929Sbrandon.potter@amd.com for (int free_fd = 0; free_fd < NUM_FDS; ++free_fd) { 2775282Srstrong@cs.ucsd.edu Process::FdMap *fdo = &fd_map[free_fd]; 27810496Ssteve.reinhardt@amd.com if (fdo->fd == -1 && fdo->driver == NULL) { 2795282Srstrong@cs.ucsd.edu fdo->fd = sim_fd; 2805282Srstrong@cs.ucsd.edu fdo->filename = filename; 2815282Srstrong@cs.ucsd.edu fdo->mode = mode; 2825282Srstrong@cs.ucsd.edu fdo->fileOffset = 0; 2835282Srstrong@cs.ucsd.edu fdo->flags = flags; 2845282Srstrong@cs.ucsd.edu fdo->isPipe = pipe; 2855282Srstrong@cs.ucsd.edu fdo->readPipeSource = 0; 2861970SN/A return free_fd; 2871970SN/A } 2882SN/A } 2892SN/A 2901970SN/A panic("Process::alloc_fd: out of file descriptors!"); 2911970SN/A} 2922SN/A 2931970SN/Avoid 29410929Sbrandon.potter@amd.comProcess::free_fdmap_entry(int tgt_fd) 2951970SN/A{ 2965282Srstrong@cs.ucsd.edu Process::FdMap *fdo = &fd_map[tgt_fd]; 29710929Sbrandon.potter@amd.com assert(fd_map[tgt_fd].fd > -1); 2981970SN/A 2995282Srstrong@cs.ucsd.edu fdo->fd = -1; 3005282Srstrong@cs.ucsd.edu fdo->filename = "NULL"; 3015282Srstrong@cs.ucsd.edu fdo->mode = 0; 3025282Srstrong@cs.ucsd.edu fdo->fileOffset = 0; 3035282Srstrong@cs.ucsd.edu fdo->flags = 0; 3045282Srstrong@cs.ucsd.edu fdo->isPipe = false; 3055282Srstrong@cs.ucsd.edu fdo->readPipeSource = 0; 30610496Ssteve.reinhardt@amd.com fdo->driver = NULL; 3072SN/A} 3082SN/A 3092SN/Aint 3102SN/AProcess::sim_fd(int tgt_fd) 3112SN/A{ 31210929Sbrandon.potter@amd.com FdMap *obj = sim_fd_obj(tgt_fd); 31310929Sbrandon.potter@amd.com return obj ? obj->fd : -1; 3142SN/A} 3152SN/A 3165282Srstrong@cs.ucsd.eduProcess::FdMap * 3175282Srstrong@cs.ucsd.eduProcess::sim_fd_obj(int tgt_fd) 3185282Srstrong@cs.ucsd.edu{ 31910929Sbrandon.potter@amd.com if (tgt_fd < 0 || tgt_fd >= NUM_FDS) 3208324Ssteve.reinhardt@amd.com return NULL; 32110929Sbrandon.potter@amd.com return &fd_map[tgt_fd]; 32210929Sbrandon.potter@amd.com} 3235282Srstrong@cs.ucsd.edu 32410929Sbrandon.potter@amd.comint 32510929Sbrandon.potter@amd.comProcess::tgt_fd(int sim_fd) 32610929Sbrandon.potter@amd.com{ 32710929Sbrandon.potter@amd.com for (int index = 0; index < NUM_FDS; ++index) 32810929Sbrandon.potter@amd.com if (fd_map[index].fd == sim_fd) 32910929Sbrandon.potter@amd.com return index; 33010929Sbrandon.potter@amd.com return -1; 3315282Srstrong@cs.ucsd.edu} 3327487Ssteve.reinhardt@amd.com 3338601Ssteve.reinhardt@amd.comvoid 3348601Ssteve.reinhardt@amd.comProcess::allocateMem(Addr vaddr, int64_t size, bool clobber) 3358601Ssteve.reinhardt@amd.com{ 33610318Sandreas.hansson@arm.com int npages = divCeil(size, (int64_t)PageBytes); 3378601Ssteve.reinhardt@amd.com Addr paddr = system->allocPhysPages(npages); 33810558Salexandru.dutu@amd.com pTable->map(vaddr, paddr, size, clobber ? PageTableBase::Clobber : 0); 3398601Ssteve.reinhardt@amd.com} 3408601Ssteve.reinhardt@amd.com 3414434Ssaidi@eecs.umich.edubool 3428539Sgblack@eecs.umich.eduProcess::fixupStackFault(Addr vaddr) 3434434Ssaidi@eecs.umich.edu{ 3448539Sgblack@eecs.umich.edu // Check if this is already on the stack and there's just no page there 3458539Sgblack@eecs.umich.edu // yet. 3464434Ssaidi@eecs.umich.edu if (vaddr >= stack_min && vaddr < stack_base) { 34710318Sandreas.hansson@arm.com allocateMem(roundDown(vaddr, PageBytes), PageBytes); 3484434Ssaidi@eecs.umich.edu return true; 3494434Ssaidi@eecs.umich.edu } 3504434Ssaidi@eecs.umich.edu 3518539Sgblack@eecs.umich.edu // We've accessed the next page of the stack, so extend it to include 3528539Sgblack@eecs.umich.edu // this address. 3535154Sgblack@eecs.umich.edu if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) { 3545154Sgblack@eecs.umich.edu while (vaddr < stack_min) { 3555154Sgblack@eecs.umich.edu stack_min -= TheISA::PageBytes; 3568539Sgblack@eecs.umich.edu if (stack_base - stack_min > max_stack_size) 3575154Sgblack@eecs.umich.edu fatal("Maximum stack size exceeded\n"); 3588601Ssteve.reinhardt@amd.com allocateMem(stack_min, TheISA::PageBytes); 3595823Ssaidi@eecs.umich.edu inform("Increasing stack size by one page."); 3605154Sgblack@eecs.umich.edu }; 3614434Ssaidi@eecs.umich.edu return true; 3624434Ssaidi@eecs.umich.edu } 3634434Ssaidi@eecs.umich.edu return false; 3644434Ssaidi@eecs.umich.edu} 3654434Ssaidi@eecs.umich.edu 3667487Ssteve.reinhardt@amd.com// find all offsets for currently open files and save them 3675282Srstrong@cs.ucsd.eduvoid 3687487Ssteve.reinhardt@amd.comProcess::fix_file_offsets() 3697487Ssteve.reinhardt@amd.com{ 3705282Srstrong@cs.ucsd.edu Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO]; 3715282Srstrong@cs.ucsd.edu Process::FdMap *fdo_stdout = &fd_map[STDOUT_FILENO]; 3725282Srstrong@cs.ucsd.edu Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO]; 3735282Srstrong@cs.ucsd.edu string in = fdo_stdin->filename; 3745282Srstrong@cs.ucsd.edu string out = fdo_stdout->filename; 3755514SMichael.Adler@intel.com string err = fdo_stderr->filename; 3765282Srstrong@cs.ucsd.edu 3775282Srstrong@cs.ucsd.edu // initialize file descriptors to default: same as simulator 3785282Srstrong@cs.ucsd.edu int stdin_fd, stdout_fd, stderr_fd; 3795282Srstrong@cs.ucsd.edu 3805282Srstrong@cs.ucsd.edu if (in == "stdin" || in == "cin") 3815282Srstrong@cs.ucsd.edu stdin_fd = STDIN_FILENO; 38210782Snilay@cs.wisc.edu else if (in == "NULL") 3835282Srstrong@cs.ucsd.edu stdin_fd = -1; 3847487Ssteve.reinhardt@amd.com else { 3857487Ssteve.reinhardt@amd.com // open standard in and seek to the right location 3865282Srstrong@cs.ucsd.edu stdin_fd = Process::openInputFile(in); 3875282Srstrong@cs.ucsd.edu if (lseek(stdin_fd, fdo_stdin->fileOffset, SEEK_SET) < 0) 3885282Srstrong@cs.ucsd.edu panic("Unable to seek to correct location in file: %s", in); 3895282Srstrong@cs.ucsd.edu } 3905282Srstrong@cs.ucsd.edu 3915282Srstrong@cs.ucsd.edu if (out == "stdout" || out == "cout") 3925282Srstrong@cs.ucsd.edu stdout_fd = STDOUT_FILENO; 3935282Srstrong@cs.ucsd.edu else if (out == "stderr" || out == "cerr") 3945282Srstrong@cs.ucsd.edu stdout_fd = STDERR_FILENO; 39510782Snilay@cs.wisc.edu else if (out == "NULL") 3965282Srstrong@cs.ucsd.edu stdout_fd = -1; 3977487Ssteve.reinhardt@amd.com else { 3985282Srstrong@cs.ucsd.edu stdout_fd = Process::openOutputFile(out); 3995514SMichael.Adler@intel.com if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0) 4005514SMichael.Adler@intel.com panic("Unable to seek to correct location in file: %s", out); 4015282Srstrong@cs.ucsd.edu } 4025282Srstrong@cs.ucsd.edu 4035514SMichael.Adler@intel.com if (err == "stdout" || err == "cout") 4045514SMichael.Adler@intel.com stderr_fd = STDOUT_FILENO; 4055514SMichael.Adler@intel.com else if (err == "stderr" || err == "cerr") 4065514SMichael.Adler@intel.com stderr_fd = STDERR_FILENO; 40710782Snilay@cs.wisc.edu else if (err == "NULL") 4085514SMichael.Adler@intel.com stderr_fd = -1; 4095514SMichael.Adler@intel.com else if (err == out) 4105514SMichael.Adler@intel.com stderr_fd = stdout_fd; 4115514SMichael.Adler@intel.com else { 4125514SMichael.Adler@intel.com stderr_fd = Process::openOutputFile(err); 4135514SMichael.Adler@intel.com if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0) 4145514SMichael.Adler@intel.com panic("Unable to seek to correct location in file: %s", err); 4155514SMichael.Adler@intel.com } 4165282Srstrong@cs.ucsd.edu 4175282Srstrong@cs.ucsd.edu fdo_stdin->fd = stdin_fd; 4185282Srstrong@cs.ucsd.edu fdo_stdout->fd = stdout_fd; 4195282Srstrong@cs.ucsd.edu fdo_stderr->fd = stderr_fd; 4205282Srstrong@cs.ucsd.edu 4215282Srstrong@cs.ucsd.edu 42210929Sbrandon.potter@amd.com for (int free_fd = 3; free_fd < NUM_FDS; ++free_fd) { 4235282Srstrong@cs.ucsd.edu Process::FdMap *fdo = &fd_map[free_fd]; 4245282Srstrong@cs.ucsd.edu if (fdo->fd != -1) { 4255282Srstrong@cs.ucsd.edu if (fdo->isPipe){ 4265282Srstrong@cs.ucsd.edu if (fdo->filename == "PIPE-WRITE") 4275282Srstrong@cs.ucsd.edu continue; 4285282Srstrong@cs.ucsd.edu else { 4295282Srstrong@cs.ucsd.edu assert (fdo->filename == "PIPE-READ"); 4305282Srstrong@cs.ucsd.edu //create a new pipe 4315282Srstrong@cs.ucsd.edu int fds[2]; 4325282Srstrong@cs.ucsd.edu int pipe_retval = pipe(fds); 4335282Srstrong@cs.ucsd.edu 4345282Srstrong@cs.ucsd.edu if (pipe_retval < 0) { 4355282Srstrong@cs.ucsd.edu // error 4365282Srstrong@cs.ucsd.edu panic("Unable to create new pipe."); 4375282Srstrong@cs.ucsd.edu } 4385282Srstrong@cs.ucsd.edu fdo->fd = fds[0]; //set read pipe 4395282Srstrong@cs.ucsd.edu Process::FdMap *fdo_write = &fd_map[fdo->readPipeSource]; 4405282Srstrong@cs.ucsd.edu if (fdo_write->filename != "PIPE-WRITE") 4415282Srstrong@cs.ucsd.edu panic ("Couldn't find write end of the pipe"); 4425282Srstrong@cs.ucsd.edu 4435282Srstrong@cs.ucsd.edu fdo_write->fd = fds[1];//set write pipe 4445282Srstrong@cs.ucsd.edu } 4455282Srstrong@cs.ucsd.edu } else { 4465282Srstrong@cs.ucsd.edu //Open file 4475282Srstrong@cs.ucsd.edu int fd = open(fdo->filename.c_str(), fdo->flags, fdo->mode); 4485282Srstrong@cs.ucsd.edu 4495282Srstrong@cs.ucsd.edu if (fd == -1) 4505282Srstrong@cs.ucsd.edu panic("Unable to open file: %s", fdo->filename); 4515282Srstrong@cs.ucsd.edu fdo->fd = fd; 4525282Srstrong@cs.ucsd.edu 4535282Srstrong@cs.ucsd.edu //Seek to correct location before checkpoint 45410782Snilay@cs.wisc.edu if (lseek(fd, fdo->fileOffset, SEEK_SET) < 0) 4557487Ssteve.reinhardt@amd.com panic("Unable to seek to correct location in file: %s", 4567487Ssteve.reinhardt@amd.com fdo->filename); 4575282Srstrong@cs.ucsd.edu } 4585282Srstrong@cs.ucsd.edu } 4595282Srstrong@cs.ucsd.edu } 4605282Srstrong@cs.ucsd.edu} 4617487Ssteve.reinhardt@amd.com 4625282Srstrong@cs.ucsd.eduvoid 4637487Ssteve.reinhardt@amd.comProcess::find_file_offsets() 4647487Ssteve.reinhardt@amd.com{ 46510929Sbrandon.potter@amd.com for (int free_fd = 0; free_fd < NUM_FDS; ++free_fd) { 4665282Srstrong@cs.ucsd.edu Process::FdMap *fdo = &fd_map[free_fd]; 4675282Srstrong@cs.ucsd.edu if (fdo->fd != -1) { 4685282Srstrong@cs.ucsd.edu fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR); 4697487Ssteve.reinhardt@amd.com } else { 47010782Snilay@cs.wisc.edu fdo->filename = "NULL"; 47110782Snilay@cs.wisc.edu fdo->fileOffset = 0; 4725282Srstrong@cs.ucsd.edu } 4735282Srstrong@cs.ucsd.edu } 4745282Srstrong@cs.ucsd.edu} 4755282Srstrong@cs.ucsd.edu 4765282Srstrong@cs.ucsd.eduvoid 4777487Ssteve.reinhardt@amd.comProcess::setReadPipeSource(int read_pipe_fd, int source_fd) 4787487Ssteve.reinhardt@amd.com{ 4795282Srstrong@cs.ucsd.edu Process::FdMap *fdo = &fd_map[read_pipe_fd]; 4805282Srstrong@cs.ucsd.edu fdo->readPipeSource = source_fd; 4815282Srstrong@cs.ucsd.edu} 4825282Srstrong@cs.ucsd.edu 4835282Srstrong@cs.ucsd.eduvoid 48410905Sandreas.sandberg@arm.comProcess::FdMap::serialize(CheckpointOut &cp) const 4855282Srstrong@cs.ucsd.edu{ 4865282Srstrong@cs.ucsd.edu SERIALIZE_SCALAR(fd); 4875282Srstrong@cs.ucsd.edu SERIALIZE_SCALAR(isPipe); 4885282Srstrong@cs.ucsd.edu SERIALIZE_SCALAR(filename); 4895282Srstrong@cs.ucsd.edu SERIALIZE_SCALAR(flags); 4905282Srstrong@cs.ucsd.edu SERIALIZE_SCALAR(readPipeSource); 4915282Srstrong@cs.ucsd.edu SERIALIZE_SCALAR(fileOffset); 4925282Srstrong@cs.ucsd.edu} 4935282Srstrong@cs.ucsd.edu 4945282Srstrong@cs.ucsd.eduvoid 49510905Sandreas.sandberg@arm.comProcess::FdMap::unserialize(CheckpointIn &cp) 4965282Srstrong@cs.ucsd.edu{ 4975282Srstrong@cs.ucsd.edu UNSERIALIZE_SCALAR(fd); 4985282Srstrong@cs.ucsd.edu UNSERIALIZE_SCALAR(isPipe); 4995282Srstrong@cs.ucsd.edu UNSERIALIZE_SCALAR(filename); 5005282Srstrong@cs.ucsd.edu UNSERIALIZE_SCALAR(flags); 5015282Srstrong@cs.ucsd.edu UNSERIALIZE_SCALAR(readPipeSource); 5025282Srstrong@cs.ucsd.edu UNSERIALIZE_SCALAR(fileOffset); 5035282Srstrong@cs.ucsd.edu} 5045282Srstrong@cs.ucsd.edu 5053311Ssaidi@eecs.umich.eduvoid 50610905Sandreas.sandberg@arm.comProcess::serialize(CheckpointOut &cp) const 5073311Ssaidi@eecs.umich.edu{ 5083311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(brk_point); 5093311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_base); 5103311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_size); 5113311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_min); 5123311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(next_thread_stack_base); 5133311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(mmap_start); 5143311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(mmap_end); 5153311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(nxm_start); 5163311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(nxm_end); 51710905Sandreas.sandberg@arm.com pTable->serialize(cp); 51810929Sbrandon.potter@amd.com for (int x = 0; x < NUM_FDS; x++) { 51910905Sandreas.sandberg@arm.com fd_map[x].serializeSection(cp, csprintf("FdMap%d", x)); 5205282Srstrong@cs.ucsd.edu } 5216820SLisa.Hsu@amd.com SERIALIZE_SCALAR(M5_pid); 5223311Ssaidi@eecs.umich.edu 5233311Ssaidi@eecs.umich.edu} 5243311Ssaidi@eecs.umich.edu 5253311Ssaidi@eecs.umich.eduvoid 52610905Sandreas.sandberg@arm.comProcess::unserialize(CheckpointIn &cp) 5273311Ssaidi@eecs.umich.edu{ 5283311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(brk_point); 5293311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_base); 5303311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_size); 5313311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_min); 5323311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(next_thread_stack_base); 5333311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(mmap_start); 5343311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(mmap_end); 5353311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(nxm_start); 5363311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(nxm_end); 53710905Sandreas.sandberg@arm.com pTable->unserialize(cp); 53810929Sbrandon.potter@amd.com for (int x = 0; x < NUM_FDS; x++) { 53910905Sandreas.sandberg@arm.com fd_map[x].unserializeSection(cp, csprintf("FdMap%d", x)); 5407487Ssteve.reinhardt@amd.com } 5415282Srstrong@cs.ucsd.edu fix_file_offsets(); 5426820SLisa.Hsu@amd.com UNSERIALIZE_OPT_SCALAR(M5_pid); 5436820SLisa.Hsu@amd.com // The above returns a bool so that you could do something if you don't 5446820SLisa.Hsu@amd.com // find the param in the checkpoint if you wanted to, like set a default 5456820SLisa.Hsu@amd.com // but in this case we'll just stick with the instantianted value if not 54610929Sbrandon.potter@amd.com // found. 5473311Ssaidi@eecs.umich.edu} 5482SN/A 5492SN/A 5509110Ssteve.reinhardt@amd.combool 55110558Salexandru.dutu@amd.comProcess::map(Addr vaddr, Addr paddr, int size, bool cacheable) 5529110Ssteve.reinhardt@amd.com{ 55310558Salexandru.dutu@amd.com pTable->map(vaddr, paddr, size, 55410558Salexandru.dutu@amd.com cacheable ? 0 : PageTableBase::Uncacheable); 5559110Ssteve.reinhardt@amd.com return true; 5569110Ssteve.reinhardt@amd.com} 5579110Ssteve.reinhardt@amd.com 5589110Ssteve.reinhardt@amd.com 5592SN/A//////////////////////////////////////////////////////////////////////// 5602SN/A// 5612SN/A// LiveProcess member definitions 5622SN/A// 5632SN/A//////////////////////////////////////////////////////////////////////// 5642SN/A 56512SN/A 56610499Ssteve.reinhardt@amd.comLiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile) 5675154Sgblack@eecs.umich.edu : Process(params), objFile(_objFile), 56810496Ssteve.reinhardt@amd.com argv(params->cmd), envp(params->env), cwd(params->cwd), 56910499Ssteve.reinhardt@amd.com __uid(params->uid), __euid(params->euid), 57010499Ssteve.reinhardt@amd.com __gid(params->gid), __egid(params->egid), 57110499Ssteve.reinhardt@amd.com __pid(params->pid), __ppid(params->ppid), 57210496Ssteve.reinhardt@amd.com drivers(params->drivers) 5732SN/A{ 5743114Sgblack@eecs.umich.edu 5751158SN/A // load up symbols, if any... these may be used for debugging or 5761158SN/A // profiling. 5771158SN/A if (!debugSymbolTable) { 5781158SN/A debugSymbolTable = new SymbolTable(); 5791158SN/A if (!objFile->loadGlobalSymbols(debugSymbolTable) || 5809641Sguodeyuan@tsinghua.org.cn !objFile->loadLocalSymbols(debugSymbolTable) || 5819641Sguodeyuan@tsinghua.org.cn !objFile->loadWeakSymbols(debugSymbolTable)) { 5821158SN/A // didn't load any symbols 5831158SN/A delete debugSymbolTable; 5841158SN/A debugSymbolTable = NULL; 5851158SN/A } 5861158SN/A } 5872378SN/A} 5881158SN/A 5892378SN/Avoid 5902680Sktlim@umich.eduLiveProcess::syscall(int64_t callnum, ThreadContext *tc) 5912093SN/A{ 5922093SN/A num_syscalls++; 5932093SN/A 5942093SN/A SyscallDesc *desc = getDesc(callnum); 5952093SN/A if (desc == NULL) 5962093SN/A fatal("Syscall %d out of range", callnum); 5972093SN/A 5982680Sktlim@umich.edu desc->doSyscall(callnum, this, tc); 5992093SN/A} 6002SN/A 6016701Sgblack@eecs.umich.eduIntReg 6026701Sgblack@eecs.umich.eduLiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width) 6036701Sgblack@eecs.umich.edu{ 6046701Sgblack@eecs.umich.edu return getSyscallArg(tc, i); 6056701Sgblack@eecs.umich.edu} 6066701Sgblack@eecs.umich.edu 60710496Ssteve.reinhardt@amd.com 60810496Ssteve.reinhardt@amd.comEmulatedDriver * 60910496Ssteve.reinhardt@amd.comLiveProcess::findDriver(std::string filename) 61010496Ssteve.reinhardt@amd.com{ 61110496Ssteve.reinhardt@amd.com for (EmulatedDriver *d : drivers) { 61210496Ssteve.reinhardt@amd.com if (d->match(filename)) 61310496Ssteve.reinhardt@amd.com return d; 61410496Ssteve.reinhardt@amd.com } 61510496Ssteve.reinhardt@amd.com 61610496Ssteve.reinhardt@amd.com return NULL; 61710496Ssteve.reinhardt@amd.com} 61810496Ssteve.reinhardt@amd.com 61910496Ssteve.reinhardt@amd.com 6202715Sstever@eecs.umich.eduLiveProcess * 6215154Sgblack@eecs.umich.eduLiveProcess::create(LiveProcessParams * params) 6222715Sstever@eecs.umich.edu{ 6232715Sstever@eecs.umich.edu LiveProcess *process = NULL; 6242715Sstever@eecs.umich.edu 6255154Sgblack@eecs.umich.edu string executable = 6265154Sgblack@eecs.umich.edu params->executable == "" ? params->cmd[0] : params->executable; 6272715Sstever@eecs.umich.edu ObjectFile *objFile = createObjectFile(executable); 6282715Sstever@eecs.umich.edu if (objFile == NULL) { 6292715Sstever@eecs.umich.edu fatal("Can't load object file %s", executable); 6302715Sstever@eecs.umich.edu } 6312715Sstever@eecs.umich.edu 6323917Ssaidi@eecs.umich.edu if (objFile->isDynamic()) 6333917Ssaidi@eecs.umich.edu fatal("Object file is a dynamic executable however only static " 6345070Ssaidi@eecs.umich.edu "executables are supported!\n Please recompile your " 6353917Ssaidi@eecs.umich.edu "executable as a static binary and try again.\n"); 6363917Ssaidi@eecs.umich.edu 6375089Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA 6385753Ssteve.reinhardt@amd.com if (objFile->getArch() != ObjectFile::Alpha) 6395753Ssteve.reinhardt@amd.com fatal("Object file architecture does not match compiled ISA (Alpha)."); 6405753Ssteve.reinhardt@amd.com 6412715Sstever@eecs.umich.edu switch (objFile->getOpSys()) { 6422715Sstever@eecs.umich.edu case ObjectFile::Tru64: 6435154Sgblack@eecs.umich.edu process = new AlphaTru64Process(params, objFile); 6442715Sstever@eecs.umich.edu break; 6452715Sstever@eecs.umich.edu 6465753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6475753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6485753Ssteve.reinhardt@amd.com // fall through 6492715Sstever@eecs.umich.edu case ObjectFile::Linux: 6505154Sgblack@eecs.umich.edu process = new AlphaLinuxProcess(params, objFile); 6512715Sstever@eecs.umich.edu break; 6522715Sstever@eecs.umich.edu 6532715Sstever@eecs.umich.edu default: 6542715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6552715Sstever@eecs.umich.edu } 6562715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA 6575753Ssteve.reinhardt@amd.com if (objFile->getArch() != ObjectFile::SPARC64 && 6585753Ssteve.reinhardt@amd.com objFile->getArch() != ObjectFile::SPARC32) 6592715Sstever@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (SPARC)."); 6602715Sstever@eecs.umich.edu switch (objFile->getOpSys()) { 6615753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6625753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6635753Ssteve.reinhardt@amd.com // fall through 6642715Sstever@eecs.umich.edu case ObjectFile::Linux: 6654111Sgblack@eecs.umich.edu if (objFile->getArch() == ObjectFile::SPARC64) { 6665154Sgblack@eecs.umich.edu process = new Sparc64LinuxProcess(params, objFile); 6674111Sgblack@eecs.umich.edu } else { 6685154Sgblack@eecs.umich.edu process = new Sparc32LinuxProcess(params, objFile); 6694111Sgblack@eecs.umich.edu } 6702715Sstever@eecs.umich.edu break; 6712715Sstever@eecs.umich.edu 6722715Sstever@eecs.umich.edu 6732715Sstever@eecs.umich.edu case ObjectFile::Solaris: 6745154Sgblack@eecs.umich.edu process = new SparcSolarisProcess(params, objFile); 6752715Sstever@eecs.umich.edu break; 6765753Ssteve.reinhardt@amd.com 6772715Sstever@eecs.umich.edu default: 6782715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6792715Sstever@eecs.umich.edu } 6804157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA 6815874Sgblack@eecs.umich.edu if (objFile->getArch() != ObjectFile::X86_64 && 6825874Sgblack@eecs.umich.edu objFile->getArch() != ObjectFile::I386) 6834166Sgblack@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (x86)."); 6844157Sgblack@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 6884166Sgblack@eecs.umich.edu case ObjectFile::Linux: 6895874Sgblack@eecs.umich.edu if (objFile->getArch() == ObjectFile::X86_64) { 6905955Sgblack@eecs.umich.edu process = new X86_64LinuxProcess(params, objFile); 6915874Sgblack@eecs.umich.edu } else { 6925955Sgblack@eecs.umich.edu process = new I386LinuxProcess(params, objFile); 6935874Sgblack@eecs.umich.edu } 6944166Sgblack@eecs.umich.edu break; 6955753Ssteve.reinhardt@amd.com 6964157Sgblack@eecs.umich.edu default: 6974157Sgblack@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6984157Sgblack@eecs.umich.edu } 6992715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA 7002715Sstever@eecs.umich.edu if (objFile->getArch() != ObjectFile::Mips) 7012715Sstever@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (MIPS)."); 7022715Sstever@eecs.umich.edu switch (objFile->getOpSys()) { 7035753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 7045753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 7055753Ssteve.reinhardt@amd.com // fall through 7062715Sstever@eecs.umich.edu case ObjectFile::Linux: 7075154Sgblack@eecs.umich.edu process = new MipsLinuxProcess(params, objFile); 7082715Sstever@eecs.umich.edu break; 7092715Sstever@eecs.umich.edu 7102715Sstever@eecs.umich.edu default: 7112715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 7122715Sstever@eecs.umich.edu } 7135335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA 71410037SARM gem5 Developers ObjectFile::Arch arch = objFile->getArch(); 71510037SARM gem5 Developers if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 71610037SARM gem5 Developers arch != ObjectFile::Arm64) 7175335Shines@cs.fsu.edu fatal("Object file architecture does not match compiled ISA (ARM)."); 7185335Shines@cs.fsu.edu switch (objFile->getOpSys()) { 7195753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 7205753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 7215753Ssteve.reinhardt@amd.com // fall through 7225335Shines@cs.fsu.edu case ObjectFile::Linux: 72310037SARM gem5 Developers if (arch == ObjectFile::Arm64) { 72410037SARM gem5 Developers process = new ArmLinuxProcess64(params, objFile, 72510037SARM gem5 Developers objFile->getArch()); 72610037SARM gem5 Developers } else { 72710037SARM gem5 Developers process = new ArmLinuxProcess32(params, objFile, 72810037SARM gem5 Developers objFile->getArch()); 72910037SARM gem5 Developers } 7305335Shines@cs.fsu.edu break; 73110810Sbr@bsdpad.com case ObjectFile::FreeBSD: 73210810Sbr@bsdpad.com if (arch == ObjectFile::Arm64) { 73310810Sbr@bsdpad.com process = new ArmFreebsdProcess64(params, objFile, 73410810Sbr@bsdpad.com objFile->getArch()); 73510810Sbr@bsdpad.com } else { 73610810Sbr@bsdpad.com process = new ArmFreebsdProcess32(params, objFile, 73710810Sbr@bsdpad.com objFile->getArch()); 73810810Sbr@bsdpad.com } 73910810Sbr@bsdpad.com break; 7406392Ssaidi@eecs.umich.edu case ObjectFile::LinuxArmOABI: 7416392Ssaidi@eecs.umich.edu fatal("M5 does not support ARM OABI binaries. Please recompile with an" 7426392Ssaidi@eecs.umich.edu " EABI compiler."); 7435335Shines@cs.fsu.edu default: 7445335Shines@cs.fsu.edu fatal("Unknown/unsupported operating system."); 7455335Shines@cs.fsu.edu } 7466691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA 7476691Stjones1@inf.ed.ac.uk if (objFile->getArch() != ObjectFile::Power) 7486691Stjones1@inf.ed.ac.uk fatal("Object file architecture does not match compiled ISA (Power)."); 7496691Stjones1@inf.ed.ac.uk switch (objFile->getOpSys()) { 7506691Stjones1@inf.ed.ac.uk case ObjectFile::UnknownOpSys: 7516691Stjones1@inf.ed.ac.uk warn("Unknown operating system; assuming Linux."); 7526691Stjones1@inf.ed.ac.uk // fall through 7536691Stjones1@inf.ed.ac.uk case ObjectFile::Linux: 7546691Stjones1@inf.ed.ac.uk process = new PowerLinuxProcess(params, objFile); 7556691Stjones1@inf.ed.ac.uk break; 7566691Stjones1@inf.ed.ac.uk 7576691Stjones1@inf.ed.ac.uk default: 7586691Stjones1@inf.ed.ac.uk fatal("Unknown/unsupported operating system."); 7596691Stjones1@inf.ed.ac.uk } 7602715Sstever@eecs.umich.edu#else 7612715Sstever@eecs.umich.edu#error "THE_ISA not set" 7622715Sstever@eecs.umich.edu#endif 7632715Sstever@eecs.umich.edu 7642715Sstever@eecs.umich.edu if (process == NULL) 7652715Sstever@eecs.umich.edu fatal("Unknown error creating process object."); 7662715Sstever@eecs.umich.edu return process; 7672715Sstever@eecs.umich.edu} 7682715Sstever@eecs.umich.edu 7694762Snate@binkert.orgLiveProcess * 7704762Snate@binkert.orgLiveProcessParams::create() 7712715Sstever@eecs.umich.edu{ 7725154Sgblack@eecs.umich.edu return LiveProcess::create(this); 7732715Sstever@eecs.umich.edu} 774