process.cc revision 10559:62f5f7363197
1/*
2 * Copyright (c) 2014 Advanced Micro Devices, Inc.
3 * Copyright (c) 2012 ARM Limited
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder.  You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated
12 * unmodified and in its entirety in all distributions of the software,
13 * modified or unmodified, in source code or in binary form.
14 *
15 * Copyright (c) 2001-2005 The Regents of The University of Michigan
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Authors: Nathan Binkert
42 *          Steve Reinhardt
43 *          Ali Saidi
44 */
45
46#include <fcntl.h>
47#include <unistd.h>
48
49#include <cstdio>
50#include <string>
51
52#include "base/loader/object_file.hh"
53#include "base/loader/symtab.hh"
54#include "base/intmath.hh"
55#include "base/statistics.hh"
56#include "config/the_isa.hh"
57#include "cpu/thread_context.hh"
58#include "mem/page_table.hh"
59#include "mem/multi_level_page_table.hh"
60#include "mem/se_translating_port_proxy.hh"
61#include "params/LiveProcess.hh"
62#include "params/Process.hh"
63#include "sim/debug.hh"
64#include "sim/process.hh"
65#include "sim/process_impl.hh"
66#include "sim/stats.hh"
67#include "sim/syscall_emul.hh"
68#include "sim/system.hh"
69
70#if THE_ISA == ALPHA_ISA
71#include "arch/alpha/linux/process.hh"
72#include "arch/alpha/tru64/process.hh"
73#elif THE_ISA == SPARC_ISA
74#include "arch/sparc/linux/process.hh"
75#include "arch/sparc/solaris/process.hh"
76#elif THE_ISA == MIPS_ISA
77#include "arch/mips/linux/process.hh"
78#elif THE_ISA == ARM_ISA
79#include "arch/arm/linux/process.hh"
80#elif THE_ISA == X86_ISA
81#include "arch/x86/linux/process.hh"
82#elif THE_ISA == POWER_ISA
83#include "arch/power/linux/process.hh"
84#else
85#error "THE_ISA not set"
86#endif
87
88
89using namespace std;
90using namespace TheISA;
91
92// current number of allocated processes
93int num_processes = 0;
94
95template<class IntType>
96AuxVector<IntType>::AuxVector(IntType type, IntType val)
97{
98    a_type = TheISA::htog(type);
99    a_val = TheISA::htog(val);
100}
101
102template struct AuxVector<uint32_t>;
103template struct AuxVector<uint64_t>;
104
105Process::Process(ProcessParams * params)
106    : SimObject(params), system(params->system),
107      brk_point(0), stack_base(0), stack_size(0), stack_min(0),
108      max_stack_size(params->max_stack_size),
109      next_thread_stack_base(0),
110      M5_pid(system->allocatePID()),
111      useArchPT(params->useArchPT),
112      kvmInSE(params->kvmInSE),
113      pTable(useArchPT ?
114        static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) :
115        static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ),
116      initVirtMem(system->getSystemPort(), this,
117                  SETranslatingPortProxy::Always)
118{
119    string in = params->input;
120    string out = params->output;
121    string err = params->errout;
122
123    // initialize file descriptors to default: same as simulator
124    int stdin_fd, stdout_fd, stderr_fd;
125
126    if (in == "stdin" || in == "cin")
127        stdin_fd = STDIN_FILENO;
128    else if (in == "None")
129        stdin_fd = -1;
130    else
131        stdin_fd = Process::openInputFile(in);
132
133    if (out == "stdout" || out == "cout")
134        stdout_fd = STDOUT_FILENO;
135    else if (out == "stderr" || out == "cerr")
136        stdout_fd = STDERR_FILENO;
137    else if (out == "None")
138        stdout_fd = -1;
139    else
140        stdout_fd = Process::openOutputFile(out);
141
142    if (err == "stdout" || err == "cout")
143        stderr_fd = STDOUT_FILENO;
144    else if (err == "stderr" || err == "cerr")
145        stderr_fd = STDERR_FILENO;
146    else if (err == "None")
147        stderr_fd = -1;
148    else if (err == out)
149        stderr_fd = stdout_fd;
150    else
151        stderr_fd = Process::openOutputFile(err);
152
153    // initialize first 3 fds (stdin, stdout, stderr)
154    Process::FdMap *fdo = &fd_map[STDIN_FILENO];
155    fdo->fd = stdin_fd;
156    fdo->filename = in;
157    fdo->flags = O_RDONLY;
158    fdo->mode = -1;
159    fdo->fileOffset = 0;
160
161    fdo =  &fd_map[STDOUT_FILENO];
162    fdo->fd = stdout_fd;
163    fdo->filename = out;
164    fdo->flags =  O_WRONLY | O_CREAT | O_TRUNC;
165    fdo->mode = 0774;
166    fdo->fileOffset = 0;
167
168    fdo = &fd_map[STDERR_FILENO];
169    fdo->fd = stderr_fd;
170    fdo->filename = err;
171    fdo->flags = O_WRONLY;
172    fdo->mode = -1;
173    fdo->fileOffset = 0;
174
175
176    // mark remaining fds as free
177    for (int i = 3; i <= MAX_FD; ++i) {
178        fdo = &fd_map[i];
179        fdo->fd = -1;
180    }
181
182    mmap_start = mmap_end = 0;
183    nxm_start = nxm_end = 0;
184    // other parameters will be initialized when the program is loaded
185}
186
187
188void
189Process::regStats()
190{
191    using namespace Stats;
192
193    num_syscalls
194        .name(name() + ".num_syscalls")
195        .desc("Number of system calls")
196        ;
197}
198
199//
200// static helper functions
201//
202int
203Process::openInputFile(const string &filename)
204{
205    int fd = open(filename.c_str(), O_RDONLY);
206
207    if (fd == -1) {
208        perror(NULL);
209        cerr << "unable to open \"" << filename << "\" for reading\n";
210        fatal("can't open input file");
211    }
212
213    return fd;
214}
215
216
217int
218Process::openOutputFile(const string &filename)
219{
220    int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664);
221
222    if (fd == -1) {
223        perror(NULL);
224        cerr << "unable to open \"" << filename << "\" for writing\n";
225        fatal("can't open output file");
226    }
227
228    return fd;
229}
230
231ThreadContext *
232Process::findFreeContext()
233{
234    int size = contextIds.size();
235    ThreadContext *tc;
236    for (int i = 0; i < size; ++i) {
237        tc = system->getThreadContext(contextIds[i]);
238        if (tc->status() == ThreadContext::Halted) {
239            // inactive context, free to use
240            return tc;
241        }
242    }
243    return NULL;
244}
245
246void
247Process::initState()
248{
249    if (contextIds.empty())
250        fatal("Process %s is not associated with any HW contexts!\n", name());
251
252    // first thread context for this process... initialize & enable
253    ThreadContext *tc = system->getThreadContext(contextIds[0]);
254
255    // mark this context as active so it will start ticking.
256    tc->activate();
257
258    pTable->initState(tc);
259}
260
261// map simulator fd sim_fd to target fd tgt_fd
262void
263Process::dup_fd(int sim_fd, int tgt_fd)
264{
265    if (tgt_fd < 0 || tgt_fd > MAX_FD)
266        panic("Process::dup_fd tried to dup past MAX_FD (%d)", tgt_fd);
267
268    Process::FdMap *fdo = &fd_map[tgt_fd];
269    fdo->fd = sim_fd;
270}
271
272
273// generate new target fd for sim_fd
274int
275Process::alloc_fd(int sim_fd, string filename, int flags, int mode, bool pipe)
276{
277    // in case open() returns an error, don't allocate a new fd
278    if (sim_fd == -1)
279        return -1;
280
281    // find first free target fd
282    for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
283        Process::FdMap *fdo = &fd_map[free_fd];
284        if (fdo->fd == -1 && fdo->driver == NULL) {
285            fdo->fd = sim_fd;
286            fdo->filename = filename;
287            fdo->mode = mode;
288            fdo->fileOffset = 0;
289            fdo->flags = flags;
290            fdo->isPipe = pipe;
291            fdo->readPipeSource = 0;
292            return free_fd;
293        }
294    }
295
296    panic("Process::alloc_fd: out of file descriptors!");
297}
298
299
300// free target fd (e.g., after close)
301void
302Process::free_fd(int tgt_fd)
303{
304    Process::FdMap *fdo = &fd_map[tgt_fd];
305    if (fdo->fd == -1)
306        warn("Process::free_fd: request to free unused fd %d", tgt_fd);
307
308    fdo->fd = -1;
309    fdo->filename = "NULL";
310    fdo->mode = 0;
311    fdo->fileOffset = 0;
312    fdo->flags = 0;
313    fdo->isPipe = false;
314    fdo->readPipeSource = 0;
315    fdo->driver = NULL;
316}
317
318
319// look up simulator fd for given target fd
320int
321Process::sim_fd(int tgt_fd)
322{
323    if (tgt_fd < 0 || tgt_fd > MAX_FD)
324        return -1;
325
326    return fd_map[tgt_fd].fd;
327}
328
329Process::FdMap *
330Process::sim_fd_obj(int tgt_fd)
331{
332    if (tgt_fd < 0 || tgt_fd > MAX_FD)
333        return NULL;
334
335    return &fd_map[tgt_fd];
336}
337
338void
339Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
340{
341    int npages = divCeil(size, (int64_t)PageBytes);
342    Addr paddr = system->allocPhysPages(npages);
343    pTable->map(vaddr, paddr, size, clobber ? PageTableBase::Clobber : 0);
344}
345
346bool
347Process::fixupStackFault(Addr vaddr)
348{
349    // Check if this is already on the stack and there's just no page there
350    // yet.
351    if (vaddr >= stack_min && vaddr < stack_base) {
352        allocateMem(roundDown(vaddr, PageBytes), PageBytes);
353        return true;
354    }
355
356    // We've accessed the next page of the stack, so extend it to include
357    // this address.
358    if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
359        while (vaddr < stack_min) {
360            stack_min -= TheISA::PageBytes;
361            if (stack_base - stack_min > max_stack_size)
362                fatal("Maximum stack size exceeded\n");
363            allocateMem(stack_min, TheISA::PageBytes);
364            inform("Increasing stack size by one page.");
365        };
366        return true;
367    }
368    return false;
369}
370
371// find all offsets for currently open files and save them
372void
373Process::fix_file_offsets()
374{
375    Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO];
376    Process::FdMap *fdo_stdout = &fd_map[STDOUT_FILENO];
377    Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO];
378    string in = fdo_stdin->filename;
379    string out = fdo_stdout->filename;
380    string err = fdo_stderr->filename;
381
382    // initialize file descriptors to default: same as simulator
383    int stdin_fd, stdout_fd, stderr_fd;
384
385    if (in == "stdin" || in == "cin")
386        stdin_fd = STDIN_FILENO;
387    else if (in == "None")
388        stdin_fd = -1;
389    else {
390        // open standard in and seek to the right location
391        stdin_fd = Process::openInputFile(in);
392        if (lseek(stdin_fd, fdo_stdin->fileOffset, SEEK_SET) < 0)
393            panic("Unable to seek to correct location in file: %s", in);
394    }
395
396    if (out == "stdout" || out == "cout")
397        stdout_fd = STDOUT_FILENO;
398    else if (out == "stderr" || out == "cerr")
399        stdout_fd = STDERR_FILENO;
400    else if (out == "None")
401        stdout_fd = -1;
402    else {
403        stdout_fd = Process::openOutputFile(out);
404        if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0)
405            panic("Unable to seek to correct location in file: %s", out);
406    }
407
408    if (err == "stdout" || err == "cout")
409        stderr_fd = STDOUT_FILENO;
410    else if (err == "stderr" || err == "cerr")
411        stderr_fd = STDERR_FILENO;
412    else if (err == "None")
413        stderr_fd = -1;
414    else if (err == out)
415        stderr_fd = stdout_fd;
416    else {
417        stderr_fd = Process::openOutputFile(err);
418        if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0)
419            panic("Unable to seek to correct location in file: %s", err);
420    }
421
422    fdo_stdin->fd = stdin_fd;
423    fdo_stdout->fd = stdout_fd;
424    fdo_stderr->fd = stderr_fd;
425
426
427    for (int free_fd = 3; free_fd <= MAX_FD; ++free_fd) {
428        Process::FdMap *fdo = &fd_map[free_fd];
429        if (fdo->fd != -1) {
430            if (fdo->isPipe){
431                if (fdo->filename == "PIPE-WRITE")
432                    continue;
433                else {
434                    assert (fdo->filename == "PIPE-READ");
435                    //create a new pipe
436                    int fds[2];
437                    int pipe_retval = pipe(fds);
438
439                    if (pipe_retval < 0) {
440                        // error
441                        panic("Unable to create new pipe.");
442                    }
443                    fdo->fd = fds[0]; //set read pipe
444                    Process::FdMap *fdo_write = &fd_map[fdo->readPipeSource];
445                    if (fdo_write->filename != "PIPE-WRITE")
446                        panic ("Couldn't find write end of the pipe");
447
448                    fdo_write->fd = fds[1];//set write pipe
449               }
450            } else {
451                //Open file
452                int fd = open(fdo->filename.c_str(), fdo->flags, fdo->mode);
453
454                if (fd == -1)
455                    panic("Unable to open file: %s", fdo->filename);
456                fdo->fd = fd;
457
458                //Seek to correct location before checkpoint
459                if (lseek(fd,fdo->fileOffset, SEEK_SET) < 0)
460                    panic("Unable to seek to correct location in file: %s",
461                          fdo->filename);
462            }
463        }
464    }
465}
466
467void
468Process::find_file_offsets()
469{
470    for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
471        Process::FdMap *fdo = &fd_map[free_fd];
472        if (fdo->fd != -1) {
473            fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR);
474        } else {
475                fdo->filename = "NULL";
476                fdo->fileOffset = 0;
477        }
478    }
479}
480
481void
482Process::setReadPipeSource(int read_pipe_fd, int source_fd)
483{
484    Process::FdMap *fdo = &fd_map[read_pipe_fd];
485    fdo->readPipeSource = source_fd;
486}
487
488void
489Process::FdMap::serialize(std::ostream &os)
490{
491    SERIALIZE_SCALAR(fd);
492    SERIALIZE_SCALAR(isPipe);
493    SERIALIZE_SCALAR(filename);
494    SERIALIZE_SCALAR(flags);
495    SERIALIZE_SCALAR(readPipeSource);
496    SERIALIZE_SCALAR(fileOffset);
497}
498
499void
500Process::FdMap::unserialize(Checkpoint *cp, const std::string &section)
501{
502    UNSERIALIZE_SCALAR(fd);
503    UNSERIALIZE_SCALAR(isPipe);
504    UNSERIALIZE_SCALAR(filename);
505    UNSERIALIZE_SCALAR(flags);
506    UNSERIALIZE_SCALAR(readPipeSource);
507    UNSERIALIZE_SCALAR(fileOffset);
508}
509
510void
511Process::serialize(std::ostream &os)
512{
513    SERIALIZE_SCALAR(brk_point);
514    SERIALIZE_SCALAR(stack_base);
515    SERIALIZE_SCALAR(stack_size);
516    SERIALIZE_SCALAR(stack_min);
517    SERIALIZE_SCALAR(next_thread_stack_base);
518    SERIALIZE_SCALAR(mmap_start);
519    SERIALIZE_SCALAR(mmap_end);
520    SERIALIZE_SCALAR(nxm_start);
521    SERIALIZE_SCALAR(nxm_end);
522    find_file_offsets();
523    pTable->serialize(os);
524    for (int x = 0; x <= MAX_FD; x++) {
525        nameOut(os, csprintf("%s.FdMap%d", name(), x));
526        fd_map[x].serialize(os);
527    }
528    SERIALIZE_SCALAR(M5_pid);
529
530}
531
532void
533Process::unserialize(Checkpoint *cp, const std::string &section)
534{
535    UNSERIALIZE_SCALAR(brk_point);
536    UNSERIALIZE_SCALAR(stack_base);
537    UNSERIALIZE_SCALAR(stack_size);
538    UNSERIALIZE_SCALAR(stack_min);
539    UNSERIALIZE_SCALAR(next_thread_stack_base);
540    UNSERIALIZE_SCALAR(mmap_start);
541    UNSERIALIZE_SCALAR(mmap_end);
542    UNSERIALIZE_SCALAR(nxm_start);
543    UNSERIALIZE_SCALAR(nxm_end);
544    pTable->unserialize(cp, section);
545    for (int x = 0; x <= MAX_FD; x++) {
546        fd_map[x].unserialize(cp, csprintf("%s.FdMap%d", section, x));
547    }
548    fix_file_offsets();
549    UNSERIALIZE_OPT_SCALAR(M5_pid);
550    // The above returns a bool so that you could do something if you don't
551    // find the param in the checkpoint if you wanted to, like set a default
552    // but in this case we'll just stick with the instantianted value if not
553    // found.
554}
555
556
557bool
558Process::map(Addr vaddr, Addr paddr, int size, bool cacheable)
559{
560    pTable->map(vaddr, paddr, size,
561                cacheable ? 0 : PageTableBase::Uncacheable);
562    return true;
563}
564
565
566////////////////////////////////////////////////////////////////////////
567//
568// LiveProcess member definitions
569//
570////////////////////////////////////////////////////////////////////////
571
572
573LiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile)
574    : Process(params), objFile(_objFile),
575      argv(params->cmd), envp(params->env), cwd(params->cwd),
576      __uid(params->uid), __euid(params->euid),
577      __gid(params->gid), __egid(params->egid),
578      __pid(params->pid), __ppid(params->ppid),
579      drivers(params->drivers)
580{
581
582    // load up symbols, if any... these may be used for debugging or
583    // profiling.
584    if (!debugSymbolTable) {
585        debugSymbolTable = new SymbolTable();
586        if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
587            !objFile->loadLocalSymbols(debugSymbolTable) ||
588            !objFile->loadWeakSymbols(debugSymbolTable)) {
589            // didn't load any symbols
590            delete debugSymbolTable;
591            debugSymbolTable = NULL;
592        }
593    }
594}
595
596void
597LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
598{
599    num_syscalls++;
600
601    SyscallDesc *desc = getDesc(callnum);
602    if (desc == NULL)
603        fatal("Syscall %d out of range", callnum);
604
605    desc->doSyscall(callnum, this, tc);
606}
607
608IntReg
609LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
610{
611    return getSyscallArg(tc, i);
612}
613
614
615EmulatedDriver *
616LiveProcess::findDriver(std::string filename)
617{
618    for (EmulatedDriver *d : drivers) {
619        if (d->match(filename))
620            return d;
621    }
622
623    return NULL;
624}
625
626
627LiveProcess *
628LiveProcess::create(LiveProcessParams * params)
629{
630    LiveProcess *process = NULL;
631
632    string executable =
633        params->executable == "" ? params->cmd[0] : params->executable;
634    ObjectFile *objFile = createObjectFile(executable);
635    if (objFile == NULL) {
636        fatal("Can't load object file %s", executable);
637    }
638
639    if (objFile->isDynamic())
640       fatal("Object file is a dynamic executable however only static "
641             "executables are supported!\n       Please recompile your "
642             "executable as a static binary and try again.\n");
643
644#if THE_ISA == ALPHA_ISA
645    if (objFile->getArch() != ObjectFile::Alpha)
646        fatal("Object file architecture does not match compiled ISA (Alpha).");
647
648    switch (objFile->getOpSys()) {
649      case ObjectFile::Tru64:
650        process = new AlphaTru64Process(params, objFile);
651        break;
652
653      case ObjectFile::UnknownOpSys:
654        warn("Unknown operating system; assuming Linux.");
655        // fall through
656      case ObjectFile::Linux:
657        process = new AlphaLinuxProcess(params, objFile);
658        break;
659
660      default:
661        fatal("Unknown/unsupported operating system.");
662    }
663#elif THE_ISA == SPARC_ISA
664    if (objFile->getArch() != ObjectFile::SPARC64 &&
665        objFile->getArch() != ObjectFile::SPARC32)
666        fatal("Object file architecture does not match compiled ISA (SPARC).");
667    switch (objFile->getOpSys()) {
668      case ObjectFile::UnknownOpSys:
669        warn("Unknown operating system; assuming Linux.");
670        // fall through
671      case ObjectFile::Linux:
672        if (objFile->getArch() == ObjectFile::SPARC64) {
673            process = new Sparc64LinuxProcess(params, objFile);
674        } else {
675            process = new Sparc32LinuxProcess(params, objFile);
676        }
677        break;
678
679
680      case ObjectFile::Solaris:
681        process = new SparcSolarisProcess(params, objFile);
682        break;
683
684      default:
685        fatal("Unknown/unsupported operating system.");
686    }
687#elif THE_ISA == X86_ISA
688    if (objFile->getArch() != ObjectFile::X86_64 &&
689        objFile->getArch() != ObjectFile::I386)
690        fatal("Object file architecture does not match compiled ISA (x86).");
691    switch (objFile->getOpSys()) {
692      case ObjectFile::UnknownOpSys:
693        warn("Unknown operating system; assuming Linux.");
694        // fall through
695      case ObjectFile::Linux:
696        if (objFile->getArch() == ObjectFile::X86_64) {
697            process = new X86_64LinuxProcess(params, objFile);
698        } else {
699            process = new I386LinuxProcess(params, objFile);
700        }
701        break;
702
703      default:
704        fatal("Unknown/unsupported operating system.");
705    }
706#elif THE_ISA == MIPS_ISA
707    if (objFile->getArch() != ObjectFile::Mips)
708        fatal("Object file architecture does not match compiled ISA (MIPS).");
709    switch (objFile->getOpSys()) {
710      case ObjectFile::UnknownOpSys:
711        warn("Unknown operating system; assuming Linux.");
712        // fall through
713      case ObjectFile::Linux:
714        process = new MipsLinuxProcess(params, objFile);
715        break;
716
717      default:
718        fatal("Unknown/unsupported operating system.");
719    }
720#elif THE_ISA == ARM_ISA
721    ObjectFile::Arch arch = objFile->getArch();
722    if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
723        arch != ObjectFile::Arm64)
724        fatal("Object file architecture does not match compiled ISA (ARM).");
725    switch (objFile->getOpSys()) {
726      case ObjectFile::UnknownOpSys:
727        warn("Unknown operating system; assuming Linux.");
728        // fall through
729      case ObjectFile::Linux:
730        if (arch == ObjectFile::Arm64) {
731            process = new ArmLinuxProcess64(params, objFile,
732                                            objFile->getArch());
733        } else {
734            process = new ArmLinuxProcess32(params, objFile,
735                                            objFile->getArch());
736        }
737        break;
738      case ObjectFile::LinuxArmOABI:
739        fatal("M5 does not support ARM OABI binaries. Please recompile with an"
740              " EABI compiler.");
741      default:
742        fatal("Unknown/unsupported operating system.");
743    }
744#elif THE_ISA == POWER_ISA
745    if (objFile->getArch() != ObjectFile::Power)
746        fatal("Object file architecture does not match compiled ISA (Power).");
747    switch (objFile->getOpSys()) {
748      case ObjectFile::UnknownOpSys:
749        warn("Unknown operating system; assuming Linux.");
750        // fall through
751      case ObjectFile::Linux:
752        process = new PowerLinuxProcess(params, objFile);
753        break;
754
755      default:
756        fatal("Unknown/unsupported operating system.");
757    }
758#else
759#error "THE_ISA not set"
760#endif
761
762    if (process == NULL)
763        fatal("Unknown error creating process object.");
764    return process;
765}
766
767LiveProcess *
768LiveProcessParams::create()
769{
770    return LiveProcess::create(this);
771}
772