Changeset bc73be3 in mainline for tools/ew.py
- Timestamp:
- 2019-06-27T08:51:20Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8add15e0
- Parents:
- ad40b74b (diff), aeba767 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/ew.py
rad40b74b rbc73be3 57 57 58 58 def termemu_detect(): 59 for termemu in ['xfce4-terminal', 'xterm']: 59 emus = ['gnome-terminal', 'xfce4-terminal', 'xterm'] 60 for termemu in emus: 60 61 try: 61 62 subprocess.check_output('which ' + termemu, shell = True) … … 64 65 pass 65 66 67 print('Could not find any of the terminal emulators %s.'%(emus)) 68 sys.exit(1) 69 66 70 def run_in_console(cmd, title): 67 ecmd = cmd.replace('"', '\\"') 68 cmdline = termemu_detect() + ' -T ' + '"' + title + '"' + ' -e "' + ecmd + '"' 71 temu = termemu_detect() 72 if temu == 'gnome-terminal': 73 cmdline = temu + ' -- ' + cmd 74 else: 75 ecmd = cmd.replace('"', '\\"') 76 cmdline = temu + ' -T ' + '"' + title + '"' + ' -e "' + ecmd + '"' 77 69 78 print(cmdline) 70 79 if not is_override('dryrun'): … … 87 96 88 97 def malta_options(): 89 return '-cpu 4Kc' 98 return '-cpu 4Kc -append "console=devices/\\hw\\pci0\\00:0a.0\\com1\\a"' 99 100 def find_firmware(name, environ_var, default_paths, extra_info=None): 101 """Find firmware image(s).""" 102 103 if environ_var in os.environ: 104 return os.environ[environ_var] 105 106 for path in default_paths: 107 if os.path.exists(path): 108 return path 109 110 sys.stderr.write("Cannot find %s binary image(s)!\n" % name) 111 sys.stderr.write( 112 "Either set %s environment variable accordingly or place the image(s) in one of the default locations: %s.\n" % 113 (environ_var, ", ".join(default_paths))) 114 if extra_info is not None: 115 sys.stderr.write(extra_info) 116 return None 90 117 91 118 def platform_to_qemu_options(platform, machine, processor): … … 94 121 elif platform == 'arm32': 95 122 return 'system-arm', '-M integratorcp' 123 elif platform == 'arm64': 124 # Search for the EDK2 firmware image 125 default_paths = ( 126 '/usr/local/qemu-efi-aarch64/QEMU_EFI.fd', # Custom 127 '/usr/share/edk2/aarch64/QEMU_EFI.fd', # Fedora 128 '/usr/share/qemu-efi-aarch64/QEMU_EFI.fd', # Ubuntu 129 ) 130 extra_info = ("Pre-compiled binary can be obtained from " 131 "http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_GCC49/QEMU_EFI.fd.\n") 132 efi_path = find_firmware( 133 "EDK2", 'EW_QEMU_EFI_AARCH64', default_paths, extra_info) 134 if efi_path is None: 135 raise Exception 136 137 return 'system-aarch64', \ 138 '-M virt -cpu cortex-a57 -m 1024 -bios %s' % efi_path 96 139 elif platform == 'ia32': 97 140 return 'system-i386', pc_options(32) … … 108 151 if processor == 'us': 109 152 return 'system-sparc64', '-M sun4u --prom-env boot-args="console=devices/\\hw\\pci0\\01:01.0\\com1\\a"' 110 elif processor == 'sun4v': 111 default_path = '/usr/local/opensparc/image/' 112 try: 113 if os.path.exists(default_path): 114 opensparc_bins = default_path 115 elif os.path.exists(os.environ['OPENSPARC_BINARIES']): 116 opensparc_bins = os.environ['OPENSPARC_BINARIES'] 117 else: 118 raise Exception 119 except: 120 print("Cannot find OpenSPARC binary images!") 121 print("Either set OPENSPARC_BINARIES environment variable accordingly or place the images in %s." % (default_path)) 153 154 # processor = 'sun4v' 155 opensparc_bins = find_firmware( 156 "OpenSPARC", 'OPENSPARC_BINARIES', 157 ('/usr/local/opensparc/image/', )) 158 if opensparc_bins is None: 122 159 raise Exception 123 160 … … 135 172 hdisk_mk() 136 173 137 return ' -drive file=hdisk.img,index=0,media=disk,format=raw' 174 hdd_options = '' 175 if 'hdd' in overrides.keys(): 176 if 'ata' in overrides['hdd'].keys(): 177 hdd_options += '' 178 elif 'virtio-blk' in overrides['hdd'].keys(): 179 hdd_options += ',if=virtio' 180 181 return ' -drive file=hdisk.img,index=0,media=disk,format=raw' + hdd_options 138 182 139 183 def qemu_nic_ne2k_options(): … … 201 245 cmdline += ' ' + options 202 246 203 cmdline += qemu_bd_options()204 247 if (not 'hdd' in cfg.keys() or cfg['hdd']): 248 cmdline += qemu_bd_options() 205 249 if (not 'net' in cfg.keys()) or cfg['net']: 206 250 cmdline += qemu_net_options() … … 227 271 if cfg['image'] == 'image.iso': 228 272 cmdline += ' -boot d -cdrom image.iso' 273 elif cfg['image'] == 'image.iso@arm64': 274 # Define image.iso cdrom backend. 275 cmdline += ' -drive if=none,file=image.iso,id=cdrom,media=cdrom' 276 # Define scsi bus. 277 cmdline += ' -device virtio-scsi-device' 278 # Define cdrom frontend connected to this scsi bus. 279 cmdline += ' -device scsi-cd,drive=cdrom' 229 280 elif cfg['image'] == 'image.boot': 230 281 cmdline += ' -kernel image.boot' … … 269 320 'xhci' : False, 270 321 'tablet' : False 322 } 323 }, 324 'arm64' : { 325 'virt' : { 326 'run' : qemu_run, 327 'image' : 'image.iso@arm64', 328 'audio' : False, 329 'console' : True, 330 'hdd' : False, 331 'net' : False, 332 'tablet' : False, 333 'usb' : False, 334 'xhci' : False 271 335 } 272 336 }, … … 336 400 def usage(): 337 401 print("%s - emulator wrapper for running HelenOS\n" % os.path.basename(sys.argv[0])) 338 print("%s [-d] [-h] [-net e1k|rtl8139|ne2k|virtio-net] [- nohdd] [-nokvm] [-nonet] [-nosnd] [-nousb] [-noxhci] [-notablet]\n" %402 print("%s [-d] [-h] [-net e1k|rtl8139|ne2k|virtio-net] [-hdd ata|virtio-blk] [-nohdd] [-nokvm] [-nonet] [-nosnd] [-nousb] [-noxhci] [-notablet]\n" % 339 403 os.path.basename(sys.argv[0])) 340 404 print("-d\tDry run: do not run the emulation, just print the command line.") … … 357 421 def run(): 358 422 expect_nic = False 423 expect_hdd = False 359 424 expect_qemu = False 360 425 … … 378 443 continue 379 444 445 if expect_hdd: 446 expect_hdd = False 447 if not 'hdd' in overrides.keys(): 448 overrides['hdd'] = {} 449 if sys.argv[i] == 'ata': 450 overrides['hdd']['ata'] = True 451 elif sys.argv[i] == 'virtio-blk': 452 overrides['hdd']['virtio-blk'] = True 453 else: 454 usage() 455 exit() 456 continue 457 380 458 if expect_qemu: 381 459 expect_qemu = False … … 389 467 elif sys.argv[i] == '-net' and i < len(sys.argv) - 1: 390 468 expect_nic = True 469 elif sys.argv[i] == '-hdd' and i < len(sys.argv) - 1: 470 expect_hdd = True 391 471 elif sys.argv[i] == '-nohdd': 392 472 overrides['nohdd'] = True
Note:
See TracChangeset
for help on using the changeset viewer.