process.cc (13981:577196ddd040) | process.cc (13990:828a9dfb6bd0) |
---|---|
1/* 2 * Copyright (c) 2014-2016 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 --- 58 unchanged lines hidden (view full) --- 67#include "params/Process.hh" 68#include "sim/emul_driver.hh" 69#include "sim/fd_array.hh" 70#include "sim/fd_entry.hh" 71#include "sim/redirect_path.hh" 72#include "sim/syscall_desc.hh" 73#include "sim/system.hh" 74 | 1/* 2 * Copyright (c) 2014-2016 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 --- 58 unchanged lines hidden (view full) --- 67#include "params/Process.hh" 68#include "sim/emul_driver.hh" 69#include "sim/fd_array.hh" 70#include "sim/fd_entry.hh" 71#include "sim/redirect_path.hh" 72#include "sim/syscall_desc.hh" 73#include "sim/system.hh" 74 |
75#if THE_ISA == ALPHA_ISA 76#include "arch/alpha/linux/process.hh" 77 78#elif THE_ISA == SPARC_ISA 79#include "arch/sparc/linux/process.hh" 80#include "arch/sparc/solaris/process.hh" 81 82#elif THE_ISA == MIPS_ISA 83#include "arch/mips/linux/process.hh" 84 85#elif THE_ISA == ARM_ISA 86#include "arch/arm/freebsd/process.hh" 87#include "arch/arm/linux/process.hh" 88 89#elif THE_ISA == X86_ISA 90#include "arch/x86/linux/process.hh" 91 92#elif THE_ISA == POWER_ISA 93#include "arch/power/linux/process.hh" 94 95#elif THE_ISA == RISCV_ISA 96#include "arch/riscv/linux/process.hh" 97 98#else 99#error "THE_ISA not set" 100#endif 101 102 | |
103using namespace std; 104using namespace TheISA; 105 106static std::string 107normalize(std::string& directory) 108{ 109 if (directory.back() != '/') 110 directory += '/'; --- 447 unchanged lines hidden (view full) --- 558 559 // If not specified, set the executable parameter equal to the 560 // simulated system's zeroth command line parameter 561 if (executable == "") { 562 executable = cmd[0]; 563 } 564 565 ObjectFile *obj_file = createObjectFile(executable); | 75using namespace std; 76using namespace TheISA; 77 78static std::string 79normalize(std::string& directory) 80{ 81 if (directory.back() != '/') 82 directory += '/'; --- 447 unchanged lines hidden (view full) --- 530 531 // If not specified, set the executable parameter equal to the 532 // simulated system's zeroth command line parameter 533 if (executable == "") { 534 executable = cmd[0]; 535 } 536 537 ObjectFile *obj_file = createObjectFile(executable); |
566 if (obj_file == nullptr) { 567 fatal("Can't load object file %s", executable); 568 } | 538 fatal_if(!obj_file, "Can't load object file %s", executable); |
569 | 539 |
570#if THE_ISA == ALPHA_ISA 571 if (obj_file->getArch() != ObjectFile::Alpha) 572 fatal("Object file architecture does not match compiled ISA (Alpha)."); | 540 process = ObjectFile::tryLoaders(this, obj_file); 541 fatal_if(!process, "Unknown error creating process object."); |
573 | 542 |
574 switch (obj_file->getOpSys()) { 575 case ObjectFile::UnknownOpSys: 576 warn("Unknown operating system; assuming Linux."); 577 // fall through 578 case ObjectFile::Linux: 579 process = new AlphaLinuxProcess(this, obj_file); 580 break; 581 582 default: 583 fatal("Unknown/unsupported operating system."); 584 } 585#elif THE_ISA == SPARC_ISA 586 if (obj_file->getArch() != ObjectFile::SPARC64 && 587 obj_file->getArch() != ObjectFile::SPARC32) 588 fatal("Object file architecture does not match compiled ISA (SPARC)."); 589 switch (obj_file->getOpSys()) { 590 case ObjectFile::UnknownOpSys: 591 warn("Unknown operating system; assuming Linux."); 592 // fall through 593 case ObjectFile::Linux: 594 if (obj_file->getArch() == ObjectFile::SPARC64) { 595 process = new Sparc64LinuxProcess(this, obj_file); 596 } else { 597 process = new Sparc32LinuxProcess(this, obj_file); 598 } 599 break; 600 601 case ObjectFile::Solaris: 602 process = new SparcSolarisProcess(this, obj_file); 603 break; 604 605 default: 606 fatal("Unknown/unsupported operating system."); 607 } 608#elif THE_ISA == X86_ISA 609 if (obj_file->getArch() != ObjectFile::X86_64 && 610 obj_file->getArch() != ObjectFile::I386) 611 fatal("Object file architecture does not match compiled ISA (x86)."); 612 switch (obj_file->getOpSys()) { 613 case ObjectFile::UnknownOpSys: 614 warn("Unknown operating system; assuming Linux."); 615 // fall through 616 case ObjectFile::Linux: 617 if (obj_file->getArch() == ObjectFile::X86_64) { 618 process = new X86_64LinuxProcess(this, obj_file); 619 } else { 620 process = new I386LinuxProcess(this, obj_file); 621 } 622 break; 623 624 default: 625 fatal("Unknown/unsupported operating system."); 626 } 627#elif THE_ISA == MIPS_ISA 628 if (obj_file->getArch() != ObjectFile::Mips) 629 fatal("Object file architecture does not match compiled ISA (MIPS)."); 630 switch (obj_file->getOpSys()) { 631 case ObjectFile::UnknownOpSys: 632 warn("Unknown operating system; assuming Linux."); 633 // fall through 634 case ObjectFile::Linux: 635 process = new MipsLinuxProcess(this, obj_file); 636 break; 637 638 default: 639 fatal("Unknown/unsupported operating system."); 640 } 641#elif THE_ISA == ARM_ISA 642 ObjectFile::Arch arch = obj_file->getArch(); 643 if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb && 644 arch != ObjectFile::Arm64) 645 fatal("Object file architecture does not match compiled ISA (ARM)."); 646 switch (obj_file->getOpSys()) { 647 case ObjectFile::UnknownOpSys: 648 warn("Unknown operating system; assuming Linux."); 649 // fall through 650 case ObjectFile::Linux: 651 if (arch == ObjectFile::Arm64) { 652 process = new ArmLinuxProcess64(this, obj_file, 653 obj_file->getArch()); 654 } else { 655 process = new ArmLinuxProcess32(this, obj_file, 656 obj_file->getArch()); 657 } 658 break; 659 case ObjectFile::FreeBSD: 660 if (arch == ObjectFile::Arm64) { 661 process = new ArmFreebsdProcess64(this, obj_file, 662 obj_file->getArch()); 663 } else { 664 process = new ArmFreebsdProcess32(this, obj_file, 665 obj_file->getArch()); 666 } 667 break; 668 case ObjectFile::LinuxArmOABI: 669 fatal("M5 does not support ARM OABI binaries. Please recompile with an" 670 " EABI compiler."); 671 default: 672 fatal("Unknown/unsupported operating system."); 673 } 674#elif THE_ISA == POWER_ISA 675 if (obj_file->getArch() != ObjectFile::Power) 676 fatal("Object file architecture does not match compiled ISA (Power)."); 677 switch (obj_file->getOpSys()) { 678 case ObjectFile::UnknownOpSys: 679 warn("Unknown operating system; assuming Linux."); 680 // fall through 681 case ObjectFile::Linux: 682 process = new PowerLinuxProcess(this, obj_file); 683 break; 684 685 default: 686 fatal("Unknown/unsupported operating system."); 687 } 688#elif THE_ISA == RISCV_ISA 689 ObjectFile::Arch arch = obj_file->getArch(); 690 if (arch != ObjectFile::Riscv64 && arch != ObjectFile::Riscv32) 691 fatal("Object file architecture does not match compiled ISA (RISCV)."); 692 switch (obj_file->getOpSys()) { 693 case ObjectFile::UnknownOpSys: 694 warn("Unknown operating system; assuming Linux."); 695 // fall through 696 case ObjectFile::Linux: 697 if (arch == ObjectFile::Riscv64) { 698 process = new RiscvLinuxProcess64(this, obj_file); 699 } else { 700 process = new RiscvLinuxProcess32(this, obj_file); 701 } 702 break; 703 default: 704 fatal("Unknown/unsupported operating system."); 705 } 706#else 707#error "THE_ISA not set" 708#endif 709 710 if (process == nullptr) 711 fatal("Unknown error creating process object."); | |
712 return process; 713} | 543 return process; 544} |