fs.py revision 6135
13970Sgblack@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan 23005Sstever@eecs.umich.edu# All rights reserved. 33005Sstever@eecs.umich.edu# 43005Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 53005Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are 63005Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright 73005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 83005Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 93005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 103005Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution; 113005Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its 123005Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from 133005Sstever@eecs.umich.edu# this software without specific prior written permission. 143005Sstever@eecs.umich.edu# 153005Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 163005Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 173005Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 183005Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 193005Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 203005Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 213005Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 223005Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 233005Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 243005Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 253005Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 263005Sstever@eecs.umich.edu# 273005Sstever@eecs.umich.edu# Authors: Ali Saidi 283005Sstever@eecs.umich.edu 292889SN/Aimport optparse, os, sys 302889SN/A 312710SN/Aimport m5 325457Ssaidi@eecs.umich.edu 335457Ssaidi@eecs.umich.eduif not m5.build_env['FULL_SYSTEM']: 345822Ssaidi@eecs.umich.edu m5.fatal("This script requires full-system mode (*_FS).") 355457Ssaidi@eecs.umich.edu 362710SN/Afrom m5.objects import * 372934SN/Am5.AddToPath('../common') 382934SN/Afrom FSConfig import * 392549SN/Afrom SysPaths import * 402995SN/Afrom Benchmarks import * 413395Shsul@eecs.umich.eduimport Simulation 423448Shsul@eecs.umich.edufrom Caches import * 432549SN/A 443444Sktlim@umich.edu# Get paths we might need. It's expected this file is in m5/configs/example. 453444Sktlim@umich.educonfig_path = os.path.dirname(os.path.abspath(__file__)) 463444Sktlim@umich.educonfig_root = os.path.dirname(config_path) 473444Sktlim@umich.edu 482889SN/Aparser = optparse.OptionParser() 492710SN/A 503873Sbinkertn@umich.edu# System options 513873Sbinkertn@umich.eduparser.add_option("--kernel", action="store", type="string") 523873Sbinkertn@umich.eduparser.add_option("--script", action="store", type="string") 533873Sbinkertn@umich.edu 543322Shsul@eecs.umich.edu# Benchmark options 552995SN/Aparser.add_option("--dual", action="store_true", 562995SN/A help="Simulate two systems attached with an ethernet link") 572995SN/Aparser.add_option("-b", "--benchmark", action="store", type="string", 582995SN/A dest="benchmark", 592995SN/A help="Specify the benchmark to run. Available benchmarks: %s"\ 603143Shsul@eecs.umich.edu % DefinedBenchmarks) 613322Shsul@eecs.umich.edu 623322Shsul@eecs.umich.edu# Metafile options 633025Ssaidi@eecs.umich.eduparser.add_option("--etherdump", action="store", type="string", dest="etherdump", 643143Shsul@eecs.umich.edu help="Specify the filename to dump a pcap capture of the" \ 653143Shsul@eecs.umich.edu "ethernet traffic") 663322Shsul@eecs.umich.edu 673444Sktlim@umich.eduexecfile(os.path.join(config_root, "common", "Options.py")) 683322Shsul@eecs.umich.edu 692710SN/A(options, args) = parser.parse_args() 702710SN/A 712710SN/Aif args: 722710SN/A print "Error: script doesn't take any positional arguments" 732710SN/A sys.exit(1) 742710SN/A 753322Shsul@eecs.umich.edu# driver system CPU is always simple... note this is an assignment of 763304Sstever@eecs.umich.edu# a class, not an instance. 773322Shsul@eecs.umich.eduDriveCPUClass = AtomicSimpleCPU 783322Shsul@eecs.umich.edudrive_mem_mode = 'atomic' 793304Sstever@eecs.umich.edu 803481Shsul@eecs.umich.edu# system under test can be any CPU 813481Shsul@eecs.umich.edu(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options) 822566SN/A 833322Shsul@eecs.umich.eduTestCPUClass.clock = '2GHz' 843322Shsul@eecs.umich.eduDriveCPUClass.clock = '2GHz' 852995SN/A 862995SN/Aif options.benchmark: 873304Sstever@eecs.umich.edu try: 883304Sstever@eecs.umich.edu bm = Benchmarks[options.benchmark] 893304Sstever@eecs.umich.edu except KeyError: 902995SN/A print "Error benchmark %s has not been defined." % options.benchmark 912995SN/A print "Valid benchmarks are: %s" % DefinedBenchmarks 922995SN/A sys.exit(1) 932917SN/Aelse: 942995SN/A if options.dual: 953304Sstever@eecs.umich.edu bm = [SysConfig(), SysConfig()] 962995SN/A else: 973304Sstever@eecs.umich.edu bm = [SysConfig()] 983304Sstever@eecs.umich.edu 996135Sgblack@eecs.umich.edunp = options.num_cpus 1006135Sgblack@eecs.umich.edu 1013819Shsul@eecs.umich.eduif m5.build_env['TARGET_ISA'] == "alpha": 1023819Shsul@eecs.umich.edu test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0]) 1035222Sksewell@umich.eduelif m5.build_env['TARGET_ISA'] == "mips": 1045222Sksewell@umich.edu test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0]) 1053819Shsul@eecs.umich.eduelif m5.build_env['TARGET_ISA'] == "sparc": 1063819Shsul@eecs.umich.edu test_sys = makeSparcSystem(test_mem_mode, bm[0]) 1075133Sgblack@eecs.umich.eduelif m5.build_env['TARGET_ISA'] == "x86": 1086135Sgblack@eecs.umich.edu test_sys = makeLinuxX86System(test_mem_mode, np, bm[0]) 1093819Shsul@eecs.umich.eduelse: 1105822Ssaidi@eecs.umich.edu m5.fatal("incapable of building non-alpha or non-sparc full system!") 1113819Shsul@eecs.umich.edu 1123873Sbinkertn@umich.eduif options.kernel is not None: 1133873Sbinkertn@umich.edu test_sys.kernel = binary(options.kernel) 1143873Sbinkertn@umich.edu 1153873Sbinkertn@umich.eduif options.script is not None: 1163873Sbinkertn@umich.edu test_sys.readfile = options.script 1173873Sbinkertn@umich.edu 1183668Srdreslin@umich.eduif options.l2cache: 1193668Srdreslin@umich.edu test_sys.l2 = L2Cache(size = '2MB') 1203668Srdreslin@umich.edu test_sys.tol2bus = Bus() 1213668Srdreslin@umich.edu test_sys.l2.cpu_side = test_sys.tol2bus.port 1223668Srdreslin@umich.edu test_sys.l2.mem_side = test_sys.membus.port 1233668Srdreslin@umich.edu 1243322Shsul@eecs.umich.edutest_sys.cpu = [TestCPUClass(cpu_id=i) for i in xrange(np)] 1255142Ssaidi@eecs.umich.edu 1265142Ssaidi@eecs.umich.eduif options.caches: 1275142Ssaidi@eecs.umich.edu test_sys.bridge.filter_ranges_a=[AddrRange(0, Addr.max)] 1285142Ssaidi@eecs.umich.edu test_sys.bridge.filter_ranges_b=[AddrRange(0, size='8GB')] 1296122SSteve.Reinhardt@amd.com test_sys.iocache = IOCache(addr_range=AddrRange(0, size='8GB')) 1305142Ssaidi@eecs.umich.edu test_sys.iocache.cpu_side = test_sys.iobus.port 1315142Ssaidi@eecs.umich.edu test_sys.iocache.mem_side = test_sys.membus.port 1325142Ssaidi@eecs.umich.edu 1333312Sstever@eecs.umich.edufor i in xrange(np): 1343514Sktlim@umich.edu if options.caches: 1353395Shsul@eecs.umich.edu test_sys.cpu[i].addPrivateSplitL1Caches(L1Cache(size = '32kB'), 1363448Shsul@eecs.umich.edu L1Cache(size = '64kB')) 1373668Srdreslin@umich.edu if options.l2cache: 1383668Srdreslin@umich.edu test_sys.cpu[i].connectMemPorts(test_sys.tol2bus) 1393668Srdreslin@umich.edu else: 1403668Srdreslin@umich.edu test_sys.cpu[i].connectMemPorts(test_sys.membus) 1413005Sstever@eecs.umich.edu 1424968Sacolyte@umich.edu if options.fastmem: 1434968Sacolyte@umich.edu test_sys.cpu[i].physmem_port = test_sys.physmem.port 1444968Sacolyte@umich.edu 1455222Sksewell@umich.eduif m5.build_env['TARGET_ISA'] == 'mips': 1465254Sksewell@umich.edu setMipsOptions(TestCPUClass) 1475222Sksewell@umich.edu 1483005Sstever@eecs.umich.eduif len(bm) == 2: 1493819Shsul@eecs.umich.edu if m5.build_env['TARGET_ISA'] == 'alpha': 1503819Shsul@eecs.umich.edu drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1]) 1515222Sksewell@umich.edu elif m5.build_env['TARGET_ISA'] == 'mips': 1525222Sksewell@umich.edu drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1]) 1533819Shsul@eecs.umich.edu elif m5.build_env['TARGET_ISA'] == 'sparc': 1543819Shsul@eecs.umich.edu drive_sys = makeSparcSystem(drive_mem_mode, bm[1]) 1555133Sgblack@eecs.umich.edu elif m5.build.env['TARGET_ISA'] == 'x86': 1566135Sgblack@eecs.umich.edu drive_sys = makeX86System(drive_mem_mode, np, bm[1]) 1573322Shsul@eecs.umich.edu drive_sys.cpu = DriveCPUClass(cpu_id=0) 1583322Shsul@eecs.umich.edu drive_sys.cpu.connectMemPorts(drive_sys.membus) 1594968Sacolyte@umich.edu if options.fastmem: 1604968Sacolyte@umich.edu drive_sys.cpu.physmem_port = drive_sys.physmem.port 1614837Ssaidi@eecs.umich.edu if options.kernel is not None: 1624837Ssaidi@eecs.umich.edu drive_sys.kernel = binary(options.kernel) 1634837Ssaidi@eecs.umich.edu 1643322Shsul@eecs.umich.edu root = makeDualRoot(test_sys, drive_sys, options.etherdump) 1653005Sstever@eecs.umich.eduelif len(bm) == 1: 1664167Sbinkertn@umich.edu root = Root(system=test_sys) 1673005Sstever@eecs.umich.eduelse: 1683005Sstever@eecs.umich.edu print "Error I don't know how to create more than 2 systems." 1693005Sstever@eecs.umich.edu sys.exit(1) 1702566SN/A 1713481Shsul@eecs.umich.eduSimulation.run(options, root, test_sys, FutureClass) 172