fs.py revision 12475
111598Sandreas.sandberg@arm.com# Copyright (c) 2010-2013, 2016 ARM Limited 27586SAli.Saidi@arm.com# All rights reserved. 37586SAli.Saidi@arm.com# 47586SAli.Saidi@arm.com# The license below extends only to copyright in the software and shall 57586SAli.Saidi@arm.com# not be construed as granting a license to any other intellectual 67586SAli.Saidi@arm.com# property including but not limited to intellectual property relating 77586SAli.Saidi@arm.com# to a hardware implementation of the functionality of the software 87586SAli.Saidi@arm.com# licensed hereunder. You may use the software subject to the license 97586SAli.Saidi@arm.com# terms below provided that you ensure that this notice is replicated 107586SAli.Saidi@arm.com# unmodified and in its entirety in all distributions of the software, 117586SAli.Saidi@arm.com# modified or unmodified, in source code or in binary form. 127586SAli.Saidi@arm.com# 1310118Snilay@cs.wisc.edu# Copyright (c) 2012-2014 Mark D. Hill and David A. Wood 1410118Snilay@cs.wisc.edu# Copyright (c) 2009-2011 Advanced Micro Devices, Inc. 153970Sgblack@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan 163005Sstever@eecs.umich.edu# All rights reserved. 173005Sstever@eecs.umich.edu# 183005Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 193005Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are 203005Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright 213005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 223005Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 233005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 243005Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution; 253005Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its 263005Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from 273005Sstever@eecs.umich.edu# this software without specific prior written permission. 283005Sstever@eecs.umich.edu# 293005Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 303005Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 313005Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 323005Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 333005Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 343005Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 353005Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 363005Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 373005Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 383005Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 393005Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 403005Sstever@eecs.umich.edu# 413005Sstever@eecs.umich.edu# Authors: Ali Saidi 4210118Snilay@cs.wisc.edu# Brad Beckmann 433005Sstever@eecs.umich.edu 446654Snate@binkert.orgimport optparse 456654Snate@binkert.orgimport sys 462889SN/A 472710SN/Aimport m5 486654Snate@binkert.orgfrom m5.defines import buildEnv 496654Snate@binkert.orgfrom m5.objects import * 5012395Sswapnilster@gmail.comfrom m5.util import addToPath, fatal, warn 5112475Sglenn.bergmans@arm.comfrom m5.util.fdthelper import * 525457Ssaidi@eecs.umich.edu 5311670Sandreas.hansson@arm.comaddToPath('../') 5410118Snilay@cs.wisc.edu 5511670Sandreas.hansson@arm.comfrom ruby import Ruby 566654Snate@binkert.org 5711682Sandreas.hansson@arm.comfrom common.FSConfig import * 5811682Sandreas.hansson@arm.comfrom common.SysPaths import * 5911682Sandreas.hansson@arm.comfrom common.Benchmarks import * 6011682Sandreas.hansson@arm.comfrom common import Simulation 6111682Sandreas.hansson@arm.comfrom common import CacheConfig 6211682Sandreas.hansson@arm.comfrom common import MemConfig 6311790Sjungma@eit.uni-kl.defrom common import CpuConfig 6411682Sandreas.hansson@arm.comfrom common.Caches import * 6511682Sandreas.hansson@arm.comfrom common import Options 663444Sktlim@umich.edu 673304Sstever@eecs.umich.edu 689653SAndreas.Sandberg@ARM.com# Check if KVM support has been enabled, we might need to do VM 699653SAndreas.Sandberg@ARM.com# configuration if that's the case. 709653SAndreas.Sandberg@ARM.comhave_kvm_support = 'BaseKvmCPU' in globals() 719653SAndreas.Sandberg@ARM.comdef is_kvm_cpu(cpu_class): 729653SAndreas.Sandberg@ARM.com return have_kvm_support and cpu_class != None and \ 739653SAndreas.Sandberg@ARM.com issubclass(cpu_class, BaseKvmCPU) 749653SAndreas.Sandberg@ARM.com 7510594Sgabeblack@google.comdef cmd_line_template(): 7610594Sgabeblack@google.com if options.command_line and options.command_line_file: 7710594Sgabeblack@google.com print "Error: --command-line and --command-line-file are " \ 7810594Sgabeblack@google.com "mutually exclusive" 7910594Sgabeblack@google.com sys.exit(1) 8010594Sgabeblack@google.com if options.command_line: 8110594Sgabeblack@google.com return options.command_line 8210594Sgabeblack@google.com if options.command_line_file: 8310594Sgabeblack@google.com return open(options.command_line_file).read().strip() 8410594Sgabeblack@google.com return None 8510594Sgabeblack@google.com 8610119Snilay@cs.wisc.edudef build_test_system(np): 8710594Sgabeblack@google.com cmdline = cmd_line_template() 8810119Snilay@cs.wisc.edu if buildEnv['TARGET_ISA'] == "alpha": 8910594Sgabeblack@google.com test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0], options.ruby, 9010594Sgabeblack@google.com cmdline=cmdline) 9110119Snilay@cs.wisc.edu elif buildEnv['TARGET_ISA'] == "mips": 9210594Sgabeblack@google.com test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0], cmdline=cmdline) 9310119Snilay@cs.wisc.edu elif buildEnv['TARGET_ISA'] == "sparc": 9410594Sgabeblack@google.com test_sys = makeSparcSystem(test_mem_mode, bm[0], cmdline=cmdline) 9510119Snilay@cs.wisc.edu elif buildEnv['TARGET_ISA'] == "x86": 9610119Snilay@cs.wisc.edu test_sys = makeLinuxX86System(test_mem_mode, options.num_cpus, bm[0], 9710594Sgabeblack@google.com options.ruby, cmdline=cmdline) 9810119Snilay@cs.wisc.edu elif buildEnv['TARGET_ISA'] == "arm": 9910512SAli.Saidi@ARM.com test_sys = makeArmSystem(test_mem_mode, options.machine_type, 10010512SAli.Saidi@ARM.com options.num_cpus, bm[0], options.dtb_filename, 10110594Sgabeblack@google.com bare_metal=options.bare_metal, 10210780SCurtis.Dunham@arm.com cmdline=cmdline, 10312475Sglenn.bergmans@arm.com ignore_dtb=options.generate_dtb, 10412475Sglenn.bergmans@arm.com external_memory= 10512475Sglenn.bergmans@arm.com options.external_memory_system, 10612079Sgedare@rtems.org ruby=options.ruby, 10712079Sgedare@rtems.org security=options.enable_security_extensions) 10810119Snilay@cs.wisc.edu if options.enable_context_switch_stats_dump: 10910119Snilay@cs.wisc.edu test_sys.enable_context_switch_stats_dump = True 11010119Snilay@cs.wisc.edu else: 11110119Snilay@cs.wisc.edu fatal("Incapable of building %s full system!", buildEnv['TARGET_ISA']) 1122566SN/A 11310119Snilay@cs.wisc.edu # Set the cache line size for the entire system 11410119Snilay@cs.wisc.edu test_sys.cache_line_size = options.cacheline_size 1159665Sandreas.hansson@arm.com 11610119Snilay@cs.wisc.edu # Create a top-level voltage domain 11710119Snilay@cs.wisc.edu test_sys.voltage_domain = VoltageDomain(voltage = options.sys_voltage) 11810119Snilay@cs.wisc.edu 11910119Snilay@cs.wisc.edu # Create a source clock for the system and set the clock period 12010119Snilay@cs.wisc.edu test_sys.clk_domain = SrcClockDomain(clock = options.sys_clock, 12110119Snilay@cs.wisc.edu voltage_domain = test_sys.voltage_domain) 12210119Snilay@cs.wisc.edu 12310119Snilay@cs.wisc.edu # Create a CPU voltage domain 12410119Snilay@cs.wisc.edu test_sys.cpu_voltage_domain = VoltageDomain() 12510119Snilay@cs.wisc.edu 12610119Snilay@cs.wisc.edu # Create a source clock for the CPUs and set the clock period 12710119Snilay@cs.wisc.edu test_sys.cpu_clk_domain = SrcClockDomain(clock = options.cpu_clock, 12810119Snilay@cs.wisc.edu voltage_domain = 12910119Snilay@cs.wisc.edu test_sys.cpu_voltage_domain) 13010119Snilay@cs.wisc.edu 13110119Snilay@cs.wisc.edu if options.kernel is not None: 13210119Snilay@cs.wisc.edu test_sys.kernel = binary(options.kernel) 13310119Snilay@cs.wisc.edu 13410119Snilay@cs.wisc.edu if options.script is not None: 13510119Snilay@cs.wisc.edu test_sys.readfile = options.script 13610119Snilay@cs.wisc.edu 13710119Snilay@cs.wisc.edu if options.lpae: 13810119Snilay@cs.wisc.edu test_sys.have_lpae = True 13910119Snilay@cs.wisc.edu 14010119Snilay@cs.wisc.edu if options.virtualisation: 14110119Snilay@cs.wisc.edu test_sys.have_virtualization = True 14210119Snilay@cs.wisc.edu 14310119Snilay@cs.wisc.edu test_sys.init_param = options.init_param 14410119Snilay@cs.wisc.edu 14510119Snilay@cs.wisc.edu # For now, assign all the CPUs to the same clock domain 14610119Snilay@cs.wisc.edu test_sys.cpu = [TestCPUClass(clk_domain=test_sys.cpu_clk_domain, cpu_id=i) 14710119Snilay@cs.wisc.edu for i in xrange(np)] 14810119Snilay@cs.wisc.edu 14910119Snilay@cs.wisc.edu if is_kvm_cpu(TestCPUClass) or is_kvm_cpu(FutureClass): 15011839SCurtis.Dunham@arm.com test_sys.kvm_vm = KvmVM() 15110119Snilay@cs.wisc.edu 15210119Snilay@cs.wisc.edu if options.ruby: 15310519Snilay@cs.wisc.edu Ruby.create_system(options, True, test_sys, test_sys.iobus, 15410519Snilay@cs.wisc.edu test_sys._dma_ports) 15510119Snilay@cs.wisc.edu 15610119Snilay@cs.wisc.edu # Create a seperate clock domain for Ruby 15710119Snilay@cs.wisc.edu test_sys.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock, 15810119Snilay@cs.wisc.edu voltage_domain = test_sys.voltage_domain) 15910119Snilay@cs.wisc.edu 16010547Snilay@cs.wisc.edu # Connect the ruby io port to the PIO bus, 16110547Snilay@cs.wisc.edu # assuming that there is just one such port. 16210547Snilay@cs.wisc.edu test_sys.iobus.master = test_sys.ruby._io_port.slave 16310547Snilay@cs.wisc.edu 16410119Snilay@cs.wisc.edu for (i, cpu) in enumerate(test_sys.cpu): 16510119Snilay@cs.wisc.edu # 16610119Snilay@cs.wisc.edu # Tie the cpu ports to the correct ruby system ports 16710119Snilay@cs.wisc.edu # 16810119Snilay@cs.wisc.edu cpu.clk_domain = test_sys.cpu_clk_domain 16910119Snilay@cs.wisc.edu cpu.createThreads() 17010119Snilay@cs.wisc.edu cpu.createInterruptController() 17110119Snilay@cs.wisc.edu 17210120Snilay@cs.wisc.edu cpu.icache_port = test_sys.ruby._cpu_ports[i].slave 17310120Snilay@cs.wisc.edu cpu.dcache_port = test_sys.ruby._cpu_ports[i].slave 17410119Snilay@cs.wisc.edu 17511598Sandreas.sandberg@arm.com if buildEnv['TARGET_ISA'] in ("x86", "arm"): 17610120Snilay@cs.wisc.edu cpu.itb.walker.port = test_sys.ruby._cpu_ports[i].slave 17710120Snilay@cs.wisc.edu cpu.dtb.walker.port = test_sys.ruby._cpu_ports[i].slave 17810119Snilay@cs.wisc.edu 17911598Sandreas.sandberg@arm.com if buildEnv['TARGET_ISA'] in "x86": 18011150Smitch.hayenga@arm.com cpu.interrupts[0].pio = test_sys.ruby._cpu_ports[i].master 18111150Smitch.hayenga@arm.com cpu.interrupts[0].int_master = test_sys.ruby._cpu_ports[i].slave 18211150Smitch.hayenga@arm.com cpu.interrupts[0].int_slave = test_sys.ruby._cpu_ports[i].master 18310119Snilay@cs.wisc.edu 1842995SN/A else: 18510119Snilay@cs.wisc.edu if options.caches or options.l2cache: 18610119Snilay@cs.wisc.edu # By default the IOCache runs at the system clock 18710119Snilay@cs.wisc.edu test_sys.iocache = IOCache(addr_ranges = test_sys.mem_ranges) 18810119Snilay@cs.wisc.edu test_sys.iocache.cpu_side = test_sys.iobus.master 18910119Snilay@cs.wisc.edu test_sys.iocache.mem_side = test_sys.membus.slave 19010780SCurtis.Dunham@arm.com elif not options.external_memory_system: 19110119Snilay@cs.wisc.edu test_sys.iobridge = Bridge(delay='50ns', ranges = test_sys.mem_ranges) 19210119Snilay@cs.wisc.edu test_sys.iobridge.slave = test_sys.iobus.master 19310119Snilay@cs.wisc.edu test_sys.iobridge.master = test_sys.membus.slave 1943304Sstever@eecs.umich.edu 19510119Snilay@cs.wisc.edu # Sanity check 19610119Snilay@cs.wisc.edu if options.fastmem: 19710119Snilay@cs.wisc.edu if TestCPUClass != AtomicSimpleCPU: 19810119Snilay@cs.wisc.edu fatal("Fastmem can only be used with atomic CPU!") 19910119Snilay@cs.wisc.edu if (options.caches or options.l2cache): 20010119Snilay@cs.wisc.edu fatal("You cannot use fastmem in combination with caches!") 2016135Sgblack@eecs.umich.edu 20210608Sdam.sunwoo@arm.com if options.simpoint_profile: 20310608Sdam.sunwoo@arm.com if not options.fastmem: 20410608Sdam.sunwoo@arm.com # Atomic CPU checked with fastmem option already 20510608Sdam.sunwoo@arm.com fatal("SimPoint generation should be done with atomic cpu and fastmem") 20610608Sdam.sunwoo@arm.com if np > 1: 20710608Sdam.sunwoo@arm.com fatal("SimPoint generation not supported with more than one CPUs") 20810608Sdam.sunwoo@arm.com 20910119Snilay@cs.wisc.edu for i in xrange(np): 21010119Snilay@cs.wisc.edu if options.fastmem: 21110119Snilay@cs.wisc.edu test_sys.cpu[i].fastmem = True 21210608Sdam.sunwoo@arm.com if options.simpoint_profile: 21310608Sdam.sunwoo@arm.com test_sys.cpu[i].addSimPointProbe(options.simpoint_interval) 21410119Snilay@cs.wisc.edu if options.checker: 21510119Snilay@cs.wisc.edu test_sys.cpu[i].addCheckerCpu() 21610119Snilay@cs.wisc.edu test_sys.cpu[i].createThreads() 2173819Shsul@eecs.umich.edu 21811251Sradhika.jagtap@ARM.com # If elastic tracing is enabled when not restoring from checkpoint and 21911251Sradhika.jagtap@ARM.com # when not fast forwarding using the atomic cpu, then check that the 22011251Sradhika.jagtap@ARM.com # TestCPUClass is DerivO3CPU or inherits from DerivO3CPU. If the check 22111251Sradhika.jagtap@ARM.com # passes then attach the elastic trace probe. 22211251Sradhika.jagtap@ARM.com # If restoring from checkpoint or fast forwarding, the code that does this for 22311251Sradhika.jagtap@ARM.com # FutureCPUClass is in the Simulation module. If the check passes then the 22411251Sradhika.jagtap@ARM.com # elastic trace probe is attached to the switch CPUs. 22511251Sradhika.jagtap@ARM.com if options.elastic_trace_en and options.checkpoint_restore == None and \ 22611251Sradhika.jagtap@ARM.com not options.fast_forward: 22711251Sradhika.jagtap@ARM.com CpuConfig.config_etrace(TestCPUClass, test_sys.cpu, options) 22811251Sradhika.jagtap@ARM.com 22910119Snilay@cs.wisc.edu CacheConfig.config_cache(options, test_sys) 23011183Serfan.azarkhish@unibo.it 23110119Snilay@cs.wisc.edu MemConfig.config_mem(options, test_sys) 23210118Snilay@cs.wisc.edu 23310119Snilay@cs.wisc.edu return test_sys 2349827Sakash.bagdia@arm.com 23510119Snilay@cs.wisc.edudef build_drive_system(np): 23610119Snilay@cs.wisc.edu # driver system CPU is always simple, so is the memory 23710119Snilay@cs.wisc.edu # Note this is an assignment of a class, not an instance. 23810119Snilay@cs.wisc.edu DriveCPUClass = AtomicSimpleCPU 23910119Snilay@cs.wisc.edu drive_mem_mode = 'atomic' 24010119Snilay@cs.wisc.edu DriveMemClass = SimpleMemory 2419827Sakash.bagdia@arm.com 24210594Sgabeblack@google.com cmdline = cmd_line_template() 2436654Snate@binkert.org if buildEnv['TARGET_ISA'] == 'alpha': 24410594Sgabeblack@google.com drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1], cmdline=cmdline) 2456654Snate@binkert.org elif buildEnv['TARGET_ISA'] == 'mips': 24610594Sgabeblack@google.com drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1], cmdline=cmdline) 2476654Snate@binkert.org elif buildEnv['TARGET_ISA'] == 'sparc': 24810594Sgabeblack@google.com drive_sys = makeSparcSystem(drive_mem_mode, bm[1], cmdline=cmdline) 2496654Snate@binkert.org elif buildEnv['TARGET_ISA'] == 'x86': 25010594Sgabeblack@google.com drive_sys = makeLinuxX86System(drive_mem_mode, np, bm[1], 25110594Sgabeblack@google.com cmdline=cmdline) 2527586SAli.Saidi@arm.com elif buildEnv['TARGET_ISA'] == 'arm': 25310635Satgutier@umich.edu drive_sys = makeArmSystem(drive_mem_mode, options.machine_type, np, 25412475Sglenn.bergmans@arm.com bm[1], options.dtb_filename, cmdline=cmdline, 25512475Sglenn.bergmans@arm.com ignore_dtb=options.generate_dtb) 2568661SAli.Saidi@ARM.com 2579827Sakash.bagdia@arm.com # Create a top-level voltage domain 2589827Sakash.bagdia@arm.com drive_sys.voltage_domain = VoltageDomain(voltage = options.sys_voltage) 2599827Sakash.bagdia@arm.com 2609793Sakash.bagdia@arm.com # Create a source clock for the system and set the clock period 26110119Snilay@cs.wisc.edu drive_sys.clk_domain = SrcClockDomain(clock = options.sys_clock, 26210119Snilay@cs.wisc.edu voltage_domain = drive_sys.voltage_domain) 2639790Sakash.bagdia@arm.com 2649827Sakash.bagdia@arm.com # Create a CPU voltage domain 2659827Sakash.bagdia@arm.com drive_sys.cpu_voltage_domain = VoltageDomain() 2669827Sakash.bagdia@arm.com 2679793Sakash.bagdia@arm.com # Create a source clock for the CPUs and set the clock period 2689827Sakash.bagdia@arm.com drive_sys.cpu_clk_domain = SrcClockDomain(clock = options.cpu_clock, 2699827Sakash.bagdia@arm.com voltage_domain = 2709827Sakash.bagdia@arm.com drive_sys.cpu_voltage_domain) 2719793Sakash.bagdia@arm.com 2729793Sakash.bagdia@arm.com drive_sys.cpu = DriveCPUClass(clk_domain=drive_sys.cpu_clk_domain, 2739793Sakash.bagdia@arm.com cpu_id=0) 2749384SAndreas.Sandberg@arm.com drive_sys.cpu.createThreads() 2758863Snilay@cs.wisc.edu drive_sys.cpu.createInterruptController() 2767876Sgblack@eecs.umich.edu drive_sys.cpu.connectAllPorts(drive_sys.membus) 2774968Sacolyte@umich.edu if options.fastmem: 2788926Sandreas.hansson@arm.com drive_sys.cpu.fastmem = True 2794837Ssaidi@eecs.umich.edu if options.kernel is not None: 2804837Ssaidi@eecs.umich.edu drive_sys.kernel = binary(options.kernel) 2819408Sandreas.hansson@arm.com 2829653SAndreas.Sandberg@ARM.com if is_kvm_cpu(DriveCPUClass): 28311839SCurtis.Dunham@arm.com drive_sys.kvm_vm = KvmVM() 2849653SAndreas.Sandberg@ARM.com 2859164Sandreas.hansson@arm.com drive_sys.iobridge = Bridge(delay='50ns', 2869408Sandreas.hansson@arm.com ranges = drive_sys.mem_ranges) 2878845Sandreas.hansson@arm.com drive_sys.iobridge.slave = drive_sys.iobus.master 2888845Sandreas.hansson@arm.com drive_sys.iobridge.master = drive_sys.membus.slave 2894837Ssaidi@eecs.umich.edu 2909826Sandreas.hansson@arm.com # Create the appropriate memory controllers and connect them to the 2919826Sandreas.hansson@arm.com # memory bus 2929835Sandreas.hansson@arm.com drive_sys.mem_ctrls = [DriveMemClass(range = r) 2939826Sandreas.hansson@arm.com for r in drive_sys.mem_ranges] 2949826Sandreas.hansson@arm.com for i in xrange(len(drive_sys.mem_ctrls)): 2959826Sandreas.hansson@arm.com drive_sys.mem_ctrls[i].port = drive_sys.membus.master 2969826Sandreas.hansson@arm.com 2978659SAli.Saidi@ARM.com drive_sys.init_param = options.init_param 29810119Snilay@cs.wisc.edu 29910119Snilay@cs.wisc.edu return drive_sys 30010119Snilay@cs.wisc.edu 30110119Snilay@cs.wisc.edu# Add options 30210119Snilay@cs.wisc.eduparser = optparse.OptionParser() 30310119Snilay@cs.wisc.eduOptions.addCommonOptions(parser) 30410119Snilay@cs.wisc.eduOptions.addFSOptions(parser) 30510119Snilay@cs.wisc.edu 30610119Snilay@cs.wisc.edu# Add the ruby specific and protocol specific options 30710119Snilay@cs.wisc.eduif '--ruby' in sys.argv: 30810119Snilay@cs.wisc.edu Ruby.define_options(parser) 30910119Snilay@cs.wisc.edu 31010119Snilay@cs.wisc.edu(options, args) = parser.parse_args() 31110119Snilay@cs.wisc.edu 31210119Snilay@cs.wisc.eduif args: 31310119Snilay@cs.wisc.edu print "Error: script doesn't take any positional arguments" 31410119Snilay@cs.wisc.edu sys.exit(1) 31510119Snilay@cs.wisc.edu 31610119Snilay@cs.wisc.edu# system under test can be any CPU 31710119Snilay@cs.wisc.edu(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options) 31810119Snilay@cs.wisc.edu 31910119Snilay@cs.wisc.edu# Match the memories with the CPUs, based on the options for the test system 32010119Snilay@cs.wisc.eduTestMemClass = Simulation.setMemClass(options) 32110119Snilay@cs.wisc.edu 32210119Snilay@cs.wisc.eduif options.benchmark: 32310119Snilay@cs.wisc.edu try: 32410119Snilay@cs.wisc.edu bm = Benchmarks[options.benchmark] 32510119Snilay@cs.wisc.edu except KeyError: 32610119Snilay@cs.wisc.edu print "Error benchmark %s has not been defined." % options.benchmark 32710119Snilay@cs.wisc.edu print "Valid benchmarks are: %s" % DefinedBenchmarks 32810119Snilay@cs.wisc.edu sys.exit(1) 32910119Snilay@cs.wisc.eduelse: 33010119Snilay@cs.wisc.edu if options.dual: 33110697SCurtis.Dunham@arm.com bm = [SysConfig(disk=options.disk_image, rootdev=options.root_device, 33210747SChris.Emmons@arm.com mem=options.mem_size, os_type=options.os_type), 33310697SCurtis.Dunham@arm.com SysConfig(disk=options.disk_image, rootdev=options.root_device, 33410747SChris.Emmons@arm.com mem=options.mem_size, os_type=options.os_type)] 33510119Snilay@cs.wisc.edu else: 33610697SCurtis.Dunham@arm.com bm = [SysConfig(disk=options.disk_image, rootdev=options.root_device, 33710747SChris.Emmons@arm.com mem=options.mem_size, os_type=options.os_type)] 33810119Snilay@cs.wisc.edu 33910119Snilay@cs.wisc.edunp = options.num_cpus 34010119Snilay@cs.wisc.edu 34110119Snilay@cs.wisc.edutest_sys = build_test_system(np) 34210119Snilay@cs.wisc.eduif len(bm) == 2: 34310119Snilay@cs.wisc.edu drive_sys = build_drive_system(np) 3448801Sgblack@eecs.umich.edu root = makeDualRoot(True, test_sys, drive_sys, options.etherdump) 34511291Sgabor.dozsa@arm.comelif len(bm) == 1 and options.dist: 34611291Sgabor.dozsa@arm.com # This system is part of a dist-gem5 simulation 34711291Sgabor.dozsa@arm.com root = makeDistRoot(test_sys, 34811291Sgabor.dozsa@arm.com options.dist_rank, 34911291Sgabor.dozsa@arm.com options.dist_size, 35011291Sgabor.dozsa@arm.com options.dist_server_name, 35111291Sgabor.dozsa@arm.com options.dist_server_port, 35211291Sgabor.dozsa@arm.com options.dist_sync_repeat, 35311291Sgabor.dozsa@arm.com options.dist_sync_start, 35411291Sgabor.dozsa@arm.com options.ethernet_linkspeed, 35511291Sgabor.dozsa@arm.com options.ethernet_linkdelay, 35611291Sgabor.dozsa@arm.com options.etherdump); 3573005Sstever@eecs.umich.eduelif len(bm) == 1: 3588801Sgblack@eecs.umich.edu root = Root(full_system=True, system=test_sys) 3593005Sstever@eecs.umich.eduelse: 3603005Sstever@eecs.umich.edu print "Error I don't know how to create more than 2 systems." 3613005Sstever@eecs.umich.edu sys.exit(1) 3622566SN/A 3637861Sgblack@eecs.umich.eduif options.timesync: 3647861Sgblack@eecs.umich.edu root.time_sync_enable = True 3657861Sgblack@eecs.umich.edu 3668635Schris.emmons@arm.comif options.frame_capture: 3678635Schris.emmons@arm.com VncServer.frame_capture = True 3688635Schris.emmons@arm.com 36912475Sglenn.bergmans@arm.comif buildEnv['TARGET_ISA'] == "arm" and options.generate_dtb: 37012475Sglenn.bergmans@arm.com # Sanity checks 37112475Sglenn.bergmans@arm.com if options.dtb_filename: 37212475Sglenn.bergmans@arm.com fatal("--generate-dtb and --dtb-filename cannot be specified at the"\ 37312475Sglenn.bergmans@arm.com "same time.") 37412475Sglenn.bergmans@arm.com 37512475Sglenn.bergmans@arm.com if options.machine_type not in ["VExpress_GEM5", "VExpress_GEM5_V1"]: 37612475Sglenn.bergmans@arm.com warn("Can only correctly generate a dtb for VExpress_GEM5_V1 " \ 37712475Sglenn.bergmans@arm.com "platforms, unless custom hardware models have been equipped "\ 37812475Sglenn.bergmans@arm.com "with generation functionality.") 37912475Sglenn.bergmans@arm.com 38012475Sglenn.bergmans@arm.com # Generate a Device Tree 38112475Sglenn.bergmans@arm.com def create_dtb_for_system(system, filename): 38212475Sglenn.bergmans@arm.com state = FdtState(addr_cells=2, size_cells=2, cpu_cells=1) 38312475Sglenn.bergmans@arm.com rootNode = system.generateDeviceTree(state) 38412475Sglenn.bergmans@arm.com 38512475Sglenn.bergmans@arm.com fdt = Fdt() 38612475Sglenn.bergmans@arm.com fdt.add_rootnode(rootNode) 38712475Sglenn.bergmans@arm.com dtb_filename = os.path.join(m5.options.outdir, filename) 38812475Sglenn.bergmans@arm.com return fdt.writeDtbFile(dtb_filename) 38912475Sglenn.bergmans@arm.com 39012475Sglenn.bergmans@arm.com for sysname in ('system', 'testsys', 'drivesys'): 39112475Sglenn.bergmans@arm.com if hasattr(root, sysname): 39212475Sglenn.bergmans@arm.com sys = getattr(root, sysname) 39312475Sglenn.bergmans@arm.com sys.dtb_filename = create_dtb_for_system(sys, '%s.dtb' % sysname) 39412475Sglenn.bergmans@arm.com 39512475Sglenn.bergmans@arm.comelif buildEnv['TARGET_ISA'] != "arm" and options.generate_dtb: 39612475Sglenn.bergmans@arm.com fatal("Can only generate dtb files for ARM systems.") 39712475Sglenn.bergmans@arm.com 3989061Snilay@cs.wisc.eduSimulation.setWorkCountOptions(test_sys, options) 3993481Shsul@eecs.umich.eduSimulation.run(options, root, test_sys, FutureClass) 400