FSConfig.py revision 12067:9423cf8c1e87
1# Copyright (c) 2010-2012, 2015-2017 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 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. 12# 13# Copyright (c) 2010-2011 Advanced Micro Devices, Inc. 14# Copyright (c) 2006-2008 The Regents of The University of Michigan 15# All rights reserved. 16# 17# Redistribution and use in source and binary forms, with or without 18# modification, are permitted provided that the following conditions are 19# met: redistributions of source code must retain the above copyright 20# notice, this list of conditions and the following disclaimer; 21# redistributions in binary form must reproduce the above copyright 22# notice, this list of conditions and the following disclaimer in the 23# documentation and/or other materials provided with the distribution; 24# neither the name of the copyright holders nor the names of its 25# contributors may be used to endorse or promote products derived from 26# this software without specific prior written permission. 27# 28# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39# 40# Authors: Kevin Lim 41 42from m5.objects import * 43from Benchmarks import * 44from m5.util import * 45from common import PlatformConfig 46 47# Populate to reflect supported os types per target ISA 48os_types = { 'alpha' : [ 'linux' ], 49 'mips' : [ 'linux' ], 50 'sparc' : [ 'linux' ], 51 'x86' : [ 'linux' ], 52 'arm' : [ 'linux', 53 'android-gingerbread', 54 'android-ics', 55 'android-jellybean', 56 'android-kitkat', 57 'android-nougat', ], 58 } 59 60class CowIdeDisk(IdeDisk): 61 image = CowDiskImage(child=RawDiskImage(read_only=True), 62 read_only=False) 63 64 def childImage(self, ci): 65 self.image.child.image_file = ci 66 67class MemBus(SystemXBar): 68 badaddr_responder = BadAddr() 69 default = Self.badaddr_responder.pio 70 71def fillInCmdline(mdesc, template, **kwargs): 72 kwargs.setdefault('disk', mdesc.disk()) 73 kwargs.setdefault('rootdev', mdesc.rootdev()) 74 kwargs.setdefault('mem', mdesc.mem()) 75 kwargs.setdefault('script', mdesc.script()) 76 return template % kwargs 77 78def makeLinuxAlphaSystem(mem_mode, mdesc=None, ruby=False, cmdline=None): 79 80 class BaseTsunami(Tsunami): 81 ethernet = NSGigE(pci_bus=0, pci_dev=1, pci_func=0) 82 ide = IdeController(disks=[Parent.disk0, Parent.disk2], 83 pci_func=0, pci_dev=0, pci_bus=0) 84 85 self = LinuxAlphaSystem() 86 if not mdesc: 87 # generic system 88 mdesc = SysConfig() 89 self.readfile = mdesc.script() 90 91 self.tsunami = BaseTsunami() 92 93 # Create the io bus to connect all device ports 94 self.iobus = IOXBar() 95 self.tsunami.attachIO(self.iobus) 96 97 self.tsunami.ide.pio = self.iobus.master 98 99 self.tsunami.ethernet.pio = self.iobus.master 100 101 if ruby: 102 # Store the dma devices for later connection to dma ruby ports. 103 # Append an underscore to dma_ports to avoid the SimObjectVector check. 104 self._dma_ports = [self.tsunami.ide.dma, self.tsunami.ethernet.dma] 105 else: 106 self.membus = MemBus() 107 108 # By default the bridge responds to all addresses above the I/O 109 # base address (including the PCI config space) 110 IO_address_space_base = 0x80000000000 111 self.bridge = Bridge(delay='50ns', 112 ranges = [AddrRange(IO_address_space_base, Addr.max)]) 113 self.bridge.master = self.iobus.slave 114 self.bridge.slave = self.membus.master 115 116 self.tsunami.ide.dma = self.iobus.slave 117 self.tsunami.ethernet.dma = self.iobus.slave 118 119 self.system_port = self.membus.slave 120 121 self.mem_ranges = [AddrRange(mdesc.mem())] 122 self.disk0 = CowIdeDisk(driveID='master') 123 self.disk2 = CowIdeDisk(driveID='master') 124 self.disk0.childImage(mdesc.disk()) 125 self.disk2.childImage(disk('linux-bigswap2.img')) 126 self.simple_disk = SimpleDisk(disk=RawDiskImage(image_file = mdesc.disk(), 127 read_only = True)) 128 self.intrctrl = IntrControl() 129 self.mem_mode = mem_mode 130 self.terminal = Terminal() 131 self.kernel = binary('vmlinux') 132 self.pal = binary('ts_osfpal') 133 self.console = binary('console') 134 if not cmdline: 135 cmdline = 'root=/dev/hda1 console=ttyS0' 136 self.boot_osflags = fillInCmdline(mdesc, cmdline) 137 138 return self 139 140def makeSparcSystem(mem_mode, mdesc=None, cmdline=None): 141 # Constants from iob.cc and uart8250.cc 142 iob_man_addr = 0x9800000000 143 uart_pio_size = 8 144 145 class CowMmDisk(MmDisk): 146 image = CowDiskImage(child=RawDiskImage(read_only=True), 147 read_only=False) 148 149 def childImage(self, ci): 150 self.image.child.image_file = ci 151 152 self = SparcSystem() 153 if not mdesc: 154 # generic system 155 mdesc = SysConfig() 156 self.readfile = mdesc.script() 157 self.iobus = IOXBar() 158 self.membus = MemBus() 159 self.bridge = Bridge(delay='50ns') 160 self.t1000 = T1000() 161 self.t1000.attachOnChipIO(self.membus) 162 self.t1000.attachIO(self.iobus) 163 self.mem_ranges = [AddrRange(Addr('1MB'), size = '64MB'), 164 AddrRange(Addr('2GB'), size ='256MB')] 165 self.bridge.master = self.iobus.slave 166 self.bridge.slave = self.membus.master 167 self.rom.port = self.membus.master 168 self.nvram.port = self.membus.master 169 self.hypervisor_desc.port = self.membus.master 170 self.partition_desc.port = self.membus.master 171 self.intrctrl = IntrControl() 172 self.disk0 = CowMmDisk() 173 self.disk0.childImage(mdesc.disk()) 174 self.disk0.pio = self.iobus.master 175 176 # The puart0 and hvuart are placed on the IO bus, so create ranges 177 # for them. The remaining IO range is rather fragmented, so poke 178 # holes for the iob and partition descriptors etc. 179 self.bridge.ranges = \ 180 [ 181 AddrRange(self.t1000.puart0.pio_addr, 182 self.t1000.puart0.pio_addr + uart_pio_size - 1), 183 AddrRange(self.disk0.pio_addr, 184 self.t1000.fake_jbi.pio_addr + 185 self.t1000.fake_jbi.pio_size - 1), 186 AddrRange(self.t1000.fake_clk.pio_addr, 187 iob_man_addr - 1), 188 AddrRange(self.t1000.fake_l2_1.pio_addr, 189 self.t1000.fake_ssi.pio_addr + 190 self.t1000.fake_ssi.pio_size - 1), 191 AddrRange(self.t1000.hvuart.pio_addr, 192 self.t1000.hvuart.pio_addr + uart_pio_size - 1) 193 ] 194 self.reset_bin = binary('reset_new.bin') 195 self.hypervisor_bin = binary('q_new.bin') 196 self.openboot_bin = binary('openboot_new.bin') 197 self.nvram_bin = binary('nvram1') 198 self.hypervisor_desc_bin = binary('1up-hv.bin') 199 self.partition_desc_bin = binary('1up-md.bin') 200 201 self.system_port = self.membus.slave 202 203 return self 204 205def makeArmSystem(mem_mode, machine_type, num_cpus=1, mdesc=None, 206 dtb_filename=None, bare_metal=False, cmdline=None, 207 external_memory="", ruby=False): 208 assert machine_type 209 210 default_dtbs = { 211 "RealViewEB": None, 212 "RealViewPBX": None, 213 "VExpress_EMM": "vexpress.aarch32.ll_20131205.0-gem5.%dcpu.dtb" % num_cpus, 214 "VExpress_EMM64": "vexpress.aarch64.20140821.dtb", 215 } 216 217 default_kernels = { 218 "RealViewEB": "vmlinux.arm.smp.fb.2.6.38.8", 219 "RealViewPBX": "vmlinux.arm.smp.fb.2.6.38.8", 220 "VExpress_EMM": "vmlinux.aarch32.ll_20131205.0-gem5", 221 "VExpress_EMM64": "vmlinux.aarch64.20140821", 222 } 223 224 pci_devices = [] 225 226 if bare_metal: 227 self = ArmSystem() 228 else: 229 self = LinuxArmSystem() 230 231 if not mdesc: 232 # generic system 233 mdesc = SysConfig() 234 235 self.readfile = mdesc.script() 236 self.iobus = IOXBar() 237 if not ruby: 238 self.bridge = Bridge(delay='50ns') 239 self.bridge.master = self.iobus.slave 240 self.membus = MemBus() 241 self.membus.badaddr_responder.warn_access = "warn" 242 self.bridge.slave = self.membus.master 243 244 self.mem_mode = mem_mode 245 246 platform_class = PlatformConfig.get(machine_type) 247 # Resolve the real platform name, the original machine_type 248 # variable might have been an alias. 249 machine_type = platform_class.__name__ 250 self.realview = platform_class() 251 252 if not dtb_filename and not bare_metal: 253 try: 254 dtb_filename = default_dtbs[machine_type] 255 except KeyError: 256 fatal("No DTB specified and no default DTB known for '%s'" % \ 257 machine_type) 258 259 if isinstance(self.realview, VExpress_EMM64): 260 if os.path.split(mdesc.disk())[-1] == 'linux-aarch32-ael.img': 261 print "Selected 64-bit ARM architecture, updating default disk image..." 262 mdesc.diskname = 'linaro-minimal-aarch64.img' 263 264 265 # Attach any PCI devices this platform supports 266 self.realview.attachPciDevices() 267 268 self.cf0 = CowIdeDisk(driveID='master') 269 self.cf0.childImage(mdesc.disk()) 270 # Old platforms have a built-in IDE or CF controller. Default to 271 # the IDE controller if both exist. New platforms expect the 272 # storage controller to be added from the config script. 273 if hasattr(self.realview, "ide"): 274 self.realview.ide.disks = [self.cf0] 275 elif hasattr(self.realview, "cf_ctrl"): 276 self.realview.cf_ctrl.disks = [self.cf0] 277 else: 278 self.pci_ide = IdeController(disks=[self.cf0]) 279 pci_devices.append(self.pci_ide) 280 281 self.mem_ranges = [] 282 size_remain = long(Addr(mdesc.mem())) 283 for region in self.realview._mem_regions: 284 if size_remain > long(region[1]): 285 self.mem_ranges.append(AddrRange(region[0], size=region[1])) 286 size_remain = size_remain - long(region[1]) 287 else: 288 self.mem_ranges.append(AddrRange(region[0], size=size_remain)) 289 size_remain = 0 290 break 291 warn("Memory size specified spans more than one region. Creating" \ 292 " another memory controller for that range.") 293 294 if size_remain > 0: 295 fatal("The currently selected ARM platforms doesn't support" \ 296 " the amount of DRAM you've selected. Please try" \ 297 " another platform") 298 299 if bare_metal: 300 # EOT character on UART will end the simulation 301 self.realview.uart.end_on_eot = True 302 else: 303 if machine_type in default_kernels: 304 self.kernel = binary(default_kernels[machine_type]) 305 306 if dtb_filename: 307 self.dtb_filename = binary(dtb_filename) 308 309 self.machine_type = machine_type if machine_type in ArmMachineType.map \ 310 else "DTOnly" 311 312 # Ensure that writes to the UART actually go out early in the boot 313 if not cmdline: 314 cmdline = 'earlyprintk=pl011,0x1c090000 console=ttyAMA0 ' + \ 315 'lpj=19988480 norandmaps rw loglevel=8 ' + \ 316 'mem=%(mem)s root=%(rootdev)s' 317 318 # When using external memory, gem5 writes the boot loader to nvmem 319 # and then SST will read from it, but SST can only get to nvmem from 320 # iobus, as gem5's membus is only used for initialization and 321 # SST doesn't use it. Attaching nvmem to iobus solves this issue. 322 # During initialization, system_port -> membus -> iobus -> nvmem. 323 if external_memory or ruby: 324 self.realview.setupBootLoader(self.iobus, self, binary) 325 else: 326 self.realview.setupBootLoader(self.membus, self, binary) 327 self.gic_cpu_addr = self.realview.gic.cpu_addr 328 self.flags_addr = self.realview.realview_io.pio_addr + 0x30 329 330 # This check is for users who have previously put 'android' in 331 # the disk image filename to tell the config scripts to 332 # prepare the kernel with android-specific boot options. That 333 # behavior has been replaced with a more explicit option per 334 # the error message below. The disk can have any name now and 335 # doesn't need to include 'android' substring. 336 if (os.path.split(mdesc.disk())[-1]).lower().count('android'): 337 if 'android' not in mdesc.os_type(): 338 fatal("It looks like you are trying to boot an Android " \ 339 "platform. To boot Android, you must specify " \ 340 "--os-type with an appropriate Android release on " \ 341 "the command line.") 342 343 # android-specific tweaks 344 if 'android' in mdesc.os_type(): 345 # generic tweaks 346 cmdline += " init=/init" 347 348 # release-specific tweaks 349 if 'kitkat' in mdesc.os_type(): 350 cmdline += " androidboot.hardware=gem5 qemu=1 qemu.gles=0 " + \ 351 "android.bootanim=0 " 352 elif 'nougat' in mdesc.os_type(): 353 cmdline += " androidboot.hardware=gem5 qemu=1 qemu.gles=0 " + \ 354 "android.bootanim=0 " + \ 355 "vmalloc=640MB " + \ 356 "android.early.fstab=/fstab.gem5 " + \ 357 "androidboot.selinux=permissive " + \ 358 "video=Virtual-1:1920x1080-16" 359 360 self.boot_osflags = fillInCmdline(mdesc, cmdline) 361 362 if external_memory: 363 # I/O traffic enters iobus 364 self.external_io = ExternalMaster(port_data="external_io", 365 port_type=external_memory) 366 self.external_io.port = self.iobus.slave 367 368 # Ensure iocache only receives traffic destined for (actual) memory. 369 self.iocache = ExternalSlave(port_data="iocache", 370 port_type=external_memory, 371 addr_ranges=self.mem_ranges) 372 self.iocache.port = self.iobus.master 373 374 # Let system_port get to nvmem and nothing else. 375 self.bridge.ranges = [self.realview.nvmem.range] 376 377 self.realview.attachOnChipIO(self.iobus) 378 # Attach off-chip devices 379 self.realview.attachIO(self.iobus) 380 elif ruby: 381 self._dma_ports = [ ] 382 self.realview.attachOnChipIO(self.iobus, dma_ports=self._dma_ports) 383 # Force Ruby to treat the boot ROM as an IO device. 384 self.realview.nvmem.in_addr_map = False 385 self.realview.attachIO(self.iobus, dma_ports=self._dma_ports) 386 else: 387 self.realview.attachOnChipIO(self.membus, self.bridge) 388 # Attach off-chip devices 389 self.realview.attachIO(self.iobus) 390 391 for dev_id, dev in enumerate(pci_devices): 392 dev.pci_bus, dev.pci_dev, dev.pci_func = (0, dev_id + 1, 0) 393 self.realview.attachPciDevice( 394 dev, self.iobus, 395 dma_ports=self._dma_ports if ruby else None) 396 397 self.intrctrl = IntrControl() 398 self.terminal = Terminal() 399 self.vncserver = VncServer() 400 401 if not ruby: 402 self.system_port = self.membus.slave 403 404 if ruby: 405 if buildEnv['PROTOCOL'] == 'MI_example' and num_cpus > 1: 406 fatal("The MI_example protocol cannot implement Load/Store " 407 "Exclusive operations. Multicore ARM systems configured " 408 "with the MI_example protocol will not work properly.") 409 warn("You are trying to use Ruby on ARM, which is not working " 410 "properly yet.") 411 412 return self 413 414 415def makeLinuxMipsSystem(mem_mode, mdesc=None, cmdline=None): 416 class BaseMalta(Malta): 417 ethernet = NSGigE(pci_bus=0, pci_dev=1, pci_func=0) 418 ide = IdeController(disks=[Parent.disk0, Parent.disk2], 419 pci_func=0, pci_dev=0, pci_bus=0) 420 421 self = LinuxMipsSystem() 422 if not mdesc: 423 # generic system 424 mdesc = SysConfig() 425 self.readfile = mdesc.script() 426 self.iobus = IOXBar() 427 self.membus = MemBus() 428 self.bridge = Bridge(delay='50ns') 429 self.mem_ranges = [AddrRange('1GB')] 430 self.bridge.master = self.iobus.slave 431 self.bridge.slave = self.membus.master 432 self.disk0 = CowIdeDisk(driveID='master') 433 self.disk2 = CowIdeDisk(driveID='master') 434 self.disk0.childImage(mdesc.disk()) 435 self.disk2.childImage(disk('linux-bigswap2.img')) 436 self.malta = BaseMalta() 437 self.malta.attachIO(self.iobus) 438 self.malta.ide.pio = self.iobus.master 439 self.malta.ide.dma = self.iobus.slave 440 self.malta.ethernet.pio = self.iobus.master 441 self.malta.ethernet.dma = self.iobus.slave 442 self.simple_disk = SimpleDisk(disk=RawDiskImage(image_file = mdesc.disk(), 443 read_only = True)) 444 self.intrctrl = IntrControl() 445 self.mem_mode = mem_mode 446 self.terminal = Terminal() 447 self.kernel = binary('mips/vmlinux') 448 self.console = binary('mips/console') 449 if not cmdline: 450 cmdline = 'root=/dev/hda1 console=ttyS0' 451 self.boot_osflags = fillInCmdline(mdesc, cmdline) 452 453 self.system_port = self.membus.slave 454 455 return self 456 457def x86IOAddress(port): 458 IO_address_space_base = 0x8000000000000000 459 return IO_address_space_base + port 460 461def connectX86ClassicSystem(x86_sys, numCPUs): 462 # Constants similar to x86_traits.hh 463 IO_address_space_base = 0x8000000000000000 464 pci_config_address_space_base = 0xc000000000000000 465 interrupts_address_space_base = 0xa000000000000000 466 APIC_range_size = 1 << 12; 467 468 x86_sys.membus = MemBus() 469 470 # North Bridge 471 x86_sys.iobus = IOXBar() 472 x86_sys.bridge = Bridge(delay='50ns') 473 x86_sys.bridge.master = x86_sys.iobus.slave 474 x86_sys.bridge.slave = x86_sys.membus.master 475 # Allow the bridge to pass through: 476 # 1) kernel configured PCI device memory map address: address range 477 # [0xC0000000, 0xFFFF0000). (The upper 64kB are reserved for m5ops.) 478 # 2) the bridge to pass through the IO APIC (two pages, already contained in 1), 479 # 3) everything in the IO address range up to the local APIC, and 480 # 4) then the entire PCI address space and beyond. 481 x86_sys.bridge.ranges = \ 482 [ 483 AddrRange(0xC0000000, 0xFFFF0000), 484 AddrRange(IO_address_space_base, 485 interrupts_address_space_base - 1), 486 AddrRange(pci_config_address_space_base, 487 Addr.max) 488 ] 489 490 # Create a bridge from the IO bus to the memory bus to allow access to 491 # the local APIC (two pages) 492 x86_sys.apicbridge = Bridge(delay='50ns') 493 x86_sys.apicbridge.slave = x86_sys.iobus.master 494 x86_sys.apicbridge.master = x86_sys.membus.slave 495 x86_sys.apicbridge.ranges = [AddrRange(interrupts_address_space_base, 496 interrupts_address_space_base + 497 numCPUs * APIC_range_size 498 - 1)] 499 500 # connect the io bus 501 x86_sys.pc.attachIO(x86_sys.iobus) 502 503 x86_sys.system_port = x86_sys.membus.slave 504 505def connectX86RubySystem(x86_sys): 506 # North Bridge 507 x86_sys.iobus = IOXBar() 508 509 # add the ide to the list of dma devices that later need to attach to 510 # dma controllers 511 x86_sys._dma_ports = [x86_sys.pc.south_bridge.ide.dma] 512 x86_sys.pc.attachIO(x86_sys.iobus, x86_sys._dma_ports) 513 514 515def makeX86System(mem_mode, numCPUs=1, mdesc=None, self=None, Ruby=False): 516 if self == None: 517 self = X86System() 518 519 if not mdesc: 520 # generic system 521 mdesc = SysConfig() 522 self.readfile = mdesc.script() 523 524 self.mem_mode = mem_mode 525 526 # Physical memory 527 # On the PC platform, the memory region 0xC0000000-0xFFFFFFFF is reserved 528 # for various devices. Hence, if the physical memory size is greater than 529 # 3GB, we need to split it into two parts. 530 excess_mem_size = \ 531 convert.toMemorySize(mdesc.mem()) - convert.toMemorySize('3GB') 532 if excess_mem_size <= 0: 533 self.mem_ranges = [AddrRange(mdesc.mem())] 534 else: 535 warn("Physical memory size specified is %s which is greater than " \ 536 "3GB. Twice the number of memory controllers would be " \ 537 "created." % (mdesc.mem())) 538 539 self.mem_ranges = [AddrRange('3GB'), 540 AddrRange(Addr('4GB'), size = excess_mem_size)] 541 542 # Platform 543 self.pc = Pc() 544 545 # Create and connect the busses required by each memory system 546 if Ruby: 547 connectX86RubySystem(self) 548 else: 549 connectX86ClassicSystem(self, numCPUs) 550 551 self.intrctrl = IntrControl() 552 553 # Disks 554 disk0 = CowIdeDisk(driveID='master') 555 disk2 = CowIdeDisk(driveID='master') 556 disk0.childImage(mdesc.disk()) 557 disk2.childImage(disk('linux-bigswap2.img')) 558 self.pc.south_bridge.ide.disks = [disk0, disk2] 559 560 # Add in a Bios information structure. 561 structures = [X86SMBiosBiosInformation()] 562 self.smbios_table.structures = structures 563 564 # Set up the Intel MP table 565 base_entries = [] 566 ext_entries = [] 567 for i in xrange(numCPUs): 568 bp = X86IntelMPProcessor( 569 local_apic_id = i, 570 local_apic_version = 0x14, 571 enable = True, 572 bootstrap = (i == 0)) 573 base_entries.append(bp) 574 io_apic = X86IntelMPIOAPIC( 575 id = numCPUs, 576 version = 0x11, 577 enable = True, 578 address = 0xfec00000) 579 self.pc.south_bridge.io_apic.apic_id = io_apic.id 580 base_entries.append(io_apic) 581 # In gem5 Pc::calcPciConfigAddr(), it required "assert(bus==0)", 582 # but linux kernel cannot config PCI device if it was not connected to PCI bus, 583 # so we fix PCI bus id to 0, and ISA bus id to 1. 584 pci_bus = X86IntelMPBus(bus_id = 0, bus_type='PCI ') 585 base_entries.append(pci_bus) 586 isa_bus = X86IntelMPBus(bus_id = 1, bus_type='ISA ') 587 base_entries.append(isa_bus) 588 connect_busses = X86IntelMPBusHierarchy(bus_id=1, 589 subtractive_decode=True, parent_bus=0) 590 ext_entries.append(connect_busses) 591 pci_dev4_inta = X86IntelMPIOIntAssignment( 592 interrupt_type = 'INT', 593 polarity = 'ConformPolarity', 594 trigger = 'ConformTrigger', 595 source_bus_id = 0, 596 source_bus_irq = 0 + (4 << 2), 597 dest_io_apic_id = io_apic.id, 598 dest_io_apic_intin = 16) 599 base_entries.append(pci_dev4_inta) 600 def assignISAInt(irq, apicPin): 601 assign_8259_to_apic = X86IntelMPIOIntAssignment( 602 interrupt_type = 'ExtInt', 603 polarity = 'ConformPolarity', 604 trigger = 'ConformTrigger', 605 source_bus_id = 1, 606 source_bus_irq = irq, 607 dest_io_apic_id = io_apic.id, 608 dest_io_apic_intin = 0) 609 base_entries.append(assign_8259_to_apic) 610 assign_to_apic = X86IntelMPIOIntAssignment( 611 interrupt_type = 'INT', 612 polarity = 'ConformPolarity', 613 trigger = 'ConformTrigger', 614 source_bus_id = 1, 615 source_bus_irq = irq, 616 dest_io_apic_id = io_apic.id, 617 dest_io_apic_intin = apicPin) 618 base_entries.append(assign_to_apic) 619 assignISAInt(0, 2) 620 assignISAInt(1, 1) 621 for i in range(3, 15): 622 assignISAInt(i, i) 623 self.intel_mp_table.base_entries = base_entries 624 self.intel_mp_table.ext_entries = ext_entries 625 626def makeLinuxX86System(mem_mode, numCPUs=1, mdesc=None, Ruby=False, 627 cmdline=None): 628 self = LinuxX86System() 629 630 # Build up the x86 system and then specialize it for Linux 631 makeX86System(mem_mode, numCPUs, mdesc, self, Ruby) 632 633 # We assume below that there's at least 1MB of memory. We'll require 2 634 # just to avoid corner cases. 635 phys_mem_size = sum(map(lambda r: r.size(), self.mem_ranges)) 636 assert(phys_mem_size >= 0x200000) 637 assert(len(self.mem_ranges) <= 2) 638 639 entries = \ 640 [ 641 # Mark the first megabyte of memory as reserved 642 X86E820Entry(addr = 0, size = '639kB', range_type = 1), 643 X86E820Entry(addr = 0x9fc00, size = '385kB', range_type = 2), 644 # Mark the rest of physical memory as available 645 X86E820Entry(addr = 0x100000, 646 size = '%dB' % (self.mem_ranges[0].size() - 0x100000), 647 range_type = 1), 648 ] 649 650 # Mark [mem_size, 3GB) as reserved if memory less than 3GB, which force 651 # IO devices to be mapped to [0xC0000000, 0xFFFF0000). Requests to this 652 # specific range can pass though bridge to iobus. 653 if len(self.mem_ranges) == 1: 654 entries.append(X86E820Entry(addr = self.mem_ranges[0].size(), 655 size='%dB' % (0xC0000000 - self.mem_ranges[0].size()), 656 range_type=2)) 657 658 # Reserve the last 16kB of the 32-bit address space for the m5op interface 659 entries.append(X86E820Entry(addr=0xFFFF0000, size='64kB', range_type=2)) 660 661 # In case the physical memory is greater than 3GB, we split it into two 662 # parts and add a separate e820 entry for the second part. This entry 663 # starts at 0x100000000, which is the first address after the space 664 # reserved for devices. 665 if len(self.mem_ranges) == 2: 666 entries.append(X86E820Entry(addr = 0x100000000, 667 size = '%dB' % (self.mem_ranges[1].size()), range_type = 1)) 668 669 self.e820_table.entries = entries 670 671 # Command line 672 if not cmdline: 673 cmdline = 'earlyprintk=ttyS0 console=ttyS0 lpj=7999923 root=/dev/hda1' 674 self.boot_osflags = fillInCmdline(mdesc, cmdline) 675 self.kernel = binary('x86_64-vmlinux-2.6.22.9') 676 return self 677 678 679def makeDualRoot(full_system, testSystem, driveSystem, dumpfile): 680 self = Root(full_system = full_system) 681 self.testsys = testSystem 682 self.drivesys = driveSystem 683 self.etherlink = EtherLink() 684 685 if hasattr(testSystem, 'realview'): 686 self.etherlink.int0 = Parent.testsys.realview.ethernet.interface 687 self.etherlink.int1 = Parent.drivesys.realview.ethernet.interface 688 elif hasattr(testSystem, 'tsunami'): 689 self.etherlink.int0 = Parent.testsys.tsunami.ethernet.interface 690 self.etherlink.int1 = Parent.drivesys.tsunami.ethernet.interface 691 else: 692 fatal("Don't know how to connect these system together") 693 694 if dumpfile: 695 self.etherdump = EtherDump(file=dumpfile) 696 self.etherlink.dump = Parent.etherdump 697 698 return self 699 700 701def makeDistRoot(testSystem, 702 rank, 703 size, 704 server_name, 705 server_port, 706 sync_repeat, 707 sync_start, 708 linkspeed, 709 linkdelay, 710 dumpfile): 711 self = Root(full_system = True) 712 self.testsys = testSystem 713 714 self.etherlink = DistEtherLink(speed = linkspeed, 715 delay = linkdelay, 716 dist_rank = rank, 717 dist_size = size, 718 server_name = server_name, 719 server_port = server_port, 720 sync_start = sync_start, 721 sync_repeat = sync_repeat) 722 723 if hasattr(testSystem, 'realview'): 724 self.etherlink.int0 = Parent.testsys.realview.ethernet.interface 725 elif hasattr(testSystem, 'tsunami'): 726 self.etherlink.int0 = Parent.testsys.tsunami.ethernet.interface 727 else: 728 fatal("Don't know how to connect DistEtherLink to this system") 729 730 if dumpfile: 731 self.etherdump = EtherDump(file=dumpfile) 732 self.etherlink.dump = Parent.etherdump 733 734 return self 735