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