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