Deleted Added
sdiff udiff text old ( 11801:cd7f3a1dbf55 ) new ( 11813:d0586994a10e )
full compact
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 "sim/process.hh"
47
48#include <fcntl.h>
49#include <unistd.h>
50
51#include <array>
52#include <map>
53#include <string>
54#include <vector>
55
56#include "base/intmath.hh"
57#include "base/loader/object_file.hh"
58#include "base/loader/symtab.hh"
59#include "base/statistics.hh"
60#include "config/the_isa.hh"
61#include "cpu/thread_context.hh"
62#include "mem/page_table.hh"
63#include "mem/se_translating_port_proxy.hh"
64#include "params/LiveProcess.hh"
65#include "params/Process.hh"
66#include "sim/emul_driver.hh"
67#include "sim/syscall_desc.hh"
68#include "sim/system.hh"
69
70#if THE_ISA == ALPHA_ISA
71#include "arch/alpha/linux/process.hh"
72#elif THE_ISA == SPARC_ISA
73#include "arch/sparc/linux/process.hh"
74#include "arch/sparc/solaris/process.hh"
75#elif THE_ISA == MIPS_ISA
76#include "arch/mips/linux/process.hh"
77#elif THE_ISA == ARM_ISA
78#include "arch/arm/linux/process.hh"
79#include "arch/arm/freebsd/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#elif THE_ISA == RISCV_ISA
85#include "arch/riscv/linux/process.hh"
86#else
87#error "THE_ISA not set"
88#endif
89
90
91using namespace std;
92using namespace TheISA;
93
94// current number of allocated processes
95int num_processes = 0;
96
97template<class IntType>
98
99AuxVector<IntType>::AuxVector(IntType type, IntType val)
100{
101 a_type = TheISA::htog(type);
102 a_val = TheISA::htog(val);
103}
104
105template struct AuxVector<uint32_t>;
106template struct AuxVector<uint64_t>;
107
108static int
109openFile(const string& filename, int flags, mode_t mode)
110{
111 int sim_fd = open(filename.c_str(), flags, mode);
112 if (sim_fd != -1)
113 return sim_fd;
114 fatal("Unable to open %s with mode %O", filename, mode);
115}
116
117static int
118openInputFile(const string &filename)
119{
120 return openFile(filename, O_RDONLY, 0);
121}
122
123static int
124openOutputFile(const string &filename)
125{
126 return openFile(filename, O_WRONLY | O_CREAT | O_TRUNC, 0664);
127}
128
129Process::Process(ProcessParams * params)
130 : SimObject(params), system(params->system),
131 brk_point(0), stack_base(0), stack_size(0), stack_min(0),
132 max_stack_size(params->max_stack_size),
133 next_thread_stack_base(0),
134 useArchPT(params->useArchPT),
135 kvmInSE(params->kvmInSE),
136 pTable(useArchPT ?
137 static_cast<PageTableBase *>(new ArchPageTable(name(), _pid, system)) :
138 static_cast<PageTableBase *>(new FuncPageTable(name(), _pid))),
139 initVirtMem(system->getSystemPort(), this,
140 SETranslatingPortProxy::Always),
141 fd_array(make_shared<array<FDEntry, NUM_FDS>>()),
142 imap {{"", -1},
143 {"cin", STDIN_FILENO},
144 {"stdin", STDIN_FILENO}},
145 oemap{{"", -1},
146 {"cout", STDOUT_FILENO},
147 {"stdout", STDOUT_FILENO},
148 {"cerr", STDERR_FILENO},
149 {"stderr", STDERR_FILENO}},
150 _uid(params->uid), _euid(params->euid),
151 _gid(params->gid), _egid(params->egid),
152 _pid(params->pid), _ppid(params->ppid)
153{
154 int sim_fd;
155 std::map<string,int>::iterator it;
156
157 // Search through the input options and set fd if match is found;
158 // otherwise, open an input file and seek to location.
159 FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
160 if ((it = imap.find(params->input)) != imap.end())
161 sim_fd = it->second;
162 else
163 sim_fd = openInputFile(params->input);
164 fde_stdin->set(sim_fd, params->input, O_RDONLY, -1, false);
165
166 // Search through the output/error options and set fd if match is found;
167 // otherwise, open an output file and seek to location.
168 FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
169 if ((it = oemap.find(params->output)) != oemap.end())
170 sim_fd = it->second;
171 else
172 sim_fd = openOutputFile(params->output);
173 fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC,
174 0664, false);
175
176 FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
177 if (params->output == params->errout)
178 // Reuse the same file descriptor if these match.
179 sim_fd = fde_stdout->fd;
180 else if ((it = oemap.find(params->errout)) != oemap.end())
181 sim_fd = it->second;
182 else
183 sim_fd = openOutputFile(params->errout);
184 fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC,
185 0664, false);
186
187 mmap_end = 0;
188 nxm_start = nxm_end = 0;
189 // other parameters will be initialized when the program is loaded
190}
191
192
193void
194Process::regStats()
195{
196 SimObject::regStats();
197
198 using namespace Stats;
199
200 num_syscalls
201 .name(name() + ".num_syscalls")
202 .desc("Number of system calls")
203 ;
204}
205
206void
207Process::inheritFDArray(Process *p)
208{
209 fd_array = p->fd_array;
210}
211
212ThreadContext *
213Process::findFreeContext()
214{
215 for (int id : contextIds) {
216 ThreadContext *tc = system->getThreadContext(id);
217 if (tc->status() == ThreadContext::Halted)
218 return tc;
219 }
220 return NULL;
221}
222
223void
224Process::initState()
225{
226 if (contextIds.empty())
227 fatal("Process %s is not associated with any HW contexts!\n", name());
228
229 // first thread context for this process... initialize & enable
230 ThreadContext *tc = system->getThreadContext(contextIds[0]);
231
232 // mark this context as active so it will start ticking.
233 tc->activate();
234
235 pTable->initState(tc);
236}
237
238DrainState
239Process::drain()
240{
241 findFileOffsets();
242 return DrainState::Drained;
243}
244
245int
246Process::allocFD(int sim_fd, const string& filename, int flags, int mode,
247 bool pipe)
248{
249 for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) {
250 FDEntry *fde = getFDEntry(free_fd);
251 if (fde->isFree()) {
252 fde->set(sim_fd, filename, flags, mode, pipe);
253 return free_fd;
254 }
255 }
256
257 fatal("Out of target file descriptors");
258}
259
260void
261Process::resetFDEntry(int tgt_fd)
262{
263 FDEntry *fde = getFDEntry(tgt_fd);
264 assert(fde->fd > -1);
265
266 fde->reset();
267}
268
269int
270Process::getSimFD(int tgt_fd)
271{
272 FDEntry *entry = getFDEntry(tgt_fd);
273 return entry ? entry->fd : -1;
274}
275
276FDEntry *
277Process::getFDEntry(int tgt_fd)
278{
279 assert(0 <= tgt_fd && tgt_fd < fd_array->size());
280 return &(*fd_array)[tgt_fd];
281}
282
283int
284Process::getTgtFD(int sim_fd)
285{
286 for (int index = 0; index < fd_array->size(); index++)
287 if ((*fd_array)[index].fd == sim_fd)
288 return index;
289 return -1;
290}
291
292void
293Process::allocateMem(Addr vaddr, int64_t size, bool clobber)
294{
295 int npages = divCeil(size, (int64_t)PageBytes);
296 Addr paddr = system->allocPhysPages(npages);
297 pTable->map(vaddr, paddr, size,
298 clobber ? PageTableBase::Clobber : PageTableBase::Zero);
299}
300
301bool
302Process::fixupStackFault(Addr vaddr)
303{
304 // Check if this is already on the stack and there's just no page there
305 // yet.
306 if (vaddr >= stack_min && vaddr < stack_base) {
307 allocateMem(roundDown(vaddr, PageBytes), PageBytes);
308 return true;
309 }
310
311 // We've accessed the next page of the stack, so extend it to include
312 // this address.
313 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
314 while (vaddr < stack_min) {
315 stack_min -= TheISA::PageBytes;
316 if (stack_base - stack_min > max_stack_size)
317 fatal("Maximum stack size exceeded\n");
318 allocateMem(stack_min, TheISA::PageBytes);
319 inform("Increasing stack size by one page.");
320 };
321 return true;
322 }
323 return false;
324}
325
326void
327Process::fixFileOffsets()
328{
329 auto seek = [] (FDEntry *fde)
330 {
331 if (lseek(fde->fd, fde->fileOffset, SEEK_SET) < 0)
332 fatal("Unable to see to location in %s", fde->filename);
333 };
334
335 std::map<string,int>::iterator it;
336
337 // Search through the input options and set fd if match is found;
338 // otherwise, open an input file and seek to location.
339 FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
340
341 // Check if user has specified a different input file, and if so, use it
342 // instead of the file specified in the checkpoint. This also resets the
343 // file offset from the checkpointed value
344 string new_in = ((ProcessParams*)params())->input;
345 if (new_in != fde_stdin->filename) {
346 warn("Using new input file (%s) rather than checkpointed (%s)\n",
347 new_in, fde_stdin->filename);
348 fde_stdin->filename = new_in;
349 fde_stdin->fileOffset = 0;
350 }
351
352 if ((it = imap.find(fde_stdin->filename)) != imap.end()) {
353 fde_stdin->fd = it->second;
354 } else {
355 fde_stdin->fd = openInputFile(fde_stdin->filename);
356 seek(fde_stdin);
357 }
358
359 // Search through the output/error options and set fd if match is found;
360 // otherwise, open an output file and seek to location.
361 FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
362
363 // Check if user has specified a different output file, and if so, use it
364 // instead of the file specified in the checkpoint. This also resets the
365 // file offset from the checkpointed value
366 string new_out = ((ProcessParams*)params())->output;
367 if (new_out != fde_stdout->filename) {
368 warn("Using new output file (%s) rather than checkpointed (%s)\n",
369 new_out, fde_stdout->filename);
370 fde_stdout->filename = new_out;
371 fde_stdout->fileOffset = 0;
372 }
373
374 if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) {
375 fde_stdout->fd = it->second;
376 } else {
377 fde_stdout->fd = openOutputFile(fde_stdout->filename);
378 seek(fde_stdout);
379 }
380
381 FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
382
383 // Check if user has specified a different error file, and if so, use it
384 // instead of the file specified in the checkpoint. This also resets the
385 // file offset from the checkpointed value
386 string new_err = ((ProcessParams*)params())->errout;
387 if (new_err != fde_stderr->filename) {
388 warn("Using new error file (%s) rather than checkpointed (%s)\n",
389 new_err, fde_stderr->filename);
390 fde_stderr->filename = new_err;
391 fde_stderr->fileOffset = 0;
392 }
393
394 if (fde_stdout->filename == fde_stderr->filename) {
395 // Reuse the same file descriptor if these match.
396 fde_stderr->fd = fde_stdout->fd;
397 } else if ((it = oemap.find(fde_stderr->filename)) != oemap.end()) {
398 fde_stderr->fd = it->second;
399 } else {
400 fde_stderr->fd = openOutputFile(fde_stderr->filename);
401 seek(fde_stderr);
402 }
403
404 for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) {
405 FDEntry *fde = getFDEntry(tgt_fd);
406 if (fde->fd == -1)
407 continue;
408
409 if (fde->isPipe) {
410 if (fde->filename == "PIPE-WRITE")
411 continue;
412 assert(fde->filename == "PIPE-READ");
413
414 int fds[2];
415 if (pipe(fds) < 0)
416 fatal("Unable to create new pipe");
417
418 fde->fd = fds[0];
419
420 FDEntry *fde_write = getFDEntry(fde->readPipeSource);
421 assert(fde_write->filename == "PIPE-WRITE");
422 fde_write->fd = fds[1];
423 } else {
424 fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode);
425 seek(fde);
426 }
427 }
428}
429
430void
431Process::findFileOffsets()
432{
433 for (auto& fde : *fd_array) {
434 if (fde.fd != -1)
435 fde.fileOffset = lseek(fde.fd, 0, SEEK_CUR);
436 }
437}
438
439void
440Process::setReadPipeSource(int read_pipe_fd, int source_fd)
441{
442 FDEntry *fde = getFDEntry(read_pipe_fd);
443 assert(source_fd >= -1);
444 fde->readPipeSource = source_fd;
445}
446
447void
448Process::serialize(CheckpointOut &cp) const
449{
450 SERIALIZE_SCALAR(brk_point);
451 SERIALIZE_SCALAR(stack_base);
452 SERIALIZE_SCALAR(stack_size);
453 SERIALIZE_SCALAR(stack_min);
454 SERIALIZE_SCALAR(next_thread_stack_base);
455 SERIALIZE_SCALAR(mmap_end);
456 SERIALIZE_SCALAR(nxm_start);
457 SERIALIZE_SCALAR(nxm_end);
458 pTable->serialize(cp);
459 for (int x = 0; x < fd_array->size(); x++) {
460 (*fd_array)[x].serializeSection(cp, csprintf("FDEntry%d", x));
461 }
462
463}
464
465void
466Process::unserialize(CheckpointIn &cp)
467{
468 UNSERIALIZE_SCALAR(brk_point);
469 UNSERIALIZE_SCALAR(stack_base);
470 UNSERIALIZE_SCALAR(stack_size);
471 UNSERIALIZE_SCALAR(stack_min);
472 UNSERIALIZE_SCALAR(next_thread_stack_base);
473 UNSERIALIZE_SCALAR(mmap_end);
474 UNSERIALIZE_SCALAR(nxm_start);
475 UNSERIALIZE_SCALAR(nxm_end);
476 pTable->unserialize(cp);
477 for (int x = 0; x < fd_array->size(); x++) {
478 FDEntry *fde = getFDEntry(x);
479 fde->unserializeSection(cp, csprintf("FDEntry%d", x));
480 }
481 fixFileOffsets();
482 // The above returns a bool so that you could do something if you don't
483 // find the param in the checkpoint if you wanted to, like set a default
484 // but in this case we'll just stick with the instantiated value if not
485 // found.
486}
487
488
489bool
490Process::map(Addr vaddr, Addr paddr, int size, bool cacheable)
491{
492 pTable->map(vaddr, paddr, size,
493 cacheable ? PageTableBase::Zero : PageTableBase::Uncacheable);
494 return true;
495}
496
497
498////////////////////////////////////////////////////////////////////////
499//
500// LiveProcess member definitions
501//
502////////////////////////////////////////////////////////////////////////
503
504
505LiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile)
506 : Process(params), objFile(_objFile),
507 argv(params->cmd), envp(params->env), cwd(params->cwd),
508 executable(params->executable),
509 drivers(params->drivers)
510{
511
512 // load up symbols, if any... these may be used for debugging or
513 // profiling.
514 if (!debugSymbolTable) {
515 debugSymbolTable = new SymbolTable();
516 if (!objFile->loadGlobalSymbols(debugSymbolTable) ||
517 !objFile->loadLocalSymbols(debugSymbolTable) ||
518 !objFile->loadWeakSymbols(debugSymbolTable)) {
519 // didn't load any symbols
520 delete debugSymbolTable;
521 debugSymbolTable = NULL;
522 }
523 }
524}
525
526void
527LiveProcess::syscall(int64_t callnum, ThreadContext *tc)
528{
529 num_syscalls++;
530
531 SyscallDesc *desc = getDesc(callnum);
532 if (desc == NULL)
533 fatal("Syscall %d out of range", callnum);
534
535 desc->doSyscall(callnum, this, tc);
536}
537
538IntReg
539LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width)
540{
541 return getSyscallArg(tc, i);
542}
543
544
545EmulatedDriver *
546LiveProcess::findDriver(std::string filename)
547{
548 for (EmulatedDriver *d : drivers) {
549 if (d->match(filename))
550 return d;
551 }
552
553 return NULL;
554}
555
556void
557LiveProcess::updateBias()
558{
559 ObjectFile *interp = objFile->getInterpreter();
560
561 if (!interp || !interp->relocatable())
562 return;
563
564 // Determine how large the interpreters footprint will be in the process
565 // address space.
566 Addr interp_mapsize = roundUp(interp->mapSize(), TheISA::PageBytes);
567
568 // We are allocating the memory area; set the bias to the lowest address
569 // in the allocated memory region.
570 Addr ld_bias = mmapGrowsDown() ? mmap_end - interp_mapsize : mmap_end;
571
572 // Adjust the process mmap area to give the interpreter room; the real
573 // execve system call would just invoke the kernel's internal mmap
574 // functions to make these adjustments.
575 mmap_end = mmapGrowsDown() ? ld_bias : mmap_end + interp_mapsize;
576
577 interp->updateBias(ld_bias);
578}
579
580
581ObjectFile *
582LiveProcess::getInterpreter()
583{
584 return objFile->getInterpreter();
585}
586
587
588Addr
589LiveProcess::getBias()
590{
591 ObjectFile *interp = getInterpreter();
592
593 return interp ? interp->bias() : objFile->bias();
594}
595
596
597Addr
598LiveProcess::getStartPC()
599{
600 ObjectFile *interp = getInterpreter();
601
602 return interp ? interp->entryPoint() : objFile->entryPoint();
603}
604
605
606LiveProcess *
607LiveProcess::create(LiveProcessParams * params)
608{
609 LiveProcess *process = NULL;
610
611 // If not specified, set the executable parameter equal to the
612 // simulated system's zeroth command line parameter
613 if (params->executable == "") {
614 params->executable = params->cmd[0];
615 }
616
617 ObjectFile *objFile = createObjectFile(params->executable);
618 if (objFile == NULL) {
619 fatal("Can't load object file %s", params->executable);
620 }
621
622#if THE_ISA == ALPHA_ISA
623 if (objFile->getArch() != ObjectFile::Alpha)
624 fatal("Object file architecture does not match compiled ISA (Alpha).");
625
626 switch (objFile->getOpSys()) {
627 case ObjectFile::UnknownOpSys:
628 warn("Unknown operating system; assuming Linux.");
629 // fall through
630 case ObjectFile::Linux:
631 process = new AlphaLinuxProcess(params, objFile);
632 break;
633
634 default:
635 fatal("Unknown/unsupported operating system.");
636 }
637#elif THE_ISA == SPARC_ISA
638 if (objFile->getArch() != ObjectFile::SPARC64 &&
639 objFile->getArch() != ObjectFile::SPARC32)
640 fatal("Object file architecture does not match compiled ISA (SPARC).");
641 switch (objFile->getOpSys()) {
642 case ObjectFile::UnknownOpSys:
643 warn("Unknown operating system; assuming Linux.");
644 // fall through
645 case ObjectFile::Linux:
646 if (objFile->getArch() == ObjectFile::SPARC64) {
647 process = new Sparc64LinuxProcess(params, objFile);
648 } else {
649 process = new Sparc32LinuxProcess(params, objFile);
650 }
651 break;
652
653
654 case ObjectFile::Solaris:
655 process = new SparcSolarisProcess(params, objFile);
656 break;
657
658 default:
659 fatal("Unknown/unsupported operating system.");
660 }
661#elif THE_ISA == X86_ISA
662 if (objFile->getArch() != ObjectFile::X86_64 &&
663 objFile->getArch() != ObjectFile::I386)
664 fatal("Object file architecture does not match compiled ISA (x86).");
665 switch (objFile->getOpSys()) {
666 case ObjectFile::UnknownOpSys:
667 warn("Unknown operating system; assuming Linux.");
668 // fall through
669 case ObjectFile::Linux:
670 if (objFile->getArch() == ObjectFile::X86_64) {
671 process = new X86_64LinuxProcess(params, objFile);
672 } else {
673 process = new I386LinuxProcess(params, objFile);
674 }
675 break;
676
677 default:
678 fatal("Unknown/unsupported operating system.");
679 }
680#elif THE_ISA == MIPS_ISA
681 if (objFile->getArch() != ObjectFile::Mips)
682 fatal("Object file architecture does not match compiled ISA (MIPS).");
683 switch (objFile->getOpSys()) {
684 case ObjectFile::UnknownOpSys:
685 warn("Unknown operating system; assuming Linux.");
686 // fall through
687 case ObjectFile::Linux:
688 process = new MipsLinuxProcess(params, objFile);
689 break;
690
691 default:
692 fatal("Unknown/unsupported operating system.");
693 }
694#elif THE_ISA == ARM_ISA
695 ObjectFile::Arch arch = objFile->getArch();
696 if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
697 arch != ObjectFile::Arm64)
698 fatal("Object file architecture does not match compiled ISA (ARM).");
699 switch (objFile->getOpSys()) {
700 case ObjectFile::UnknownOpSys:
701 warn("Unknown operating system; assuming Linux.");
702 // fall through
703 case ObjectFile::Linux:
704 if (arch == ObjectFile::Arm64) {
705 process = new ArmLinuxProcess64(params, objFile,
706 objFile->getArch());
707 } else {
708 process = new ArmLinuxProcess32(params, objFile,
709 objFile->getArch());
710 }
711 break;
712 case ObjectFile::FreeBSD:
713 if (arch == ObjectFile::Arm64) {
714 process = new ArmFreebsdProcess64(params, objFile,
715 objFile->getArch());
716 } else {
717 process = new ArmFreebsdProcess32(params, objFile,
718 objFile->getArch());
719 }
720 break;
721 case ObjectFile::LinuxArmOABI:
722 fatal("M5 does not support ARM OABI binaries. Please recompile with an"
723 " EABI compiler.");
724 default:
725 fatal("Unknown/unsupported operating system.");
726 }
727#elif THE_ISA == POWER_ISA
728 if (objFile->getArch() != ObjectFile::Power)
729 fatal("Object file architecture does not match compiled ISA (Power).");
730 switch (objFile->getOpSys()) {
731 case ObjectFile::UnknownOpSys:
732 warn("Unknown operating system; assuming Linux.");
733 // fall through
734 case ObjectFile::Linux:
735 process = new PowerLinuxProcess(params, objFile);
736 break;
737
738 default:
739 fatal("Unknown/unsupported operating system.");
740 }
741#elif THE_ISA == RISCV_ISA
742 if (objFile->getArch() != ObjectFile::Riscv)
743 fatal("Object file architecture does not match compiled ISA (RISCV).");
744 switch (objFile->getOpSys()) {
745 case ObjectFile::UnknownOpSys:
746 warn("Unknown operating system; assuming Linux.");
747 // fall through
748 case ObjectFile::Linux:
749 process = new RiscvLinuxProcess(params, objFile);
750 break;
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}