fs.py revision 6995
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
476981SLisa.Hsu@amd.comimport CacheConfig
483448Shsul@eecs.umich.edufrom Caches import *
492549SN/A
503444Sktlim@umich.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
513444Sktlim@umich.educonfig_path = os.path.dirname(os.path.abspath(__file__))
523444Sktlim@umich.educonfig_root = os.path.dirname(config_path)
533444Sktlim@umich.edu
542889SN/Aparser = optparse.OptionParser()
552710SN/A
563873Sbinkertn@umich.edu# System options
573873Sbinkertn@umich.eduparser.add_option("--kernel", action="store", type="string")
583873Sbinkertn@umich.eduparser.add_option("--script", action="store", type="string")
593873Sbinkertn@umich.edu
603322Shsul@eecs.umich.edu# Benchmark options
612995SN/Aparser.add_option("--dual", action="store_true",
622995SN/A                  help="Simulate two systems attached with an ethernet link")
632995SN/Aparser.add_option("-b", "--benchmark", action="store", type="string",
642995SN/A                  dest="benchmark",
652995SN/A                  help="Specify the benchmark to run. Available benchmarks: %s"\
663143Shsul@eecs.umich.edu                  % DefinedBenchmarks)
673322Shsul@eecs.umich.edu
683322Shsul@eecs.umich.edu# Metafile options
693025Ssaidi@eecs.umich.eduparser.add_option("--etherdump", action="store", type="string", dest="etherdump",
703143Shsul@eecs.umich.edu                  help="Specify the filename to dump a pcap capture of the" \
713143Shsul@eecs.umich.edu                  "ethernet traffic")
723322Shsul@eecs.umich.edu
733444Sktlim@umich.eduexecfile(os.path.join(config_root, "common", "Options.py"))
743322Shsul@eecs.umich.edu
752710SN/A(options, args) = parser.parse_args()
762710SN/A
772710SN/Aif args:
782710SN/A    print "Error: script doesn't take any positional arguments"
792710SN/A    sys.exit(1)
802710SN/A
813322Shsul@eecs.umich.edu# driver system CPU is always simple... note this is an assignment of
823304Sstever@eecs.umich.edu# a class, not an instance.
833322Shsul@eecs.umich.eduDriveCPUClass = AtomicSimpleCPU
843322Shsul@eecs.umich.edudrive_mem_mode = 'atomic'
853304Sstever@eecs.umich.edu
863481Shsul@eecs.umich.edu# system under test can be any CPU
873481Shsul@eecs.umich.edu(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
882566SN/A
893322Shsul@eecs.umich.eduTestCPUClass.clock = '2GHz'
903322Shsul@eecs.umich.eduDriveCPUClass.clock = '2GHz'
912995SN/A
922995SN/Aif options.benchmark:
933304Sstever@eecs.umich.edu    try:
943304Sstever@eecs.umich.edu        bm = Benchmarks[options.benchmark]
953304Sstever@eecs.umich.edu    except KeyError:
962995SN/A        print "Error benchmark %s has not been defined." % options.benchmark
972995SN/A        print "Valid benchmarks are: %s" % DefinedBenchmarks
982995SN/A        sys.exit(1)
992917SN/Aelse:
1002995SN/A    if options.dual:
1013304Sstever@eecs.umich.edu        bm = [SysConfig(), SysConfig()]
1022995SN/A    else:
1033304Sstever@eecs.umich.edu        bm = [SysConfig()]
1043304Sstever@eecs.umich.edu
1056135Sgblack@eecs.umich.edunp = options.num_cpus
1066135Sgblack@eecs.umich.edu
1076654Snate@binkert.orgif buildEnv['TARGET_ISA'] == "alpha":
1083819Shsul@eecs.umich.edu    test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0])
1096654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "mips":
1105222Sksewell@umich.edu    test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0])
1116654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "sparc":
1123819Shsul@eecs.umich.edu    test_sys = makeSparcSystem(test_mem_mode, bm[0])
1136654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "x86":
1146135Sgblack@eecs.umich.edu    test_sys = makeLinuxX86System(test_mem_mode, np, bm[0])
1153819Shsul@eecs.umich.eduelse:
1166654Snate@binkert.org    fatal("incapable of building non-alpha or non-sparc full system!")
1173819Shsul@eecs.umich.edu
1183873Sbinkertn@umich.eduif options.kernel is not None:
1193873Sbinkertn@umich.edu    test_sys.kernel = binary(options.kernel)
1203873Sbinkertn@umich.edu
1213873Sbinkertn@umich.eduif options.script is not None:
1223873Sbinkertn@umich.edu    test_sys.readfile = options.script
1233873Sbinkertn@umich.edu
1246995Sgblack@eecs.umich.edutest_sys.cpu = [TestCPUClass(cpu_id=i) for i in xrange(np)]
1253668Srdreslin@umich.edu
1266995Sgblack@eecs.umich.eduCacheConfig.config_cache(options, test_sys)
1275142Ssaidi@eecs.umich.edu
1286636Ssteve.reinhardt@amd.comif options.caches or options.l2cache:
1295142Ssaidi@eecs.umich.edu    test_sys.bridge.filter_ranges_a=[AddrRange(0, Addr.max)]
1305142Ssaidi@eecs.umich.edu    test_sys.bridge.filter_ranges_b=[AddrRange(0, size='8GB')]
1316122SSteve.Reinhardt@amd.com    test_sys.iocache = IOCache(addr_range=AddrRange(0, size='8GB'))
1325142Ssaidi@eecs.umich.edu    test_sys.iocache.cpu_side = test_sys.iobus.port
1335142Ssaidi@eecs.umich.edu    test_sys.iocache.mem_side = test_sys.membus.port
1345142Ssaidi@eecs.umich.edu
1353312Sstever@eecs.umich.edufor i in xrange(np):
1364968Sacolyte@umich.edu    if options.fastmem:
1374968Sacolyte@umich.edu        test_sys.cpu[i].physmem_port = test_sys.physmem.port
1384968Sacolyte@umich.edu
1396654Snate@binkert.orgif buildEnv['TARGET_ISA'] == 'mips':
1405254Sksewell@umich.edu    setMipsOptions(TestCPUClass)
1415222Sksewell@umich.edu
1423005Sstever@eecs.umich.eduif len(bm) == 2:
1436654Snate@binkert.org    if buildEnv['TARGET_ISA'] == 'alpha':
1443819Shsul@eecs.umich.edu        drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1])
1456654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'mips':
1465222Sksewell@umich.edu        drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1])
1476654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'sparc':
1483819Shsul@eecs.umich.edu        drive_sys = makeSparcSystem(drive_mem_mode, bm[1])
1496654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'x86':
1506135Sgblack@eecs.umich.edu        drive_sys = makeX86System(drive_mem_mode, np, bm[1])
1513322Shsul@eecs.umich.edu    drive_sys.cpu = DriveCPUClass(cpu_id=0)
1523322Shsul@eecs.umich.edu    drive_sys.cpu.connectMemPorts(drive_sys.membus)
1534968Sacolyte@umich.edu    if options.fastmem:
1544968Sacolyte@umich.edu        drive_sys.cpu.physmem_port = drive_sys.physmem.port
1554837Ssaidi@eecs.umich.edu    if options.kernel is not None:
1564837Ssaidi@eecs.umich.edu        drive_sys.kernel = binary(options.kernel)
1574837Ssaidi@eecs.umich.edu
1583322Shsul@eecs.umich.edu    root = makeDualRoot(test_sys, drive_sys, options.etherdump)
1593005Sstever@eecs.umich.eduelif len(bm) == 1:
1604167Sbinkertn@umich.edu    root = Root(system=test_sys)
1613005Sstever@eecs.umich.eduelse:
1623005Sstever@eecs.umich.edu    print "Error I don't know how to create more than 2 systems."
1633005Sstever@eecs.umich.edu    sys.exit(1)
1642566SN/A
1653481Shsul@eecs.umich.eduSimulation.run(options, root, test_sys, FutureClass)
166