process.cc revision 10558
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 ? PageTableBase::Clobber : 0); 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, bool cacheable) 557{ 558 pTable->map(vaddr, paddr, size, 559 cacheable ? 0 : PageTableBase::Uncacheable); 560 return true; 561} 562 563 564//////////////////////////////////////////////////////////////////////// 565// 566// LiveProcess member definitions 567// 568//////////////////////////////////////////////////////////////////////// 569 570 571LiveProcess::LiveProcess(LiveProcessParams *params, ObjectFile *_objFile) 572 : Process(params), objFile(_objFile), 573 argv(params->cmd), envp(params->env), cwd(params->cwd), 574 __uid(params->uid), __euid(params->euid), 575 __gid(params->gid), __egid(params->egid), 576 __pid(params->pid), __ppid(params->ppid), 577 drivers(params->drivers) 578{ 579 580 // load up symbols, if any... these may be used for debugging or 581 // profiling. 582 if (!debugSymbolTable) { 583 debugSymbolTable = new SymbolTable(); 584 if (!objFile->loadGlobalSymbols(debugSymbolTable) || 585 !objFile->loadLocalSymbols(debugSymbolTable) || 586 !objFile->loadWeakSymbols(debugSymbolTable)) { 587 // didn't load any symbols 588 delete debugSymbolTable; 589 debugSymbolTable = NULL; 590 } 591 } 592} 593 594void 595LiveProcess::syscall(int64_t callnum, ThreadContext *tc) 596{ 597 num_syscalls++; 598 599 SyscallDesc *desc = getDesc(callnum); 600 if (desc == NULL) 601 fatal("Syscall %d out of range", callnum); 602 603 desc->doSyscall(callnum, this, tc); 604} 605 606IntReg 607LiveProcess::getSyscallArg(ThreadContext *tc, int &i, int width) 608{ 609 return getSyscallArg(tc, i); 610} 611 612 613EmulatedDriver * 614LiveProcess::findDriver(std::string filename) 615{ 616 for (EmulatedDriver *d : drivers) { 617 if (d->match(filename)) 618 return d; 619 } 620 621 return NULL; 622} 623 624 625LiveProcess * 626LiveProcess::create(LiveProcessParams * params) 627{ 628 LiveProcess *process = NULL; 629 630 string executable = 631 params->executable == "" ? params->cmd[0] : params->executable; 632 ObjectFile *objFile = createObjectFile(executable); 633 if (objFile == NULL) { 634 fatal("Can't load object file %s", executable); 635 } 636 637 if (objFile->isDynamic()) 638 fatal("Object file is a dynamic executable however only static " 639 "executables are supported!\n Please recompile your " 640 "executable as a static binary and try again.\n"); 641 642#if THE_ISA == ALPHA_ISA 643 if (objFile->getArch() != ObjectFile::Alpha) 644 fatal("Object file architecture does not match compiled ISA (Alpha)."); 645 646 switch (objFile->getOpSys()) { 647 case ObjectFile::Tru64: 648 process = new AlphaTru64Process(params, objFile); 649 break; 650 651 case ObjectFile::UnknownOpSys: 652 warn("Unknown operating system; assuming Linux."); 653 // fall through 654 case ObjectFile::Linux: 655 process = new AlphaLinuxProcess(params, objFile); 656 break; 657 658 default: 659 fatal("Unknown/unsupported operating system."); 660 } 661#elif THE_ISA == SPARC_ISA 662 if (objFile->getArch() != ObjectFile::SPARC64 && 663 objFile->getArch() != ObjectFile::SPARC32) 664 fatal("Object file architecture does not match compiled ISA (SPARC)."); 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::SPARC64) { 671 process = new Sparc64LinuxProcess(params, objFile); 672 } else { 673 process = new Sparc32LinuxProcess(params, objFile); 674 } 675 break; 676 677 678 case ObjectFile::Solaris: 679 process = new SparcSolarisProcess(params, objFile); 680 break; 681 682 default: 683 fatal("Unknown/unsupported operating system."); 684 } 685#elif THE_ISA == X86_ISA 686 if (objFile->getArch() != ObjectFile::X86_64 && 687 objFile->getArch() != ObjectFile::I386) 688 fatal("Object file architecture does not match compiled ISA (x86)."); 689 switch (objFile->getOpSys()) { 690 case ObjectFile::UnknownOpSys: 691 warn("Unknown operating system; assuming Linux."); 692 // fall through 693 case ObjectFile::Linux: 694 if (objFile->getArch() == ObjectFile::X86_64) { 695 process = new X86_64LinuxProcess(params, objFile); 696 } else { 697 process = new I386LinuxProcess(params, objFile); 698 } 699 break; 700 701 default: 702 fatal("Unknown/unsupported operating system."); 703 } 704#elif THE_ISA == MIPS_ISA 705 if (objFile->getArch() != ObjectFile::Mips) 706 fatal("Object file architecture does not match compiled ISA (MIPS)."); 707 switch (objFile->getOpSys()) { 708 case ObjectFile::UnknownOpSys: 709 warn("Unknown operating system; assuming Linux."); 710 // fall through 711 case ObjectFile::Linux: 712 process = new MipsLinuxProcess(params, objFile); 713 break; 714 715 default: 716 fatal("Unknown/unsupported operating system."); 717 } 718#elif THE_ISA == ARM_ISA 719 ObjectFile::Arch arch = objFile->getArch(); 720 if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 721 arch != ObjectFile::Arm64) 722 fatal("Object file architecture does not match compiled ISA (ARM)."); 723 switch (objFile->getOpSys()) { 724 case ObjectFile::UnknownOpSys: 725 warn("Unknown operating system; assuming Linux."); 726 // fall through 727 case ObjectFile::Linux: 728 if (arch == ObjectFile::Arm64) { 729 process = new ArmLinuxProcess64(params, objFile, 730 objFile->getArch()); 731 } else { 732 process = new ArmLinuxProcess32(params, objFile, 733 objFile->getArch()); 734 } 735 break; 736 case ObjectFile::LinuxArmOABI: 737 fatal("M5 does not support ARM OABI binaries. Please recompile with an" 738 " EABI compiler."); 739 default: 740 fatal("Unknown/unsupported operating system."); 741 } 742#elif THE_ISA == POWER_ISA 743 if (objFile->getArch() != ObjectFile::Power) 744 fatal("Object file architecture does not match compiled ISA (Power)."); 745 switch (objFile->getOpSys()) { 746 case ObjectFile::UnknownOpSys: 747 warn("Unknown operating system; assuming Linux."); 748 // fall through 749 case ObjectFile::Linux: 750 process = new PowerLinuxProcess(params, objFile); 751 break; 752 753 default: 754 fatal("Unknown/unsupported operating system."); 755 } 756#else 757#error "THE_ISA not set" 758#endif 759 760 if (process == NULL) 761 fatal("Unknown error creating process object."); 762 return process; 763} 764 765LiveProcess * 766LiveProcessParams::create() 767{ 768 return LiveProcess::create(this); 769} 770