fs.py revision 8801
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.orgif not buildEnv['FULL_SYSTEM']:
516654Snate@binkert.org    fatal("This script requires full-system mode (*_FS).")
525457Ssaidi@eecs.umich.edu
536654Snate@binkert.orgaddToPath('../common')
546654Snate@binkert.org
552934SN/Afrom FSConfig import *
562549SN/Afrom SysPaths import *
572995SN/Afrom Benchmarks import *
583395Shsul@eecs.umich.eduimport Simulation
596981SLisa.Hsu@amd.comimport CacheConfig
603448Shsul@eecs.umich.edufrom Caches import *
612549SN/A
623444Sktlim@umich.edu# Get paths we might need.  It's expected this file is in m5/configs/example.
633444Sktlim@umich.educonfig_path = os.path.dirname(os.path.abspath(__file__))
643444Sktlim@umich.educonfig_root = os.path.dirname(config_path)
653444Sktlim@umich.edu
662889SN/Aparser = optparse.OptionParser()
672710SN/A
687861Sgblack@eecs.umich.edu# Simulation options
697861Sgblack@eecs.umich.eduparser.add_option("--timesync", action="store_true",
707861Sgblack@eecs.umich.edu        help="Prevent simulated time from getting ahead of real time")
717861Sgblack@eecs.umich.edu
723873Sbinkertn@umich.edu# System options
733873Sbinkertn@umich.eduparser.add_option("--kernel", action="store", type="string")
743873Sbinkertn@umich.eduparser.add_option("--script", action="store", type="string")
758635Schris.emmons@arm.comparser.add_option("--frame-capture", action="store_true",
768635Schris.emmons@arm.com        help="Stores changed frame buffers from the VNC server to compressed "\
778635Schris.emmons@arm.com        "files in the gem5 output directory")
788635Schris.emmons@arm.com
797586SAli.Saidi@arm.comif buildEnv['TARGET_ISA'] == "arm":
807586SAli.Saidi@arm.com    parser.add_option("--bare-metal", action="store_true",
817586SAli.Saidi@arm.com               help="Provide the raw system without the linux specific bits")
827586SAli.Saidi@arm.com    parser.add_option("--machine-type", action="store", type="choice",
837586SAli.Saidi@arm.com            choices=ArmMachineType.map.keys(), default="RealView_PBX")
843322Shsul@eecs.umich.edu# Benchmark options
852995SN/Aparser.add_option("--dual", action="store_true",
862995SN/A                  help="Simulate two systems attached with an ethernet link")
872995SN/Aparser.add_option("-b", "--benchmark", action="store", type="string",
882995SN/A                  dest="benchmark",
892995SN/A                  help="Specify the benchmark to run. Available benchmarks: %s"\
903143Shsul@eecs.umich.edu                  % DefinedBenchmarks)
913322Shsul@eecs.umich.edu
923322Shsul@eecs.umich.edu# Metafile options
933025Ssaidi@eecs.umich.eduparser.add_option("--etherdump", action="store", type="string", dest="etherdump",
943143Shsul@eecs.umich.edu                  help="Specify the filename to dump a pcap capture of the" \
953143Shsul@eecs.umich.edu                  "ethernet traffic")
963322Shsul@eecs.umich.edu
973444Sktlim@umich.eduexecfile(os.path.join(config_root, "common", "Options.py"))
983322Shsul@eecs.umich.edu
992710SN/A(options, args) = parser.parse_args()
1002710SN/A
1012710SN/Aif args:
1022710SN/A    print "Error: script doesn't take any positional arguments"
1032710SN/A    sys.exit(1)
1042710SN/A
1053322Shsul@eecs.umich.edu# driver system CPU is always simple... note this is an assignment of
1063304Sstever@eecs.umich.edu# a class, not an instance.
1073322Shsul@eecs.umich.eduDriveCPUClass = AtomicSimpleCPU
1083322Shsul@eecs.umich.edudrive_mem_mode = 'atomic'
1093304Sstever@eecs.umich.edu
1103481Shsul@eecs.umich.edu# system under test can be any CPU
1113481Shsul@eecs.umich.edu(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options)
1122566SN/A
1133322Shsul@eecs.umich.eduTestCPUClass.clock = '2GHz'
1143322Shsul@eecs.umich.eduDriveCPUClass.clock = '2GHz'
1152995SN/A
1162995SN/Aif options.benchmark:
1173304Sstever@eecs.umich.edu    try:
1183304Sstever@eecs.umich.edu        bm = Benchmarks[options.benchmark]
1193304Sstever@eecs.umich.edu    except KeyError:
1202995SN/A        print "Error benchmark %s has not been defined." % options.benchmark
1212995SN/A        print "Valid benchmarks are: %s" % DefinedBenchmarks
1222995SN/A        sys.exit(1)
1232917SN/Aelse:
1242995SN/A    if options.dual:
1253304Sstever@eecs.umich.edu        bm = [SysConfig(), SysConfig()]
1262995SN/A    else:
1273304Sstever@eecs.umich.edu        bm = [SysConfig()]
1283304Sstever@eecs.umich.edu
1296135Sgblack@eecs.umich.edunp = options.num_cpus
1306135Sgblack@eecs.umich.edu
1316654Snate@binkert.orgif buildEnv['TARGET_ISA'] == "alpha":
1323819Shsul@eecs.umich.edu    test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0])
1336654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "mips":
1345222Sksewell@umich.edu    test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0])
1356654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "sparc":
1363819Shsul@eecs.umich.edu    test_sys = makeSparcSystem(test_mem_mode, bm[0])
1376654Snate@binkert.orgelif buildEnv['TARGET_ISA'] == "x86":
1387925Sgblack@eecs.umich.edu    test_sys = makeLinuxX86System(test_mem_mode, options.num_cpus, bm[0])
1397925Sgblack@eecs.umich.edu    setWorkCountOptions(test_sys, options)
1407586SAli.Saidi@arm.comelif buildEnv['TARGET_ISA'] == "arm":
1418061SAli.Saidi@ARM.com    test_sys = makeArmSystem(test_mem_mode,
1428061SAli.Saidi@ARM.com            options.machine_type, bm[0],
1438061SAli.Saidi@ARM.com            bare_metal=options.bare_metal)
1448354Sgedare@gwmail.gwu.edu    setWorkCountOptions(test_sys, options)
1453819Shsul@eecs.umich.eduelse:
1466654Snate@binkert.org    fatal("incapable of building non-alpha or non-sparc full system!")
1473819Shsul@eecs.umich.edu
1483873Sbinkertn@umich.eduif options.kernel is not None:
1493873Sbinkertn@umich.edu    test_sys.kernel = binary(options.kernel)
1503873Sbinkertn@umich.edu
1513873Sbinkertn@umich.eduif options.script is not None:
1523873Sbinkertn@umich.edu    test_sys.readfile = options.script
1533873Sbinkertn@umich.edu
1548659SAli.Saidi@ARM.comtest_sys.init_param = options.init_param
1558659SAli.Saidi@ARM.com
1566995Sgblack@eecs.umich.edutest_sys.cpu = [TestCPUClass(cpu_id=i) for i in xrange(np)]
1573668Srdreslin@umich.edu
1586995Sgblack@eecs.umich.eduCacheConfig.config_cache(options, test_sys)
1595142Ssaidi@eecs.umich.edu
1608713Sandreas.hansson@arm.comif bm[0]:
1618713Sandreas.hansson@arm.com    mem_size = bm[0].mem()
1628713Sandreas.hansson@arm.comelse:
1638713Sandreas.hansson@arm.com    mem_size = SysConfig().mem()
1646636Ssteve.reinhardt@amd.comif options.caches or options.l2cache:
1657586SAli.Saidi@arm.com    test_sys.iocache = IOCache(addr_range=mem_size)
1665142Ssaidi@eecs.umich.edu    test_sys.iocache.cpu_side = test_sys.iobus.port
1675142Ssaidi@eecs.umich.edu    test_sys.iocache.mem_side = test_sys.membus.port
1688713Sandreas.hansson@arm.comelse:
1698713Sandreas.hansson@arm.com    test_sys.iobridge = Bridge(delay='50ns', nack_delay='4ns',
1708723Sandreas.hansson@arm.com                               ranges = [AddrRange(mem_size)])
1718713Sandreas.hansson@arm.com    test_sys.iobridge.slave = test_sys.iobus.port
1728713Sandreas.hansson@arm.com    test_sys.iobridge.master = test_sys.membus.port
1735142Ssaidi@eecs.umich.edu
1743312Sstever@eecs.umich.edufor i in xrange(np):
1754968Sacolyte@umich.edu    if options.fastmem:
1764968Sacolyte@umich.edu        test_sys.cpu[i].physmem_port = test_sys.physmem.port
1774968Sacolyte@umich.edu
1786654Snate@binkert.orgif buildEnv['TARGET_ISA'] == 'mips':
1795254Sksewell@umich.edu    setMipsOptions(TestCPUClass)
1805222Sksewell@umich.edu
1813005Sstever@eecs.umich.eduif len(bm) == 2:
1826654Snate@binkert.org    if buildEnv['TARGET_ISA'] == 'alpha':
1833819Shsul@eecs.umich.edu        drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1])
1846654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'mips':
1855222Sksewell@umich.edu        drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1])
1866654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'sparc':
1873819Shsul@eecs.umich.edu        drive_sys = makeSparcSystem(drive_mem_mode, bm[1])
1886654Snate@binkert.org    elif buildEnv['TARGET_ISA'] == 'x86':
1896135Sgblack@eecs.umich.edu        drive_sys = makeX86System(drive_mem_mode, np, bm[1])
1907586SAli.Saidi@arm.com    elif buildEnv['TARGET_ISA'] == 'arm':
1918661SAli.Saidi@ARM.com        drive_sys = makeArmSystem(drive_mem_mode, options.machine_type, bm[1])
1928661SAli.Saidi@ARM.com
1933322Shsul@eecs.umich.edu    drive_sys.cpu = DriveCPUClass(cpu_id=0)
1947876Sgblack@eecs.umich.edu    drive_sys.cpu.connectAllPorts(drive_sys.membus)
1954968Sacolyte@umich.edu    if options.fastmem:
1964968Sacolyte@umich.edu        drive_sys.cpu.physmem_port = drive_sys.physmem.port
1974837Ssaidi@eecs.umich.edu    if options.kernel is not None:
1984837Ssaidi@eecs.umich.edu        drive_sys.kernel = binary(options.kernel)
1994837Ssaidi@eecs.umich.edu
2008659SAli.Saidi@ARM.com    drive_sys.init_param = options.init_param
2018801Sgblack@eecs.umich.edu    root = makeDualRoot(True, test_sys, drive_sys, options.etherdump)
2023005Sstever@eecs.umich.eduelif len(bm) == 1:
2038801Sgblack@eecs.umich.edu    root = Root(full_system=True, system=test_sys)
2043005Sstever@eecs.umich.eduelse:
2053005Sstever@eecs.umich.edu    print "Error I don't know how to create more than 2 systems."
2063005Sstever@eecs.umich.edu    sys.exit(1)
2072566SN/A
2087861Sgblack@eecs.umich.eduif options.timesync:
2097861Sgblack@eecs.umich.edu    root.time_sync_enable = True
2107861Sgblack@eecs.umich.edu
2118635Schris.emmons@arm.comif options.frame_capture:
2128635Schris.emmons@arm.com    VncServer.frame_capture = True
2138635Schris.emmons@arm.com
2143481Shsul@eecs.umich.eduSimulation.run(options, root, test_sys, FutureClass)
215