Changes in tools/ew.py [3f4c537a:644352c] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/ew.py

    r3f4c537a r644352c  
    11#!/usr/bin/env python
    22#
    3 # Copyright (c) 2013 Jakub Jermar
     3# Copyright (c) 2013 Jakub Jermar 
    44# All rights reserved.
    55#
     
    3333"""
    3434
    35 import os
     35import os 
    3636import sys
    37 import subprocess
     37import subprocess 
    3838import autotool
    3939import platform
    40 import thread
    41 import time
    4240
    4341overrides = {}
     
    4846        return False
    4947
    50 def cfg_get(platform, machine, processor):
    51         if machine == "" or emulators[platform].has_key("run"):
     48def cfg_get(platform, machine):
     49        if machine == "":
    5250                return emulators[platform]
    53         elif processor == "" or emulators[platform][machine].has_key("run"):
     51        else:
    5452                return emulators[platform][machine]
    55         else:
    56                 return emulators[platform][machine][processor]
    5753
    5854def run_in_console(cmd, title):
     
    9793                return 'system-sparc64', ''
    9894
    99 def hdisk_mk():
    100         if not os.path.exists('hdisk.img'):
    101                 subprocess.call('tools/mkfat.py 1048576 uspace/dist/data hdisk.img', shell = True)
    102 
    10395def qemu_bd_options():
    10496        if is_override('nohdd'):
    10597                return ''
    106        
    107         hdisk_mk()
    108        
    109         return ' -drive file=hdisk.img,index=0,media=disk,format=raw'
     98
     99        if not os.path.exists('hdisk.img'):
     100                subprocess.call('tools/mkfat.py 1048576 uspace/dist/data hdisk.img', shell = True)
     101
     102        return ' -hda hdisk.img'
    110103
    111104def qemu_nic_ne2k_options():
     
    134127                nic_options += qemu_nic_e1k_options()
    135128
    136         return nic_options + ' -net user,hostfwd=udp::8080-:8080,hostfwd=udp::8081-:8081,hostfwd=tcp::8080-:8080,hostfwd=tcp::8081-:8081,hostfwd=tcp::2223-:2223'
     129        return nic_options + ' -net user -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -redir tcp:2223::2223'
    137130
    138131def qemu_usb_options():
     
    146139        return ' -device intel-hda -device hda-duplex'
    147140
    148 def qemu_run(platform, machine, processor):
    149         cfg = cfg_get(platform, machine, processor)
     141def qemu_run(platform, machine):
     142        cfg = cfg_get(platform, machine)
    150143        suffix, options = platform_to_qemu_options(platform, machine)
    151144        cmd = 'qemu-' + suffix
     
    180173                if not is_override('dryrun'):
    181174                        subprocess.call(cmdline, shell = True)
    182 
    183 def ski_run(platform, machine, processor):
     175               
     176def ski_run(platform, machine):
    184177        run_in_console('ski -i contrib/conf/ski.conf', 'HelenOS/ia64 on ski')
    185178
    186 def msim_run(platform, machine, processor):
    187         hdisk_mk()
     179def msim_run(platform, machine):
    188180        run_in_console('msim -c contrib/conf/msim.conf', 'HelenOS/mips32 on msim')
    189181
    190 def spike_run(platform, machine, processor):
    191         run_in_console('spike image.boot', 'HelenOS/risvc64 on Spike')
    192 
    193 def gem5_console_thread():
    194         # Wait a little bit so that gem5 can create the port
    195         time.sleep(1)
    196         term = os.environ['M5_PATH'] + '/gem5/util/term/m5term'
    197         port = 3457
    198         run_in_console('expect -c \'spawn %s %d; expect "ok " { send "boot\n" } timeout exp_continue; interact\'' % (term, port), 'HelenOS/sun4v on gem5')
    199 
    200 def gem5_run(platform, machine, processor):
    201         try:
    202                 gem5 = os.environ['M5_PATH'] + '/gem5/build/SPARC/gem5.fast'
    203                 if not os.path.exists(gem5):
    204                         raise Exception
    205         except:
    206                 print("Did you forget to set M5_PATH?")
    207                 raise
    208 
    209         thread.start_new_thread(gem5_console_thread, ())
    210 
    211         cmdline = gem5 + ' ' + os.environ['M5_PATH'] + '/configs/example/fs.py --disk-image=' + os.path.abspath('image.iso')
    212 
    213         print(cmdline)
    214         if not is_override('dry_run'):
    215                 subprocess.call(cmdline, shell = True)
    216182
    217183emulators = {
     
    257223                'audio' : False
    258224        },
    259         'riscv64' : {
    260                 'run' : spike_run,
    261                 'image' : 'image.boot'
    262         },
    263225        'sparc64' : {
    264226                'generic' : {
    265                         'us' : {
    266                                 'run' : qemu_run,
    267                                 'image' : 'image.iso',
    268                                 'audio' : False
    269                         },
    270                         'sun4v' : {
    271                                 'run' : gem5_run,
    272                         }
     227                        'run' : qemu_run,
     228                        'image' : 'image.iso',
     229                        'audio' : False
    273230                }
    274231        },
     
    286243        print("-nosnd\tDisable sound, if applicable.")
    287244        print("-nousb\tDisable USB support, if applicable.")
    288 
    289 def fail(platform, machine):
    290         print("Cannot start emulation for the chosen configuration. (%s/%s)" % (platform, machine))
    291        
    292245
    293246def run():
     
    344297                mach = ''
    345298
    346         if 'PROCESSOR' in config.keys():
    347                 processor = config['PROCESSOR']
    348         else:
    349                 processor = ''
    350 
    351299        try:
    352                 emu_run = cfg_get(platform, mach, processor)['run']
    353                 emu_run(platform, mach, processor)
     300                emu_run = cfg_get(platform, mach)['run']
    354301        except:
    355                 fail(platform, mach)
     302                print("Cannot start emulation for the chosen configuration. (%s/%s)" % (platform, mach))
    356303                return
    357304
     305        emu_run(platform, mach)
     306
    358307run()
Note: See TracChangeset for help on using the changeset viewer.