process.cc revision 10499:4e715fe2abbd
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      max_stack_size(params->max_stack_size),
108      M5_pid(system->allocatePID()),
109      useArchPT(params->useArchPT),
110      pTable(useArchPT ?
111        static_cast<PageTableBase *>(new ArchPageTable(name(), M5_pid, system)) :
112        static_cast<PageTableBase *>(new FuncPageTable(name(), M5_pid)) ),
113      initVirtMem(system->getSystemPort(), this,
114                  SETranslatingPortProxy::Always)
115{
116    string in = params->input;
117    string out = params->output;
118    string err = params->errout;
119
120    // initialize file descriptors to default: same as simulator
121    int stdin_fd, stdout_fd, stderr_fd;
122
123    if (in == "stdin" || in == "cin")
124        stdin_fd = STDIN_FILENO;
125    else if (in == "None")
126        stdin_fd = -1;
127    else
128        stdin_fd = Process::openInputFile(in);
129
130    if (out == "stdout" || out == "cout")
131        stdout_fd = STDOUT_FILENO;
132    else if (out == "stderr" || out == "cerr")
133        stdout_fd = STDERR_FILENO;
134    else if (out == "None")
135        stdout_fd = -1;
136    else
137        stdout_fd = Process::openOutputFile(out);
138
139    if (err == "stdout" || err == "cout")
140        stderr_fd = STDOUT_FILENO;
141    else if (err == "stderr" || err == "cerr")
142        stderr_fd = STDERR_FILENO;
143    else if (err == "None")
144        stderr_fd = -1;
145    else if (err == out)
146        stderr_fd = stdout_fd;
147    else
148        stderr_fd = Process::openOutputFile(err);
149
150    // initialize first 3 fds (stdin, stdout, stderr)
151    Process::FdMap *fdo = &fd_map[STDIN_FILENO];
152    fdo->fd = stdin_fd;
153    fdo->filename = in;
154    fdo->flags = O_RDONLY;
155    fdo->mode = -1;
156    fdo->fileOffset = 0;
157
158    fdo =  &fd_map[STDOUT_FILENO];
159    fdo->fd = stdout_fd;
160    fdo->filename = out;
161    fdo->flags =  O_WRONLY | O_CREAT | O_TRUNC;
162    fdo->mode = 0774;
163    fdo->fileOffset = 0;
164
165    fdo = &fd_map[STDERR_FILENO];
166    fdo->fd = stderr_fd;
167    fdo->filename = err;
168    fdo->flags = O_WRONLY;
169    fdo->mode = -1;
170    fdo->fileOffset = 0;
171
172
173    // mark remaining fds as free
174    for (int i = 3; i <= MAX_FD; ++i) {
175        fdo = &fd_map[i];
176        fdo->fd = -1;
177    }
178
179    mmap_start = mmap_end = 0;
180    nxm_start = nxm_end = 0;
181    // other parameters will be initialized when the program is loaded
182}
183
184
185void
186Process::regStats()
187{
188    using namespace Stats;
189
190    num_syscalls
191        .name(name() + ".num_syscalls")
192        .desc("Number of system calls")
193        ;
194}
195
196//
197// static helper functions
198//
199int
200Process::openInputFile(const string &filename)
201{
202    int fd = open(filename.c_str(), O_RDONLY);
203
204    if (fd == -1) {
205        perror(NULL);
206        cerr << "unable to open \"" << filename << "\" for reading\n";
207        fatal("can't open input file");
208    }
209
210    return fd;
211}
212
213
214int
215Process::openOutputFile(const string &filename)
216{
217    int fd = open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664);
218
219    if (fd == -1) {
220        perror(NULL);
221        cerr << "unable to open \"" << filename << "\" for writing\n";
222        fatal("can't open output file");
223    }
224
225    return fd;
226}
227
228ThreadContext *
229Process::findFreeContext()
230{
231    int size = contextIds.size();
232    ThreadContext *tc;
233    for (int i = 0; i < size; ++i) {
234        tc = system->getThreadContext(contextIds[i]);
235        if (tc->status() == ThreadContext::Halted) {
236            // inactive context, free to use
237            return tc;
238        }
239    }
240    return NULL;
241}
242
243void
244Process::initState()
245{
246    if (contextIds.empty())
247        fatal("Process %s is not associated with any HW contexts!\n", name());
248
249    // first thread context for this process... initialize & enable
250    ThreadContext *tc = system->getThreadContext(contextIds[0]);
251
252    // mark this context as active so it will start ticking.
253    tc->activate();
254
255    pTable->initState(tc);
256}
257
258// map simulator fd sim_fd to target fd tgt_fd
259void
260Process::dup_fd(int sim_fd, int tgt_fd)
261{
262    if (tgt_fd < 0 || tgt_fd > MAX_FD)
263        panic("Process::dup_fd tried to dup past MAX_FD (%d)", tgt_fd);
264
265    Process::FdMap *fdo = &fd_map[tgt_fd];
266    fdo->fd = sim_fd;
267}
268
269
270// generate new target fd for sim_fd
271int
272Process::alloc_fd(int sim_fd, string filename, int flags, int mode, bool pipe)
273{
274    // in case open() returns an error, don't allocate a new fd
275    if (sim_fd == -1)
276        return -1;
277
278    // find first free target fd
279    for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
280        Process::FdMap *fdo = &fd_map[free_fd];
281        if (fdo->fd == -1 && fdo->driver == NULL) {
282            fdo->fd = sim_fd;
283            fdo->filename = filename;
284            fdo->mode = mode;
285            fdo->fileOffset = 0;
286            fdo->flags = flags;
287            fdo->isPipe = pipe;
288            fdo->readPipeSource = 0;
289            return free_fd;
290        }
291    }
292
293    panic("Process::alloc_fd: out of file descriptors!");
294}
295
296
297// free target fd (e.g., after close)
298void
299Process::free_fd(int tgt_fd)
300{
301    Process::FdMap *fdo = &fd_map[tgt_fd];
302    if (fdo->fd == -1)
303        warn("Process::free_fd: request to free unused fd %d", tgt_fd);
304
305    fdo->fd = -1;
306    fdo->filename = "NULL";
307    fdo->mode = 0;
308    fdo->fileOffset = 0;
309    fdo->flags = 0;
310    fdo->isPipe = false;
311    fdo->readPipeSource = 0;
312    fdo->driver = NULL;
313}
314
315
316// look up simulator fd for given target fd
317int
318Process::sim_fd(int tgt_fd)
319{
320    if (tgt_fd < 0 || tgt_fd > MAX_FD)
321        return -1;
322
323    return fd_map[tgt_fd].fd;
324}
325
326Process::FdMap *
327Process::sim_fd_obj(int tgt_fd)
328{
329    if (tgt_fd < 0 || tgt_fd > MAX_FD)
330        return NULL;
331
332    return &fd_map[tgt_fd];
333}
334
335void
336Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
337{
338    int npages = divCeil(size, (int64_t)PageBytes);
339    Addr paddr = system->allocPhysPages(npages);
340    pTable->map(vaddr, paddr, size, clobber);
341}
342
343bool
344Process::fixupStackFault(Addr vaddr)
345{
346    // Check if this is already on the stack and there's just no page there
347    // yet.
348    if (vaddr >= stack_min && vaddr < stack_base) {
349        allocateMem(roundDown(vaddr, PageBytes), PageBytes);
350        return true;
351    }
352
353    // We've accessed the next page of the stack, so extend it to include
354    // this address.
355    if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
356        while (vaddr < stack_min) {
357            stack_min -= TheISA::PageBytes;
358            if (stack_base - stack_min > max_stack_size)
359                fatal("Maximum stack size exceeded\n");
360            allocateMem(stack_min, TheISA::PageBytes);
361            inform("Increasing stack size by one page.");
362        };
363        return true;
364    }
365    return false;
366}
367
368// find all offsets for currently open files and save them
369void
370Process::fix_file_offsets()
371{
372    Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO];
373    Process::FdMap *fdo_stdout = &fd_map[STDOUT_FILENO];
374    Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO];
375    string in = fdo_stdin->filename;
376    string out = fdo_stdout->filename;
377    string err = fdo_stderr->filename;
378
379    // initialize file descriptors to default: same as simulator
380    int stdin_fd, stdout_fd, stderr_fd;
381
382    if (in == "stdin" || in == "cin")
383        stdin_fd = STDIN_FILENO;
384    else if (in == "None")
385        stdin_fd = -1;
386    else {
387        // open standard in and seek to the right location
388        stdin_fd = Process::openInputFile(in);
389        if (lseek(stdin_fd, fdo_stdin->fileOffset, SEEK_SET) < 0)
390            panic("Unable to seek to correct location in file: %s", in);
391    }
392
393    if (out == "stdout" || out == "cout")
394        stdout_fd = STDOUT_FILENO;
395    else if (out == "stderr" || out == "cerr")
396        stdout_fd = STDERR_FILENO;
397    else if (out == "None")
398        stdout_fd = -1;
399    else {
400        stdout_fd = Process::openOutputFile(out);
401        if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0)
402            panic("Unable to seek to correct location in file: %s", out);
403    }
404
405    if (err == "stdout" || err == "cout")
406        stderr_fd = STDOUT_FILENO;
407    else if (err == "stderr" || err == "cerr")
408        stderr_fd = STDERR_FILENO;
409    else if (err == "None")
410        stderr_fd = -1;
411    else if (err == out)
412        stderr_fd = stdout_fd;
413    else {
414        stderr_fd = Process::openOutputFile(err);
415        if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0)
416            panic("Unable to seek to correct location in file: %s", err);
417    }
418
419    fdo_stdin->fd = stdin_fd;
420    fdo_stdout->fd = stdout_fd;
421    fdo_stderr->fd = stderr_fd;
422
423
424    for (int free_fd = 3; free_fd <= MAX_FD; ++free_fd) {
425        Process::FdMap *fdo = &fd_map[free_fd];
426        if (fdo->fd != -1) {
427            if (fdo->isPipe){
428                if (fdo->filename == "PIPE-WRITE")
429                    continue;
430                else {
431                    assert (fdo->filename == "PIPE-READ");
432                    //create a new pipe
433                    int fds[2];
434                    int pipe_retval = pipe(fds);
435
436                    if (pipe_retval < 0) {
437                        // error
438                        panic("Unable to create new pipe.");
439                    }
440                    fdo->fd = fds[0]; //set read pipe
441                    Process::FdMap *fdo_write = &fd_map[fdo->readPipeSource];
442                    if (fdo_write->filename != "PIPE-WRITE")
443                        panic ("Couldn't find write end of the pipe");
444
445                    fdo_write->fd = fds[1];//set write pipe
446               }
447            } else {
448                //Open file
449                int fd = open(fdo->filename.c_str(), fdo->flags, fdo->mode);
450
451                if (fd == -1)
452                    panic("Unable to open file: %s", fdo->filename);
453                fdo->fd = fd;
454
455                //Seek to correct location before checkpoint
456                if (lseek(fd,fdo->fileOffset, SEEK_SET) < 0)
457                    panic("Unable to seek to correct location in file: %s",
458                          fdo->filename);
459            }
460        }
461    }
462}
463
464void
465Process::find_file_offsets()
466{
467    for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) {
468        Process::FdMap *fdo = &fd_map[free_fd];
469        if (fdo->fd != -1) {
470            fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR);
471        } else {
472                fdo->filename = "NULL";
473                fdo->fileOffset = 0;
474        }
475    }
476}
477
478void
479Process::setReadPipeSource(int read_pipe_fd, int source_fd)
480{
481    Process::FdMap *fdo = &fd_map[read_pipe_fd];
482    fdo->readPipeSource = source_fd;
483}
484
485void
486Process::FdMap::serialize(std::ostream &os)
487{
488    SERIALIZE_SCALAR(fd);
489    SERIALIZE_SCALAR(isPipe);
490    SERIALIZE_SCALAR(filename);
491    SERIALIZE_SCALAR(flags);
492    SERIALIZE_SCALAR(readPipeSource);
493    SERIALIZE_SCALAR(fileOffset);
494}
495
496void
497Process::FdMap::unserialize(Checkpoint *cp, const std::string &section)
498{
499    UNSERIALIZE_SCALAR(fd);
500    UNSERIALIZE_SCALAR(isPipe);
501    UNSERIALIZE_SCALAR(filename);
502    UNSERIALIZE_SCALAR(flags);
503    UNSERIALIZE_SCALAR(readPipeSource);
504    UNSERIALIZE_SCALAR(fileOffset);
505}
506
507void
508Process::serialize(std::ostream &os)
509{
510    SERIALIZE_SCALAR(brk_point);
511    SERIALIZE_SCALAR(stack_base);
512    SERIALIZE_SCALAR(stack_size);
513    SERIALIZE_SCALAR(stack_min);
514    SERIALIZE_SCALAR(next_thread_stack_base);
515    SERIALIZE_SCALAR(mmap_start);
516    SERIALIZE_SCALAR(mmap_end);
517    SERIALIZE_SCALAR(nxm_start);
518    SERIALIZE_SCALAR(nxm_end);
519    find_file_offsets();
520    pTable->serialize(os);
521    for (int x = 0; x <= MAX_FD; x++) {
522        nameOut(os, csprintf("%s.FdMap%d", name(), x));
523        fd_map[x].serialize(os);
524    }
525    SERIALIZE_SCALAR(M5_pid);
526
527}
528
529void
530Process::unserialize(Checkpoint *cp, const std::string &section)
531{
532    UNSERIALIZE_SCALAR(brk_point);
533    UNSERIALIZE_SCALAR(stack_base);
534    UNSERIALIZE_SCALAR(stack_size);
535    UNSERIALIZE_SCALAR(stack_min);
536    UNSERIALIZE_SCALAR(next_thread_stack_base);
537    UNSERIALIZE_SCALAR(mmap_start);
538    UNSERIALIZE_SCALAR(mmap_end);
539    UNSERIALIZE_SCALAR(nxm_start);
540    UNSERIALIZE_SCALAR(nxm_end);
541    pTable->unserialize(cp, section);
542    for (int x = 0; x <= MAX_FD; x++) {
543        fd_map[x].unserialize(cp, csprintf("%s.FdMap%d", section, x));
544    }
545    fix_file_offsets();
546    UNSERIALIZE_OPT_SCALAR(M5_pid);
547    // The above returns a bool so that you could do something if you don't
548    // find the param in the checkpoint if you wanted to, like set a default
549    // but in this case we'll just stick with the instantianted value if not
550    // found.
551}
552
553
554bool
555Process::map(Addr vaddr, Addr paddr, int size)
556{
557    pTable->map(vaddr, paddr, size);
558    return true;
559}
560
561
562////////////////////////////////////////////////////////////////////////
563//
564// LiveProcess member definitions
565//
566////////////////////////////////////////////////////////////////////////
567
568
569LiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile)
570    : Process(params), objFile(_objFile),
571      argv(params->cmd), envp(params->env), cwd(params->cwd),
572      __uid(params->uid), __euid(params->euid),
573      __gid(params->gid), __egid(params->egid),
574      __pid(params->pid), __ppid(params->ppid),
575      drivers(params->drivers)
576{
577
578    // load up symbols, if any... these may be used for debugging or
579    // profiling.
580    if (!debugSymbolTable) {
581        debugSymbolTable = new SymbolTable();
582        if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
583            !objFile->loadLocalSymbols(debugSymbolTable) ||
584            !objFile->loadWeakSymbols(debugSymbolTable)) {
585            // didn't load any symbols
586            delete debugSymbolTable;
587            debugSymbolTable = NULL;
588        }
589    }
590}
591
592void
593LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
594{
595    num_syscalls++;
596
597    SyscallDesc *desc = getDesc(callnum);
598    if (desc == NULL)
599        fatal("Syscall %d out of range", callnum);
600
601    desc->doSyscall(callnum, this, tc);
602}
603
604IntReg
605LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
606{
607    return getSyscallArg(tc, i);
608}
609
610
611EmulatedDriver *
612LiveProcess::findDriver(std::string filename)
613{
614    for (EmulatedDriver *d : drivers) {
615        if (d->match(filename))
616            return d;
617    }
618
619    return NULL;
620}
621
622
623LiveProcess *
624LiveProcess::create(LiveProcessParams * params)
625{
626    LiveProcess *process = NULL;
627
628    string executable =
629        params->executable == "" ? params->cmd[0] : params->executable;
630    ObjectFile *objFile = createObjectFile(executable);
631    if (objFile == NULL) {
632        fatal("Can't load object file %s", executable);
633    }
634
635    if (objFile->isDynamic())
636       fatal("Object file is a dynamic executable however only static "
637             "executables are supported!\n       Please recompile your "
638             "executable as a static binary and try again.\n");
639
640#if THE_ISA == ALPHA_ISA
641    if (objFile->getArch() != ObjectFile::Alpha)
642        fatal("Object file architecture does not match compiled ISA (Alpha).");
643
644    switch (objFile->getOpSys()) {
645      case ObjectFile::Tru64:
646        process = new AlphaTru64Process(params, objFile);
647        break;
648
649      case ObjectFile::UnknownOpSys:
650        warn("Unknown operating system; assuming Linux.");
651        // fall through
652      case ObjectFile::Linux:
653        process = new AlphaLinuxProcess(params, objFile);
654        break;
655
656      default:
657        fatal("Unknown/unsupported operating system.");
658    }
659#elif THE_ISA == SPARC_ISA
660    if (objFile->getArch() != ObjectFile::SPARC64 &&
661        objFile->getArch() != ObjectFile::SPARC32)
662        fatal("Object file architecture does not match compiled ISA (SPARC).");
663    switch (objFile->getOpSys()) {
664      case ObjectFile::UnknownOpSys:
665        warn("Unknown operating system; assuming Linux.");
666        // fall through
667      case ObjectFile::Linux:
668        if (objFile->getArch() == ObjectFile::SPARC64) {
669            process = new Sparc64LinuxProcess(params, objFile);
670        } else {
671            process = new Sparc32LinuxProcess(params, objFile);
672        }
673        break;
674
675
676      case ObjectFile::Solaris:
677        process = new SparcSolarisProcess(params, objFile);
678        break;
679
680      default:
681        fatal("Unknown/unsupported operating system.");
682    }
683#elif THE_ISA == X86_ISA
684    if (objFile->getArch() != ObjectFile::X86_64 &&
685        objFile->getArch() != ObjectFile::I386)
686        fatal("Object file architecture does not match compiled ISA (x86).");
687    switch (objFile->getOpSys()) {
688      case ObjectFile::UnknownOpSys:
689        warn("Unknown operating system; assuming Linux.");
690        // fall through
691      case ObjectFile::Linux:
692        if (objFile->getArch() == ObjectFile::X86_64) {
693            process = new X86_64LinuxProcess(params, objFile);
694        } else {
695            process = new I386LinuxProcess(params, objFile);
696        }
697        break;
698
699      default:
700        fatal("Unknown/unsupported operating system.");
701    }
702#elif THE_ISA == MIPS_ISA
703    if (objFile->getArch() != ObjectFile::Mips)
704        fatal("Object file architecture does not match compiled ISA (MIPS).");
705    switch (objFile->getOpSys()) {
706      case ObjectFile::UnknownOpSys:
707        warn("Unknown operating system; assuming Linux.");
708        // fall through
709      case ObjectFile::Linux:
710        process = new MipsLinuxProcess(params, objFile);
711        break;
712
713      default:
714        fatal("Unknown/unsupported operating system.");
715    }
716#elif THE_ISA == ARM_ISA
717    ObjectFile::Arch arch = objFile->getArch();
718    if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
719        arch != ObjectFile::Arm64)
720        fatal("Object file architecture does not match compiled ISA (ARM).");
721    switch (objFile->getOpSys()) {
722      case ObjectFile::UnknownOpSys:
723        warn("Unknown operating system; assuming Linux.");
724        // fall through
725      case ObjectFile::Linux:
726        if (arch == ObjectFile::Arm64) {
727            process = new ArmLinuxProcess64(params, objFile,
728                                            objFile->getArch());
729        } else {
730            process = new ArmLinuxProcess32(params, objFile,
731                                            objFile->getArch());
732        }
733        break;
734      case ObjectFile::LinuxArmOABI:
735        fatal("M5 does not support ARM OABI binaries. Please recompile with an"
736              " EABI compiler.");
737      default:
738        fatal("Unknown/unsupported operating system.");
739    }
740#elif THE_ISA == POWER_ISA
741    if (objFile->getArch() != ObjectFile::Power)
742        fatal("Object file architecture does not match compiled ISA (Power).");
743    switch (objFile->getOpSys()) {
744      case ObjectFile::UnknownOpSys:
745        warn("Unknown operating system; assuming Linux.");
746        // fall through
747      case ObjectFile::Linux:
748        process = new PowerLinuxProcess(params, objFile);
749        break;
750
751      default:
752        fatal("Unknown/unsupported operating system.");
753    }
754#else
755#error "THE_ISA not set"
756#endif
757
758    if (process == NULL)
759        fatal("Unknown error creating process object.");
760    return process;
761}
762
763LiveProcess *
764LiveProcessParams::create()
765{
766    return LiveProcess::create(this);
767}
768