Changes in tools/ew.py [c35cc8b:e9c1639] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/ew.py

    rc35cc8b re9c1639  
    7676
    7777def termemu_detect():
    78         emus = ['gnome-terminal', 'foot', 'xfce4-terminal', 'xterm']
    79 
    80         if 'TERMINAL' in os.environ:
    81                 emus.insert(0, os.environ['TERMINAL'])
    82 
     78        emus = ['gnome-terminal', 'xfce4-terminal', 'xterm']
    8379        for termemu in emus:
    8480                try:
    85                         subprocess.check_output('which ' + termemu, shell = True, stderr = subprocess.STDOUT)
     81                        subprocess.check_output('which ' + termemu, shell = True)
    8682                        return termemu
    8783                except:
     
    9389def run_in_console(cmd, title):
    9490        temu = termemu_detect()
    95 
    96         if os.path.basename(temu.split(' ')[0]) in ['gnome-terminal', 'foot']:
     91        if temu == 'gnome-terminal':
    9792                cmdline = temu + ' -- ' + cmd
    9893        else:
     
    144139                return 'system-x86_64', pc_options(64)
    145140        elif platform == 'arm32':
    146                 if machine == 'integratorcp':
    147                         return 'system-arm', '-M integratorcp'
    148                 elif machine == 'raspberrypi':
    149                         return 'system-arm', '-M raspi1ap'
     141                return 'system-arm', '-M integratorcp'
    150142        elif platform == 'arm64':
    151                 if machine == 'virt':
    152                         # Search for the EDK2 firmware image
    153                         default_paths = (
    154                                 '/usr/local/qemu-efi-aarch64/QEMU_EFI.fd', # Custom
    155                                 '/usr/share/edk2/aarch64/QEMU_EFI.fd',     # Fedora
    156                                 '/usr/share/qemu-efi-aarch64/QEMU_EFI.fd', # Ubuntu
    157                         )
    158                         extra_info = ("Pre-compiled binary can be obtained from "
    159                             "http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/QEMU-AARCH64/RELEASE_GCC5/QEMU_EFI.fd.\n")
    160                         efi_path = find_firmware(
    161                             "EDK2", 'EW_QEMU_EFI_AARCH64', default_paths, extra_info)
    162                         if efi_path is None:
    163                                 raise Exception
    164 
    165                         return 'system-aarch64', \
    166                             '-M virt -cpu cortex-a57 -m 1024 -bios %s' % efi_path
     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_GCC5/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
    167158        elif platform == 'ia32':
    168159                return 'system-i386', pc_options(32)
     
    178169                        raise Exception
    179170                if processor == 'us':
    180                         cmdline = '-M sun4u'
    181                         if is_override('nographic'):
    182                             cmdline += ' --prom-env boot-args="console=devices/\\hw\\pci0\\01:01.0\\com1\\a"'
    183                         return 'system-sparc64', cmdline
     171                        return 'system-sparc64', '-M sun4u --prom-env boot-args="console=devices/\\hw\\pci0\\01:01.0\\com1\\a"'
    184172
    185173                # processor = 'sun4v'
     
    268256        suffix, options = platform_to_qemu_options(platform, machine, processor)
    269257        cmd = 'qemu-' + suffix
     258
     259        if cpus:
     260        cmd += ' -smp cpus=' + cpus + ' '
    270261
    271262        cmdline = cmd
     
    293284        if (is_override('nographic')):
    294285                cmdline += ' -nographic'
    295                 console = True
    296286
    297287        if (not console and (not is_override('nographic')) and not is_override('noserial')):
     
    312302        elif cfg['image'] == 'image.boot':
    313303                cmdline += ' -kernel image.boot'
    314         elif cfg['image'] == 'kernel.img@rpi':
    315                 cmdline += ' -bios boot/image.boot.bin'
    316304        else:
    317305                cmdline += ' ' + cfg['image']
     
    336324def msim_run(platform, machine, processor):
    337325        hdisk_mk()
    338         run_in_console('msim -n -c ' + TOOLS_DIR + '/conf/msim.conf', 'HelenOS/mips32 on msim')
     326        run_in_console('msim -c ' + TOOLS_DIR + '/conf/msim.conf', 'HelenOS/mips32 on msim')
    339327
    340328def spike_run(platform, machine, processor):
     
    354342                        'xhci' : False,
    355343                        'tablet' : False
    356                 },
    357                 'raspberrypi' : {
    358                         'run' : qemu_run,
    359                         'image' : 'kernel.img@rpi',
    360                         'audio' : False,
    361                         'console' : True,
    362                         'hdd' : False,
    363                         'net' : False,
    364                         'tablet' : False,
    365                         'usb' : False,
    366                         'xhci' : False
    367                 },
     344                }
    368345        },
    369346        'arm64' : {
     
    419396                                'image' : 'image.iso',
    420397                                'audio' : False,
    421                                 'console' : False,
     398                                'console' : True,
    422399                                'net' : False,
    423400                                'usb' : False,
     
    427404                        'sun4v' : {
    428405                                'run' : qemu_run,
    429                                 # QEMU 8.0.0 ignores the 'file' argument and instead uses 'id',
    430                                 # which defaults to 'pflash0', but can be changed to the same value
    431                                 # as 'file'
    432                                 'image' : '-drive if=pflash,id=image.iso,readonly=on,file=image.iso',
     406                                'image' : '-drive if=pflash,readonly=on,file=image.iso',
    433407                                'audio' : False,
    434408                                'console' : True,
     
    448422def usage():
    449423        print("%s - emulator wrapper for running HelenOS\n" % os.path.basename(sys.argv[0]))
    450         print("%s [-d] [-h] [-net e1k|rtl8139|ne2k|virtio-net] [-hdd ata|virtio-blk] [-nohdd] [-nokvm] [-nonet] [-nosnd] [-nousb] [-noxhci] [-notablet]\n" %
     424        print("%s [$] [-d] [-h] [-net e1k|rtl8139|ne2k|virtio-net] [-hdd ata|virtio-blk] [-nohdd] [-nokvm] [-nonet] [-nosnd] [-nousb] [-noxhci] [-notablet]\n" %
    451425            os.path.basename(sys.argv[0]))
     426        print("$\t to run multiple($) cpus")
    452427        print("-d\tDry run: do not run the emulation, just print the command line.")
    453428        print("-h\tPrint the usage information and exit.")
     
    471446        expect_hdd = False
    472447        expect_qemu = False
     448        global cpus
     449    cpus = ''
    473450
    474451        for i in range(1, len(sys.argv)):
     
    511488                        usage()
    512489                        exit()
     490                elif sys.argv[i].isdigit():
     491            cpus = sys.argv[i]
    513492                elif sys.argv[i] == '-d':
    514493                        overrides['dryrun'] = True
Note: See TracChangeset for help on using the changeset viewer.