[edb57bc6] | 1 | #!/usr/bin/env python3
|
---|
[df64dbc] | 2 | #
|
---|
[3f4c537a] | 3 | # Copyright (c) 2013 Jakub Jermar
|
---|
[df64dbc] | 4 | # All rights reserved.
|
---|
| 5 | #
|
---|
| 6 | # Redistribution and use in source and binary forms, with or without
|
---|
| 7 | # modification, are permitted provided that the following conditions
|
---|
| 8 | # are met:
|
---|
| 9 | #
|
---|
| 10 | # - Redistributions of source code must retain the above copyright
|
---|
| 11 | # notice, this list of conditions and the following disclaimer.
|
---|
| 12 | # - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | # notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | # documentation and/or other materials provided with the distribution.
|
---|
| 15 | # - The name of the author may not be used to endorse or promote products
|
---|
| 16 | # derived from this software without specific prior written permission.
|
---|
| 17 | #
|
---|
| 18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | #
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | """
|
---|
| 32 | Emulator wrapper for running HelenOS
|
---|
| 33 | """
|
---|
| 34 |
|
---|
[4b65f9a] | 35 | import inspect
|
---|
[1c24c7c] | 36 | import os
|
---|
[8a26f82] | 37 | import platform
|
---|
[1783f75] | 38 | import re
|
---|
| 39 | import subprocess
|
---|
| 40 | import sys
|
---|
[663f445f] | 41 | import _thread
|
---|
[df425da] | 42 | import time
|
---|
[df64dbc] | 43 |
|
---|
[f5ceb18] | 44 | overrides = {}
|
---|
| 45 |
|
---|
[1783f75] | 46 | CONFIG = 'Makefile.config'
|
---|
| 47 |
|
---|
[4b65f9a] | 48 | TOOLS_DIR = os.path.dirname(inspect.getabsfile(inspect.currentframe()))
|
---|
| 49 |
|
---|
[1783f75] | 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
|
---|
| 63 |
|
---|
[f5ceb18] | 64 | def is_override(str):
|
---|
| 65 | if str in overrides.keys():
|
---|
| 66 | return overrides[str]
|
---|
| 67 | return False
|
---|
| 68 |
|
---|
[df425da] | 69 | def cfg_get(platform, machine, processor):
|
---|
[663f445f] | 70 | if machine == "" or "run" in emulators[platform]:
|
---|
[f5ceb18] | 71 | return emulators[platform]
|
---|
[663f445f] | 72 | elif processor == "" or "run" in emulators[platform][machine]:
|
---|
[f5ceb18] | 73 | return emulators[platform][machine]
|
---|
[df425da] | 74 | else:
|
---|
| 75 | return emulators[platform][machine][processor]
|
---|
[f5ceb18] | 76 |
|
---|
[e4c8e3cf] | 77 | def termemu_detect():
|
---|
[ac49d23c] | 78 | emus = ['gnome-terminal', 'xfce4-terminal', 'xterm']
|
---|
| 79 | for termemu in emus:
|
---|
[e4c8e3cf] | 80 | try:
|
---|
| 81 | subprocess.check_output('which ' + termemu, shell = True)
|
---|
| 82 | return termemu
|
---|
| 83 | except:
|
---|
| 84 | pass
|
---|
| 85 |
|
---|
[ac49d23c] | 86 | print('Could not find any of the terminal emulators %s.'%(emus))
|
---|
| 87 | sys.exit(1)
|
---|
| 88 |
|
---|
[df64dbc] | 89 | def run_in_console(cmd, title):
|
---|
[ac49d23c] | 90 | temu = termemu_detect()
|
---|
| 91 | if temu == 'gnome-terminal':
|
---|
[ecf0a04b] | 92 | cmdline = temu + ' -- ' + cmd
|
---|
[ac49d23c] | 93 | else:
|
---|
[ecf0a04b] | 94 | ecmd = cmd.replace('"', '\\"')
|
---|
[ac49d23c] | 95 | cmdline = temu + ' -T ' + '"' + title + '"' + ' -e "' + ecmd + '"'
|
---|
| 96 |
|
---|
[e4a1497] | 97 | print(cmdline)
|
---|
[f5ceb18] | 98 | if not is_override('dryrun'):
|
---|
[e4c8e3cf] | 99 | subprocess.call(cmdline, shell = True)
|
---|
[df64dbc] | 100 |
|
---|
[8a26f82] | 101 | def get_host_native_width():
|
---|
| 102 | return int(platform.architecture()[0].strip('bit'))
|
---|
| 103 |
|
---|
| 104 | def pc_options(guest_width):
|
---|
| 105 | opts = ''
|
---|
[a35b458] | 106 |
|
---|
[8a26f82] | 107 | # Do not enable KVM if running 64 bits HelenOS
|
---|
| 108 | # on 32 bits host
|
---|
| 109 | host_width = get_host_native_width()
|
---|
[f5ceb18] | 110 | if guest_width <= host_width and not is_override('nokvm'):
|
---|
[8a26f82] | 111 | opts = opts + ' -enable-kvm'
|
---|
[a35b458] | 112 |
|
---|
[8a26f82] | 113 | # Remove the leading space
|
---|
| 114 | return opts[1:]
|
---|
[df64dbc] | 115 |
|
---|
| 116 | def malta_options():
|
---|
[dabaa83] | 117 | return '-cpu 4Kc -append "console=devices/\\hw\\pci0\\00:0a.0\\com1\\a"'
|
---|
[df64dbc] | 118 |
|
---|
[739bc43] | 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
|
---|
| 136 |
|
---|
[9185e42] | 137 | def platform_to_qemu_options(platform, machine, processor):
|
---|
[df64dbc] | 138 | if platform == 'amd64':
|
---|
[8a26f82] | 139 | return 'system-x86_64', pc_options(64)
|
---|
[df64dbc] | 140 | elif platform == 'arm32':
|
---|
[83b01c2] | 141 | return 'system-arm', '-M integratorcp'
|
---|
[84176f3] | 142 | elif platform == 'arm64':
|
---|
[739bc43] | 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 "
|
---|
[dc69b5c] | 150 | "http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd.\n")
|
---|
[739bc43] | 151 | efi_path = find_firmware(
|
---|
| 152 | "EDK2", 'EW_QEMU_EFI_AARCH64', default_paths, extra_info)
|
---|
| 153 | if efi_path is None:
|
---|
[84176f3] | 154 | raise Exception
|
---|
[739bc43] | 155 |
|
---|
[84176f3] | 156 | return 'system-aarch64', \
|
---|
[739bc43] | 157 | '-M virt -cpu cortex-a57 -m 1024 -bios %s' % efi_path
|
---|
[df64dbc] | 158 | elif platform == 'ia32':
|
---|
[8a26f82] | 159 | return 'system-i386', pc_options(32)
|
---|
[df64dbc] | 160 | elif platform == 'mips32':
|
---|
| 161 | if machine == 'lmalta':
|
---|
| 162 | return 'system-mipsel', malta_options()
|
---|
| 163 | elif machine == 'bmalta':
|
---|
| 164 | return 'system-mips', malta_options()
|
---|
| 165 | elif platform == 'ppc32':
|
---|
[644352c] | 166 | return 'system-ppc', '-m 256'
|
---|
[df64dbc] | 167 | elif platform == 'sparc64':
|
---|
[9185e42] | 168 | if machine != 'generic':
|
---|
| 169 | raise Exception
|
---|
| 170 | if processor == 'us':
|
---|
[7f4937e] | 171 | return 'system-sparc64', '-M sun4u --prom-env boot-args="console=devices/\\hw\\pci0\\01:01.0\\com1\\a"'
|
---|
[739bc43] | 172 |
|
---|
| 173 | # processor = 'sun4v'
|
---|
| 174 | opensparc_bins = find_firmware(
|
---|
| 175 | "OpenSPARC", 'OPENSPARC_BINARIES',
|
---|
| 176 | ('/usr/local/opensparc/image/', ))
|
---|
| 177 | if opensparc_bins is None:
|
---|
[9185e42] | 178 | raise Exception
|
---|
| 179 |
|
---|
| 180 | return 'system-sparc64', '-M niagara -m 256 -L %s' % (opensparc_bins)
|
---|
| 181 |
|
---|
[df64dbc] | 182 |
|
---|
[129b92c6] | 183 | def hdisk_mk():
|
---|
[df64dbc] | 184 | if not os.path.exists('hdisk.img'):
|
---|
[4b65f9a] | 185 | subprocess.call(TOOLS_DIR + '/mkfat.py 1048576 dist/data hdisk.img', shell = True)
|
---|
[f5ceb18] | 186 |
|
---|
[129b92c6] | 187 | def qemu_bd_options():
|
---|
| 188 | if is_override('nohdd'):
|
---|
| 189 | return ''
|
---|
[a35b458] | 190 |
|
---|
[129b92c6] | 191 | hdisk_mk()
|
---|
[a35b458] | 192 |
|
---|
[13eecc4] | 193 | hdd_options = ''
|
---|
| 194 | if 'hdd' in overrides.keys():
|
---|
| 195 | if 'ata' in overrides['hdd'].keys():
|
---|
| 196 | hdd_options += ''
|
---|
| 197 | elif 'virtio-blk' in overrides['hdd'].keys():
|
---|
| 198 | hdd_options += ',if=virtio'
|
---|
| 199 |
|
---|
| 200 | return ' -drive file=hdisk.img,index=0,media=disk,format=raw' + hdd_options
|
---|
[df64dbc] | 201 |
|
---|
| 202 | def qemu_nic_ne2k_options():
|
---|
[d4b7b29] | 203 | return ' -device ne2k_isa,irq=5,netdev=n1'
|
---|
[df64dbc] | 204 |
|
---|
| 205 | def qemu_nic_e1k_options():
|
---|
[d4b7b29] | 206 | return ' -device e1000,netdev=n1'
|
---|
[df64dbc] | 207 |
|
---|
| 208 | def qemu_nic_rtl8139_options():
|
---|
[d4b7b29] | 209 | return ' -device rtl8139,netdev=n1'
|
---|
[df64dbc] | 210 |
|
---|
[7bf16b7e] | 211 | def qemu_nic_virtio_options():
|
---|
[d4b7b29] | 212 | return ' -device virtio-net,netdev=n1'
|
---|
[7bf16b7e] | 213 |
|
---|
[df64dbc] | 214 | def qemu_net_options():
|
---|
[f5ceb18] | 215 | if is_override('nonet'):
|
---|
| 216 | return ''
|
---|
| 217 |
|
---|
| 218 | nic_options = ''
|
---|
| 219 | if 'net' in overrides.keys():
|
---|
| 220 | if 'e1k' in overrides['net'].keys():
|
---|
| 221 | nic_options += qemu_nic_e1k_options()
|
---|
| 222 | if 'rtl8139' in overrides['net'].keys():
|
---|
| 223 | nic_options += qemu_nic_rtl8139_options()
|
---|
| 224 | if 'ne2k' in overrides['net'].keys():
|
---|
| 225 | nic_options += qemu_nic_ne2k_options()
|
---|
[7bf16b7e] | 226 | if 'virtio-net' in overrides['net'].keys():
|
---|
| 227 | nic_options += qemu_nic_virtio_options()
|
---|
[f5ceb18] | 228 | else:
|
---|
| 229 | # Use the default NIC
|
---|
| 230 | nic_options += qemu_nic_e1k_options()
|
---|
| 231 |
|
---|
[d4b7b29] | 232 | return nic_options + ' -netdev user,id=n1,hostfwd=udp::8080-:8080,hostfwd=udp::8081-:8081,hostfwd=tcp::8080-:8080,hostfwd=tcp::8081-:8081,hostfwd=tcp::2223-:2223'
|
---|
[df64dbc] | 233 |
|
---|
| 234 | def qemu_usb_options():
|
---|
[f5ceb18] | 235 | if is_override('nousb'):
|
---|
| 236 | return ''
|
---|
| 237 | return ' -usb'
|
---|
[df64dbc] | 238 |
|
---|
[5119d34] | 239 | def qemu_xhci_options():
|
---|
| 240 | if is_override('noxhci'):
|
---|
| 241 | return ''
|
---|
| 242 | return ' -device nec-usb-xhci,id=xhci'
|
---|
| 243 |
|
---|
[27de618] | 244 | def qemu_tablet_options():
|
---|
| 245 | if is_override('notablet') or (is_override('nousb') and is_override('noxhci')):
|
---|
| 246 | return ''
|
---|
| 247 | return ' -device usb-tablet'
|
---|
| 248 |
|
---|
[f5ceb18] | 249 | def qemu_audio_options():
|
---|
| 250 | if is_override('nosnd'):
|
---|
| 251 | return ''
|
---|
[089901e] | 252 | return ' -device intel-hda -device hda-duplex'
|
---|
[f5ceb18] | 253 |
|
---|
[df425da] | 254 | def qemu_run(platform, machine, processor):
|
---|
| 255 | cfg = cfg_get(platform, machine, processor)
|
---|
[9185e42] | 256 | suffix, options = platform_to_qemu_options(platform, machine, processor)
|
---|
[df64dbc] | 257 | cmd = 'qemu-' + suffix
|
---|
| 258 |
|
---|
| 259 | cmdline = cmd
|
---|
[3692678] | 260 | if 'qemu_path' in overrides.keys():
|
---|
| 261 | cmdline = overrides['qemu_path'] + cmd
|
---|
| 262 |
|
---|
[df64dbc] | 263 | if options != '':
|
---|
| 264 | cmdline += ' ' + options
|
---|
| 265 |
|
---|
[84176f3] | 266 | if (not 'hdd' in cfg.keys() or cfg['hdd']):
|
---|
| 267 | cmdline += qemu_bd_options()
|
---|
[f5ceb18] | 268 | if (not 'net' in cfg.keys()) or cfg['net']:
|
---|
[df64dbc] | 269 | cmdline += qemu_net_options()
|
---|
[f5ceb18] | 270 | if (not 'usb' in cfg.keys()) or cfg['usb']:
|
---|
[df64dbc] | 271 | cmdline += qemu_usb_options()
|
---|
[5119d34] | 272 | if (not 'xhci' in cfg.keys()) or cfg['xhci']:
|
---|
| 273 | cmdline += qemu_xhci_options()
|
---|
[27de618] | 274 | if (not 'tablet' in cfg.keys()) or cfg['tablet']:
|
---|
| 275 | cmdline += qemu_tablet_options()
|
---|
[f5ceb18] | 276 | if (not 'audio' in cfg.keys()) or cfg['audio']:
|
---|
| 277 | cmdline += qemu_audio_options()
|
---|
[a35b458] | 278 |
|
---|
[868d75c] | 279 | console = ('console' in cfg.keys() and cfg['console'])
|
---|
| 280 |
|
---|
[0ceeac3] | 281 | if (is_override('nographic')):
|
---|
| 282 | cmdline += ' -nographic'
|
---|
| 283 |
|
---|
[868d75c] | 284 | if (not console and (not is_override('nographic')) and not is_override('noserial')):
|
---|
[01552e3] | 285 | cmdline += ' -serial stdio'
|
---|
[2fc9bfd] | 286 |
|
---|
[abf8bd8] | 287 | if (is_override('bigmem')):
|
---|
| 288 | cmdline += ' -m 4G'
|
---|
| 289 |
|
---|
[f5ceb18] | 290 | if cfg['image'] == 'image.iso':
|
---|
[4b65f9a] | 291 | cmdline += ' -boot d -cdrom image.iso'
|
---|
[84176f3] | 292 | elif cfg['image'] == 'image.iso@arm64':
|
---|
| 293 | # Define image.iso cdrom backend.
|
---|
[4b65f9a] | 294 | cmdline += ' -drive if=none,file=image.iso,id=cdrom,media=cdrom'
|
---|
[84176f3] | 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'
|
---|
[f5ceb18] | 299 | elif cfg['image'] == 'image.boot':
|
---|
[4b65f9a] | 300 | cmdline += ' -kernel image.boot'
|
---|
[9185e42] | 301 | else:
|
---|
| 302 | cmdline += ' ' + cfg['image']
|
---|
[df64dbc] | 303 |
|
---|
[868d75c] | 304 | if console:
|
---|
[df64dbc] | 305 | cmdline += ' -nographic'
|
---|
| 306 |
|
---|
| 307 | title = 'HelenOS/' + platform
|
---|
| 308 | if machine != '':
|
---|
| 309 | title += ' on ' + machine
|
---|
[9185e42] | 310 | if 'expect' in cfg.keys():
|
---|
| 311 | cmdline = 'expect -c \'spawn %s; expect "%s" { send "%s" } timeout exp_continue; interact\'' % (cmdline, cfg['expect']['src'], cfg['expect']['dst'])
|
---|
[df64dbc] | 312 | run_in_console(cmdline, title)
|
---|
| 313 | else:
|
---|
[e4a1497] | 314 | print(cmdline)
|
---|
[f5ceb18] | 315 | if not is_override('dryrun'):
|
---|
| 316 | subprocess.call(cmdline, shell = True)
|
---|
[3f4c537a] | 317 |
|
---|
[df425da] | 318 | def ski_run(platform, machine, processor):
|
---|
[4b65f9a] | 319 | run_in_console('ski -i ' + TOOLS_DIR + '/conf/ski.conf', 'HelenOS/ia64 on ski')
|
---|
[df64dbc] | 320 |
|
---|
[df425da] | 321 | def msim_run(platform, machine, processor):
|
---|
[129b92c6] | 322 | hdisk_mk()
|
---|
[4b65f9a] | 323 | run_in_console('msim -c ' + TOOLS_DIR + '/conf/msim.conf', 'HelenOS/mips32 on msim')
|
---|
[df64dbc] | 324 |
|
---|
[3f4c537a] | 325 | def spike_run(platform, machine, processor):
|
---|
[4b65f9a] | 326 | run_in_console('spike -m1073741824:1073741824 image.boot', 'HelenOS/risvc64 on Spike')
|
---|
[3f4c537a] | 327 |
|
---|
[f5ceb18] | 328 | emulators = {
|
---|
| 329 | 'amd64' : {
|
---|
| 330 | 'run' : qemu_run,
|
---|
| 331 | 'image' : 'image.iso'
|
---|
| 332 | },
|
---|
| 333 | 'arm32' : {
|
---|
| 334 | 'integratorcp' : {
|
---|
| 335 | 'run' : qemu_run,
|
---|
| 336 | 'image' : 'image.boot',
|
---|
| 337 | 'net' : False,
|
---|
[a1a81f69] | 338 | 'audio' : False,
|
---|
| 339 | 'xhci' : False,
|
---|
| 340 | 'tablet' : False
|
---|
[f5ceb18] | 341 | }
|
---|
| 342 | },
|
---|
[84176f3] | 343 | 'arm64' : {
|
---|
| 344 | 'virt' : {
|
---|
| 345 | 'run' : qemu_run,
|
---|
| 346 | 'image' : 'image.iso@arm64',
|
---|
| 347 | 'audio' : False,
|
---|
[01552e3] | 348 | 'console' : True,
|
---|
[84176f3] | 349 | 'hdd' : False,
|
---|
| 350 | 'net' : False,
|
---|
| 351 | 'tablet' : False,
|
---|
| 352 | 'usb' : False,
|
---|
| 353 | 'xhci' : False
|
---|
| 354 | }
|
---|
| 355 | },
|
---|
[f5ceb18] | 356 | 'ia32' : {
|
---|
| 357 | 'run' : qemu_run,
|
---|
| 358 | 'image' : 'image.iso'
|
---|
| 359 | },
|
---|
| 360 | 'ia64' : {
|
---|
| 361 | 'ski' : {
|
---|
| 362 | 'run' : ski_run
|
---|
| 363 | }
|
---|
| 364 | },
|
---|
| 365 | 'mips32' : {
|
---|
| 366 | 'msim' : {
|
---|
| 367 | 'run' : msim_run
|
---|
| 368 | },
|
---|
| 369 | 'lmalta' : {
|
---|
| 370 | 'run' : qemu_run,
|
---|
| 371 | 'image' : 'image.boot',
|
---|
[868d75c] | 372 | 'console' : True
|
---|
[f5ceb18] | 373 | },
|
---|
| 374 | 'bmalta' : {
|
---|
| 375 | 'run' : qemu_run,
|
---|
| 376 | 'image' : 'image.boot',
|
---|
[868d75c] | 377 | 'console' : True
|
---|
[f5ceb18] | 378 | },
|
---|
| 379 | },
|
---|
| 380 | 'ppc32' : {
|
---|
| 381 | 'run' : qemu_run,
|
---|
| 382 | 'image' : 'image.iso',
|
---|
| 383 | 'audio' : False
|
---|
| 384 | },
|
---|
[3f4c537a] | 385 | 'riscv64' : {
|
---|
| 386 | 'run' : spike_run,
|
---|
| 387 | 'image' : 'image.boot'
|
---|
| 388 | },
|
---|
[f5ceb18] | 389 | 'sparc64' : {
|
---|
| 390 | 'generic' : {
|
---|
[df425da] | 391 | 'us' : {
|
---|
| 392 | 'run' : qemu_run,
|
---|
| 393 | 'image' : 'image.iso',
|
---|
[0195374] | 394 | 'audio' : False,
|
---|
[868d75c] | 395 | 'console' : True,
|
---|
[fd57cf17] | 396 | 'net' : False,
|
---|
| 397 | 'usb' : False,
|
---|
| 398 | 'xhci' : False,
|
---|
| 399 | 'tablet' : False
|
---|
[df425da] | 400 | },
|
---|
| 401 | 'sun4v' : {
|
---|
[9185e42] | 402 | 'run' : qemu_run,
|
---|
[4b65f9a] | 403 | 'image' : '-drive if=pflash,readonly=on,file=image.iso',
|
---|
[9185e42] | 404 | 'audio' : False,
|
---|
[868d75c] | 405 | 'console' : True,
|
---|
[9185e42] | 406 | 'net' : False,
|
---|
| 407 | 'usb' : False,
|
---|
[fd57cf17] | 408 | 'xhci' : False,
|
---|
| 409 | 'tablet' : False,
|
---|
[9185e42] | 410 | 'expect' : {
|
---|
| 411 | 'src' : 'ok ',
|
---|
| 412 | 'dst' : 'boot\n'
|
---|
| 413 | },
|
---|
[df425da] | 414 | }
|
---|
[f5ceb18] | 415 | }
|
---|
| 416 | },
|
---|
| 417 | }
|
---|
| 418 |
|
---|
| 419 | def usage():
|
---|
| 420 | print("%s - emulator wrapper for running HelenOS\n" % os.path.basename(sys.argv[0]))
|
---|
[13eecc4] | 421 | print("%s [-d] [-h] [-net e1k|rtl8139|ne2k|virtio-net] [-hdd ata|virtio-blk] [-nohdd] [-nokvm] [-nonet] [-nosnd] [-nousb] [-noxhci] [-notablet]\n" %
|
---|
[f5ceb18] | 422 | os.path.basename(sys.argv[0]))
|
---|
| 423 | print("-d\tDry run: do not run the emulation, just print the command line.")
|
---|
| 424 | print("-h\tPrint the usage information and exit.")
|
---|
| 425 | print("-nohdd\tDisable hard disk, if applicable.")
|
---|
| 426 | print("-nokvm\tDisable KVM, if applicable.")
|
---|
| 427 | print("-nonet\tDisable networking support, if applicable.")
|
---|
| 428 | print("-nosnd\tDisable sound, if applicable.")
|
---|
| 429 | print("-nousb\tDisable USB support, if applicable.")
|
---|
[5119d34] | 430 | print("-noxhci\tDisable XHCI support, if applicable.")
|
---|
[27de618] | 431 | print("-notablet\tDisable USB tablet (use only relative-position PS/2 mouse instead), if applicable.")
|
---|
[abf8bd8] | 432 | print("-nographic\tDisable graphical output. Serial port output must be enabled for this to be useful.")
|
---|
[2fc9bfd] | 433 | print("-noserial\tDisable serial port output in the terminal.")
|
---|
[abf8bd8] | 434 | print("-bigmem\tSets maximum RAM size to 4GB.")
|
---|
[df64dbc] | 435 |
|
---|
[df425da] | 436 | def fail(platform, machine):
|
---|
| 437 | print("Cannot start emulation for the chosen configuration. (%s/%s)" % (platform, machine))
|
---|
[a35b458] | 438 |
|
---|
[df425da] | 439 |
|
---|
[df64dbc] | 440 | def run():
|
---|
[f5ceb18] | 441 | expect_nic = False
|
---|
[13eecc4] | 442 | expect_hdd = False
|
---|
[3692678] | 443 | expect_qemu = False
|
---|
[f5ceb18] | 444 |
|
---|
| 445 | for i in range(1, len(sys.argv)):
|
---|
| 446 |
|
---|
| 447 | if expect_nic:
|
---|
| 448 | expect_nic = False
|
---|
| 449 | if not 'net' in overrides.keys():
|
---|
| 450 | overrides['net'] = {}
|
---|
| 451 | if sys.argv[i] == 'e1k':
|
---|
| 452 | overrides['net']['e1k'] = True
|
---|
| 453 | elif sys.argv[i] == 'rtl8139':
|
---|
| 454 | overrides['net']['rtl8139'] = True
|
---|
| 455 | elif sys.argv[i] == 'ne2k':
|
---|
| 456 | overrides['net']['ne2k'] = True
|
---|
[7bf16b7e] | 457 | elif sys.argv[i] == 'virtio-net':
|
---|
| 458 | overrides['net']['virtio-net'] = True
|
---|
[f5ceb18] | 459 | else:
|
---|
| 460 | usage()
|
---|
| 461 | exit()
|
---|
[f134413] | 462 | continue
|
---|
[f5ceb18] | 463 |
|
---|
[13eecc4] | 464 | if expect_hdd:
|
---|
| 465 | expect_hdd = False
|
---|
| 466 | if not 'hdd' in overrides.keys():
|
---|
| 467 | overrides['hdd'] = {}
|
---|
| 468 | if sys.argv[i] == 'ata':
|
---|
| 469 | overrides['hdd']['ata'] = True
|
---|
| 470 | elif sys.argv[i] == 'virtio-blk':
|
---|
| 471 | overrides['hdd']['virtio-blk'] = True
|
---|
| 472 | else:
|
---|
| 473 | usage()
|
---|
| 474 | exit()
|
---|
| 475 | continue
|
---|
| 476 |
|
---|
[3692678] | 477 | if expect_qemu:
|
---|
| 478 | expect_qemu = False
|
---|
| 479 | overrides['qemu_path'] = sys.argv[i]
|
---|
| 480 |
|
---|
[f5ceb18] | 481 | elif sys.argv[i] == '-h':
|
---|
| 482 | usage()
|
---|
| 483 | exit()
|
---|
| 484 | elif sys.argv[i] == '-d':
|
---|
| 485 | overrides['dryrun'] = True
|
---|
| 486 | elif sys.argv[i] == '-net' and i < len(sys.argv) - 1:
|
---|
| 487 | expect_nic = True
|
---|
[13eecc4] | 488 | elif sys.argv[i] == '-hdd' and i < len(sys.argv) - 1:
|
---|
| 489 | expect_hdd = True
|
---|
[f5ceb18] | 490 | elif sys.argv[i] == '-nohdd':
|
---|
| 491 | overrides['nohdd'] = True
|
---|
| 492 | elif sys.argv[i] == '-nokvm':
|
---|
| 493 | overrides['nokvm'] = True
|
---|
| 494 | elif sys.argv[i] == '-nonet':
|
---|
| 495 | overrides['nonet'] = True
|
---|
| 496 | elif sys.argv[i] == '-nosnd':
|
---|
| 497 | overrides['nosnd'] = True
|
---|
| 498 | elif sys.argv[i] == '-nousb':
|
---|
| 499 | overrides['nousb'] = True
|
---|
[5119d34] | 500 | elif sys.argv[i] == '-noxhci':
|
---|
| 501 | overrides['noxhci'] = True
|
---|
[27de618] | 502 | elif sys.argv[i] == '-notablet':
|
---|
| 503 | overrides['notablet'] = True
|
---|
[0ceeac3] | 504 | elif sys.argv[i] == '-nographic':
|
---|
| 505 | overrides['nographic'] = True
|
---|
[abf8bd8] | 506 | elif sys.argv[i] == '-bigmem':
|
---|
| 507 | overrides['bigmem'] = True
|
---|
[2fc9bfd] | 508 | elif sys.argv[i] == '-noserial':
|
---|
| 509 | overrides['noserial'] = True
|
---|
[3692678] | 510 | elif sys.argv[i] == '-qemu_path' and i < len(sys.argv) - 1:
|
---|
| 511 | expect_qemu = True
|
---|
[f5ceb18] | 512 | else:
|
---|
| 513 | usage()
|
---|
| 514 | exit()
|
---|
| 515 |
|
---|
[1783f75] | 516 | config = read_config()
|
---|
[df64dbc] | 517 |
|
---|
[f5ceb18] | 518 | if 'PLATFORM' in config.keys():
|
---|
[df64dbc] | 519 | platform = config['PLATFORM']
|
---|
[f5ceb18] | 520 | else:
|
---|
[df64dbc] | 521 | platform = ''
|
---|
| 522 |
|
---|
[f5ceb18] | 523 | if 'MACHINE' in config.keys():
|
---|
[df64dbc] | 524 | mach = config['MACHINE']
|
---|
[f5ceb18] | 525 | else:
|
---|
[df64dbc] | 526 | mach = ''
|
---|
| 527 |
|
---|
[df425da] | 528 | if 'PROCESSOR' in config.keys():
|
---|
| 529 | processor = config['PROCESSOR']
|
---|
| 530 | else:
|
---|
| 531 | processor = ''
|
---|
| 532 |
|
---|
[df64dbc] | 533 | try:
|
---|
[df425da] | 534 | emu_run = cfg_get(platform, mach, processor)['run']
|
---|
| 535 | emu_run(platform, mach, processor)
|
---|
[df64dbc] | 536 | except:
|
---|
[df425da] | 537 | fail(platform, mach)
|
---|
[df64dbc] | 538 | return
|
---|
| 539 |
|
---|
| 540 | run()
|
---|