fs.py (10118:5e1f04b4d5e4) | fs.py (10119:6f3f839bb496) |
---|---|
1# Copyright (c) 2010-2013 ARM Limited 2# All rights reserved. 3# 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 --- 49 unchanged lines hidden (view full) --- 58from SysPaths import * 59from Benchmarks import * 60import Simulation 61import CacheConfig 62import MemConfig 63from Caches import * 64import Options 65 | 1# Copyright (c) 2010-2013 ARM Limited 2# All rights reserved. 3# 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 --- 49 unchanged lines hidden (view full) --- 58from SysPaths import * 59from Benchmarks import * 60import Simulation 61import CacheConfig 62import MemConfig 63from Caches import * 64import Options 65 |
66parser = optparse.OptionParser() 67Options.addCommonOptions(parser) 68Options.addFSOptions(parser) | |
69 | 66 |
70# Add the ruby specific and protocol specific options 71if '--ruby' in sys.argv: 72 Ruby.define_options(parser) 73 74(options, args) = parser.parse_args() 75 76if args: 77 print "Error: script doesn't take any positional arguments" 78 sys.exit(1) 79 80# driver system CPU is always simple... note this is an assignment of 81# a class, not an instance. 82DriveCPUClass = AtomicSimpleCPU 83drive_mem_mode = 'atomic' 84 | |
85# Check if KVM support has been enabled, we might need to do VM 86# configuration if that's the case. 87have_kvm_support = 'BaseKvmCPU' in globals() 88def is_kvm_cpu(cpu_class): 89 return have_kvm_support and cpu_class != None and \ 90 issubclass(cpu_class, BaseKvmCPU) 91 | 67# Check if KVM support has been enabled, we might need to do VM 68# configuration if that's the case. 69have_kvm_support = 'BaseKvmCPU' in globals() 70def is_kvm_cpu(cpu_class): 71 return have_kvm_support and cpu_class != None and \ 72 issubclass(cpu_class, BaseKvmCPU) 73 |
92# system under test can be any CPU 93(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options) 94 95# Match the memories with the CPUs, the driver system always simple, 96# and based on the options for the test system 97DriveMemClass = SimpleMemory 98TestMemClass = Simulation.setMemClass(options) 99 100if options.benchmark: 101 try: 102 bm = Benchmarks[options.benchmark] 103 except KeyError: 104 print "Error benchmark %s has not been defined." % options.benchmark 105 print "Valid benchmarks are: %s" % DefinedBenchmarks 106 sys.exit(1) 107else: 108 if options.dual: 109 bm = [SysConfig(disk=options.disk_image, mem=options.mem_size), 110 SysConfig(disk=options.disk_image, mem=options.mem_size)] | 74def build_test_system(np): 75 if buildEnv['TARGET_ISA'] == "alpha": 76 test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0], options.ruby) 77 elif buildEnv['TARGET_ISA'] == "mips": 78 test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0]) 79 elif buildEnv['TARGET_ISA'] == "sparc": 80 test_sys = makeSparcSystem(test_mem_mode, bm[0]) 81 elif buildEnv['TARGET_ISA'] == "x86": 82 test_sys = makeLinuxX86System(test_mem_mode, options.num_cpus, bm[0], 83 options.ruby) 84 elif buildEnv['TARGET_ISA'] == "arm": 85 test_sys = makeArmSystem(test_mem_mode, options.machine_type, bm[0], 86 options.dtb_filename, 87 bare_metal=options.bare_metal) 88 if options.enable_context_switch_stats_dump: 89 test_sys.enable_context_switch_stats_dump = True |
111 else: | 90 else: |
112 bm = [SysConfig(disk=options.disk_image, mem=options.mem_size)] | 91 fatal("Incapable of building %s full system!", buildEnv['TARGET_ISA']) |
113 | 92 |
114np = options.num_cpus | 93 # Set the cache line size for the entire system 94 test_sys.cache_line_size = options.cacheline_size |
115 | 95 |
116if buildEnv['TARGET_ISA'] == "alpha": 117 test_sys = makeLinuxAlphaSystem(test_mem_mode, bm[0], options.ruby) 118elif buildEnv['TARGET_ISA'] == "mips": 119 test_sys = makeLinuxMipsSystem(test_mem_mode, bm[0]) 120elif buildEnv['TARGET_ISA'] == "sparc": 121 test_sys = makeSparcSystem(test_mem_mode, bm[0]) 122elif buildEnv['TARGET_ISA'] == "x86": 123 test_sys = makeLinuxX86System(test_mem_mode, options.num_cpus, bm[0], 124 options.ruby) 125elif buildEnv['TARGET_ISA'] == "arm": 126 test_sys = makeArmSystem(test_mem_mode, options.machine_type, bm[0], 127 options.dtb_filename, 128 bare_metal=options.bare_metal) 129 if options.enable_context_switch_stats_dump: 130 test_sys.enable_context_switch_stats_dump = True 131else: 132 fatal("Incapable of building %s full system!", buildEnv['TARGET_ISA']) | 96 # Create a top-level voltage domain 97 test_sys.voltage_domain = VoltageDomain(voltage = options.sys_voltage) |
133 | 98 |
134# Set the cache line size for the entire system 135test_sys.cache_line_size = options.cacheline_size | 99 # Create a source clock for the system and set the clock period 100 test_sys.clk_domain = SrcClockDomain(clock = options.sys_clock, 101 voltage_domain = test_sys.voltage_domain) |
136 | 102 |
137# Create a top-level voltage domain 138test_sys.voltage_domain = VoltageDomain(voltage = options.sys_voltage) | 103 # Create a CPU voltage domain 104 test_sys.cpu_voltage_domain = VoltageDomain() |
139 | 105 |
140# Create a source clock for the system and set the clock period 141test_sys.clk_domain = SrcClockDomain(clock = options.sys_clock, 142 voltage_domain = test_sys.voltage_domain) | 106 # Create a source clock for the CPUs and set the clock period 107 test_sys.cpu_clk_domain = SrcClockDomain(clock = options.cpu_clock, 108 voltage_domain = 109 test_sys.cpu_voltage_domain) |
143 | 110 |
144# Create a CPU voltage domain 145test_sys.cpu_voltage_domain = VoltageDomain() | 111 if options.kernel is not None: 112 test_sys.kernel = binary(options.kernel) |
146 | 113 |
147# Create a source clock for the CPUs and set the clock period 148test_sys.cpu_clk_domain = SrcClockDomain(clock = options.cpu_clock, 149 voltage_domain = 150 test_sys.cpu_voltage_domain) | 114 if options.script is not None: 115 test_sys.readfile = options.script |
151 | 116 |
152if options.kernel is not None: 153 test_sys.kernel = binary(options.kernel) | 117 if options.lpae: 118 test_sys.have_lpae = True |
154 | 119 |
155if options.script is not None: 156 test_sys.readfile = options.script | 120 if options.virtualisation: 121 test_sys.have_virtualization = True |
157 | 122 |
158if options.lpae: 159 test_sys.have_lpae = True | 123 test_sys.init_param = options.init_param |
160 | 124 |
161if options.virtualisation: 162 test_sys.have_virtualization = True | 125 # For now, assign all the CPUs to the same clock domain 126 test_sys.cpu = [TestCPUClass(clk_domain=test_sys.cpu_clk_domain, cpu_id=i) 127 for i in xrange(np)] |
163 | 128 |
164test_sys.init_param = options.init_param | 129 if is_kvm_cpu(TestCPUClass) or is_kvm_cpu(FutureClass): 130 test_sys.vm = KvmVM() |
165 | 131 |
166# For now, assign all the CPUs to the same clock domain 167test_sys.cpu = [TestCPUClass(clk_domain=test_sys.cpu_clk_domain, cpu_id=i) 168 for i in xrange(np)] | 132 if options.ruby: 133 # Check for timing mode because ruby does not support atomic accesses 134 if not (options.cpu_type == "detailed" or options.cpu_type == "timing"): 135 print >> sys.stderr, "Ruby requires TimingSimpleCPU or O3CPU!!" 136 sys.exit(1) |
169 | 137 |
170if is_kvm_cpu(TestCPUClass) or is_kvm_cpu(FutureClass): 171 test_sys.vm = KvmVM() | 138 Ruby.create_system(options, test_sys, test_sys.iobus, test_sys._dma_ports) |
172 | 139 |
173if options.ruby: 174 # Check for timing mode because ruby does not support atomic accesses 175 if not (options.cpu_type == "detailed" or options.cpu_type == "timing"): 176 print >> sys.stderr, "Ruby requires TimingSimpleCPU or O3CPU!!" 177 sys.exit(1) | 140 # Create a seperate clock domain for Ruby 141 test_sys.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock, 142 voltage_domain = test_sys.voltage_domain) |
178 | 143 |
179 Ruby.create_system(options, test_sys, test_sys.iobus, test_sys._dma_ports) | 144 for (i, cpu) in enumerate(test_sys.cpu): 145 # 146 # Tie the cpu ports to the correct ruby system ports 147 # 148 cpu.clk_domain = test_sys.cpu_clk_domain 149 cpu.createThreads() 150 cpu.createInterruptController() |
180 | 151 |
181 # Create a seperate clock domain for Ruby 182 test_sys.ruby.clk_domain = SrcClockDomain(clock = options.ruby_clock, 183 voltage_domain = test_sys.voltage_domain) | 152 cpu.icache_port = test_sys.ruby._cpu_ruby_ports[i].slave 153 cpu.dcache_port = test_sys.ruby._cpu_ruby_ports[i].slave |
184 | 154 |
185 for (i, cpu) in enumerate(test_sys.cpu): 186 # 187 # Tie the cpu ports to the correct ruby system ports 188 # 189 cpu.clk_domain = test_sys.cpu_clk_domain 190 cpu.createThreads() 191 cpu.createInterruptController() | 155 if buildEnv['TARGET_ISA'] == "x86": 156 cpu.itb.walker.port = test_sys.ruby._cpu_ruby_ports[i].slave 157 cpu.dtb.walker.port = test_sys.ruby._cpu_ruby_ports[i].slave |
192 | 158 |
193 cpu.icache_port = test_sys.ruby._cpu_ruby_ports[i].slave 194 cpu.dcache_port = test_sys.ruby._cpu_ruby_ports[i].slave | 159 cpu.interrupts.pio = test_sys.ruby._cpu_ruby_ports[i].master 160 cpu.interrupts.int_master = test_sys.ruby._cpu_ruby_ports[i].slave 161 cpu.interrupts.int_slave = test_sys.ruby._cpu_ruby_ports[i].master |
195 | 162 |
196 if buildEnv['TARGET_ISA'] == "x86": 197 cpu.itb.walker.port = test_sys.ruby._cpu_ruby_ports[i].slave 198 cpu.dtb.walker.port = test_sys.ruby._cpu_ruby_ports[i].slave | 163 test_sys.ruby._cpu_ruby_ports[i].access_phys_mem = True |
199 | 164 |
200 cpu.interrupts.pio = test_sys.ruby._cpu_ruby_ports[i].master 201 cpu.interrupts.int_master = test_sys.ruby._cpu_ruby_ports[i].slave 202 cpu.interrupts.int_slave = test_sys.ruby._cpu_ruby_ports[i].master | 165 # Create the appropriate memory controllers 166 # and connect them to the IO bus 167 test_sys.mem_ctrls = [TestMemClass(range = r) for r in test_sys.mem_ranges] 168 for i in xrange(len(test_sys.mem_ctrls)): 169 test_sys.mem_ctrls[i].port = test_sys.iobus.master |
203 | 170 |
204 test_sys.ruby._cpu_ruby_ports[i].access_phys_mem = True | 171 else: 172 if options.caches or options.l2cache: 173 # By default the IOCache runs at the system clock 174 test_sys.iocache = IOCache(addr_ranges = test_sys.mem_ranges) 175 test_sys.iocache.cpu_side = test_sys.iobus.master 176 test_sys.iocache.mem_side = test_sys.membus.slave 177 else: 178 test_sys.iobridge = Bridge(delay='50ns', ranges = test_sys.mem_ranges) 179 test_sys.iobridge.slave = test_sys.iobus.master 180 test_sys.iobridge.master = test_sys.membus.slave |
205 | 181 |
206 # Create the appropriate memory controllers and connect them to the 207 # PIO bus 208 test_sys.mem_ctrls = [TestMemClass(range = r) for r in test_sys.mem_ranges] 209 for i in xrange(len(test_sys.mem_ctrls)): 210 test_sys.mem_ctrls[i].port = test_sys.iobus.master | 182 # Sanity check 183 if options.fastmem: 184 if TestCPUClass != AtomicSimpleCPU: 185 fatal("Fastmem can only be used with atomic CPU!") 186 if (options.caches or options.l2cache): 187 fatal("You cannot use fastmem in combination with caches!") |
211 | 188 |
212else: 213 if options.caches or options.l2cache: 214 # By default the IOCache runs at the system clock 215 test_sys.iocache = IOCache(addr_ranges = test_sys.mem_ranges) 216 test_sys.iocache.cpu_side = test_sys.iobus.master 217 test_sys.iocache.mem_side = test_sys.membus.slave 218 else: 219 test_sys.iobridge = Bridge(delay='50ns', ranges = test_sys.mem_ranges) 220 test_sys.iobridge.slave = test_sys.iobus.master 221 test_sys.iobridge.master = test_sys.membus.slave | 189 for i in xrange(np): 190 if options.fastmem: 191 test_sys.cpu[i].fastmem = True 192 if options.checker: 193 test_sys.cpu[i].addCheckerCpu() 194 test_sys.cpu[i].createThreads() |
222 | 195 |
223 # Sanity check 224 if options.fastmem: 225 if TestCPUClass != AtomicSimpleCPU: 226 fatal("Fastmem can only be used with atomic CPU!") 227 if (options.caches or options.l2cache): 228 fatal("You cannot use fastmem in combination with caches!") | 196 CacheConfig.config_cache(options, test_sys) 197 MemConfig.config_mem(options, test_sys) |
229 | 198 |
230 for i in xrange(np): 231 if options.fastmem: 232 test_sys.cpu[i].fastmem = True 233 if options.checker: 234 test_sys.cpu[i].addCheckerCpu() 235 test_sys.cpu[i].createThreads() | 199 return test_sys |
236 | 200 |
237 CacheConfig.config_cache(options, test_sys) 238 MemConfig.config_mem(options, test_sys) | 201def build_drive_system(np): 202 # driver system CPU is always simple, so is the memory 203 # Note this is an assignment of a class, not an instance. 204 DriveCPUClass = AtomicSimpleCPU 205 drive_mem_mode = 'atomic' 206 DriveMemClass = SimpleMemory |
239 | 207 |
240if len(bm) == 2: | |
241 if buildEnv['TARGET_ISA'] == 'alpha': 242 drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1]) 243 elif buildEnv['TARGET_ISA'] == 'mips': 244 drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1]) 245 elif buildEnv['TARGET_ISA'] == 'sparc': 246 drive_sys = makeSparcSystem(drive_mem_mode, bm[1]) 247 elif buildEnv['TARGET_ISA'] == 'x86': 248 drive_sys = makeLinuxX86System(drive_mem_mode, np, bm[1]) 249 elif buildEnv['TARGET_ISA'] == 'arm': 250 drive_sys = makeArmSystem(drive_mem_mode, options.machine_type, bm[1]) 251 252 # Create a top-level voltage domain 253 drive_sys.voltage_domain = VoltageDomain(voltage = options.sys_voltage) 254 255 # Create a source clock for the system and set the clock period | 208 if buildEnv['TARGET_ISA'] == 'alpha': 209 drive_sys = makeLinuxAlphaSystem(drive_mem_mode, bm[1]) 210 elif buildEnv['TARGET_ISA'] == 'mips': 211 drive_sys = makeLinuxMipsSystem(drive_mem_mode, bm[1]) 212 elif buildEnv['TARGET_ISA'] == 'sparc': 213 drive_sys = makeSparcSystem(drive_mem_mode, bm[1]) 214 elif buildEnv['TARGET_ISA'] == 'x86': 215 drive_sys = makeLinuxX86System(drive_mem_mode, np, bm[1]) 216 elif buildEnv['TARGET_ISA'] == 'arm': 217 drive_sys = makeArmSystem(drive_mem_mode, options.machine_type, bm[1]) 218 219 # Create a top-level voltage domain 220 drive_sys.voltage_domain = VoltageDomain(voltage = options.sys_voltage) 221 222 # Create a source clock for the system and set the clock period |
256 drive_sys.clk_domain = SrcClockDomain(clock = options.sys_clock) | 223 drive_sys.clk_domain = SrcClockDomain(clock = options.sys_clock, 224 voltage_domain = drive_sys.voltage_domain) |
257 258 # Create a CPU voltage domain 259 drive_sys.cpu_voltage_domain = VoltageDomain() 260 261 # Create a source clock for the CPUs and set the clock period 262 drive_sys.cpu_clk_domain = SrcClockDomain(clock = options.cpu_clock, 263 voltage_domain = 264 drive_sys.cpu_voltage_domain) --- 19 unchanged lines hidden (view full) --- 284 # Create the appropriate memory controllers and connect them to the 285 # memory bus 286 drive_sys.mem_ctrls = [DriveMemClass(range = r) 287 for r in drive_sys.mem_ranges] 288 for i in xrange(len(drive_sys.mem_ctrls)): 289 drive_sys.mem_ctrls[i].port = drive_sys.membus.master 290 291 drive_sys.init_param = options.init_param | 225 226 # Create a CPU voltage domain 227 drive_sys.cpu_voltage_domain = VoltageDomain() 228 229 # Create a source clock for the CPUs and set the clock period 230 drive_sys.cpu_clk_domain = SrcClockDomain(clock = options.cpu_clock, 231 voltage_domain = 232 drive_sys.cpu_voltage_domain) --- 19 unchanged lines hidden (view full) --- 252 # Create the appropriate memory controllers and connect them to the 253 # memory bus 254 drive_sys.mem_ctrls = [DriveMemClass(range = r) 255 for r in drive_sys.mem_ranges] 256 for i in xrange(len(drive_sys.mem_ctrls)): 257 drive_sys.mem_ctrls[i].port = drive_sys.membus.master 258 259 drive_sys.init_param = options.init_param |
260 261 return drive_sys 262 263# Add options 264parser = optparse.OptionParser() 265Options.addCommonOptions(parser) 266Options.addFSOptions(parser) 267 268# Add the ruby specific and protocol specific options 269if '--ruby' in sys.argv: 270 Ruby.define_options(parser) 271 272(options, args) = parser.parse_args() 273 274if args: 275 print "Error: script doesn't take any positional arguments" 276 sys.exit(1) 277 278# system under test can be any CPU 279(TestCPUClass, test_mem_mode, FutureClass) = Simulation.setCPUClass(options) 280 281# Match the memories with the CPUs, based on the options for the test system 282TestMemClass = Simulation.setMemClass(options) 283 284if options.benchmark: 285 try: 286 bm = Benchmarks[options.benchmark] 287 except KeyError: 288 print "Error benchmark %s has not been defined." % options.benchmark 289 print "Valid benchmarks are: %s" % DefinedBenchmarks 290 sys.exit(1) 291else: 292 if options.dual: 293 bm = [SysConfig(disk=options.disk_image, mem=options.mem_size), 294 SysConfig(disk=options.disk_image, mem=options.mem_size)] 295 else: 296 bm = [SysConfig(disk=options.disk_image, mem=options.mem_size)] 297 298np = options.num_cpus 299 300test_sys = build_test_system(np) 301if len(bm) == 2: 302 drive_sys = build_drive_system(np) |
|
292 root = makeDualRoot(True, test_sys, drive_sys, options.etherdump) 293elif len(bm) == 1: 294 root = Root(full_system=True, system=test_sys) 295else: 296 print "Error I don't know how to create more than 2 systems." 297 sys.exit(1) 298 299if options.timesync: 300 root.time_sync_enable = True 301 302if options.frame_capture: 303 VncServer.frame_capture = True 304 305Simulation.setWorkCountOptions(test_sys, options) 306Simulation.run(options, root, test_sys, FutureClass) | 303 root = makeDualRoot(True, test_sys, drive_sys, options.etherdump) 304elif len(bm) == 1: 305 root = Root(full_system=True, system=test_sys) 306else: 307 print "Error I don't know how to create more than 2 systems." 308 sys.exit(1) 309 310if options.timesync: 311 root.time_sync_enable = True 312 313if options.frame_capture: 314 VncServer.frame_capture = True 315 316Simulation.setWorkCountOptions(test_sys, options) 317Simulation.run(options, root, test_sys, FutureClass) |