[df64dbc] | 1 | #!/usr/bin/env python
|
---|
| 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 |
|
---|
[1c24c7c] | 35 | import os
|
---|
[f5ceb18] | 36 | import sys
|
---|
[1c24c7c] | 37 | import subprocess
|
---|
[df64dbc] | 38 | import autotool
|
---|
[8a26f82] | 39 | import platform
|
---|
[df425da] | 40 | import thread
|
---|
| 41 | import time
|
---|
[df64dbc] | 42 |
|
---|
[f5ceb18] | 43 | overrides = {}
|
---|
| 44 |
|
---|
| 45 | def is_override(str):
|
---|
| 46 | if str in overrides.keys():
|
---|
| 47 | return overrides[str]
|
---|
| 48 | return False
|
---|
| 49 |
|
---|
[df425da] | 50 | def cfg_get(platform, machine, processor):
|
---|
| 51 | if machine == "" or emulators[platform].has_key("run"):
|
---|
[f5ceb18] | 52 | return emulators[platform]
|
---|
[df425da] | 53 | elif processor == "" or emulators[platform][machine].has_key("run"):
|
---|
[f5ceb18] | 54 | return emulators[platform][machine]
|
---|
[df425da] | 55 | else:
|
---|
| 56 | return emulators[platform][machine][processor]
|
---|
[f5ceb18] | 57 |
|
---|
[e4c8e3cf] | 58 | def termemu_detect():
|
---|
| 59 | for termemu in ['xfce4-terminal', 'xterm']:
|
---|
| 60 | try:
|
---|
| 61 | subprocess.check_output('which ' + termemu, shell = True)
|
---|
| 62 | return termemu
|
---|
| 63 | except:
|
---|
| 64 | pass
|
---|
| 65 |
|
---|
[df64dbc] | 66 | def run_in_console(cmd, title):
|
---|
[1dab093] | 67 | ecmd = cmd.replace('"', '\\"')
|
---|
| 68 | cmdline = termemu_detect() + ' -T ' + '"' + title + '"' + ' -e "' + ecmd + '"'
|
---|
[e4a1497] | 69 | print(cmdline)
|
---|
[f5ceb18] | 70 | if not is_override('dryrun'):
|
---|
[e4c8e3cf] | 71 | subprocess.call(cmdline, shell = True)
|
---|
[df64dbc] | 72 |
|
---|
[8a26f82] | 73 | def get_host_native_width():
|
---|
| 74 | return int(platform.architecture()[0].strip('bit'))
|
---|
| 75 |
|
---|
| 76 | def pc_options(guest_width):
|
---|
| 77 | opts = ''
|
---|
[a35b458] | 78 |
|
---|
[8a26f82] | 79 | # Do not enable KVM if running 64 bits HelenOS
|
---|
| 80 | # on 32 bits host
|
---|
| 81 | host_width = get_host_native_width()
|
---|
[f5ceb18] | 82 | if guest_width <= host_width and not is_override('nokvm'):
|
---|
[8a26f82] | 83 | opts = opts + ' -enable-kvm'
|
---|
[a35b458] | 84 |
|
---|
[8a26f82] | 85 | # Remove the leading space
|
---|
| 86 | return opts[1:]
|
---|
[df64dbc] | 87 |
|
---|
| 88 | def malta_options():
|
---|
| 89 | return '-cpu 4Kc'
|
---|
| 90 |
|
---|
[9185e42] | 91 | def platform_to_qemu_options(platform, machine, processor):
|
---|
[df64dbc] | 92 | if platform == 'amd64':
|
---|
[8a26f82] | 93 | return 'system-x86_64', pc_options(64)
|
---|
[df64dbc] | 94 | elif platform == 'arm32':
|
---|
[83b01c2] | 95 | return 'system-arm', '-M integratorcp'
|
---|
[84176f3] | 96 | elif platform == 'arm64':
|
---|
| 97 | # Check that ROM image is present. Provide the user with
|
---|
| 98 | # appropriate steps to fix this problem.
|
---|
| 99 | if not os.path.exists('QEMU_EFI_ARM64.fd'):
|
---|
| 100 | sys.stderr.write('Could not find ' +
|
---|
| 101 | '\'QEMU_EFI_ARM64.fd\' which is expected to ' +
|
---|
| 102 | 'contain EDK2 firmware image.\n')
|
---|
| 103 | sys.stderr.write('Pre-built image can be obtained by ' +
|
---|
| 104 | 'running the following command:\n')
|
---|
| 105 | sys.stderr.write('$ wget http://snapshots.linaro.org/' +
|
---|
| 106 | 'components/kernel/leg-virt-tianocore-edk2-' +
|
---|
| 107 | 'upstream/latest/QEMU-AARCH64/RELEASE_GCC49/' +
|
---|
| 108 | 'QEMU_EFI.fd -O QEMU_EFI_ARM64.fd\n')
|
---|
| 109 | raise Exception
|
---|
| 110 | return 'system-aarch64', \
|
---|
| 111 | '-M virt -cpu cortex-a57 -m 1024 -bios QEMU_EFI_ARM64.fd'
|
---|
[df64dbc] | 112 | elif platform == 'ia32':
|
---|
[8a26f82] | 113 | return 'system-i386', pc_options(32)
|
---|
[df64dbc] | 114 | elif platform == 'mips32':
|
---|
| 115 | if machine == 'lmalta':
|
---|
| 116 | return 'system-mipsel', malta_options()
|
---|
| 117 | elif machine == 'bmalta':
|
---|
| 118 | return 'system-mips', malta_options()
|
---|
| 119 | elif platform == 'ppc32':
|
---|
[644352c] | 120 | return 'system-ppc', '-m 256'
|
---|
[df64dbc] | 121 | elif platform == 'sparc64':
|
---|
[9185e42] | 122 | if machine != 'generic':
|
---|
| 123 | raise Exception
|
---|
| 124 | if processor == 'us':
|
---|
[7f4937e] | 125 | return 'system-sparc64', '-M sun4u --prom-env boot-args="console=devices/\\hw\\pci0\\01:01.0\\com1\\a"'
|
---|
[9185e42] | 126 | elif processor == 'sun4v':
|
---|
| 127 | default_path = '/usr/local/opensparc/image/'
|
---|
| 128 | try:
|
---|
| 129 | if os.path.exists(default_path):
|
---|
| 130 | opensparc_bins = default_path
|
---|
| 131 | elif os.path.exists(os.environ['OPENSPARC_BINARIES']):
|
---|
| 132 | opensparc_bins = os.environ['OPENSPARC_BINARIES']
|
---|
| 133 | else:
|
---|
| 134 | raise Exception
|
---|
| 135 | except:
|
---|
| 136 | print("Cannot find OpenSPARC binary images!")
|
---|
| 137 | print("Either set OPENSPARC_BINARIES environment variable accordingly or place the images in %s." % (default_path))
|
---|
| 138 | raise Exception
|
---|
| 139 |
|
---|
| 140 | return 'system-sparc64', '-M niagara -m 256 -L %s' % (opensparc_bins)
|
---|
| 141 |
|
---|
[df64dbc] | 142 |
|
---|
[129b92c6] | 143 | def hdisk_mk():
|
---|
[df64dbc] | 144 | if not os.path.exists('hdisk.img'):
|
---|
| 145 | subprocess.call('tools/mkfat.py 1048576 uspace/dist/data hdisk.img', shell = True)
|
---|
[f5ceb18] | 146 |
|
---|
[129b92c6] | 147 | def qemu_bd_options():
|
---|
| 148 | if is_override('nohdd'):
|
---|
| 149 | return ''
|
---|
[a35b458] | 150 |
|
---|
[129b92c6] | 151 | hdisk_mk()
|
---|
[a35b458] | 152 |
|
---|
[13eecc4] | 153 | hdd_options = ''
|
---|
| 154 | if 'hdd' in overrides.keys():
|
---|
| 155 | if 'ata' in overrides['hdd'].keys():
|
---|
| 156 | hdd_options += ''
|
---|
| 157 | elif 'virtio-blk' in overrides['hdd'].keys():
|
---|
| 158 | hdd_options += ',if=virtio'
|
---|
| 159 |
|
---|
| 160 | return ' -drive file=hdisk.img,index=0,media=disk,format=raw' + hdd_options
|
---|
[df64dbc] | 161 |
|
---|
| 162 | def qemu_nic_ne2k_options():
|
---|
[d4b7b29] | 163 | return ' -device ne2k_isa,irq=5,netdev=n1'
|
---|
[df64dbc] | 164 |
|
---|
| 165 | def qemu_nic_e1k_options():
|
---|
[d4b7b29] | 166 | return ' -device e1000,netdev=n1'
|
---|
[df64dbc] | 167 |
|
---|
| 168 | def qemu_nic_rtl8139_options():
|
---|
[d4b7b29] | 169 | return ' -device rtl8139,netdev=n1'
|
---|
[df64dbc] | 170 |
|
---|
[7bf16b7e] | 171 | def qemu_nic_virtio_options():
|
---|
[d4b7b29] | 172 | return ' -device virtio-net,netdev=n1'
|
---|
[7bf16b7e] | 173 |
|
---|
[df64dbc] | 174 | def qemu_net_options():
|
---|
[f5ceb18] | 175 | if is_override('nonet'):
|
---|
| 176 | return ''
|
---|
| 177 |
|
---|
| 178 | nic_options = ''
|
---|
| 179 | if 'net' in overrides.keys():
|
---|
| 180 | if 'e1k' in overrides['net'].keys():
|
---|
| 181 | nic_options += qemu_nic_e1k_options()
|
---|
| 182 | if 'rtl8139' in overrides['net'].keys():
|
---|
| 183 | nic_options += qemu_nic_rtl8139_options()
|
---|
| 184 | if 'ne2k' in overrides['net'].keys():
|
---|
| 185 | nic_options += qemu_nic_ne2k_options()
|
---|
[7bf16b7e] | 186 | if 'virtio-net' in overrides['net'].keys():
|
---|
| 187 | nic_options += qemu_nic_virtio_options()
|
---|
[f5ceb18] | 188 | else:
|
---|
| 189 | # Use the default NIC
|
---|
| 190 | nic_options += qemu_nic_e1k_options()
|
---|
| 191 |
|
---|
[d4b7b29] | 192 | 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] | 193 |
|
---|
| 194 | def qemu_usb_options():
|
---|
[f5ceb18] | 195 | if is_override('nousb'):
|
---|
| 196 | return ''
|
---|
| 197 | return ' -usb'
|
---|
[df64dbc] | 198 |
|
---|
[5119d34] | 199 | def qemu_xhci_options():
|
---|
| 200 | if is_override('noxhci'):
|
---|
| 201 | return ''
|
---|
| 202 | return ' -device nec-usb-xhci,id=xhci'
|
---|
| 203 |
|
---|
[27de618] | 204 | def qemu_tablet_options():
|
---|
| 205 | if is_override('notablet') or (is_override('nousb') and is_override('noxhci')):
|
---|
| 206 | return ''
|
---|
| 207 | return ' -device usb-tablet'
|
---|
| 208 |
|
---|
[f5ceb18] | 209 | def qemu_audio_options():
|
---|
| 210 | if is_override('nosnd'):
|
---|
| 211 | return ''
|
---|
[089901e] | 212 | return ' -device intel-hda -device hda-duplex'
|
---|
[f5ceb18] | 213 |
|
---|
[df425da] | 214 | def qemu_run(platform, machine, processor):
|
---|
| 215 | cfg = cfg_get(platform, machine, processor)
|
---|
[9185e42] | 216 | suffix, options = platform_to_qemu_options(platform, machine, processor)
|
---|
[df64dbc] | 217 | cmd = 'qemu-' + suffix
|
---|
| 218 |
|
---|
| 219 | cmdline = cmd
|
---|
[3692678] | 220 | if 'qemu_path' in overrides.keys():
|
---|
| 221 | cmdline = overrides['qemu_path'] + cmd
|
---|
| 222 |
|
---|
[df64dbc] | 223 | if options != '':
|
---|
| 224 | cmdline += ' ' + options
|
---|
| 225 |
|
---|
[84176f3] | 226 | if (not 'hdd' in cfg.keys() or cfg['hdd']):
|
---|
| 227 | cmdline += qemu_bd_options()
|
---|
[f5ceb18] | 228 | if (not 'net' in cfg.keys()) or cfg['net']:
|
---|
[df64dbc] | 229 | cmdline += qemu_net_options()
|
---|
[f5ceb18] | 230 | if (not 'usb' in cfg.keys()) or cfg['usb']:
|
---|
[df64dbc] | 231 | cmdline += qemu_usb_options()
|
---|
[5119d34] | 232 | if (not 'xhci' in cfg.keys()) or cfg['xhci']:
|
---|
| 233 | cmdline += qemu_xhci_options()
|
---|
[27de618] | 234 | if (not 'tablet' in cfg.keys()) or cfg['tablet']:
|
---|
| 235 | cmdline += qemu_tablet_options()
|
---|
[f5ceb18] | 236 | if (not 'audio' in cfg.keys()) or cfg['audio']:
|
---|
| 237 | cmdline += qemu_audio_options()
|
---|
[a35b458] | 238 |
|
---|
[868d75c] | 239 | console = ('console' in cfg.keys() and cfg['console'])
|
---|
| 240 |
|
---|
[0ceeac3] | 241 | if (is_override('nographic')):
|
---|
| 242 | cmdline += ' -nographic'
|
---|
| 243 |
|
---|
[868d75c] | 244 | if (not console and (not is_override('nographic')) and not is_override('noserial')):
|
---|
[2fc9bfd] | 245 | cmdline += ' -serial stdio'
|
---|
| 246 |
|
---|
[abf8bd8] | 247 | if (is_override('bigmem')):
|
---|
| 248 | cmdline += ' -m 4G'
|
---|
| 249 |
|
---|
[f5ceb18] | 250 | if cfg['image'] == 'image.iso':
|
---|
[df64dbc] | 251 | cmdline += ' -boot d -cdrom image.iso'
|
---|
[84176f3] | 252 | elif cfg['image'] == 'image.iso@arm64':
|
---|
| 253 | # Define image.iso cdrom backend.
|
---|
| 254 | cmdline += ' -drive if=none,file=image.iso,id=cdrom,media=cdrom'
|
---|
| 255 | # Define scsi bus.
|
---|
| 256 | cmdline += ' -device virtio-scsi-device'
|
---|
| 257 | # Define cdrom frontend connected to this scsi bus.
|
---|
| 258 | cmdline += ' -device scsi-cd,drive=cdrom'
|
---|
[f5ceb18] | 259 | elif cfg['image'] == 'image.boot':
|
---|
[df64dbc] | 260 | cmdline += ' -kernel image.boot'
|
---|
[9185e42] | 261 | else:
|
---|
| 262 | cmdline += ' ' + cfg['image']
|
---|
[df64dbc] | 263 |
|
---|
[868d75c] | 264 | if console:
|
---|
[df64dbc] | 265 | cmdline += ' -nographic'
|
---|
| 266 |
|
---|
| 267 | title = 'HelenOS/' + platform
|
---|
| 268 | if machine != '':
|
---|
| 269 | title += ' on ' + machine
|
---|
[9185e42] | 270 | if 'expect' in cfg.keys():
|
---|
| 271 | cmdline = 'expect -c \'spawn %s; expect "%s" { send "%s" } timeout exp_continue; interact\'' % (cmdline, cfg['expect']['src'], cfg['expect']['dst'])
|
---|
[df64dbc] | 272 | run_in_console(cmdline, title)
|
---|
| 273 | else:
|
---|
[e4a1497] | 274 | print(cmdline)
|
---|
[f5ceb18] | 275 | if not is_override('dryrun'):
|
---|
| 276 | subprocess.call(cmdline, shell = True)
|
---|
[3f4c537a] | 277 |
|
---|
[df425da] | 278 | def ski_run(platform, machine, processor):
|
---|
[63d46341] | 279 | run_in_console('ski -i tools/conf/ski.conf', 'HelenOS/ia64 on ski')
|
---|
[df64dbc] | 280 |
|
---|
[df425da] | 281 | def msim_run(platform, machine, processor):
|
---|
[129b92c6] | 282 | hdisk_mk()
|
---|
[63d46341] | 283 | run_in_console('msim -c tools/conf/msim.conf', 'HelenOS/mips32 on msim')
|
---|
[df64dbc] | 284 |
|
---|
[3f4c537a] | 285 | def spike_run(platform, machine, processor):
|
---|
[ae8d7b0] | 286 | run_in_console('spike -m1073741824:1073741824 image.boot', 'HelenOS/risvc64 on Spike')
|
---|
[3f4c537a] | 287 |
|
---|
[f5ceb18] | 288 | emulators = {
|
---|
| 289 | 'amd64' : {
|
---|
| 290 | 'run' : qemu_run,
|
---|
| 291 | 'image' : 'image.iso'
|
---|
| 292 | },
|
---|
| 293 | 'arm32' : {
|
---|
| 294 | 'integratorcp' : {
|
---|
| 295 | 'run' : qemu_run,
|
---|
| 296 | 'image' : 'image.boot',
|
---|
| 297 | 'net' : False,
|
---|
[a1a81f69] | 298 | 'audio' : False,
|
---|
| 299 | 'xhci' : False,
|
---|
| 300 | 'tablet' : False
|
---|
[f5ceb18] | 301 | }
|
---|
| 302 | },
|
---|
[84176f3] | 303 | 'arm64' : {
|
---|
| 304 | 'virt' : {
|
---|
| 305 | 'run' : qemu_run,
|
---|
| 306 | 'image' : 'image.iso@arm64',
|
---|
| 307 | 'audio' : False,
|
---|
| 308 | 'console' : True,
|
---|
| 309 | 'hdd' : False,
|
---|
| 310 | 'net' : False,
|
---|
| 311 | 'tablet' : False,
|
---|
| 312 | 'usb' : False,
|
---|
| 313 | 'xhci' : False
|
---|
| 314 | }
|
---|
| 315 | },
|
---|
[f5ceb18] | 316 | 'ia32' : {
|
---|
| 317 | 'run' : qemu_run,
|
---|
| 318 | 'image' : 'image.iso'
|
---|
| 319 | },
|
---|
| 320 | 'ia64' : {
|
---|
| 321 | 'ski' : {
|
---|
| 322 | 'run' : ski_run
|
---|
| 323 | }
|
---|
| 324 | },
|
---|
| 325 | 'mips32' : {
|
---|
| 326 | 'msim' : {
|
---|
| 327 | 'run' : msim_run
|
---|
| 328 | },
|
---|
| 329 | 'lmalta' : {
|
---|
| 330 | 'run' : qemu_run,
|
---|
| 331 | 'image' : 'image.boot',
|
---|
[868d75c] | 332 | 'console' : True
|
---|
[f5ceb18] | 333 | },
|
---|
| 334 | 'bmalta' : {
|
---|
| 335 | 'run' : qemu_run,
|
---|
| 336 | 'image' : 'image.boot',
|
---|
[868d75c] | 337 | 'console' : True
|
---|
[f5ceb18] | 338 | },
|
---|
| 339 | },
|
---|
| 340 | 'ppc32' : {
|
---|
| 341 | 'run' : qemu_run,
|
---|
| 342 | 'image' : 'image.iso',
|
---|
| 343 | 'audio' : False
|
---|
| 344 | },
|
---|
[3f4c537a] | 345 | 'riscv64' : {
|
---|
| 346 | 'run' : spike_run,
|
---|
| 347 | 'image' : 'image.boot'
|
---|
| 348 | },
|
---|
[f5ceb18] | 349 | 'sparc64' : {
|
---|
| 350 | 'generic' : {
|
---|
[df425da] | 351 | 'us' : {
|
---|
| 352 | 'run' : qemu_run,
|
---|
| 353 | 'image' : 'image.iso',
|
---|
[0195374] | 354 | 'audio' : False,
|
---|
[868d75c] | 355 | 'console' : True,
|
---|
[fd57cf17] | 356 | 'net' : False,
|
---|
| 357 | 'usb' : False,
|
---|
| 358 | 'xhci' : False,
|
---|
| 359 | 'tablet' : False
|
---|
[df425da] | 360 | },
|
---|
| 361 | 'sun4v' : {
|
---|
[9185e42] | 362 | 'run' : qemu_run,
|
---|
| 363 | 'image' : '-drive if=pflash,readonly=on,file=image.iso',
|
---|
| 364 | 'audio' : False,
|
---|
[868d75c] | 365 | 'console' : True,
|
---|
[9185e42] | 366 | 'net' : False,
|
---|
| 367 | 'usb' : False,
|
---|
[fd57cf17] | 368 | 'xhci' : False,
|
---|
| 369 | 'tablet' : False,
|
---|
[9185e42] | 370 | 'expect' : {
|
---|
| 371 | 'src' : 'ok ',
|
---|
| 372 | 'dst' : 'boot\n'
|
---|
| 373 | },
|
---|
[df425da] | 374 | }
|
---|
[f5ceb18] | 375 | }
|
---|
| 376 | },
|
---|
| 377 | }
|
---|
| 378 |
|
---|
| 379 | def usage():
|
---|
| 380 | print("%s - emulator wrapper for running HelenOS\n" % os.path.basename(sys.argv[0]))
|
---|
[13eecc4] | 381 | print("%s [-d] [-h] [-net e1k|rtl8139|ne2k|virtio-net] [-hdd ata|virtio-blk] [-nohdd] [-nokvm] [-nonet] [-nosnd] [-nousb] [-noxhci] [-notablet]\n" %
|
---|
[f5ceb18] | 382 | os.path.basename(sys.argv[0]))
|
---|
| 383 | print("-d\tDry run: do not run the emulation, just print the command line.")
|
---|
| 384 | print("-h\tPrint the usage information and exit.")
|
---|
| 385 | print("-nohdd\tDisable hard disk, if applicable.")
|
---|
| 386 | print("-nokvm\tDisable KVM, if applicable.")
|
---|
| 387 | print("-nonet\tDisable networking support, if applicable.")
|
---|
| 388 | print("-nosnd\tDisable sound, if applicable.")
|
---|
| 389 | print("-nousb\tDisable USB support, if applicable.")
|
---|
[5119d34] | 390 | print("-noxhci\tDisable XHCI support, if applicable.")
|
---|
[27de618] | 391 | print("-notablet\tDisable USB tablet (use only relative-position PS/2 mouse instead), if applicable.")
|
---|
[abf8bd8] | 392 | print("-nographic\tDisable graphical output. Serial port output must be enabled for this to be useful.")
|
---|
[2fc9bfd] | 393 | print("-noserial\tDisable serial port output in the terminal.")
|
---|
[abf8bd8] | 394 | print("-bigmem\tSets maximum RAM size to 4GB.")
|
---|
[df64dbc] | 395 |
|
---|
[df425da] | 396 | def fail(platform, machine):
|
---|
| 397 | print("Cannot start emulation for the chosen configuration. (%s/%s)" % (platform, machine))
|
---|
[a35b458] | 398 |
|
---|
[df425da] | 399 |
|
---|
[df64dbc] | 400 | def run():
|
---|
[f5ceb18] | 401 | expect_nic = False
|
---|
[13eecc4] | 402 | expect_hdd = False
|
---|
[3692678] | 403 | expect_qemu = False
|
---|
[f5ceb18] | 404 |
|
---|
| 405 | for i in range(1, len(sys.argv)):
|
---|
| 406 |
|
---|
| 407 | if expect_nic:
|
---|
| 408 | expect_nic = False
|
---|
| 409 | if not 'net' in overrides.keys():
|
---|
| 410 | overrides['net'] = {}
|
---|
| 411 | if sys.argv[i] == 'e1k':
|
---|
| 412 | overrides['net']['e1k'] = True
|
---|
| 413 | elif sys.argv[i] == 'rtl8139':
|
---|
| 414 | overrides['net']['rtl8139'] = True
|
---|
| 415 | elif sys.argv[i] == 'ne2k':
|
---|
| 416 | overrides['net']['ne2k'] = True
|
---|
[7bf16b7e] | 417 | elif sys.argv[i] == 'virtio-net':
|
---|
| 418 | overrides['net']['virtio-net'] = True
|
---|
[f5ceb18] | 419 | else:
|
---|
| 420 | usage()
|
---|
| 421 | exit()
|
---|
[f134413] | 422 | continue
|
---|
[f5ceb18] | 423 |
|
---|
[13eecc4] | 424 | if expect_hdd:
|
---|
| 425 | expect_hdd = False
|
---|
| 426 | if not 'hdd' in overrides.keys():
|
---|
| 427 | overrides['hdd'] = {}
|
---|
| 428 | if sys.argv[i] == 'ata':
|
---|
| 429 | overrides['hdd']['ata'] = True
|
---|
| 430 | elif sys.argv[i] == 'virtio-blk':
|
---|
| 431 | overrides['hdd']['virtio-blk'] = True
|
---|
| 432 | else:
|
---|
| 433 | usage()
|
---|
| 434 | exit()
|
---|
| 435 | continue
|
---|
| 436 |
|
---|
[3692678] | 437 | if expect_qemu:
|
---|
| 438 | expect_qemu = False
|
---|
| 439 | overrides['qemu_path'] = sys.argv[i]
|
---|
| 440 |
|
---|
[f5ceb18] | 441 | elif sys.argv[i] == '-h':
|
---|
| 442 | usage()
|
---|
| 443 | exit()
|
---|
| 444 | elif sys.argv[i] == '-d':
|
---|
| 445 | overrides['dryrun'] = True
|
---|
| 446 | elif sys.argv[i] == '-net' and i < len(sys.argv) - 1:
|
---|
| 447 | expect_nic = True
|
---|
[13eecc4] | 448 | elif sys.argv[i] == '-hdd' and i < len(sys.argv) - 1:
|
---|
| 449 | expect_hdd = True
|
---|
[f5ceb18] | 450 | elif sys.argv[i] == '-nohdd':
|
---|
| 451 | overrides['nohdd'] = True
|
---|
| 452 | elif sys.argv[i] == '-nokvm':
|
---|
| 453 | overrides['nokvm'] = True
|
---|
| 454 | elif sys.argv[i] == '-nonet':
|
---|
| 455 | overrides['nonet'] = True
|
---|
| 456 | elif sys.argv[i] == '-nosnd':
|
---|
| 457 | overrides['nosnd'] = True
|
---|
| 458 | elif sys.argv[i] == '-nousb':
|
---|
| 459 | overrides['nousb'] = True
|
---|
[5119d34] | 460 | elif sys.argv[i] == '-noxhci':
|
---|
| 461 | overrides['noxhci'] = True
|
---|
[27de618] | 462 | elif sys.argv[i] == '-notablet':
|
---|
| 463 | overrides['notablet'] = True
|
---|
[0ceeac3] | 464 | elif sys.argv[i] == '-nographic':
|
---|
| 465 | overrides['nographic'] = True
|
---|
[abf8bd8] | 466 | elif sys.argv[i] == '-bigmem':
|
---|
| 467 | overrides['bigmem'] = True
|
---|
[2fc9bfd] | 468 | elif sys.argv[i] == '-noserial':
|
---|
| 469 | overrides['noserial'] = True
|
---|
[3692678] | 470 | elif sys.argv[i] == '-qemu_path' and i < len(sys.argv) - 1:
|
---|
| 471 | expect_qemu = True
|
---|
[f5ceb18] | 472 | else:
|
---|
| 473 | usage()
|
---|
| 474 | exit()
|
---|
| 475 |
|
---|
[df64dbc] | 476 | config = {}
|
---|
| 477 | autotool.read_config(autotool.CONFIG, config)
|
---|
| 478 |
|
---|
[f5ceb18] | 479 | if 'PLATFORM' in config.keys():
|
---|
[df64dbc] | 480 | platform = config['PLATFORM']
|
---|
[f5ceb18] | 481 | else:
|
---|
[df64dbc] | 482 | platform = ''
|
---|
| 483 |
|
---|
[f5ceb18] | 484 | if 'MACHINE' in config.keys():
|
---|
[df64dbc] | 485 | mach = config['MACHINE']
|
---|
[f5ceb18] | 486 | else:
|
---|
[df64dbc] | 487 | mach = ''
|
---|
| 488 |
|
---|
[df425da] | 489 | if 'PROCESSOR' in config.keys():
|
---|
| 490 | processor = config['PROCESSOR']
|
---|
| 491 | else:
|
---|
| 492 | processor = ''
|
---|
| 493 |
|
---|
[df64dbc] | 494 | try:
|
---|
[df425da] | 495 | emu_run = cfg_get(platform, mach, processor)['run']
|
---|
| 496 | emu_run(platform, mach, processor)
|
---|
[df64dbc] | 497 | except:
|
---|
[df425da] | 498 | fail(platform, mach)
|
---|
[df64dbc] | 499 | return
|
---|
| 500 |
|
---|
| 501 | run()
|
---|