Changeset bc73be3 in mainline for tools/ew.py


Ignore:
Timestamp:
2019-06-27T08:51:20Z (6 years ago)
Author:
Jaroslav Jindrak <dzejrou@…>
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.
Message:

cpp: merge and resolve conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/ew.py

    rad40b74b rbc73be3  
    5757
    5858def termemu_detect():
    59         for termemu in ['xfce4-terminal', 'xterm']:
     59        emus = ['gnome-terminal', 'xfce4-terminal', 'xterm']
     60        for termemu in emus:
    6061                try:
    6162                        subprocess.check_output('which ' + termemu, shell = True)
     
    6465                        pass
    6566
     67        print('Could not find any of the terminal emulators %s.'%(emus))
     68        sys.exit(1)
     69
    6670def 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
    6978        print(cmdline)
    7079        if not is_override('dryrun'):
     
    8796
    8897def malta_options():
    89         return '-cpu 4Kc'
     98        return '-cpu 4Kc -append "console=devices/\\hw\\pci0\\00:0a.0\\com1\\a"'
     99
     100def 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
    90117
    91118def platform_to_qemu_options(platform, machine, processor):
     
    94121        elif platform == 'arm32':
    95122                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
    96139        elif platform == 'ia32':
    97140                return 'system-i386', pc_options(32)
     
    108151                if processor == 'us':
    109152                        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:
    122159                        raise Exception
    123160
     
    135172        hdisk_mk()
    136173
    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
    138182
    139183def qemu_nic_ne2k_options():
     
    201245                cmdline += ' ' + options
    202246
    203         cmdline += qemu_bd_options()
    204 
     247        if (not 'hdd' in cfg.keys() or cfg['hdd']):
     248                cmdline += qemu_bd_options()
    205249        if (not 'net' in cfg.keys()) or cfg['net']:
    206250                cmdline += qemu_net_options()
     
    227271        if cfg['image'] == 'image.iso':
    228272                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'
    229280        elif cfg['image'] == 'image.boot':
    230281                cmdline += ' -kernel image.boot'
     
    269320                        'xhci' : False,
    270321                        '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
    271335                }
    272336        },
     
    336400def usage():
    337401        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" %
    339403            os.path.basename(sys.argv[0]))
    340404        print("-d\tDry run: do not run the emulation, just print the command line.")
     
    357421def run():
    358422        expect_nic = False
     423        expect_hdd = False
    359424        expect_qemu = False
    360425
     
    378443                        continue
    379444
     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
    380458                if expect_qemu:
    381459                        expect_qemu = False
     
    389467                elif sys.argv[i] == '-net' and i < len(sys.argv) - 1:
    390468                        expect_nic = True
     469                elif sys.argv[i] == '-hdd' and i < len(sys.argv) - 1:
     470                        expect_hdd = True
    391471                elif sys.argv[i] == '-nohdd':
    392472                        overrides['nohdd'] = True
Note: See TracChangeset for help on using the changeset viewer.