fs.py revision 6654
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 296654Snate@binkert.orgimport optparse 306654Snate@binkert.orgimport os 316654Snate@binkert.orgimport sys 322889SN/A 332710SN/Aimport m5 346654Snate@binkert.orgfrom m5.defines import buildEnv 356654Snate@binkert.orgfrom m5.objects import * 366654Snate@binkert.orgfrom m5.util import addToPath, fatal 375457Ssaidi@eecs.umich.edu 386654Snate@binkert.orgif not buildEnv['FULL_SYSTEM']: 396654Snate@binkert.org fatal("This script requires full-system mode (*_FS).") 405457Ssaidi@eecs.umich.edu 416654Snate@binkert.orgaddToPath('../common') 426654Snate@binkert.org 432934SN/Afrom FSConfig import * 442549SN/Afrom SysPaths import * 452995SN/Afrom Benchmarks import * 463395Shsul@eecs.umich.eduimport Simulation 473448Shsul@eecs.umich.edufrom Caches import * 482549SN/A 493444Sktlim@umich.edu# Get paths we might need. It's expected this file is in m5/configs/example. 503444Sktlim@umich.educonfig_path = os.path.dirname(os.path.abspath(__file__)) 513444Sktlim@umich.educonfig_root = os.path.dirname(config_path) 523444Sktlim@umich.edu 532889SN/Aparser = optparse.OptionParser() 542710SN/A 553873Sbinkertn@umich.edu# System options 563873Sbinkertn@umich.eduparser.add_option("--kernel", action="store", type="string") 573873Sbinkertn@umich.eduparser.add_option("--script", action="store", type="string") 583873Sbinkertn@umich.edu 593322Shsul@eecs.umich.edu# Benchmark options 602995SN/Aparser.add_option("--dual", action="store_true", 612995SN/A help="Simulate two systems attached with an ethernet link") 622995SN/Aparser.add_option("-b", "--benchmark", action="store", type="string", 632995SN/A dest="benchmark", 642995SN/A help="Specify the benchmark to run. Available benchmarks: %s"\ 653143Shsul@eecs.umich.edu % DefinedBenchmarks) 663322Shsul@eecs.umich.edu 673322Shsul@eecs.umich.edu# Metafile options 683025Ssaidi@eecs.umich.eduparser.add_option("--etherdump", action="store", type="string", dest="etherdump", 693143Shsul@eecs.umich.edu help="Specify the filename to dump a pcap capture of the" \ 703143Shsul@eecs.umich.edu "ethernet traffic") 713322Shsul@eecs.umich.edu 723444Sktlim@umich.eduexecfile(os.path.join(config_root, "common", "Options.py")) 733322Shsul@eecs.umich.edu 742710SN/A(options, args) = parser.parse_args() 752710SN/A 762710SN/Aif args: 772710SN/A print "Error: script doesn't take any positional arguments" 782710SN/A sys.exit(1) 792710SN/A 803322Shsul@eecs.umich.edu# driver system CPU is always simple... note this is an assignment of 813304Sstever@eecs.umich.edu# a class, not an instance. 823322Shsul@eecs.umich.eduDriveCPUClass = AtomicSimpleCPU 833322Shsul@eecs.umich.edudrive_mem_mode = 'atomic' 843304Sstever@eecs.umich.edu 853481Shsul@eecs.umich.edu# system under test can be any CPU 863481Shsul@eecs.umich.edu(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options) 872566SN/A 883322Shsul@eecs.umich.eduTestCPUClass.clock = '2GHz' 893322Shsul@eecs.umich.eduDriveCPUClass.clock = '2GHz' 902995SN/A 912995SN/Aif options.benchmark: 923304Sstever@eecs.umich.edu try: 933304Sstever@eecs.umich.edu bm = Benchmarks[options.benchmark] 943304Sstever@eecs.umich.edu except KeyError: 952995SN/A print "Error benchmark %s has not been defined." % options.benchmark 962995SN/A print "Valid benchmarks are: %s" % DefinedBenchmarks 972995SN/A sys.exit(1) 982917SN/Aelse: 992995SN/A if options.dual: 1003304Sstever@eecs.umich.edu bm = [SysConfig(), SysConfig()] 1012995SN/A else: 1023304Sstever@eecs.umich.edu bm = [SysConfig()] 1033304Sstever@eecs.umich.edu 1046135Sgblack@eecs.umich.edunp = options.num_cpus 1056135Sgblack@eecs.umich.edu 1066654Snate@binkert.orgif buildEnv['TARGET_ISA'] == "alpha": 1073819Shsul@eecs.umich.edu test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0]) 1086654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "mips": 1095222Sksewell@umich.edu test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0]) 1106654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "sparc": 1113819Shsul@eecs.umich.edu test_sys = makeSparcSystem(test_mem_mode, bm[0]) 1126654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "x86": 1136135Sgblack@eecs.umich.edu test_sys = makeLinuxX86System(test_mem_mode, np, bm[0]) 1143819Shsul@eecs.umich.eduelse: 1156654Snate@binkert.org fatal("incapable of building non-alpha or non-sparc full system!") 1163819Shsul@eecs.umich.edu 1173873Sbinkertn@umich.eduif options.kernel is not None: 1183873Sbinkertn@umich.edu test_sys.kernel = binary(options.kernel) 1193873Sbinkertn@umich.edu 1203873Sbinkertn@umich.eduif options.script is not None: 1213873Sbinkertn@umich.edu test_sys.readfile = options.script 1223873Sbinkertn@umich.edu 1233668Srdreslin@umich.eduif options.l2cache: 1243668Srdreslin@umich.edu test_sys.l2 = L2Cache(size = '2MB') 1253668Srdreslin@umich.edu test_sys.tol2bus = Bus() 1263668Srdreslin@umich.edu test_sys.l2.cpu_side = test_sys.tol2bus.port 1273668Srdreslin@umich.edu test_sys.l2.mem_side = test_sys.membus.port 1283668Srdreslin@umich.edu 1293322Shsul@eecs.umich.edutest_sys.cpu = [TestCPUClass(cpu_id=i) for i in xrange(np)] 1305142Ssaidi@eecs.umich.edu 1316636Ssteve.reinhardt@amd.comif options.caches or options.l2cache: 1325142Ssaidi@eecs.umich.edu test_sys.bridge.filter_ranges_a=[AddrRange(0, Addr.max)] 1335142Ssaidi@eecs.umich.edu test_sys.bridge.filter_ranges_b=[AddrRange(0, size='8GB')] 1346122SSteve.Reinhardt@amd.com test_sys.iocache = IOCache(addr_range=AddrRange(0, size='8GB')) 1355142Ssaidi@eecs.umich.edu test_sys.iocache.cpu_side = test_sys.iobus.port 1365142Ssaidi@eecs.umich.edu test_sys.iocache.mem_side = test_sys.membus.port 1375142Ssaidi@eecs.umich.edu 1383312Sstever@eecs.umich.edufor i in xrange(np): 1393514Sktlim@umich.edu if options.caches: 1403395Shsul@eecs.umich.edu test_sys.cpu[i].addPrivateSplitL1Caches(L1Cache(size = '32kB'), 1413448Shsul@eecs.umich.edu L1Cache(size = '64kB')) 1423668Srdreslin@umich.edu if options.l2cache: 1433668Srdreslin@umich.edu test_sys.cpu[i].connectMemPorts(test_sys.tol2bus) 1443668Srdreslin@umich.edu else: 1453668Srdreslin@umich.edu test_sys.cpu[i].connectMemPorts(test_sys.membus) 1463005Sstever@eecs.umich.edu 1474968Sacolyte@umich.edu if options.fastmem: 1484968Sacolyte@umich.edu test_sys.cpu[i].physmem_port = test_sys.physmem.port 1494968Sacolyte@umich.edu 1506654Snate@binkert.orgif buildEnv['TARGET_ISA'] == 'mips': 1515254Sksewell@umich.edu setMipsOptions(TestCPUClass) 1525222Sksewell@umich.edu 1533005Sstever@eecs.umich.eduif len(bm) == 2: 1546654Snate@binkert.org if buildEnv['TARGET_ISA'] == 'alpha': 1553819Shsul@eecs.umich.edu drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1]) 1566654Snate@binkert.org elif buildEnv['TARGET_ISA'] == 'mips': 1575222Sksewell@umich.edu drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1]) 1586654Snate@binkert.org elif buildEnv['TARGET_ISA'] == 'sparc': 1593819Shsul@eecs.umich.edu drive_sys = makeSparcSystem(drive_mem_mode, bm[1]) 1606654Snate@binkert.org elif buildEnv['TARGET_ISA'] == 'x86': 1616135Sgblack@eecs.umich.edu drive_sys = makeX86System(drive_mem_mode, np, bm[1]) 1623322Shsul@eecs.umich.edu drive_sys.cpu = DriveCPUClass(cpu_id=0) 1633322Shsul@eecs.umich.edu drive_sys.cpu.connectMemPorts(drive_sys.membus) 1644968Sacolyte@umich.edu if options.fastmem: 1654968Sacolyte@umich.edu drive_sys.cpu.physmem_port = drive_sys.physmem.port 1664837Ssaidi@eecs.umich.edu if options.kernel is not None: 1674837Ssaidi@eecs.umich.edu drive_sys.kernel = binary(options.kernel) 1684837Ssaidi@eecs.umich.edu 1693322Shsul@eecs.umich.edu root = makeDualRoot(test_sys, drive_sys, options.etherdump) 1703005Sstever@eecs.umich.eduelif len(bm) == 1: 1714167Sbinkertn@umich.edu root = Root(system=test_sys) 1723005Sstever@eecs.umich.eduelse: 1733005Sstever@eecs.umich.edu print "Error I don't know how to create more than 2 systems." 1743005Sstever@eecs.umich.edu sys.exit(1) 1752566SN/A 1763481Shsul@eecs.umich.eduSimulation.run(options, root, test_sys, FutureClass) 177