fs.py revision 8863
18713Sandreas.hansson@arm.com# Copyright (c) 2010-2011 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#
133970Sgblack@eecs.umich.edu# Copyright (c) 2006-2007 The Regents of The University of Michigan
143005Sstever@eecs.umich.edu# All rights reserved.
153005Sstever@eecs.umich.edu#
163005Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without
173005Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are
183005Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright
193005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer;
203005Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright
213005Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the
223005Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution;
233005Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its
243005Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from
253005Sstever@eecs.umich.edu# this software without specific prior written permission.
263005Sstever@eecs.umich.edu#
273005Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
283005Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
293005Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
303005Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
313005Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
323005Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
333005Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
343005Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
353005Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
363005Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
373005Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
383005Sstever@eecs.umich.edu#
393005Sstever@eecs.umich.edu# Authors: Ali Saidi
403005Sstever@eecs.umich.edu
416654Snate@binkert.orgimport optparse
426654Snate@binkert.orgimport os
436654Snate@binkert.orgimport sys
442889SN/A
452710SN/Aimport m5
466654Snate@binkert.orgfrom m5.defines import buildEnv
476654Snate@binkert.orgfrom m5.objects import *
486654Snate@binkert.orgfrom m5.util import addToPath, fatal
495457Ssaidi@eecs.umich.edu
506654Snate@binkert.orgaddToPath('../common')
516654Snate@binkert.org
522934SN/Afrom FSConfig import *
532549SN/Afrom SysPaths import *
542995SN/Afrom Benchmarks import *
553395Shsul@eecs.umich.eduimport Simulation
566981SLisa.Hsu@amd.comimport CacheConfig
573448Shsul@eecs.umich.edufrom Caches import *
582549SN/A
593444Sktlim@umich.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
603444Sktlim@umich.educonfig_path = os.path.dirname(os.path.abspath(__file__))
613444Sktlim@umich.educonfig_root = os.path.dirname(config_path)
623444Sktlim@umich.edu
632889SN/Aparser = optparse.OptionParser()
642710SN/A
657861Sgblack@eecs.umich.edu# Simulation options
667861Sgblack@eecs.umich.eduparser.add_option("--timesync", action="store_true",
677861Sgblack@eecs.umich.edu        help="Prevent simulated time from getting ahead of real time")
687861Sgblack@eecs.umich.edu
693873Sbinkertn@umich.edu# System options
703873Sbinkertn@umich.eduparser.add_option("--kernel", action="store", type="string")
713873Sbinkertn@umich.eduparser.add_option("--script", action="store", type="string")
728635Schris.emmons@arm.comparser.add_option("--frame-capture", action="store_true",
738635Schris.emmons@arm.com        help="Stores changed frame buffers from the VNC server to compressed "\
748635Schris.emmons@arm.com        "files in the gem5 output directory")
758635Schris.emmons@arm.com
767586SAli.Saidi@arm.comif buildEnv['TARGET_ISA'] == "arm":
777586SAli.Saidi@arm.com    parser.add_option("--bare-metal", action="store_true",
787586SAli.Saidi@arm.com               help="Provide the raw system without the linux specific bits")
797586SAli.Saidi@arm.com    parser.add_option("--machine-type", action="store", type="choice",
807586SAli.Saidi@arm.com            choices=ArmMachineType.map.keys(), default="RealView_PBX")
813322Shsul@eecs.umich.edu# Benchmark options
822995SN/Aparser.add_option("--dual", action="store_true",
832995SN/A                  help="Simulate two systems attached with an ethernet link")
842995SN/Aparser.add_option("-b", "--benchmark", action="store", type="string",
852995SN/A                  dest="benchmark",
862995SN/A                  help="Specify the benchmark to run. Available benchmarks: %s"\
873143Shsul@eecs.umich.edu                  % DefinedBenchmarks)
883322Shsul@eecs.umich.edu
893322Shsul@eecs.umich.edu# Metafile options
903025Ssaidi@eecs.umich.eduparser.add_option("--etherdump", action="store", type="string", dest="etherdump",
913143Shsul@eecs.umich.edu                  help="Specify the filename to dump a pcap capture of the" \
923143Shsul@eecs.umich.edu                  "ethernet traffic")
933322Shsul@eecs.umich.edu
943444Sktlim@umich.eduexecfile(os.path.join(config_root, "common", "Options.py"))
953322Shsul@eecs.umich.edu
962710SN/A(options, args) = parser.parse_args()
972710SN/A
982710SN/Aif args:
992710SN/A    print "Error: script doesn't take any positional arguments"
1002710SN/A    sys.exit(1)
1012710SN/A
1023322Shsul@eecs.umich.edu# driver system CPU is always simple... note this is an assignment of
1033304Sstever@eecs.umich.edu# a class, not an instance.
1043322Shsul@eecs.umich.eduDriveCPUClass = AtomicSimpleCPU
1053322Shsul@eecs.umich.edudrive_mem_mode = 'atomic'
1063304Sstever@eecs.umich.edu
1073481Shsul@eecs.umich.edu# system under test can be any CPU
1083481Shsul@eecs.umich.edu(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
1092566SN/A
1103322Shsul@eecs.umich.eduTestCPUClass.clock = '2GHz'
1113322Shsul@eecs.umich.eduDriveCPUClass.clock = '2GHz'
1122995SN/A
1132995SN/Aif options.benchmark:
1143304Sstever@eecs.umich.edu    try:
1153304Sstever@eecs.umich.edu        bm = Benchmarks[options.benchmark]
1163304Sstever@eecs.umich.edu    except KeyError:
1172995SN/A        print "Error benchmark %s has not been defined." % options.benchmark
1182995SN/A        print "Valid benchmarks are: %s" % DefinedBenchmarks
1192995SN/A        sys.exit(1)
1202917SN/Aelse:
1212995SN/A    if options.dual:
1223304Sstever@eecs.umich.edu        bm = [SysConfig(), SysConfig()]
1232995SN/A    else:
1243304Sstever@eecs.umich.edu        bm = [SysConfig()]
1253304Sstever@eecs.umich.edu
1266135Sgblack@eecs.umich.edunp = options.num_cpus
1276135Sgblack@eecs.umich.edu
1286654Snate@binkert.orgif buildEnv['TARGET_ISA'] == "alpha":
1293819Shsul@eecs.umich.edu    test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0])
1306654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "mips":
1315222Sksewell@umich.edu    test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0])
1326654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "sparc":
1333819Shsul@eecs.umich.edu    test_sys = makeSparcSystem(test_mem_mode, bm[0])
1346654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "x86":
1357925Sgblack@eecs.umich.edu    test_sys = makeLinuxX86System(test_mem_mode, options.num_cpus, bm[0])
1367925Sgblack@eecs.umich.edu    setWorkCountOptions(test_sys, options)
1377586SAli.Saidi@arm.comelif buildEnv['TARGET_ISA'] == "arm":
1388061SAli.Saidi@ARM.com    test_sys = makeArmSystem(test_mem_mode,
1398061SAli.Saidi@ARM.com            options.machine_type, bm[0],
1408061SAli.Saidi@ARM.com            bare_metal=options.bare_metal)
1418354Sgedare@gwmail.gwu.edu    setWorkCountOptions(test_sys, options)
1423819Shsul@eecs.umich.eduelse:
1436654Snate@binkert.org    fatal("incapable of building non-alpha or non-sparc full system!")
1443819Shsul@eecs.umich.edu
1453873Sbinkertn@umich.eduif options.kernel is not None:
1463873Sbinkertn@umich.edu    test_sys.kernel = binary(options.kernel)
1473873Sbinkertn@umich.edu
1483873Sbinkertn@umich.eduif options.script is not None:
1493873Sbinkertn@umich.edu    test_sys.readfile = options.script
1503873Sbinkertn@umich.edu
1518659SAli.Saidi@ARM.comtest_sys.init_param = options.init_param
1528659SAli.Saidi@ARM.com
1536995Sgblack@eecs.umich.edutest_sys.cpu = [TestCPUClass(cpu_id=i) for i in xrange(np)]
1543668Srdreslin@umich.edu
1556995Sgblack@eecs.umich.eduCacheConfig.config_cache(options, test_sys)
1565142Ssaidi@eecs.umich.edu
1578713Sandreas.hansson@arm.comif bm[0]:
1588713Sandreas.hansson@arm.com    mem_size = bm[0].mem()
1598713Sandreas.hansson@arm.comelse:
1608713Sandreas.hansson@arm.com    mem_size = SysConfig().mem()
1616636Ssteve.reinhardt@amd.comif options.caches or options.l2cache:
1627586SAli.Saidi@arm.com    test_sys.iocache = IOCache(addr_range=mem_size)
1638839Sandreas.hansson@arm.com    test_sys.iocache.cpu_side = test_sys.iobus.master
1648839Sandreas.hansson@arm.com    test_sys.iocache.mem_side = test_sys.membus.slave
1658713Sandreas.hansson@arm.comelse:
1668713Sandreas.hansson@arm.com    test_sys.iobridge = Bridge(delay='50ns', nack_delay='4ns',
1678723Sandreas.hansson@arm.com                               ranges = [AddrRange(mem_size)])
1688839Sandreas.hansson@arm.com    test_sys.iobridge.slave = test_sys.iobus.master
1698839Sandreas.hansson@arm.com    test_sys.iobridge.master = test_sys.membus.slave
1705142Ssaidi@eecs.umich.edu
1713312Sstever@eecs.umich.edufor i in xrange(np):
1724968Sacolyte@umich.edu    if options.fastmem:
1734968Sacolyte@umich.edu        test_sys.cpu[i].physmem_port = test_sys.physmem.port
1744968Sacolyte@umich.edu
1756654Snate@binkert.orgif buildEnv['TARGET_ISA'] == 'mips':
1765254Sksewell@umich.edu    setMipsOptions(TestCPUClass)
1775222Sksewell@umich.edu
1783005Sstever@eecs.umich.eduif len(bm) == 2:
1796654Snate@binkert.org    if buildEnv['TARGET_ISA'] == 'alpha':
1803819Shsul@eecs.umich.edu        drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1])
1816654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'mips':
1825222Sksewell@umich.edu        drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1])
1836654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'sparc':
1843819Shsul@eecs.umich.edu        drive_sys = makeSparcSystem(drive_mem_mode, bm[1])
1856654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'x86':
1866135Sgblack@eecs.umich.edu        drive_sys = makeX86System(drive_mem_mode, np, bm[1])
1877586SAli.Saidi@arm.com    elif buildEnv['TARGET_ISA'] == 'arm':
1888661SAli.Saidi@ARM.com        drive_sys = makeArmSystem(drive_mem_mode, options.machine_type, bm[1])
1898661SAli.Saidi@ARM.com
1903322Shsul@eecs.umich.edu    drive_sys.cpu = DriveCPUClass(cpu_id=0)
1918863Snilay@cs.wisc.edu    drive_sys.cpu.createInterruptController()
1927876Sgblack@eecs.umich.edu    drive_sys.cpu.connectAllPorts(drive_sys.membus)
1934968Sacolyte@umich.edu    if options.fastmem:
1944968Sacolyte@umich.edu        drive_sys.cpu.physmem_port = drive_sys.physmem.port
1954837Ssaidi@eecs.umich.edu    if options.kernel is not None:
1964837Ssaidi@eecs.umich.edu        drive_sys.kernel = binary(options.kernel)
1978810SAli.Saidi@ARM.com    drive_sys.iobridge = Bridge(delay='50ns', nack_delay='4ns',
1988810SAli.Saidi@ARM.com                               ranges = [AddrRange(bm[1].mem())])
1998845Sandreas.hansson@arm.com    drive_sys.iobridge.slave = drive_sys.iobus.master
2008845Sandreas.hansson@arm.com    drive_sys.iobridge.master = drive_sys.membus.slave
2014837Ssaidi@eecs.umich.edu
2028659SAli.Saidi@ARM.com    drive_sys.init_param = options.init_param
2038801Sgblack@eecs.umich.edu    root = makeDualRoot(True, test_sys, drive_sys, options.etherdump)
2043005Sstever@eecs.umich.eduelif len(bm) == 1:
2058801Sgblack@eecs.umich.edu    root = Root(full_system=True, system=test_sys)
2063005Sstever@eecs.umich.eduelse:
2073005Sstever@eecs.umich.edu    print "Error I don't know how to create more than 2 systems."
2083005Sstever@eecs.umich.edu    sys.exit(1)
2092566SN/A
2107861Sgblack@eecs.umich.eduif options.timesync:
2117861Sgblack@eecs.umich.edu    root.time_sync_enable = True
2127861Sgblack@eecs.umich.edu
2138635Schris.emmons@arm.comif options.frame_capture:
2148635Schris.emmons@arm.com    VncServer.frame_capture = True
2158635Schris.emmons@arm.com
2163481Shsul@eecs.umich.eduSimulation.run(options, root, test_sys, FutureClass)
217