1 # Copyright (c) 2010-2013 ARM Limited
4 # The license below extends only to copyright in the software and shall
5 # not be construed as granting a license to any other intellectual
6 # property including but not limited to intellectual property relating
7 # to a hardware implementation of the functionality of the software
8 # licensed hereunder. You may use the software subject to the license
9 # terms below provided that you ensure that this notice is replicated
10 # unmodified and in its entirety in all distributions of the software,
11 # modified or unmodified, in source code or in binary form.
13 # Copyright (c) 2006-2007 The Regents of The University of Michigan
14 # All rights reserved.
16 # Redistribution and use in source and binary forms, with or without
17 # modification, are permitted provided that the following conditions are
18 # met: redistributions of source code must retain the above copyright
19 # notice, this list of conditions and the following disclaimer;
20 # redistributions in binary form must reproduce the above copyright
21 # notice, this list of conditions and the following disclaimer in the
22 # documentation and/or other materials provided with the distribution;
23 # neither the name of the copyright holders nor the names of its
24 # contributors may be used to endorse or promote products derived from
25 # this software without specific prior written permission.
27 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 from m5
.defines
import buildEnv
46 from m5
.objects
import *
47 from m5
.util
import addToPath
, fatal
49 addToPath('../common')
51 from FSConfig
import *
52 from SysPaths
import *
53 from Benchmarks
import *
60 parser
= optparse
.OptionParser()
61 Options
.addCommonOptions(parser
)
62 Options
.addFSOptions(parser
)
64 (options
, args
) = parser
.parse_args()
67 print "Error: script doesn't take any positional arguments"
70 # driver system CPU is always simple... note this is an assignment of
71 # a class, not an instance.
72 DriveCPUClass
= AtomicSimpleCPU
73 drive_mem_mode
= 'atomic'
75 # Check if KVM support has been enabled, we might need to do VM
76 # configuration if that's the case.
77 have_kvm_support
= 'BaseKvmCPU' in globals()
78 def is_kvm_cpu(cpu_class
):
79 return have_kvm_support
and cpu_class
!= None and \
80 issubclass(cpu_class
, BaseKvmCPU
)
82 # system under test can be any CPU
83 (TestCPUClass
, test_mem_mode
, FutureClass
) = Simulation
.setCPUClass(options
)
85 # Match the memories with the CPUs, the driver system always simple,
86 # and based on the options for the test system
87 DriveMemClass
= SimpleMemory
88 TestMemClass
= Simulation
.setMemClass(options
)
92 bm
= Benchmarks
[options
.benchmark
]
94 print "Error benchmark %s has not been defined." % options
.benchmark
95 print "Valid benchmarks are: %s" % DefinedBenchmarks
99 bm
= [SysConfig(disk
=options
.disk_image
, mem
=options
.mem_size
),
100 SysConfig(disk
=options
.disk_image
, mem
=options
.mem_size
)]
102 bm
= [SysConfig(disk
=options
.disk_image
, mem
=options
.mem_size
)]
104 np
= options
.num_cpus
106 if buildEnv
['TARGET_ISA'] == "alpha":
107 test_sys
= makeLinuxAlphaSystem(test_mem_mode
, bm
[0])
108 elif buildEnv
['TARGET_ISA'] == "mips":
109 test_sys
= makeLinuxMipsSystem(test_mem_mode
, bm
[0])
110 elif buildEnv
['TARGET_ISA'] == "sparc":
111 test_sys
= makeSparcSystem(test_mem_mode
, bm
[0])
112 elif buildEnv
['TARGET_ISA'] == "x86":
113 test_sys
= makeLinuxX86System(test_mem_mode
, options
.num_cpus
, bm
[0])
114 elif buildEnv
['TARGET_ISA'] == "arm":
115 test_sys
= makeArmSystem(test_mem_mode
, options
.machine_type
, bm
[0],
116 options
.dtb_filename
,
117 bare_metal
=options
.bare_metal
)
118 if options
.enable_context_switch_stats_dump
:
119 test_sys
.enable_context_switch_stats_dump
= True
121 fatal("Incapable of building %s full system!", buildEnv
['TARGET_ISA'])
123 # Create a top-level voltage domain
124 test_sys
.voltage_domain
= VoltageDomain(voltage
= options
.sys_voltage
)
126 # Create a source clock for the system and set the clock period
127 test_sys
.clk_domain
= SrcClockDomain(clock
= options
.sys_clock
,
128 voltage_domain
= test_sys
.voltage_domain
)
130 # Create a CPU voltage domain
131 test_sys
.cpu_voltage_domain
= VoltageDomain()
133 # Create a source clock for the CPUs and set the clock period
134 test_sys
.cpu_clk_domain
= SrcClockDomain(clock
= options
.cpu_clock
,
136 test_sys
.cpu_voltage_domain
)
138 if options
.kernel
is not None:
139 test_sys
.kernel
= binary(options
.kernel
)
141 if options
.script
is not None:
142 test_sys
.readfile
= options
.script
145 test_sys
.have_lpae
= True
147 if options
.virtualisation
:
148 test_sys
.have_virtualization
= True
150 test_sys
.init_param
= options
.init_param
152 # For now, assign all the CPUs to the same clock domain
153 test_sys
.cpu
= [TestCPUClass(clk_domain
=test_sys
.cpu_clk_domain
, cpu_id
=i
)
156 if is_kvm_cpu(TestCPUClass
) or is_kvm_cpu(FutureClass
):
157 test_sys
.vm
= KvmVM()
159 if options
.caches
or options
.l2cache
:
160 # By default the IOCache runs at the system clock
161 test_sys
.iocache
= IOCache(addr_ranges
= test_sys
.mem_ranges
)
162 test_sys
.iocache
.cpu_side
= test_sys
.iobus
.master
163 test_sys
.iocache
.mem_side
= test_sys
.membus
.slave
165 test_sys
.iobridge
= Bridge(delay
='50ns', ranges
= test_sys
.mem_ranges
)
166 test_sys
.iobridge
.slave
= test_sys
.iobus
.master
167 test_sys
.iobridge
.master
= test_sys
.membus
.slave
171 if TestCPUClass
!= AtomicSimpleCPU
:
172 fatal("Fastmem can only be used with atomic CPU!")
173 if (options
.caches
or options
.l2cache
):
174 fatal("You cannot use fastmem in combination with caches!")
178 test_sys
.cpu
[i
].fastmem
= True
180 test_sys
.cpu
[i
].addCheckerCpu()
181 test_sys
.cpu
[i
].createThreads()
183 CacheConfig
.config_cache(options
, test_sys
)
184 MemConfig
.config_mem(options
, test_sys
)
187 if buildEnv
['TARGET_ISA'] == 'alpha':
188 drive_sys
= makeLinuxAlphaSystem(drive_mem_mode
, bm
[1])
189 elif buildEnv
['TARGET_ISA'] == 'mips':
190 drive_sys
= makeLinuxMipsSystem(drive_mem_mode
, bm
[1])
191 elif buildEnv
['TARGET_ISA'] == 'sparc':
192 drive_sys
= makeSparcSystem(drive_mem_mode
, bm
[1])
193 elif buildEnv
['TARGET_ISA'] == 'x86':
194 drive_sys
= makeLinuxX86System(drive_mem_mode
, np
, bm
[1])
195 elif buildEnv
['TARGET_ISA'] == 'arm':
196 drive_sys
= makeArmSystem(drive_mem_mode
, options
.machine_type
, bm
[1])
198 # Create a top-level voltage domain
199 drive_sys
.voltage_domain
= VoltageDomain(voltage
= options
.sys_voltage
)
201 # Create a source clock for the system and set the clock period
202 drive_sys
.clk_domain
= SrcClockDomain(clock
= options
.sys_clock
)
204 # Create a CPU voltage domain
205 drive_sys
.cpu_voltage_domain
= VoltageDomain()
207 # Create a source clock for the CPUs and set the clock period
208 drive_sys
.cpu_clk_domain
= SrcClockDomain(clock
= options
.cpu_clock
,
210 drive_sys
.cpu_voltage_domain
)
212 drive_sys
.cpu
= DriveCPUClass(clk_domain
=drive_sys
.cpu_clk_domain
,
214 drive_sys
.cpu
.createThreads()
215 drive_sys
.cpu
.createInterruptController()
216 drive_sys
.cpu
.connectAllPorts(drive_sys
.membus
)
218 drive_sys
.cpu
.fastmem
= True
219 if options
.kernel
is not None:
220 drive_sys
.kernel
= binary(options
.kernel
)
222 if is_kvm_cpu(DriveCPUClass
):
223 drive_sys
.vm
= KvmVM()
225 drive_sys
.iobridge
= Bridge(delay
='50ns',
226 ranges
= drive_sys
.mem_ranges
)
227 drive_sys
.iobridge
.slave
= drive_sys
.iobus
.master
228 drive_sys
.iobridge
.master
= drive_sys
.membus
.slave
230 # Create the appropriate memory controllers and connect them to the
232 drive_sys
.mem_ctrls
= [DriveMemClass(range = r
)
233 for r
in drive_sys
.mem_ranges
]
234 for i
in xrange(len(drive_sys
.mem_ctrls
)):
235 drive_sys
.mem_ctrls
[i
].port
= drive_sys
.membus
.master
237 drive_sys
.init_param
= options
.init_param
238 root
= makeDualRoot(True, test_sys
, drive_sys
, options
.etherdump
)
240 root
= Root(full_system
=True, system
=test_sys
)
242 print "Error I don't know how to create more than 2 systems."
246 root
.time_sync_enable
= True
248 if options
.frame_capture
:
249 VncServer
.frame_capture
= True
251 Simulation
.setWorkCountOptions(test_sys
, options
)
252 Simulation
.run(options
, root
, test_sys
, FutureClass
)