예제 #1
0
                '$root_disk_size']
            params = params + ' user_disk_image=%s' % comp_dict[section][
                '$user_disk_image']
            params = params + ' user_disk_size=%s' % comp_dict[section][
                '$user_disk_size']
        else:
            for name in comp_dict[section]:
                if name.startswith('$'):
                    cmd = '%s=%s' % (name[1:], name)
                    params = params + " " + cmd

        cmd = 'run-command-file "./targets/%s" %s' % (script, params)
        print('cmd is %s' % cmd)
        run_command(cmd)
        link_dict[section] = assignLinkNames(section)
        linkSwitches(section, comp_dict[section], link_dict[section])
else:
    print('run from checkpoint %s' % RUN_FROM_SNAP)
    run_command('read-configuration %s' % RUN_FROM_SNAP)
    #run_command('run-command-file ./targets/x86-x58-ich10/switches.simics')
run_command('log-level 0 -all')
'''
Either launch monitor, or generate kernel parameter file depending on CREATE_RESIM_PARAMS
'''
CREATE_RESIM_PARAMS = os.getenv('CREATE_RESIM_PARAMS')
if CREATE_RESIM_PARAMS is not None and CREATE_RESIM_PARAMS.upper() == 'YES':
    gkp = getKernelParams.GetKernelParams()
else:
    cgc = genMonitor.GenMonitor(comp_dict, link_dict)
    cgc.doInit()
예제 #2
0
    def __init__(self):
        global cgc, gkp
        print('Launch RESim')
        SIMICS_WORKSPACE = os.getenv('SIMICS_WORKSPACE')
        RESIM_INI = os.getenv('RESIM_INI')
        self.config = ConfigParser.ConfigParser()
        self.config.optionxform = str
        if not RESIM_INI.endswith('.ini'):
            ini_file = '%s.ini' % RESIM_INI
        else:
            ini_file = RESIM_INI
        cfg_file = os.path.join(SIMICS_WORKSPACE, ini_file)
        if not os.path.isfile(ini_file):
            print('File not found: %s' % ini_file)
            exit(1)
        self.config.read(cfg_file)

        run_command('add-directory -prepend %s/simics/simicsScripts' %
                    RESIM_REPO)
        run_command('add-directory -prepend %s/simics/monitorCore' %
                    RESIM_REPO)
        run_command('add-directory -prepend %s' % SIMICS_WORKSPACE)

        RESIM_TARGET = 'NONE'
        DRIVER_WAIT = False
        print('assign ENV variables')
        for name, value in self.config.items('ENV'):
            os.environ[name] = value
            if name == 'RESIM_TARGET':
                RESIM_TARGET = value
            elif name == 'DRIVER_WAIT' and (value.lower() == 'true'
                                            or value.lower() == 'yes'):
                print('DRIVER WILL WAIT')
                DRIVER_WAIT = True
            #print('assigned %s to %s' % (name, value))

        RUN_FROM_SNAP = os.getenv('RUN_FROM_SNAP')
        self.SIMICS_VER = os.getenv('SIMICS_VER')
        if self.SIMICS_VER is not None:
            cmd = "$simics_version=%s" % (self.SIMICS_VER)
            #print('cmd is %s' % cmd)
            run_command(cmd)

        self.not_a_target = ['ENV', 'driver']

        self.comp_dict = createDict(self.config, self.not_a_target)
        self.link_dict = {}
        if RUN_FROM_SNAP is None:
            run_command(
                'run-command-file ./targets/x86-x58-ich10/create_switches.simics'
            )
            checkVLAN(self.config)
            run_command('set-min-latency min-latency = 0.01')
            if self.config.has_section('driver'):
                run_command('$eth_dev=i82543gc')
                for name in self.comp_dict['driver']:
                    value = self.comp_dict['driver'][name]
                    if name.startswith('$'):
                        cmd = "%s=%s" % (name, value)
                        run_command(cmd)

                print('Start the %s' % self.config.get('driver', '$host_name'))
                run_command('run-command-file ./targets/%s' %
                            self.config.get('driver', 'SIMICS_SCRIPT'))
                run_command('start-agent-manager')
                done = False
                count = 0
                while not done and not DRIVER_WAIT:
                    run_command('c 50000000000')
                    if os.path.isfile('driver-ready.flag'):
                        done = True
                    count += 1
                    #print count
                self.link_dict['driver'] = assignLinkNames(
                    'driver', self.comp_dict['driver'])
                linkSwitches('driver', self.comp_dict['driver'],
                             self.link_dict['driver'])
                if DRIVER_WAIT:
                    print(
                        'DRIVER_WAIT -- will continue.  Use @resim.go to monitor'
                    )
                    return
            ''' NOTE RETURN ABOVE '''
            self.doSections()
        else:
            print('run from checkpoint %s' % RUN_FROM_SNAP)
            run_command('read-configuration %s' % RUN_FROM_SNAP)
            #run_command('run-command-file ./targets/x86-x58-ich10/switches.simics')
        run_command('log-level 0 -all')
        '''
        Either launch monitor, or generate kernel parameter file depending on CREATE_RESIM_PARAMS
        '''
        CREATE_RESIM_PARAMS = os.getenv('CREATE_RESIM_PARAMS')
        MONITOR = os.getenv('MONITOR')
        if MONITOR is None or MONITOR.lower() != 'no':
            if RESIM_TARGET.lower() != 'none':
                if CREATE_RESIM_PARAMS is not None and CREATE_RESIM_PARAMS.upper(
                ) == 'YES':
                    gkp = getKernelParams.GetKernelParams(self.comp_dict)
                else:
                    print('genMonitor for target %s' % RESIM_TARGET)
                    cgc = genMonitor.GenMonitor(self.comp_dict, self.link_dict)
                    cgc.doInit()
예제 #3
0
 def go(self):
     global cgc, gkp
     self.doSections()
     cgc = genMonitor.GenMonitor(self.comp_dict, self.link_dict)
     cgc.doInit()
예제 #4
0
    def __init__(self):
        global cgc, gkp, cfg_file
        print('Launch RESim')
        SIMICS_WORKSPACE = os.getenv('SIMICS_WORKSPACE')
        RESIM_INI = os.getenv('RESIM_INI')
        self.config = ConfigParser.ConfigParser()
        #self.config = ConfigParser.RawConfigParser()
        self.config.optionxform = str
        if not RESIM_INI.endswith('.ini'):
            ini_file = '%s.ini' % RESIM_INI
        else:
            ini_file = RESIM_INI
        cfg_file = os.path.join(SIMICS_WORKSPACE, ini_file)
        if not os.path.isfile(ini_file):
            print('File not found: %s' % ini_file)
            exit(1)
        self.config.read(cfg_file)
        SIMICS_BASE = os.getenv('SIMICS')
        parent = os.path.dirname(SIMICS_BASE)
        print('SIMICS dir is %s' % parent) 
        run_command('add-directory -prepend %s/simics-qsp-arm-6.02' % parent)        
        run_command('add-directory -prepend %s/simics-x86-x58-ich10-6.0.30/targets/x58-ich10/images' % parent)        
        run_command('add-directory -prepend %s/simics/simicsScripts' % RESIM_REPO)
        run_command('add-directory -prepend %s/simics/monitorCore' % RESIM_REPO)
        run_command('add-directory -prepend %s' % SIMICS_WORKSPACE)
        
        RESIM_TARGET = 'NONE'
        DRIVER_WAIT = False
        print('assign ENV variables')
        for name, value in self.config.items('ENV'):
            os.environ[name] = value
            if name == 'RESIM_TARGET':
                RESIM_TARGET = value
            elif name == 'DRIVER_WAIT' and (value.lower() == 'true' or value.lower() == 'yes'):
                print('DRIVER WILL WAIT')
                DRIVER_WAIT = True
            #print('assigned %s to %s' % (name, value))

        ''' hack around simics bug generating rafts of x11 traffic '''
        resim_display = os.getenv('RESIM_DISPLAY')
        if resim_display is not None:
            os.environ['DISPLAY'] = resim_display
        
        RUN_FROM_SNAP = os.getenv('RUN_FROM_SNAP')
        self.SIMICS_VER = os.getenv('SIMICS_VER')
        if self.SIMICS_VER is not None:
            cmd = "$simics_version=%s" % (self.SIMICS_VER)
            #print('cmd is %s' % cmd)
            run_command(cmd)
        
        self.not_a_target=['ENV', 'driver']
        
        self.comp_dict = createDict(self.config, self.not_a_target)
        self.link_dict = {}

        if RUN_FROM_SNAP is None:
            run_command('run-command-file ./targets/x86-x58-ich10/create_switches.simics')
            checkVLAN(self.config)
            run_command('set-min-latency min-latency = 0.01')
            interact = None
            if self.config.has_section('driver'):
                run_command('$eth_dev=i82543gc')
                for name in self.comp_dict['driver']:
                    value = self.comp_dict['driver'][name]
                    if name.startswith('$'):
                        cmd = "%s=%s" % (name, value)
                        run_command(cmd)
                    elif name == 'INTERACT_SCRIPT':
                        interact = self.comp_dict['driver'][name]
        
                driver_script = self.getSimicsScript('driver')
                print('Start the %s using %s' % (self.config.get('driver', '$host_name'), driver_script))
                run_command('run-command-file ./targets/%s' % driver_script)
                run_command('start-agent-manager')
                done = False
                count = 0
                if interact is not None:
                    print('Will run interact %s' % interact)
                    run_command('run-command-file %s' % interact)
                while not done and not DRIVER_WAIT: 
                    #print('***RUN SOME **')
                    #run_command('c 50000000000')
                    run_command('c 500000000')
                    if os.path.isfile('driver-ready.flag'):
                        #print('GOT DRIVER READY')
                        done = True 
                    count += 1
                    #print(count)
                self.link_dict['driver'] = assignLinkNames('driver', self.comp_dict['driver'])
                switch_map = linkSwitches('driver', self.comp_dict['driver'], self.link_dict['driver'])
                if DRIVER_WAIT:
                    print('DRIVER_WAIT -- will continue.  Use @resim.go to monitor')
                    return

            ''' NOTE RETURN ABOVE '''
            self.doSections() 
        else:
            print('run from checkpoint %s' % RUN_FROM_SNAP)
            run_command('read-configuration %s' % RUN_FROM_SNAP)
            #run_command('run-command-file ./targets/x86-x58-ich10/switches.simics')
        run_command('log-level 0 -all')
        ''' dummy logging object to support script branches for automated tests '''
        try:
            SIM_create_object('dummy_comp', 'RESim_log', [])
        except:
            pass
        SIM_run_command('RESim_log.log-level 1')
        '''
        Either launch monitor, or generate kernel parameter file depending on CREATE_RESIM_PARAMS
        '''
        CREATE_RESIM_PARAMS = os.getenv('CREATE_RESIM_PARAMS')
        MONITOR = os.getenv('MONITOR')
        if MONITOR is None or MONITOR.lower() != 'no':
            if RESIM_TARGET.lower() != 'none':
                if CREATE_RESIM_PARAMS is not None and CREATE_RESIM_PARAMS.upper() == 'YES':
                    gkp = getKernelParams.GetKernelParams(self.comp_dict)
                else:
                    print('genMonitor for target %s' % RESIM_TARGET)
                    cgc = genMonitor.GenMonitor(self.comp_dict, self.link_dict, cfg_file)
                    cgc.doInit()