Changeset 3e828ea in mainline for tools/ew.py
- Timestamp:
- 2019-09-23T12:49:29Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9be2358
- Parents:
- 9259d20 (diff), 1a4ec93f (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. - git-author:
- Jiri Svoboda <jiri@…> (2019-09-22 12:49:07)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-09-23 12:49:29)
- File:
-
- 1 edited
-
tools/ew.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tools/ew.py
r9259d20 r3e828ea 33 33 """ 34 34 35 import inspect 35 36 import os 37 import platform 38 import re 39 import subprocess 36 40 import sys 37 import subprocess38 import autotool39 import platform40 41 import thread 41 42 import time 42 43 43 44 overrides = {} 45 46 CONFIG = 'Makefile.config' 47 48 TOOLS_DIR = os.path.dirname(inspect.getabsfile(inspect.currentframe())) 49 50 def read_config(): 51 "Read HelenOS build configuration" 52 53 inf = open(CONFIG, 'r') 54 config = {} 55 56 for line in inf: 57 res = re.match(r'^(?:#!# )?([^#]\w*)\s*=\s*(.*?)\s*$', line) 58 if (res): 59 config[res.group(1)] = res.group(2) 60 61 inf.close() 62 return config 44 63 45 64 def is_override(str): … … 57 76 58 77 def termemu_detect(): 59 for termemu in ['xfce4-terminal', 'xterm']: 78 emus = ['gnome-terminal', 'xfce4-terminal', 'xterm'] 79 for termemu in emus: 60 80 try: 61 81 subprocess.check_output('which ' + termemu, shell = True) … … 64 84 pass 65 85 86 print('Could not find any of the terminal emulators %s.'%(emus)) 87 sys.exit(1) 88 66 89 def run_in_console(cmd, title): 67 ecmd = cmd.replace('"', '\\"') 68 cmdline = termemu_detect() + ' -T ' + '"' + title + '"' + ' -e "' + ecmd + '"' 90 temu = termemu_detect() 91 if temu == 'gnome-terminal': 92 cmdline = temu + ' -- ' + cmd 93 else: 94 ecmd = cmd.replace('"', '\\"') 95 cmdline = temu + ' -T ' + '"' + title + '"' + ' -e "' + ecmd + '"' 96 69 97 print(cmdline) 70 98 if not is_override('dryrun'): … … 87 115 88 116 def malta_options(): 89 return '-cpu 4Kc' 117 return '-cpu 4Kc -append "console=devices/\\hw\\pci0\\00:0a.0\\com1\\a"' 118 119 def find_firmware(name, environ_var, default_paths, extra_info=None): 120 """Find firmware image(s).""" 121 122 if environ_var in os.environ: 123 return os.environ[environ_var] 124 125 for path in default_paths: 126 if os.path.exists(path): 127 return path 128 129 sys.stderr.write("Cannot find %s binary image(s)!\n" % name) 130 sys.stderr.write( 131 "Either set %s environment variable accordingly or place the image(s) in one of the default locations: %s.\n" % 132 (environ_var, ", ".join(default_paths))) 133 if extra_info is not None: 134 sys.stderr.write(extra_info) 135 return None 90 136 91 137 def platform_to_qemu_options(platform, machine, processor): … … 94 140 elif platform == 'arm32': 95 141 return 'system-arm', '-M integratorcp' 142 elif platform == 'arm64': 143 # Search for the EDK2 firmware image 144 default_paths = ( 145 '/usr/local/qemu-efi-aarch64/QEMU_EFI.fd', # Custom 146 '/usr/share/edk2/aarch64/QEMU_EFI.fd', # Fedora 147 '/usr/share/qemu-efi-aarch64/QEMU_EFI.fd', # Ubuntu 148 ) 149 extra_info = ("Pre-compiled binary can be obtained from " 150 "http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_GCC49/QEMU_EFI.fd.\n") 151 efi_path = find_firmware( 152 "EDK2", 'EW_QEMU_EFI_AARCH64', default_paths, extra_info) 153 if efi_path is None: 154 raise Exception 155 156 return 'system-aarch64', \ 157 '-M virt -cpu cortex-a57 -m 1024 -bios %s' % efi_path 96 158 elif platform == 'ia32': 97 159 return 'system-i386', pc_options(32) … … 108 170 if processor == 'us': 109 171 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)) 172 173 # processor = 'sun4v' 174 opensparc_bins = find_firmware( 175 "OpenSPARC", 'OPENSPARC_BINARIES', 176 ('/usr/local/opensparc/image/', )) 177 if opensparc_bins is None: 122 178 raise Exception 123 179 … … 127 183 def hdisk_mk(): 128 184 if not os.path.exists('hdisk.img'): 129 subprocess.call( 'tools/mkfat.py 1048576 uspace/dist/data hdisk.img', shell = True)185 subprocess.call(TOOLS_DIR + '/mkfat.py 1048576 dist/data hdisk.img', shell = True) 130 186 131 187 def qemu_bd_options(): … … 208 264 cmdline += ' ' + options 209 265 210 cmdline += qemu_bd_options()211 266 if (not 'hdd' in cfg.keys() or cfg['hdd']): 267 cmdline += qemu_bd_options() 212 268 if (not 'net' in cfg.keys()) or cfg['net']: 213 269 cmdline += qemu_net_options() … … 234 290 if cfg['image'] == 'image.iso': 235 291 cmdline += ' -boot d -cdrom image.iso' 292 elif cfg['image'] == 'image.iso@arm64': 293 # Define image.iso cdrom backend. 294 cmdline += ' -drive if=none,file=image.iso,id=cdrom,media=cdrom' 295 # Define scsi bus. 296 cmdline += ' -device virtio-scsi-device' 297 # Define cdrom frontend connected to this scsi bus. 298 cmdline += ' -device scsi-cd,drive=cdrom' 236 299 elif cfg['image'] == 'image.boot': 237 300 cmdline += ' -kernel image.boot' … … 254 317 255 318 def ski_run(platform, machine, processor): 256 run_in_console('ski -i tools/conf/ski.conf', 'HelenOS/ia64 on ski')319 run_in_console('ski -i ' + TOOLS_DIR + '/conf/ski.conf', 'HelenOS/ia64 on ski') 257 320 258 321 def msim_run(platform, machine, processor): 259 322 hdisk_mk() 260 run_in_console('msim -c tools/conf/msim.conf', 'HelenOS/mips32 on msim')323 run_in_console('msim -c ' + TOOLS_DIR + '/conf/msim.conf', 'HelenOS/mips32 on msim') 261 324 262 325 def spike_run(platform, machine, processor): … … 276 339 'xhci' : False, 277 340 'tablet' : False 341 } 342 }, 343 'arm64' : { 344 'virt' : { 345 'run' : qemu_run, 346 'image' : 'image.iso@arm64', 347 'audio' : False, 348 'console' : True, 349 'hdd' : False, 350 'net' : False, 351 'tablet' : False, 352 'usb' : False, 353 'xhci' : False 278 354 } 279 355 }, … … 438 514 exit() 439 515 440 config = {} 441 autotool.read_config(autotool.CONFIG, config) 516 config = read_config() 442 517 443 518 if 'PLATFORM' in config.keys():
Note:
See TracChangeset
for help on using the changeset viewer.
