def runSim(exe_path, run_dir, policy_dir, runtime, gdb_port, soc_cfg, extra, use_validator=True): global run_cmd global uart_log_file global status_log_file global sim_log_file if use_validator == False: run_cmd = os.path.join(os.environ['ISP_PREFIX'],'stock-tools','bin','qemu-system-riscv32') else: run_cmd = os.path.join(os.environ['ISP_PREFIX'],'bin','qemu-system-riscv32') if isp_utils.generateTagInfo(exe_path, run_dir, policy_dir) is False: return isp_utils.retVals.TAG_FAIL try: logger.debug("Begin QEMU test... (timeout: {})".format(timeout_seconds)) if gdb_port is not 0: launchQEMUDebug(exe_path, run_dir, policy_dir, gdb_port, extra, runtime, use_validator) else: wd = threading.Thread(target=watchdog) wd.start() qemu = threading.Thread(target=launchQEMU, args=(exe_path, run_dir, policy_dir, runtime, extra, use_validator)) qemu.start() wd.join() qemu.join() finally: pass return isp_utils.retVals.SUCCESS
def tagInit(exe_path, run_dir, policy_dir, soc_cfg, arch, pex_kernel_path, flash_init_image_path, kernel_address, ap_address): ap_load_image_path = os.path.join( run_dir, os.path.basename(exe_path) + ".load_image") pex_load_image_path = os.path.join(run_dir, "pex.load_image") tag_file_path = os.path.join(run_dir, "bininfo", os.path.basename(exe_path) + ".taginfo") logger.debug("Using PEX kernel at path: {}".format(pex_kernel_path)) if not isp_utils.generateTagInfo( exe_path, run_dir, policy_dir, soc_cfg=soc_cfg, arch=arch): return False logger.debug("Using flash init file {}".format(flash_init_image_path)) if not os.path.exists(flash_init_image_path): logger.info("Generating flash init") isp_load_image.generate_tag_load_image(ap_load_image_path, tag_file_path) isp_load_image.generate_load_image(pex_kernel_path, pex_load_image_path) flash_init_map = { kernel_address: pex_load_image_path, ap_address: ap_load_image_path } isp_load_image.generate_flash_init(flash_init_image_path, flash_init_map) return True
def runSim(exe_path, run_dir, policy_dir, pex_path, runtime, rule_cache, gdb_port, tagfile, soc_cfg, arch, extra, use_validator=False, tag_only=False): extra_args = parseExtra(extra) ap_log_file = os.path.join(run_dir, "uart.log") pex_log_file = os.path.join(run_dir, "pex.log") tag_file_path = os.path.join(run_dir, "bininfo", os.path.basename(exe_path) + ".taginfo") ap_load_image_path = os.path.join( run_dir, os.path.basename(exe_path) + ".load_image") pex_load_image_path = os.path.join(run_dir, "pex.load_image") ap_hex_dump_path = os.path.join( run_dir, os.path.basename(ap_load_image_path) + ".hex") pex_hex_dump_path = os.path.join( run_dir, os.path.basename(pex_load_image_path) + ".hex") policy_name = os.path.basename(policy_dir) if not soc_cfg: soc_cfg = os.path.join(isp_prefix, "soc_cfg", "gfe-vcu118.yml") if isp_utils.generateTagInfo( exe_path, run_dir, policy_dir, soc_cfg=soc_cfg, arch=arch) is False: return isp_utils.retVals.TAG_FAIL logger.info("Generating hex files") tag_mem_hexdump_path = generateTagMemHexdump(tag_file_path, policy_name) isp_load_image.generate_load_image(exe_path, ap_load_image_path, tag_file_path) isp_load_image.generate_load_image(pex_path, pex_load_image_path) isp_load_image.generate_hex_dump(ap_load_image_path, ap_hex_dump_path, 64) isp_load_image.generate_hex_dump(pex_load_image_path, pex_hex_dump_path, 64) if tag_only is True: return isp_utils.retVals.SUCCESS # XXX: use default logfile names for now, update for parallel sim runs runVcsSim(exe_path, ap_hex_dump_path, pex_hex_dump_path, tag_mem_hexdump_path, extra_args.config, extra_args.debug, extra_args.timeout, extra_args.max_cycles, "uart.log", "pex.log") return isp_utils.retVals.SUCCESS
def runSim(exe_path, run_dir, policy_dir, pex_path, runtime, rule_cache, gdb_port, tagfile, soc_cfg, arch, extra, use_validator=True, tag_only=False): global run_cmd global uart_log_file global status_log_file if soc_cfg is None: soc_cfg = os.path.join(isp_prefix, "soc_cfg", "hifive_e_cfg.yml") else: soc_cfg = os.path.realpath(soc_cfg) logger.debug("Using SOC config {}".format(soc_cfg)) qemu_cmd = qemu_base_cmd + '32' if arch == 'rv64': qemu_cmd = qemu_base_cmd + '64' env = dict(os.environ) if use_validator == False: run_cmd = os.path.join(os.environ['ISP_PREFIX'], 'stock-tools', 'bin', qemu_cmd) else: run_cmd = os.path.join(os.environ['ISP_PREFIX'], 'bin', qemu_cmd) env = qemuSetupValidatorEnvironment(pex_path, run_dir, arch) doValidatorCfg(policy_dir, run_dir, exe_path, rule_cache, soc_cfg, tagfile) if tagfile is None: if isp_utils.generateTagInfo( exe_path, run_dir, policy_dir, arch=arch) is False: return isp_utils.retVals.TAG_FAIL if tag_only is True: return isp_utils.retVals.SUCCESS options = qemuOptions(exe_path, run_dir, extra, runtime, use_validator, gdb_port) try: logger.debug( "Begin QEMU test... (timeout: {})".format(timeout_seconds)) if gdb_port is not 0: launchQEMUDebug(run_dir, env, options) else: wd = threading.Thread(target=watchdog) wd.start() qemu = threading.Thread(target=launchQEMU, args=(run_dir, runtime, env, options)) qemu.start() wd.join() qemu.join() finally: pass return isp_utils.retVals.SUCCESS
def runSim(exe_path, run_dir, policy_dir, runtime, gdb_port, extra, soc_cfg, use_validator=True): global process_exit global connecting doRescScript(exe_path, run_dir, policy_dir, gdb_port) if use_validator == False: if isp_utils.generateTagInfo(exe_path, run_dir, policy_dir) is False: return retVals.TAG_FAIL try: logger.debug( "Begin Renode test... (timeout: {})".format(timeout_seconds)) wd = threading.Thread(target=watchdog) wd.start() logger.debug("Start Renode server...") renode = threading.Thread(target=launchRenode, args=(run_dir, )) renode.start() time.sleep(2) logger.debug("Start Logging...") uart_logger = threading.Thread(target=logUart, args=(run_dir, runtime)) uart_logger.start() logging.info(run_dir) status_logger = threading.Thread(target=logStatus, args=(run_dir, )) status_logger.start() logger.debug("Connecting to Renode server...") s = socketConnect(socket.gethostname(), renode_port) logger.debug("Connected.") if s: with open(os.path.join(run_dir, "main.resc"), 'r') as f: s.send(f.read().replace('\n', '\r\n').encode()) s.send('start\r\n'.encode()) while not process_exit: time.sleep(0.1) ready_r, ready_w, err = select.select([s], [], [], 1) if ready_r: print(s.recv(1024).decode().replace('\r', '')) if s: try: s.send('quit\r\n'.encode()) time.sleep(1) s.close() except: pass wd.join() uart_logger.join() status_logger.join() renode.join() finally: try: if s: s.send('quit\r\n'.encode()) time.sleep(1) s.close() except: pass return retVals.SUCCESS