Changes in tools/ew.py [13eecc4:ecf0a04b] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/ew.py

    r13eecc4 recf0a04b  
    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
     
    208245                cmdline += ' ' + options
    209246
    210         cmdline += qemu_bd_options()
    211 
     247        if (not 'hdd' in cfg.keys() or cfg['hdd']):
     248                cmdline += qemu_bd_options()
    212249        if (not 'net' in cfg.keys()) or cfg['net']:
    213250                cmdline += qemu_net_options()
     
    234271        if cfg['image'] == 'image.iso':
    235272                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'
    236280        elif cfg['image'] == 'image.boot':
    237281                cmdline += ' -kernel image.boot'
     
    276320                        'xhci' : False,
    277321                        '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
    278335                }
    279336        },
Note: See TracChangeset for help on using the changeset viewer.