process.cc revision 11785
12SN/A/* 210298Salexandru.dutu@amd.com * Copyright (c) 2014 Advanced Micro Devices, Inc. 38852Sandreas.hansson@arm.com * Copyright (c) 2012 ARM Limited 48852Sandreas.hansson@arm.com * All rights reserved 58852Sandreas.hansson@arm.com * 68852Sandreas.hansson@arm.com * The license below extends only to copyright in the software and shall 78852Sandreas.hansson@arm.com * not be construed as granting a license to any other intellectual 88852Sandreas.hansson@arm.com * property including but not limited to intellectual property relating 98852Sandreas.hansson@arm.com * to a hardware implementation of the functionality of the software 108852Sandreas.hansson@arm.com * licensed hereunder. You may use the software subject to the license 118852Sandreas.hansson@arm.com * terms below provided that you ensure that this notice is replicated 128852Sandreas.hansson@arm.com * unmodified and in its entirety in all distributions of the software, 138852Sandreas.hansson@arm.com * modified or unmodified, in source code or in binary form. 148852Sandreas.hansson@arm.com * 151762SN/A * Copyright (c) 2001-2005 The Regents of The University of Michigan 162SN/A * All rights reserved. 172SN/A * 182SN/A * Redistribution and use in source and binary forms, with or without 192SN/A * modification, are permitted provided that the following conditions are 202SN/A * met: redistributions of source code must retain the above copyright 212SN/A * notice, this list of conditions and the following disclaimer; 222SN/A * redistributions in binary form must reproduce the above copyright 232SN/A * notice, this list of conditions and the following disclaimer in the 242SN/A * documentation and/or other materials provided with the distribution; 252SN/A * neither the name of the copyright holders nor the names of its 262SN/A * contributors may be used to endorse or promote products derived from 272SN/A * this software without specific prior written permission. 282SN/A * 292SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 302SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 312SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 322SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 332SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 342SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 352SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 362SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 372SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 382SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 392SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 402665Ssaidi@eecs.umich.edu * 412665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert 422665Ssaidi@eecs.umich.edu * Steve Reinhardt 432665Ssaidi@eecs.umich.edu * Ali Saidi 442SN/A */ 452SN/A 468229Snate@binkert.org#include <fcntl.h> 472SN/A#include <unistd.h> 486712Snate@binkert.org 496712Snate@binkert.org#include <cstdio> 5010930Sbrandon.potter@amd.com#include <map> 512SN/A#include <string> 522SN/A 5356SN/A#include "base/loader/object_file.hh" 541158SN/A#include "base/loader/symtab.hh" 558229Snate@binkert.org#include "base/intmath.hh" 56146SN/A#include "base/statistics.hh" 576658Snate@binkert.org#include "config/the_isa.hh" 582680Sktlim@umich.edu#include "cpu/thread_context.hh" 592378SN/A#include "mem/page_table.hh" 6010298Salexandru.dutu@amd.com#include "mem/multi_level_page_table.hh" 618706Sandreas.hansson@arm.com#include "mem/se_translating_port_proxy.hh" 628229Snate@binkert.org#include "params/LiveProcess.hh" 635154Sgblack@eecs.umich.edu#include "params/Process.hh" 645512SMichael.Adler@intel.com#include "sim/debug.hh" 65360SN/A#include "sim/process.hh" 664434Ssaidi@eecs.umich.edu#include "sim/process_impl.hh" 67695SN/A#include "sim/stats.hh" 682093SN/A#include "sim/syscall_emul.hh" 692378SN/A#include "sim/system.hh" 702SN/A 712715Sstever@eecs.umich.edu#if THE_ISA == ALPHA_ISA 722715Sstever@eecs.umich.edu#include "arch/alpha/linux/process.hh" 732715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA 742715Sstever@eecs.umich.edu#include "arch/sparc/linux/process.hh" 752715Sstever@eecs.umich.edu#include "arch/sparc/solaris/process.hh" 762715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA 772715Sstever@eecs.umich.edu#include "arch/mips/linux/process.hh" 785335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA 795335Shines@cs.fsu.edu#include "arch/arm/linux/process.hh" 8010810Sbr@bsdpad.com#include "arch/arm/freebsd/process.hh" 814157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA 824166Sgblack@eecs.umich.edu#include "arch/x86/linux/process.hh" 836691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA 846691Stjones1@inf.ed.ac.uk#include "arch/power/linux/process.hh" 8511723Sar4jc@virginia.edu#elif THE_ISA == RISCV_ISA 8611723Sar4jc@virginia.edu#include "arch/riscv/linux/process.hh" 872715Sstever@eecs.umich.edu#else 882715Sstever@eecs.umich.edu#error "THE_ISA not set" 892715Sstever@eecs.umich.edu#endif 902715Sstever@eecs.umich.edu 912715Sstever@eecs.umich.edu 922SN/Ausing namespace std; 932107SN/Ausing namespace TheISA; 942SN/A 952SN/A// current number of allocated processes 962SN/Aint num_processes = 0; 972SN/A 985758Shsul@eecs.umich.edutemplate<class IntType> 9910932Sbrandon.potter@amd.com 1005771Shsul@eecs.umich.eduAuxVector<IntType>::AuxVector(IntType type, IntType val) 1015758Shsul@eecs.umich.edu{ 1025758Shsul@eecs.umich.edu a_type = TheISA::htog(type); 1035758Shsul@eecs.umich.edu a_val = TheISA::htog(val); 1045758Shsul@eecs.umich.edu} 1055758Shsul@eecs.umich.edu 1068737Skoansin.tan@gmail.comtemplate struct AuxVector<uint32_t>; 1078737Skoansin.tan@gmail.comtemplate struct AuxVector<uint64_t>; 1085758Shsul@eecs.umich.edu 10910930Sbrandon.potter@amd.comstatic int 11010930Sbrandon.potter@amd.comopenFile(const string& filename, int flags, mode_t mode) 11110930Sbrandon.potter@amd.com{ 11210930Sbrandon.potter@amd.com int sim_fd = open(filename.c_str(), flags, mode); 11310930Sbrandon.potter@amd.com if (sim_fd != -1) 11410930Sbrandon.potter@amd.com return sim_fd; 11510930Sbrandon.potter@amd.com fatal("Unable to open %s with mode %O", filename, mode); 11610930Sbrandon.potter@amd.com} 11710930Sbrandon.potter@amd.com 11810930Sbrandon.potter@amd.comstatic int 11910930Sbrandon.potter@amd.comopenInputFile(const string &filename) 12010930Sbrandon.potter@amd.com{ 12110930Sbrandon.potter@amd.com return openFile(filename, O_RDONLY, 0); 12210930Sbrandon.potter@amd.com} 12310930Sbrandon.potter@amd.com 12410930Sbrandon.potter@amd.comstatic int 12510930Sbrandon.potter@amd.comopenOutputFile(const string &filename) 12610930Sbrandon.potter@amd.com{ 12710930Sbrandon.potter@amd.com return openFile(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664); 12810930Sbrandon.potter@amd.com} 12910930Sbrandon.potter@amd.com 1305154Sgblack@eecs.umich.eduProcess::Process(ProcessParams * params) 1317532Ssteve.reinhardt@amd.com : SimObject(params), system(params->system), 13210559Sandreas.hansson@arm.com brk_point(0), stack_base(0), stack_size(0), stack_min(0), 1338852Sandreas.hansson@arm.com max_stack_size(params->max_stack_size), 13410559Sandreas.hansson@arm.com next_thread_stack_base(0), 1358852Sandreas.hansson@arm.com M5_pid(system->allocatePID()), 13610299Salexandru.dutu@amd.com useArchPT(params->useArchPT), 13710554Salexandru.dutu@amd.com kvmInSE(params->kvmInSE), 13810299Salexandru.dutu@amd.com pTable(useArchPT ? 13910299Salexandru.dutu@amd.com static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) : 14010299Salexandru.dutu@amd.com static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ), 1418852Sandreas.hansson@arm.com initVirtMem(system->getSystemPort(), this, 14210929Sbrandon.potter@amd.com SETranslatingPortProxy::Always), 14310930Sbrandon.potter@amd.com fd_array(make_shared<array<FDEntry, NUM_FDS>>()), 14410930Sbrandon.potter@amd.com imap {{"", -1}, 14510930Sbrandon.potter@amd.com {"cin", STDIN_FILENO}, 14610930Sbrandon.potter@amd.com {"stdin", STDIN_FILENO}}, 14710930Sbrandon.potter@amd.com oemap{{"", -1}, 14810930Sbrandon.potter@amd.com {"cout", STDOUT_FILENO}, 14910930Sbrandon.potter@amd.com {"stdout", STDOUT_FILENO}, 15010930Sbrandon.potter@amd.com {"cerr", STDERR_FILENO}, 15110930Sbrandon.potter@amd.com {"stderr", STDERR_FILENO}} 1522SN/A{ 15310930Sbrandon.potter@amd.com int sim_fd; 15410930Sbrandon.potter@amd.com std::map<string,int>::iterator it; 1555154Sgblack@eecs.umich.edu 15610930Sbrandon.potter@amd.com // Search through the input options and set fd if match is found; 15710930Sbrandon.potter@amd.com // otherwise, open an input file and seek to location. 15810932Sbrandon.potter@amd.com FDEntry *fde_stdin = getFDEntry(STDIN_FILENO); 15910930Sbrandon.potter@amd.com if ((it = imap.find(params->input)) != imap.end()) 16010930Sbrandon.potter@amd.com sim_fd = it->second; 16110930Sbrandon.potter@amd.com else 16210930Sbrandon.potter@amd.com sim_fd = openInputFile(params->input); 16310930Sbrandon.potter@amd.com fde_stdin->set(sim_fd, params->input, O_RDONLY, -1, false); 1645154Sgblack@eecs.umich.edu 16510930Sbrandon.potter@amd.com // Search through the output/error options and set fd if match is found; 16610930Sbrandon.potter@amd.com // otherwise, open an output file and seek to location. 16710932Sbrandon.potter@amd.com FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO); 16810930Sbrandon.potter@amd.com if ((it = oemap.find(params->output)) != oemap.end()) 16910930Sbrandon.potter@amd.com sim_fd = it->second; 1705154Sgblack@eecs.umich.edu else 17110930Sbrandon.potter@amd.com sim_fd = openOutputFile(params->output); 17210930Sbrandon.potter@amd.com fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC, 17310930Sbrandon.potter@amd.com 0664, false); 1745154Sgblack@eecs.umich.edu 17510932Sbrandon.potter@amd.com FDEntry *fde_stderr = getFDEntry(STDERR_FILENO); 17610930Sbrandon.potter@amd.com if (params->output == params->errout) 17710930Sbrandon.potter@amd.com // Reuse the same file descriptor if these match. 17810930Sbrandon.potter@amd.com sim_fd = fde_stdout->fd; 17910930Sbrandon.potter@amd.com else if ((it = oemap.find(params->errout)) != oemap.end()) 18010930Sbrandon.potter@amd.com sim_fd = it->second; 1815154Sgblack@eecs.umich.edu else 18210930Sbrandon.potter@amd.com sim_fd = openOutputFile(params->errout); 18310930Sbrandon.potter@amd.com fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC, 18410930Sbrandon.potter@amd.com 0664, false); 1852SN/A 18611386Ssteve.reinhardt@amd.com mmap_end = 0; 1871514SN/A nxm_start = nxm_end = 0; 1882SN/A // other parameters will be initialized when the program is loaded 1892SN/A} 1902SN/A 1912378SN/A 1922SN/Avoid 1932SN/AProcess::regStats() 1942SN/A{ 19511522Sstephan.diestelhorst@arm.com SimObject::regStats(); 19611522Sstephan.diestelhorst@arm.com 197729SN/A using namespace Stats; 1982SN/A 1992SN/A num_syscalls 2008240Snate@binkert.org .name(name() + ".num_syscalls") 2012SN/A .desc("Number of system calls") 2022SN/A ; 2032SN/A} 2042SN/A 20510930Sbrandon.potter@amd.comvoid 20610932Sbrandon.potter@amd.comProcess::inheritFDArray(Process *p) 2072SN/A{ 20810930Sbrandon.potter@amd.com fd_array = p->fd_array; 2092SN/A} 2102SN/A 2115713Shsul@eecs.umich.eduThreadContext * 2125713Shsul@eecs.umich.eduProcess::findFreeContext() 2132SN/A{ 21410929Sbrandon.potter@amd.com for (int id : contextIds) { 21510929Sbrandon.potter@amd.com ThreadContext *tc = system->getThreadContext(id); 21610929Sbrandon.potter@amd.com if (tc->status() == ThreadContext::Halted) 2175713Shsul@eecs.umich.edu return tc; 2185512SMichael.Adler@intel.com } 2195713Shsul@eecs.umich.edu return NULL; 2202SN/A} 2212SN/A 2221395SN/Avoid 2237532Ssteve.reinhardt@amd.comProcess::initState() 2241395SN/A{ 2255713Shsul@eecs.umich.edu if (contextIds.empty()) 2265713Shsul@eecs.umich.edu fatal("Process %s is not associated with any HW contexts!\n", name()); 2272378SN/A 2282680Sktlim@umich.edu // first thread context for this process... initialize & enable 2295713Shsul@eecs.umich.edu ThreadContext *tc = system->getThreadContext(contextIds[0]); 2301395SN/A 2311634SN/A // mark this context as active so it will start ticking. 23210407Smitch.hayenga@arm.com tc->activate(); 23310298Salexandru.dutu@amd.com 23410298Salexandru.dutu@amd.com pTable->initState(tc); 2351395SN/A} 2362SN/A 23710913Sandreas.sandberg@arm.comDrainState 23810913Sandreas.sandberg@arm.comProcess::drain() 23910905Sandreas.sandberg@arm.com{ 24010932Sbrandon.potter@amd.com findFileOffsets(); 24110913Sandreas.sandberg@arm.com return DrainState::Drained; 24210905Sandreas.sandberg@arm.com} 24310905Sandreas.sandberg@arm.com 2442SN/Aint 24510932Sbrandon.potter@amd.comProcess::allocFD(int sim_fd, const string& filename, int flags, int mode, 24610932Sbrandon.potter@amd.com bool pipe) 2472SN/A{ 24810930Sbrandon.potter@amd.com for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) { 24910932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(free_fd); 25010930Sbrandon.potter@amd.com if (fde->isFree()) { 25110930Sbrandon.potter@amd.com fde->set(sim_fd, filename, flags, mode, pipe); 2521970SN/A return free_fd; 2531970SN/A } 2542SN/A } 2552SN/A 25610930Sbrandon.potter@amd.com fatal("Out of target file descriptors"); 2571970SN/A} 2582SN/A 2591970SN/Avoid 26010932Sbrandon.potter@amd.comProcess::resetFDEntry(int tgt_fd) 2611970SN/A{ 26210932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(tgt_fd); 26310930Sbrandon.potter@amd.com assert(fde->fd > -1); 2641970SN/A 26510930Sbrandon.potter@amd.com fde->reset(); 2662SN/A} 2672SN/A 2682SN/Aint 26910932Sbrandon.potter@amd.comProcess::getSimFD(int tgt_fd) 2702SN/A{ 27110932Sbrandon.potter@amd.com FDEntry *entry = getFDEntry(tgt_fd); 27210930Sbrandon.potter@amd.com return entry ? entry->fd : -1; 2732SN/A} 2742SN/A 27510930Sbrandon.potter@amd.comFDEntry * 27610932Sbrandon.potter@amd.comProcess::getFDEntry(int tgt_fd) 2775282Srstrong@cs.ucsd.edu{ 27810930Sbrandon.potter@amd.com assert(0 <= tgt_fd && tgt_fd < fd_array->size()); 27910930Sbrandon.potter@amd.com return &(*fd_array)[tgt_fd]; 28010929Sbrandon.potter@amd.com} 2815282Srstrong@cs.ucsd.edu 28210929Sbrandon.potter@amd.comint 28310932Sbrandon.potter@amd.comProcess::getTgtFD(int sim_fd) 28410929Sbrandon.potter@amd.com{ 28510930Sbrandon.potter@amd.com for (int index = 0; index < fd_array->size(); index++) 28610930Sbrandon.potter@amd.com if ((*fd_array)[index].fd == sim_fd) 28710929Sbrandon.potter@amd.com return index; 28810929Sbrandon.potter@amd.com return -1; 2895282Srstrong@cs.ucsd.edu} 2907487Ssteve.reinhardt@amd.com 2918601Ssteve.reinhardt@amd.comvoid 2928601Ssteve.reinhardt@amd.comProcess::allocateMem(Addr vaddr, int64_t size, bool clobber) 2938601Ssteve.reinhardt@amd.com{ 29410318Sandreas.hansson@arm.com int npages = divCeil(size, (int64_t)PageBytes); 2958601Ssteve.reinhardt@amd.com Addr paddr = system->allocPhysPages(npages); 29611294Sandreas.hansson@arm.com pTable->map(vaddr, paddr, size, 29711294Sandreas.hansson@arm.com clobber ? PageTableBase::Clobber : PageTableBase::Zero); 2988601Ssteve.reinhardt@amd.com} 2998601Ssteve.reinhardt@amd.com 3004434Ssaidi@eecs.umich.edubool 3018539Sgblack@eecs.umich.eduProcess::fixupStackFault(Addr vaddr) 3024434Ssaidi@eecs.umich.edu{ 3038539Sgblack@eecs.umich.edu // Check if this is already on the stack and there's just no page there 3048539Sgblack@eecs.umich.edu // yet. 3054434Ssaidi@eecs.umich.edu if (vaddr >= stack_min && vaddr < stack_base) { 30610318Sandreas.hansson@arm.com allocateMem(roundDown(vaddr, PageBytes), PageBytes); 3074434Ssaidi@eecs.umich.edu return true; 3084434Ssaidi@eecs.umich.edu } 3094434Ssaidi@eecs.umich.edu 3108539Sgblack@eecs.umich.edu // We've accessed the next page of the stack, so extend it to include 3118539Sgblack@eecs.umich.edu // this address. 3125154Sgblack@eecs.umich.edu if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) { 3135154Sgblack@eecs.umich.edu while (vaddr < stack_min) { 3145154Sgblack@eecs.umich.edu stack_min -= TheISA::PageBytes; 3158539Sgblack@eecs.umich.edu if (stack_base - stack_min > max_stack_size) 3165154Sgblack@eecs.umich.edu fatal("Maximum stack size exceeded\n"); 3178601Ssteve.reinhardt@amd.com allocateMem(stack_min, TheISA::PageBytes); 3185823Ssaidi@eecs.umich.edu inform("Increasing stack size by one page."); 3195154Sgblack@eecs.umich.edu }; 3204434Ssaidi@eecs.umich.edu return true; 3214434Ssaidi@eecs.umich.edu } 3224434Ssaidi@eecs.umich.edu return false; 3234434Ssaidi@eecs.umich.edu} 3244434Ssaidi@eecs.umich.edu 3255282Srstrong@cs.ucsd.eduvoid 32610932Sbrandon.potter@amd.comProcess::fixFileOffsets() 3277487Ssteve.reinhardt@amd.com{ 32810930Sbrandon.potter@amd.com auto seek = [] (FDEntry *fde) 32910930Sbrandon.potter@amd.com { 33010930Sbrandon.potter@amd.com if (lseek(fde->fd, fde->fileOffset, SEEK_SET) < 0) 33110930Sbrandon.potter@amd.com fatal("Unable to see to location in %s", fde->filename); 33210930Sbrandon.potter@amd.com }; 3335282Srstrong@cs.ucsd.edu 33410930Sbrandon.potter@amd.com std::map<string,int>::iterator it; 3355282Srstrong@cs.ucsd.edu 33610930Sbrandon.potter@amd.com // Search through the input options and set fd if match is found; 33710930Sbrandon.potter@amd.com // otherwise, open an input file and seek to location. 33810932Sbrandon.potter@amd.com FDEntry *fde_stdin = getFDEntry(STDIN_FILENO); 33911785Sjthestness@gmail.com 34011785Sjthestness@gmail.com // Check if user has specified a different input file, and if so, use it 34111785Sjthestness@gmail.com // instead of the file specified in the checkpoint. This also resets the 34211785Sjthestness@gmail.com // file offset from the checkpointed value 34311785Sjthestness@gmail.com string new_in = ((ProcessParams*)params())->input; 34411785Sjthestness@gmail.com if (new_in != fde_stdin->filename) { 34511785Sjthestness@gmail.com warn("Using new input file (%s) rather than checkpointed (%s)\n", 34611785Sjthestness@gmail.com new_in, fde_stdin->filename); 34711785Sjthestness@gmail.com fde_stdin->filename = new_in; 34811785Sjthestness@gmail.com fde_stdin->fileOffset = 0; 34911785Sjthestness@gmail.com } 35011785Sjthestness@gmail.com 35110930Sbrandon.potter@amd.com if ((it = imap.find(fde_stdin->filename)) != imap.end()) { 35210930Sbrandon.potter@amd.com fde_stdin->fd = it->second; 35310930Sbrandon.potter@amd.com } else { 35410930Sbrandon.potter@amd.com fde_stdin->fd = openInputFile(fde_stdin->filename); 35510930Sbrandon.potter@amd.com seek(fde_stdin); 3565282Srstrong@cs.ucsd.edu } 3575282Srstrong@cs.ucsd.edu 35810930Sbrandon.potter@amd.com // Search through the output/error options and set fd if match is found; 35910930Sbrandon.potter@amd.com // otherwise, open an output file and seek to location. 36010932Sbrandon.potter@amd.com FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO); 36111785Sjthestness@gmail.com 36211785Sjthestness@gmail.com // Check if user has specified a different output file, and if so, use it 36311785Sjthestness@gmail.com // instead of the file specified in the checkpoint. This also resets the 36411785Sjthestness@gmail.com // file offset from the checkpointed value 36511785Sjthestness@gmail.com string new_out = ((ProcessParams*)params())->output; 36611785Sjthestness@gmail.com if (new_out != fde_stdout->filename) { 36711785Sjthestness@gmail.com warn("Using new output file (%s) rather than checkpointed (%s)\n", 36811785Sjthestness@gmail.com new_out, fde_stdout->filename); 36911785Sjthestness@gmail.com fde_stdout->filename = new_out; 37011785Sjthestness@gmail.com fde_stdout->fileOffset = 0; 37111785Sjthestness@gmail.com } 37211785Sjthestness@gmail.com 37310930Sbrandon.potter@amd.com if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) { 37410930Sbrandon.potter@amd.com fde_stdout->fd = it->second; 37510930Sbrandon.potter@amd.com } else { 37610930Sbrandon.potter@amd.com fde_stdout->fd = openOutputFile(fde_stdout->filename); 37710930Sbrandon.potter@amd.com seek(fde_stdout); 3785282Srstrong@cs.ucsd.edu } 3795282Srstrong@cs.ucsd.edu 38010932Sbrandon.potter@amd.com FDEntry *fde_stderr = getFDEntry(STDERR_FILENO); 38111785Sjthestness@gmail.com 38211785Sjthestness@gmail.com // Check if user has specified a different error file, and if so, use it 38311785Sjthestness@gmail.com // instead of the file specified in the checkpoint. This also resets the 38411785Sjthestness@gmail.com // file offset from the checkpointed value 38511785Sjthestness@gmail.com string new_err = ((ProcessParams*)params())->errout; 38611785Sjthestness@gmail.com if (new_err != fde_stderr->filename) { 38711785Sjthestness@gmail.com warn("Using new error file (%s) rather than checkpointed (%s)\n", 38811785Sjthestness@gmail.com new_err, fde_stderr->filename); 38911785Sjthestness@gmail.com fde_stderr->filename = new_err; 39011785Sjthestness@gmail.com fde_stderr->fileOffset = 0; 39111785Sjthestness@gmail.com } 39211785Sjthestness@gmail.com 39310930Sbrandon.potter@amd.com if (fde_stdout->filename == fde_stderr->filename) { 39410930Sbrandon.potter@amd.com // Reuse the same file descriptor if these match. 39510930Sbrandon.potter@amd.com fde_stderr->fd = fde_stdout->fd; 39610930Sbrandon.potter@amd.com } else if ((it = oemap.find(fde_stderr->filename)) != oemap.end()) { 39710930Sbrandon.potter@amd.com fde_stderr->fd = it->second; 39810930Sbrandon.potter@amd.com } else { 39910930Sbrandon.potter@amd.com fde_stderr->fd = openOutputFile(fde_stderr->filename); 40010930Sbrandon.potter@amd.com seek(fde_stderr); 4015514SMichael.Adler@intel.com } 4025282Srstrong@cs.ucsd.edu 40310930Sbrandon.potter@amd.com for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) { 40410932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(tgt_fd); 40510930Sbrandon.potter@amd.com if (fde->fd == -1) 40610930Sbrandon.potter@amd.com continue; 4075282Srstrong@cs.ucsd.edu 40810930Sbrandon.potter@amd.com if (fde->isPipe) { 40910930Sbrandon.potter@amd.com if (fde->filename == "PIPE-WRITE") 41010930Sbrandon.potter@amd.com continue; 41110930Sbrandon.potter@amd.com assert(fde->filename == "PIPE-READ"); 4125282Srstrong@cs.ucsd.edu 41310930Sbrandon.potter@amd.com int fds[2]; 41410930Sbrandon.potter@amd.com if (pipe(fds) < 0) 41510930Sbrandon.potter@amd.com fatal("Unable to create new pipe"); 4165282Srstrong@cs.ucsd.edu 41710930Sbrandon.potter@amd.com fde->fd = fds[0]; 4185282Srstrong@cs.ucsd.edu 41910932Sbrandon.potter@amd.com FDEntry *fde_write = getFDEntry(fde->readPipeSource); 42011378Sbrandon.potter@amd.com assert(fde_write->filename == "PIPE-WRITE"); 42110930Sbrandon.potter@amd.com fde_write->fd = fds[1]; 42210930Sbrandon.potter@amd.com } else { 42310930Sbrandon.potter@amd.com fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode); 42410930Sbrandon.potter@amd.com seek(fde); 4255282Srstrong@cs.ucsd.edu } 4265282Srstrong@cs.ucsd.edu } 4275282Srstrong@cs.ucsd.edu} 4287487Ssteve.reinhardt@amd.com 4295282Srstrong@cs.ucsd.eduvoid 43010932Sbrandon.potter@amd.comProcess::findFileOffsets() 4317487Ssteve.reinhardt@amd.com{ 43210930Sbrandon.potter@amd.com for (auto& fde : *fd_array) { 43310930Sbrandon.potter@amd.com if (fde.fd != -1) 43410930Sbrandon.potter@amd.com fde.fileOffset = lseek(fde.fd, 0, SEEK_CUR); 4355282Srstrong@cs.ucsd.edu } 4365282Srstrong@cs.ucsd.edu} 4375282Srstrong@cs.ucsd.edu 4385282Srstrong@cs.ucsd.eduvoid 4397487Ssteve.reinhardt@amd.comProcess::setReadPipeSource(int read_pipe_fd, int source_fd) 4407487Ssteve.reinhardt@amd.com{ 44110932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(read_pipe_fd); 44210930Sbrandon.potter@amd.com assert(source_fd >= -1); 44310930Sbrandon.potter@amd.com fde->readPipeSource = source_fd; 4445282Srstrong@cs.ucsd.edu} 4455282Srstrong@cs.ucsd.edu 4463311Ssaidi@eecs.umich.eduvoid 44710905Sandreas.sandberg@arm.comProcess::serialize(CheckpointOut &cp) const 4483311Ssaidi@eecs.umich.edu{ 4493311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(brk_point); 4503311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_base); 4513311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_size); 4523311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(stack_min); 4533311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(next_thread_stack_base); 4543311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(mmap_end); 4553311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(nxm_start); 4563311Ssaidi@eecs.umich.edu SERIALIZE_SCALAR(nxm_end); 45710905Sandreas.sandberg@arm.com pTable->serialize(cp); 45810930Sbrandon.potter@amd.com for (int x = 0; x < fd_array->size(); x++) { 45910930Sbrandon.potter@amd.com (*fd_array)[x].serializeSection(cp, csprintf("FDEntry%d", x)); 4605282Srstrong@cs.ucsd.edu } 4616820SLisa.Hsu@amd.com SERIALIZE_SCALAR(M5_pid); 4623311Ssaidi@eecs.umich.edu 4633311Ssaidi@eecs.umich.edu} 4643311Ssaidi@eecs.umich.edu 4653311Ssaidi@eecs.umich.eduvoid 46610905Sandreas.sandberg@arm.comProcess::unserialize(CheckpointIn &cp) 4673311Ssaidi@eecs.umich.edu{ 4683311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(brk_point); 4693311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_base); 4703311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_size); 4713311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(stack_min); 4723311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(next_thread_stack_base); 4733311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(mmap_end); 4743311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(nxm_start); 4753311Ssaidi@eecs.umich.edu UNSERIALIZE_SCALAR(nxm_end); 47610905Sandreas.sandberg@arm.com pTable->unserialize(cp); 47710930Sbrandon.potter@amd.com for (int x = 0; x < fd_array->size(); x++) { 47810932Sbrandon.potter@amd.com FDEntry *fde = getFDEntry(x); 47910930Sbrandon.potter@amd.com fde->unserializeSection(cp, csprintf("FDEntry%d", x)); 4807487Ssteve.reinhardt@amd.com } 48110932Sbrandon.potter@amd.com fixFileOffsets(); 4826820SLisa.Hsu@amd.com UNSERIALIZE_OPT_SCALAR(M5_pid); 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), 51010499Ssteve.reinhardt@amd.com __uid(params->uid), __euid(params->euid), 51110499Ssteve.reinhardt@amd.com __gid(params->gid), __egid(params->egid), 51210499Ssteve.reinhardt@amd.com __pid(params->pid), __ppid(params->ppid), 51310496Ssteve.reinhardt@amd.com drivers(params->drivers) 5142SN/A{ 5153114Sgblack@eecs.umich.edu 5161158SN/A // load up symbols, if any... these may be used for debugging or 5171158SN/A // profiling. 5181158SN/A if (!debugSymbolTable) { 5191158SN/A debugSymbolTable = new SymbolTable(); 5201158SN/A if (!objFile->loadGlobalSymbols(debugSymbolTable) || 5219641Sguodeyuan@tsinghua.org.cn !objFile->loadLocalSymbols(debugSymbolTable) || 5229641Sguodeyuan@tsinghua.org.cn !objFile->loadWeakSymbols(debugSymbolTable)) { 5231158SN/A // didn't load any symbols 5241158SN/A delete debugSymbolTable; 5251158SN/A debugSymbolTable = NULL; 5261158SN/A } 5271158SN/A } 5282378SN/A} 5291158SN/A 5302378SN/Avoid 5312680Sktlim@umich.eduLiveProcess::syscall(int64_t callnum, ThreadContext *tc) 5322093SN/A{ 5332093SN/A num_syscalls++; 5342093SN/A 5352093SN/A SyscallDesc *desc = getDesc(callnum); 5362093SN/A if (desc == NULL) 5372093SN/A fatal("Syscall %d out of range", callnum); 5382093SN/A 5392680Sktlim@umich.edu desc->doSyscall(callnum, this, tc); 5402093SN/A} 5412SN/A 5426701Sgblack@eecs.umich.eduIntReg 5436701Sgblack@eecs.umich.eduLiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width) 5446701Sgblack@eecs.umich.edu{ 5456701Sgblack@eecs.umich.edu return getSyscallArg(tc, i); 5466701Sgblack@eecs.umich.edu} 5476701Sgblack@eecs.umich.edu 54810496Ssteve.reinhardt@amd.com 54910496Ssteve.reinhardt@amd.comEmulatedDriver * 55010496Ssteve.reinhardt@amd.comLiveProcess::findDriver(std::string filename) 55110496Ssteve.reinhardt@amd.com{ 55210496Ssteve.reinhardt@amd.com for (EmulatedDriver *d : drivers) { 55310496Ssteve.reinhardt@amd.com if (d->match(filename)) 55410496Ssteve.reinhardt@amd.com return d; 55510496Ssteve.reinhardt@amd.com } 55610496Ssteve.reinhardt@amd.com 55710496Ssteve.reinhardt@amd.com return NULL; 55810496Ssteve.reinhardt@amd.com} 55910496Ssteve.reinhardt@amd.com 56011389Sbrandon.potter@amd.comvoid 56111389Sbrandon.potter@amd.comLiveProcess::updateBias() 56211389Sbrandon.potter@amd.com{ 56311389Sbrandon.potter@amd.com ObjectFile *interp = objFile->getInterpreter(); 56411389Sbrandon.potter@amd.com 56511389Sbrandon.potter@amd.com if (!interp || !interp->relocatable()) 56611389Sbrandon.potter@amd.com return; 56711389Sbrandon.potter@amd.com 56811389Sbrandon.potter@amd.com // Determine how large the interpreters footprint will be in the process 56911389Sbrandon.potter@amd.com // address space. 57011389Sbrandon.potter@amd.com Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes); 57111389Sbrandon.potter@amd.com 57211389Sbrandon.potter@amd.com // We are allocating the memory area; set the bias to the lowest address 57311389Sbrandon.potter@amd.com // in the allocated memory region. 57411389Sbrandon.potter@amd.com Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end; 57511389Sbrandon.potter@amd.com 57611389Sbrandon.potter@amd.com // Adjust the process mmap area to give the interpreter room; the real 57711389Sbrandon.potter@amd.com // execve system call would just invoke the kernel's internal mmap 57811389Sbrandon.potter@amd.com // functions to make these adjustments. 57911389Sbrandon.potter@amd.com mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize; 58011389Sbrandon.potter@amd.com 58111389Sbrandon.potter@amd.com interp->updateBias(ld_bias); 58211389Sbrandon.potter@amd.com} 58311389Sbrandon.potter@amd.com 58411389Sbrandon.potter@amd.com 58511392Sbrandon.potter@amd.comObjectFile * 58611392Sbrandon.potter@amd.comLiveProcess::getInterpreter() 58711392Sbrandon.potter@amd.com{ 58811392Sbrandon.potter@amd.com return objFile->getInterpreter(); 58911392Sbrandon.potter@amd.com} 59011392Sbrandon.potter@amd.com 59111392Sbrandon.potter@amd.com 59211389Sbrandon.potter@amd.comAddr 59311389Sbrandon.potter@amd.comLiveProcess::getBias() 59411389Sbrandon.potter@amd.com{ 59511392Sbrandon.potter@amd.com ObjectFile *interp = getInterpreter(); 59611389Sbrandon.potter@amd.com 59711389Sbrandon.potter@amd.com return interp ? interp->bias() : objFile->bias(); 59811389Sbrandon.potter@amd.com} 59911389Sbrandon.potter@amd.com 60011389Sbrandon.potter@amd.com 60111389Sbrandon.potter@amd.comAddr 60211389Sbrandon.potter@amd.comLiveProcess::getStartPC() 60311389Sbrandon.potter@amd.com{ 60411392Sbrandon.potter@amd.com ObjectFile *interp = getInterpreter(); 60511389Sbrandon.potter@amd.com 60611389Sbrandon.potter@amd.com return interp ? interp->entryPoint() : objFile->entryPoint(); 60711389Sbrandon.potter@amd.com} 60811389Sbrandon.potter@amd.com 60910496Ssteve.reinhardt@amd.com 6102715Sstever@eecs.umich.eduLiveProcess * 6115154Sgblack@eecs.umich.eduLiveProcess::create(LiveProcessParams * params) 6122715Sstever@eecs.umich.edu{ 6132715Sstever@eecs.umich.edu LiveProcess *process = NULL; 6142715Sstever@eecs.umich.edu 61511140Sjthestness@gmail.com // If not specified, set the executable parameter equal to the 61611140Sjthestness@gmail.com // simulated system's zeroth command line parameter 61711140Sjthestness@gmail.com if (params->executable == "") { 61811140Sjthestness@gmail.com params->executable = params->cmd[0]; 61911140Sjthestness@gmail.com } 62011140Sjthestness@gmail.com 62111140Sjthestness@gmail.com ObjectFile *objFile = createObjectFile(params->executable); 6222715Sstever@eecs.umich.edu if (objFile == NULL) { 62311140Sjthestness@gmail.com fatal("Can't load object file %s", params->executable); 6242715Sstever@eecs.umich.edu } 6252715Sstever@eecs.umich.edu 6265089Sgblack@eecs.umich.edu#if THE_ISA == ALPHA_ISA 6275753Ssteve.reinhardt@amd.com if (objFile->getArch() != ObjectFile::Alpha) 6285753Ssteve.reinhardt@amd.com fatal("Object file architecture does not match compiled ISA (Alpha)."); 6295753Ssteve.reinhardt@amd.com 6302715Sstever@eecs.umich.edu switch (objFile->getOpSys()) { 6315753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6325753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6335753Ssteve.reinhardt@amd.com // fall through 6342715Sstever@eecs.umich.edu case ObjectFile::Linux: 6355154Sgblack@eecs.umich.edu process = new AlphaLinuxProcess(params, objFile); 6362715Sstever@eecs.umich.edu break; 6372715Sstever@eecs.umich.edu 6382715Sstever@eecs.umich.edu default: 6392715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6402715Sstever@eecs.umich.edu } 6412715Sstever@eecs.umich.edu#elif THE_ISA == SPARC_ISA 6425753Ssteve.reinhardt@amd.com if (objFile->getArch() != ObjectFile::SPARC64 && 6435753Ssteve.reinhardt@amd.com objFile->getArch() != ObjectFile::SPARC32) 6442715Sstever@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (SPARC)."); 6452715Sstever@eecs.umich.edu switch (objFile->getOpSys()) { 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: 6504111Sgblack@eecs.umich.edu if (objFile->getArch() == ObjectFile::SPARC64) { 6515154Sgblack@eecs.umich.edu process = new Sparc64LinuxProcess(params, objFile); 6524111Sgblack@eecs.umich.edu } else { 6535154Sgblack@eecs.umich.edu process = new Sparc32LinuxProcess(params, objFile); 6544111Sgblack@eecs.umich.edu } 6552715Sstever@eecs.umich.edu break; 6562715Sstever@eecs.umich.edu 6572715Sstever@eecs.umich.edu 6582715Sstever@eecs.umich.edu case ObjectFile::Solaris: 6595154Sgblack@eecs.umich.edu process = new SparcSolarisProcess(params, objFile); 6602715Sstever@eecs.umich.edu break; 6615753Ssteve.reinhardt@amd.com 6622715Sstever@eecs.umich.edu default: 6632715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6642715Sstever@eecs.umich.edu } 6654157Sgblack@eecs.umich.edu#elif THE_ISA == X86_ISA 6665874Sgblack@eecs.umich.edu if (objFile->getArch() != ObjectFile::X86_64 && 6675874Sgblack@eecs.umich.edu objFile->getArch() != ObjectFile::I386) 6684166Sgblack@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (x86)."); 6694157Sgblack@eecs.umich.edu switch (objFile->getOpSys()) { 6705753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6715753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6725753Ssteve.reinhardt@amd.com // fall through 6734166Sgblack@eecs.umich.edu case ObjectFile::Linux: 6745874Sgblack@eecs.umich.edu if (objFile->getArch() == ObjectFile::X86_64) { 6755955Sgblack@eecs.umich.edu process = new X86_64LinuxProcess(params, objFile); 6765874Sgblack@eecs.umich.edu } else { 6775955Sgblack@eecs.umich.edu process = new I386LinuxProcess(params, objFile); 6785874Sgblack@eecs.umich.edu } 6794166Sgblack@eecs.umich.edu break; 6805753Ssteve.reinhardt@amd.com 6814157Sgblack@eecs.umich.edu default: 6824157Sgblack@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6834157Sgblack@eecs.umich.edu } 6842715Sstever@eecs.umich.edu#elif THE_ISA == MIPS_ISA 6852715Sstever@eecs.umich.edu if (objFile->getArch() != ObjectFile::Mips) 6862715Sstever@eecs.umich.edu fatal("Object file architecture does not match compiled ISA (MIPS)."); 6872715Sstever@eecs.umich.edu switch (objFile->getOpSys()) { 6885753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 6895753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 6905753Ssteve.reinhardt@amd.com // fall through 6912715Sstever@eecs.umich.edu case ObjectFile::Linux: 6925154Sgblack@eecs.umich.edu process = new MipsLinuxProcess(params, objFile); 6932715Sstever@eecs.umich.edu break; 6942715Sstever@eecs.umich.edu 6952715Sstever@eecs.umich.edu default: 6962715Sstever@eecs.umich.edu fatal("Unknown/unsupported operating system."); 6972715Sstever@eecs.umich.edu } 6985335Shines@cs.fsu.edu#elif THE_ISA == ARM_ISA 69910037SARM gem5 Developers ObjectFile::Arch arch = objFile->getArch(); 70010037SARM gem5 Developers if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 70110037SARM gem5 Developers arch != ObjectFile::Arm64) 7025335Shines@cs.fsu.edu fatal("Object file architecture does not match compiled ISA (ARM)."); 7035335Shines@cs.fsu.edu switch (objFile->getOpSys()) { 7045753Ssteve.reinhardt@amd.com case ObjectFile::UnknownOpSys: 7055753Ssteve.reinhardt@amd.com warn("Unknown operating system; assuming Linux."); 7065753Ssteve.reinhardt@amd.com // fall through 7075335Shines@cs.fsu.edu case ObjectFile::Linux: 70810037SARM gem5 Developers if (arch == ObjectFile::Arm64) { 70910037SARM gem5 Developers process = new ArmLinuxProcess64(params, objFile, 71010037SARM gem5 Developers objFile->getArch()); 71110037SARM gem5 Developers } else { 71210037SARM gem5 Developers process = new ArmLinuxProcess32(params, objFile, 71310037SARM gem5 Developers objFile->getArch()); 71410037SARM gem5 Developers } 7155335Shines@cs.fsu.edu break; 71610810Sbr@bsdpad.com case ObjectFile::FreeBSD: 71710810Sbr@bsdpad.com if (arch == ObjectFile::Arm64) { 71810810Sbr@bsdpad.com process = new ArmFreebsdProcess64(params, objFile, 71910810Sbr@bsdpad.com objFile->getArch()); 72010810Sbr@bsdpad.com } else { 72110810Sbr@bsdpad.com process = new ArmFreebsdProcess32(params, objFile, 72210810Sbr@bsdpad.com objFile->getArch()); 72310810Sbr@bsdpad.com } 72410810Sbr@bsdpad.com break; 7256392Ssaidi@eecs.umich.edu case ObjectFile::LinuxArmOABI: 7266392Ssaidi@eecs.umich.edu fatal("M5 does not support ARM OABI binaries. Please recompile with an" 7276392Ssaidi@eecs.umich.edu " EABI compiler."); 7285335Shines@cs.fsu.edu default: 7295335Shines@cs.fsu.edu fatal("Unknown/unsupported operating system."); 7305335Shines@cs.fsu.edu } 7316691Stjones1@inf.ed.ac.uk#elif THE_ISA == POWER_ISA 7326691Stjones1@inf.ed.ac.uk if (objFile->getArch() != ObjectFile::Power) 7336691Stjones1@inf.ed.ac.uk fatal("Object file architecture does not match compiled ISA (Power)."); 7346691Stjones1@inf.ed.ac.uk switch (objFile->getOpSys()) { 7356691Stjones1@inf.ed.ac.uk case ObjectFile::UnknownOpSys: 7366691Stjones1@inf.ed.ac.uk warn("Unknown operating system; assuming Linux."); 7376691Stjones1@inf.ed.ac.uk // fall through 7386691Stjones1@inf.ed.ac.uk case ObjectFile::Linux: 7396691Stjones1@inf.ed.ac.uk process = new PowerLinuxProcess(params, objFile); 7406691Stjones1@inf.ed.ac.uk break; 7416691Stjones1@inf.ed.ac.uk 7426691Stjones1@inf.ed.ac.uk default: 7436691Stjones1@inf.ed.ac.uk fatal("Unknown/unsupported operating system."); 7446691Stjones1@inf.ed.ac.uk } 74511723Sar4jc@virginia.edu#elif THE_ISA == RISCV_ISA 74611723Sar4jc@virginia.edu if (objFile->getArch() != ObjectFile::Riscv) 74711723Sar4jc@virginia.edu fatal("Object file architecture does not match compiled ISA (RISCV)."); 74811723Sar4jc@virginia.edu switch (objFile->getOpSys()) { 74911723Sar4jc@virginia.edu case ObjectFile::UnknownOpSys: 75011723Sar4jc@virginia.edu warn("Unknown operating system; assuming Linux."); 75111723Sar4jc@virginia.edu // fall through 75211723Sar4jc@virginia.edu case ObjectFile::Linux: 75311723Sar4jc@virginia.edu process = new RiscvLinuxProcess(params, objFile); 75411723Sar4jc@virginia.edu break; 75511723Sar4jc@virginia.edu default: 75611723Sar4jc@virginia.edu fatal("Unknown/unsupported operating system."); 75711723Sar4jc@virginia.edu } 7582715Sstever@eecs.umich.edu#else 7592715Sstever@eecs.umich.edu#error "THE_ISA not set" 7602715Sstever@eecs.umich.edu#endif 7612715Sstever@eecs.umich.edu 7622715Sstever@eecs.umich.edu if (process == NULL) 7632715Sstever@eecs.umich.edu fatal("Unknown error creating process object."); 7642715Sstever@eecs.umich.edu return process; 7652715Sstever@eecs.umich.edu} 7662715Sstever@eecs.umich.edu 7674762Snate@binkert.orgLiveProcess * 7684762Snate@binkert.orgLiveProcessParams::create() 7692715Sstever@eecs.umich.edu{ 7705154Sgblack@eecs.umich.edu return LiveProcess::create(this); 7712715Sstever@eecs.umich.edu} 772