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