def createSystem(caches, kernel, bootscript, disks=[]): sys = devices.SimpleSystem(caches, default_mem_size, kernel=SysPaths.binary(kernel), readfile=bootscript) sys.mem_ctrls = [ SimpleMemory(range=r, port=sys.membus.master) for r in sys.mem_ranges ] sys.connect() # Attach disk images if disks: def cow_disk(image_file): image = CowDiskImage() image.child.image_file = SysPaths.disk(image_file) return image sys.disk_images = [cow_disk(f) for f in disks] sys.pci_vio_block = [ PciVirtIO(vio=VirtIOBlock(image=img)) for img in sys.disk_images ] for dev in sys.pci_vio_block: sys.attach_pci(dev) sys.realview.setupBootLoader(sys.membus, sys, SysPaths.binary) return sys
def createSystem(kernel, mem_mode, bootscript, disks=[]): sys = devices.SimpleSystem(kernel=SysPaths.binary(kernel), readfile=bootscript, mem_mode=mem_mode, machine_type="DTOnly") mem_region = sys.realview._mem_regions[0] sys.mem_ctrls = SimpleMemory( range=AddrRange(start=mem_region[0], size=default_mem_size)) sys.mem_ctrls.port = sys.membus.master sys.connect() # Attach disk images if disks: def cow_disk(image_file): image = CowDiskImage() image.child.image_file = SysPaths.disk(image_file) return image sys.disk_images = [ cow_disk(f) for f in disks ] sys.pci_vio_block = [ PciVirtIO(vio=VirtIOBlock(image=img)) for img in sys.disk_images ] for dev in sys.pci_vio_block: sys.attach_pci(dev) sys.realview.setupBootLoader(sys.membus, sys, SysPaths.binary) return sys
def createSystem(caches, kernel, bootscript, machine_type="VExpress_GEM5", disks=[]): platform = ObjectList.platform_list.get(machine_type) m5.util.inform("Simulated platform: %s", platform.__name__) sys = devices.SimpleSystem(caches, default_mem_size, platform(), kernel=SysPaths.binary(kernel), readfile=bootscript) sys.mem_ctrls = [ SimpleMemory(range=r, port=sys.membus.master) for r in sys.mem_ranges ] sys.connect() # Attach disk images if disks: def cow_disk(image_file): image = CowDiskImage() image.child.image_file = SysPaths.disk(image_file) return image sys.disk_images = [ cow_disk(f) for f in disks ] sys.pci_vio_block = [ PciVirtIO(vio=VirtIOBlock(image=img)) for img in sys.disk_images ] for dev in sys.pci_vio_block: sys.attach_pci(dev) sys.realview.setupBootLoader(sys.membus, sys, SysPaths.binary) return sys
def create(args): ''' Create and configure the system object. ''' if not args.dtb: dtb_file = SysPaths.binary("armv8_gem5_v1_%icpu.%s.dtb" % (args.num_cores, default_dist_version)) else: dtb_file = args.dtb if args.script and not os.path.isfile(args.script): print "Error: Bootscript %s does not exist" % args.script sys.exit(1) cpu_class = cpu_types[args.cpu][0] mem_mode = cpu_class.memory_mode() # Only simulate caches when using a timing CPU (e.g., the HPI model) want_caches = True if mem_mode == "timing" else False system = devices.SimpleSystem(want_caches, args.mem_size, mem_mode=mem_mode, dtb_filename=dtb_file, kernel=SysPaths.binary(args.kernel), readfile=args.script, machine_type="DTOnly") MemConfig.config_mem(args, system) # Add the PCI devices we need for this system. The base system # doesn't have any PCI devices by default since they are assumed # to be added by the configurastion scripts needin them. system.pci_devices = [ # Create a VirtIO block device for the system's boot # disk. Attach the disk image using gem5's Copy-on-Write # functionality to avoid writing changes to the stored copy of # the disk image. PciVirtIO(vio=VirtIOBlock(image=create_cow_image(args.disk_image))), ] # Attach the PCI devices to the system. The helper method in the # system assigns a unique PCI bus ID to each of the devices and # connects them to the IO bus. for dev in system.pci_devices: system.attach_pci(dev) # Wire up the system's memory system system.connect() # Add CPU clusters to the system system.cpu_cluster = [ devices.CpuCluster(system, args.num_cores, args.cpu_freq, "1.0V", *cpu_types[args.cpu]), ] # Create a cache hierarchy for the cluster. We are assuming that # clusters have core-private L1 caches and an L2 that's shared # within the cluster. for cluster in system.cpu_cluster: system.addCaches(want_caches, last_cache_level=2) # Setup gem5's minimal Linux boot loader. system.realview.setupBootLoader(system.membus, system, SysPaths.binary) # Linux boot command flags kernel_cmd = [ # Tell Linux to use the simulated serial port as a console "console=ttyAMA0", # Hard-code timi "lpj=19988480", # Disable address space randomisation to get a consistent # memory layout. "norandmaps", # Tell Linux where to find the root disk image. "root=/dev/vda1", # Mount the root disk read-write by default. "rw", # Tell Linux about the amount of physical memory present. "mem=%s" % args.mem_size, ] system.boot_osflags = " ".join(kernel_cmd) return system
def create(args): ''' Create and configure the system object. ''' if args.readfile and not os.path.isfile(args.readfile): print("Error: Bootscript %s does not exist" % args.readfile) sys.exit(1) object_file = args.kernel if args.kernel else "" cpu_class = cpu_types[args.cpu][0] mem_mode = cpu_class.memory_mode() # Only simulate caches when using a timing CPU (e.g., the HPI model) want_caches = True if mem_mode == "timing" else False platform = ObjectList.platform_list.get(args.machine_type) system = devices.SimpleSystem(want_caches, args.mem_size, platform=platform(), mem_mode=mem_mode, readfile=args.readfile) MemConfig.config_mem(args, system) if args.semi_enable: system.semihosting = ArmSemihosting( stdin=args.semi_stdin, stdout=args.semi_stdout, stderr=args.semi_stderr, files_root_dir=args.semi_path, cmd_line = " ".join([ object_file ] + args.args) ) if args.disk_image: # Create a VirtIO block device for the system's boot # disk. Attach the disk image using gem5's Copy-on-Write # functionality to avoid writing changes to the stored copy of # the disk image. system.realview.vio[0].vio = VirtIOBlock( image=create_cow_image(args.disk_image)) # Wire up the system's memory system system.connect() # Add CPU clusters to the system system.cpu_cluster = [ devices.CpuCluster(system, args.num_cores, args.cpu_freq, "1.0V", *cpu_types[args.cpu]), ] # Create a cache hierarchy for the cluster. We are assuming that # clusters have core-private L1 caches and an L2 that's shared # within the cluster. system.addCaches(want_caches, last_cache_level=2) # Setup gem5's minimal Linux boot loader. system.auto_reset_addr = True # Using GICv3 system.realview.gic.gicv4 = False system.highest_el_is_64 = True system.release.add(ArmExtension('SECURITY')) system.release.add(ArmExtension('VIRTUALIZATION')) workload_class = workloads.workload_list.get(args.workload) system.workload = workload_class( object_file, system) return system