process.cc revision 10782:0a78638881d7
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, const string& filename, int flags, int mode, 276 bool pipe) 277{ 278 // in case open() returns an error, don't allocate a new fd 279 if (sim_fd == -1) 280 return -1; 281 282 // find first free target fd 283 for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) { 284 Process::FdMap *fdo = &fd_map[free_fd]; 285 if (fdo->fd == -1 && fdo->driver == NULL) { 286 fdo->fd = sim_fd; 287 fdo->filename = filename; 288 fdo->mode = mode; 289 fdo->fileOffset = 0; 290 fdo->flags = flags; 291 fdo->isPipe = pipe; 292 fdo->readPipeSource = 0; 293 return free_fd; 294 } 295 } 296 297 panic("Process::alloc_fd: out of file descriptors!"); 298} 299 300 301// free target fd (e.g., after close) 302void 303Process::free_fd(int tgt_fd) 304{ 305 Process::FdMap *fdo = &fd_map[tgt_fd]; 306 if (fdo->fd == -1) 307 warn("Process::free_fd: request to free unused fd %d", tgt_fd); 308 309 fdo->fd = -1; 310 fdo->filename = "NULL"; 311 fdo->mode = 0; 312 fdo->fileOffset = 0; 313 fdo->flags = 0; 314 fdo->isPipe = false; 315 fdo->readPipeSource = 0; 316 fdo->driver = NULL; 317} 318 319 320// look up simulator fd for given target fd 321int 322Process::sim_fd(int tgt_fd) 323{ 324 if (tgt_fd < 0 || tgt_fd > MAX_FD) 325 return -1; 326 327 return fd_map[tgt_fd].fd; 328} 329 330Process::FdMap * 331Process::sim_fd_obj(int tgt_fd) 332{ 333 if (tgt_fd < 0 || tgt_fd > MAX_FD) 334 return NULL; 335 336 return &fd_map[tgt_fd]; 337} 338 339void 340Process::allocateMem(Addr vaddr, int64_t size, bool clobber) 341{ 342 int npages = divCeil(size, (int64_t)PageBytes); 343 Addr paddr = system->allocPhysPages(npages); 344 pTable->map(vaddr, paddr, size, clobber ? PageTableBase::Clobber : 0); 345} 346 347bool 348Process::fixupStackFault(Addr vaddr) 349{ 350 // Check if this is already on the stack and there's just no page there 351 // yet. 352 if (vaddr >= stack_min && vaddr < stack_base) { 353 allocateMem(roundDown(vaddr, PageBytes), PageBytes); 354 return true; 355 } 356 357 // We've accessed the next page of the stack, so extend it to include 358 // this address. 359 if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) { 360 while (vaddr < stack_min) { 361 stack_min -= TheISA::PageBytes; 362 if (stack_base - stack_min > max_stack_size) 363 fatal("Maximum stack size exceeded\n"); 364 allocateMem(stack_min, TheISA::PageBytes); 365 inform("Increasing stack size by one page."); 366 }; 367 return true; 368 } 369 return false; 370} 371 372// find all offsets for currently open files and save them 373void 374Process::fix_file_offsets() 375{ 376 Process::FdMap *fdo_stdin = &fd_map[STDIN_FILENO]; 377 Process::FdMap *fdo_stdout = &fd_map[STDOUT_FILENO]; 378 Process::FdMap *fdo_stderr = &fd_map[STDERR_FILENO]; 379 string in = fdo_stdin->filename; 380 string out = fdo_stdout->filename; 381 string err = fdo_stderr->filename; 382 383 // initialize file descriptors to default: same as simulator 384 int stdin_fd, stdout_fd, stderr_fd; 385 386 if (in == "stdin" || in == "cin") 387 stdin_fd = STDIN_FILENO; 388 else if (in == "NULL") 389 stdin_fd = -1; 390 else { 391 // open standard in and seek to the right location 392 stdin_fd = Process::openInputFile(in); 393 if (lseek(stdin_fd, fdo_stdin->fileOffset, SEEK_SET) < 0) 394 panic("Unable to seek to correct location in file: %s", in); 395 } 396 397 if (out == "stdout" || out == "cout") 398 stdout_fd = STDOUT_FILENO; 399 else if (out == "stderr" || out == "cerr") 400 stdout_fd = STDERR_FILENO; 401 else if (out == "NULL") 402 stdout_fd = -1; 403 else { 404 stdout_fd = Process::openOutputFile(out); 405 if (lseek(stdout_fd, fdo_stdout->fileOffset, SEEK_SET) < 0) 406 panic("Unable to seek to correct location in file: %s", out); 407 } 408 409 if (err == "stdout" || err == "cout") 410 stderr_fd = STDOUT_FILENO; 411 else if (err == "stderr" || err == "cerr") 412 stderr_fd = STDERR_FILENO; 413 else if (err == "NULL") 414 stderr_fd = -1; 415 else if (err == out) 416 stderr_fd = stdout_fd; 417 else { 418 stderr_fd = Process::openOutputFile(err); 419 if (lseek(stderr_fd, fdo_stderr->fileOffset, SEEK_SET) < 0) 420 panic("Unable to seek to correct location in file: %s", err); 421 } 422 423 fdo_stdin->fd = stdin_fd; 424 fdo_stdout->fd = stdout_fd; 425 fdo_stderr->fd = stderr_fd; 426 427 428 for (int free_fd = 3; free_fd <= MAX_FD; ++free_fd) { 429 Process::FdMap *fdo = &fd_map[free_fd]; 430 if (fdo->fd != -1) { 431 if (fdo->isPipe){ 432 if (fdo->filename == "PIPE-WRITE") 433 continue; 434 else { 435 assert (fdo->filename == "PIPE-READ"); 436 //create a new pipe 437 int fds[2]; 438 int pipe_retval = pipe(fds); 439 440 if (pipe_retval < 0) { 441 // error 442 panic("Unable to create new pipe."); 443 } 444 fdo->fd = fds[0]; //set read pipe 445 Process::FdMap *fdo_write = &fd_map[fdo->readPipeSource]; 446 if (fdo_write->filename != "PIPE-WRITE") 447 panic ("Couldn't find write end of the pipe"); 448 449 fdo_write->fd = fds[1];//set write pipe 450 } 451 } else { 452 //Open file 453 int fd = open(fdo->filename.c_str(), fdo->flags, fdo->mode); 454 455 if (fd == -1) 456 panic("Unable to open file: %s", fdo->filename); 457 fdo->fd = fd; 458 459 //Seek to correct location before checkpoint 460 if (lseek(fd, fdo->fileOffset, SEEK_SET) < 0) 461 panic("Unable to seek to correct location in file: %s", 462 fdo->filename); 463 } 464 } 465 } 466} 467 468void 469Process::find_file_offsets() 470{ 471 for (int free_fd = 0; free_fd <= MAX_FD; ++free_fd) { 472 Process::FdMap *fdo = &fd_map[free_fd]; 473 if (fdo->fd != -1) { 474 fdo->fileOffset = lseek(fdo->fd, 0, SEEK_CUR); 475 } else { 476 fdo->filename = "NULL"; 477 fdo->fileOffset = 0; 478 } 479 } 480} 481 482void 483Process::setReadPipeSource(int read_pipe_fd, int source_fd) 484{ 485 Process::FdMap *fdo = &fd_map[read_pipe_fd]; 486 fdo->readPipeSource = source_fd; 487} 488 489void 490Process::FdMap::serialize(std::ostream &os) 491{ 492 SERIALIZE_SCALAR(fd); 493 SERIALIZE_SCALAR(isPipe); 494 SERIALIZE_SCALAR(filename); 495 SERIALIZE_SCALAR(flags); 496 SERIALIZE_SCALAR(readPipeSource); 497 SERIALIZE_SCALAR(fileOffset); 498} 499 500void 501Process::FdMap::unserialize(Checkpoint *cp, const std::string §ion) 502{ 503 UNSERIALIZE_SCALAR(fd); 504 UNSERIALIZE_SCALAR(isPipe); 505 UNSERIALIZE_SCALAR(filename); 506 UNSERIALIZE_SCALAR(flags); 507 UNSERIALIZE_SCALAR(readPipeSource); 508 UNSERIALIZE_SCALAR(fileOffset); 509} 510 511void 512Process::serialize(std::ostream &os) 513{ 514 SERIALIZE_SCALAR(brk_point); 515 SERIALIZE_SCALAR(stack_base); 516 SERIALIZE_SCALAR(stack_size); 517 SERIALIZE_SCALAR(stack_min); 518 SERIALIZE_SCALAR(next_thread_stack_base); 519 SERIALIZE_SCALAR(mmap_start); 520 SERIALIZE_SCALAR(mmap_end); 521 SERIALIZE_SCALAR(nxm_start); 522 SERIALIZE_SCALAR(nxm_end); 523 find_file_offsets(); 524 pTable->serialize(os); 525 for (int x = 0; x <= MAX_FD; x++) { 526 nameOut(os, csprintf("%s.FdMap%d", name(), x)); 527 fd_map[x].serialize(os); 528 } 529 SERIALIZE_SCALAR(M5_pid); 530 531} 532 533void 534Process::unserialize(Checkpoint *cp, const std::string §ion) 535{ 536 UNSERIALIZE_SCALAR(brk_point); 537 UNSERIALIZE_SCALAR(stack_base); 538 UNSERIALIZE_SCALAR(stack_size); 539 UNSERIALIZE_SCALAR(stack_min); 540 UNSERIALIZE_SCALAR(next_thread_stack_base); 541 UNSERIALIZE_SCALAR(mmap_start); 542 UNSERIALIZE_SCALAR(mmap_end); 543 UNSERIALIZE_SCALAR(nxm_start); 544 UNSERIALIZE_SCALAR(nxm_end); 545 pTable->unserialize(cp, section); 546 for (int x = 0; x <= MAX_FD; x++) { 547 fd_map[x].unserialize(cp, csprintf("%s.FdMap%d", section, x)); 548 } 549 fix_file_offsets(); 550 UNSERIALIZE_OPT_SCALAR(M5_pid); 551 // The above returns a bool so that you could do something if you don't 552 // find the param in the checkpoint if you wanted to, like set a default 553 // but in this case we'll just stick with the instantianted value if not 554 // found. 555} 556 557 558bool 559Process::map(Addr vaddr, Addr paddr, int size, bool cacheable) 560{ 561 pTable->map(vaddr, paddr, size, 562 cacheable ? 0 : PageTableBase::Uncacheable); 563 return true; 564} 565 566 567//////////////////////////////////////////////////////////////////////// 568// 569// LiveProcess member definitions 570// 571//////////////////////////////////////////////////////////////////////// 572 573 574LiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile) 575 : Process(params), objFile(_objFile), 576 argv(params->cmd), envp(params->env), cwd(params->cwd), 577 __uid(params->uid), __euid(params->euid), 578 __gid(params->gid), __egid(params->egid), 579 __pid(params->pid), __ppid(params->ppid), 580 drivers(params->drivers) 581{ 582 583 // load up symbols, if any... these may be used for debugging or 584 // profiling. 585 if (!debugSymbolTable) { 586 debugSymbolTable = new SymbolTable(); 587 if (!objFile->loadGlobalSymbols(debugSymbolTable) || 588 !objFile->loadLocalSymbols(debugSymbolTable) || 589 !objFile->loadWeakSymbols(debugSymbolTable)) { 590 // didn't load any symbols 591 delete debugSymbolTable; 592 debugSymbolTable = NULL; 593 } 594 } 595} 596 597void 598LiveProcess::syscall(int64_t callnum, ThreadContext *tc) 599{ 600 num_syscalls++; 601 602 SyscallDesc *desc = getDesc(callnum); 603 if (desc == NULL) 604 fatal("Syscall %d out of range", callnum); 605 606 desc->doSyscall(callnum, this, tc); 607} 608 609IntReg 610LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width) 611{ 612 return getSyscallArg(tc, i); 613} 614 615 616EmulatedDriver * 617LiveProcess::findDriver(std::string filename) 618{ 619 for (EmulatedDriver *d : drivers) { 620 if (d->match(filename)) 621 return d; 622 } 623 624 return NULL; 625} 626 627 628LiveProcess * 629LiveProcess::create(LiveProcessParams * params) 630{ 631 LiveProcess *process = NULL; 632 633 string executable = 634 params->executable == "" ? params->cmd[0] : params->executable; 635 ObjectFile *objFile = createObjectFile(executable); 636 if (objFile == NULL) { 637 fatal("Can't load object file %s", executable); 638 } 639 640 if (objFile->isDynamic()) 641 fatal("Object file is a dynamic executable however only static " 642 "executables are supported!\n Please recompile your " 643 "executable as a static binary and try again.\n"); 644 645#if THE_ISA == ALPHA_ISA 646 if (objFile->getArch() != ObjectFile::Alpha) 647 fatal("Object file architecture does not match compiled ISA (Alpha)."); 648 649 switch (objFile->getOpSys()) { 650 case ObjectFile::Tru64: 651 process = new AlphaTru64Process(params, objFile); 652 break; 653 654 case ObjectFile::UnknownOpSys: 655 warn("Unknown operating system; assuming Linux."); 656 // fall through 657 case ObjectFile::Linux: 658 process = new AlphaLinuxProcess(params, objFile); 659 break; 660 661 default: 662 fatal("Unknown/unsupported operating system."); 663 } 664#elif THE_ISA == SPARC_ISA 665 if (objFile->getArch() != ObjectFile::SPARC64 && 666 objFile->getArch() != ObjectFile::SPARC32) 667 fatal("Object file architecture does not match compiled ISA (SPARC)."); 668 switch (objFile->getOpSys()) { 669 case ObjectFile::UnknownOpSys: 670 warn("Unknown operating system; assuming Linux."); 671 // fall through 672 case ObjectFile::Linux: 673 if (objFile->getArch() == ObjectFile::SPARC64) { 674 process = new Sparc64LinuxProcess(params, objFile); 675 } else { 676 process = new Sparc32LinuxProcess(params, objFile); 677 } 678 break; 679 680 681 case ObjectFile::Solaris: 682 process = new SparcSolarisProcess(params, objFile); 683 break; 684 685 default: 686 fatal("Unknown/unsupported operating system."); 687 } 688#elif THE_ISA == X86_ISA 689 if (objFile->getArch() != ObjectFile::X86_64 && 690 objFile->getArch() != ObjectFile::I386) 691 fatal("Object file architecture does not match compiled ISA (x86)."); 692 switch (objFile->getOpSys()) { 693 case ObjectFile::UnknownOpSys: 694 warn("Unknown operating system; assuming Linux."); 695 // fall through 696 case ObjectFile::Linux: 697 if (objFile->getArch() == ObjectFile::X86_64) { 698 process = new X86_64LinuxProcess(params, objFile); 699 } else { 700 process = new I386LinuxProcess(params, objFile); 701 } 702 break; 703 704 default: 705 fatal("Unknown/unsupported operating system."); 706 } 707#elif THE_ISA == MIPS_ISA 708 if (objFile->getArch() != ObjectFile::Mips) 709 fatal("Object file architecture does not match compiled ISA (MIPS)."); 710 switch (objFile->getOpSys()) { 711 case ObjectFile::UnknownOpSys: 712 warn("Unknown operating system; assuming Linux."); 713 // fall through 714 case ObjectFile::Linux: 715 process = new MipsLinuxProcess(params, objFile); 716 break; 717 718 default: 719 fatal("Unknown/unsupported operating system."); 720 } 721#elif THE_ISA == ARM_ISA 722 ObjectFile::Arch arch = objFile->getArch(); 723 if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 724 arch != ObjectFile::Arm64) 725 fatal("Object file architecture does not match compiled ISA (ARM)."); 726 switch (objFile->getOpSys()) { 727 case ObjectFile::UnknownOpSys: 728 warn("Unknown operating system; assuming Linux."); 729 // fall through 730 case ObjectFile::Linux: 731 if (arch == ObjectFile::Arm64) { 732 process = new ArmLinuxProcess64(params, objFile, 733 objFile->getArch()); 734 } else { 735 process = new ArmLinuxProcess32(params, objFile, 736 objFile->getArch()); 737 } 738 break; 739 case ObjectFile::LinuxArmOABI: 740 fatal("M5 does not support ARM OABI binaries. Please recompile with an" 741 " EABI compiler."); 742 default: 743 fatal("Unknown/unsupported operating system."); 744 } 745#elif THE_ISA == POWER_ISA 746 if (objFile->getArch() != ObjectFile::Power) 747 fatal("Object file architecture does not match compiled ISA (Power)."); 748 switch (objFile->getOpSys()) { 749 case ObjectFile::UnknownOpSys: 750 warn("Unknown operating system; assuming Linux."); 751 // fall through 752 case ObjectFile::Linux: 753 process = new PowerLinuxProcess(params, objFile); 754 break; 755 756 default: 757 fatal("Unknown/unsupported operating system."); 758 } 759#else 760#error "THE_ISA not set" 761#endif 762 763 if (process == NULL) 764 fatal("Unknown error creating process object."); 765 return process; 766} 767 768LiveProcess * 769LiveProcessParams::create() 770{ 771 return LiveProcess::create(this); 772} 773