Changes in tools/ew.py [644352c:7f0580d] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/ew.py

    r644352c r7f0580d  
    3333"""
    3434
    35 import os 
     35import os
    3636import sys
    37 import subprocess 
     37import subprocess
    3838import autotool
    3939import platform
     40import thread
     41import time
    4042
    4143overrides = {}
     
    4648        return False
    4749
    48 def cfg_get(platform, machine):
    49         if machine == "":
     50def cfg_get(platform, machine, processor):
     51        if machine == "" or emulators[platform].has_key("run"):
    5052                return emulators[platform]
    51         else:
     53        elif processor == "" or emulators[platform][machine].has_key("run"):
    5254                return emulators[platform][machine]
     55        else:
     56                return emulators[platform][machine][processor]
    5357
    5458def run_in_console(cmd, title):
     
    9397                return 'system-sparc64', ''
    9498
     99def 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
    95103def qemu_bd_options():
    96104        if is_override('nohdd'):
    97105                return ''
    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'
     106       
     107        hdisk_mk()
     108       
     109        return ' -drive file=hdisk.img,index=0,media=disk,format=raw'
    103110
    104111def qemu_nic_ne2k_options():
     
    127134                nic_options += qemu_nic_e1k_options()
    128135
    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'
     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'
    130137
    131138def qemu_usb_options():
     
    139146        return ' -device intel-hda -device hda-duplex'
    140147
    141 def qemu_run(platform, machine):
    142         cfg = cfg_get(platform, machine)
     148def qemu_run(platform, machine, processor):
     149        cfg = cfg_get(platform, machine, processor)
    143150        suffix, options = platform_to_qemu_options(platform, machine)
    144151        cmd = 'qemu-' + suffix
     
    174181                        subprocess.call(cmdline, shell = True)
    175182               
    176 def ski_run(platform, machine):
     183def ski_run(platform, machine, processor):
    177184        run_in_console('ski -i contrib/conf/ski.conf', 'HelenOS/ia64 on ski')
    178185
    179 def msim_run(platform, machine):
     186def msim_run(platform, machine, processor):
     187        hdisk_mk()
    180188        run_in_console('msim -c contrib/conf/msim.conf', 'HelenOS/mips32 on msim')
    181189
     190def gem5_console_thread():
     191        # Wait a little bit so that gem5 can create the port
     192        time.sleep(1)
     193        term = os.environ['M5_PATH'] + '/gem5/util/term/m5term'
     194        port = 3457
     195        run_in_console('expect -c \'spawn %s %d; expect "ok " { send "boot\n" } timeout exp_continue; interact\'' % (term, port), 'HelenOS/sun4v on gem5')
     196
     197def gem5_run(platform, machine, processor):
     198        try:
     199                gem5 = os.environ['M5_PATH'] + '/gem5/build/SPARC/gem5.fast'
     200                if not os.path.exists(gem5):
     201                        raise Exception
     202        except:
     203                print("Did you forget to set M5_PATH?")
     204                raise
     205
     206        thread.start_new_thread(gem5_console_thread, ())
     207
     208        cmdline = gem5 + ' ' + os.environ['M5_PATH'] + '/configs/example/fs.py --disk-image=' + os.path.abspath('image.iso')
     209
     210        print(cmdline)
     211        if not is_override('dry_run'):
     212                subprocess.call(cmdline, shell = True)
    182213
    183214emulators = {
     
    225256        'sparc64' : {
    226257                'generic' : {
    227                         'run' : qemu_run,
    228                         'image' : 'image.iso',
    229                         'audio' : False
     258                        'us' : {
     259                                'run' : qemu_run,
     260                                'image' : 'image.iso',
     261                                'audio' : False
     262                        },
     263                        'sun4v' : {
     264                                'run' : gem5_run,
     265                        }
    230266                }
    231267        },
     
    243279        print("-nosnd\tDisable sound, if applicable.")
    244280        print("-nousb\tDisable USB support, if applicable.")
     281
     282def fail(platform, machine):
     283        print("Cannot start emulation for the chosen configuration. (%s/%s)" % (platform, machine))
     284       
    245285
    246286def run():
     
    297337                mach = ''
    298338
     339        if 'PROCESSOR' in config.keys():
     340                processor = config['PROCESSOR']
     341        else:
     342                processor = ''
     343
    299344        try:
    300                 emu_run = cfg_get(platform, mach)['run']
     345                emu_run = cfg_get(platform, mach, processor)['run']
     346                emu_run(platform, mach, processor)
    301347        except:
    302                 print("Cannot start emulation for the chosen configuration. (%s/%s)" % (platform, mach))
     348                fail(platform, mach)
    303349                return
    304350
    305         emu_run(platform, mach)
    306 
    307351run()
Note: See TracChangeset for help on using the changeset viewer.