def parse_disasm_def(fname): global CPU_PLUGIN with open(fname) as f: for l in f: l = filter_config_line(l) if not l: continue #print(l) while True: if not l: #return break if l[0] == "[": section = l[1:-1] print("Processing section: %s" % section) if section == "entrypoints": l = parse_entrypoints(f) elif section == "subareas": l = parse_subareas(f) else: assert 0, "Unknown section: " + section else: break if not l: break if l.startswith("load"): args = l.split() if args[2][0] in string.digits: addr = int(args[2], 0) print("Loading %s @0x%x" % (args[1], addr)) engine.ADDRESS_SPACE.load_content(open(args[1], "rb"), addr) else: print("Loading %s (%s plugin)" % (args[1], args[2])) loader = __import__(args[2]) load_target_file(loader, args[1]) elif l.startswith("cpu "): args = l.split() CPU_PLUGIN = __import__(args[1]) if hasattr(CPU_PLUGIN, "arch_id"): engine.set_arch_id(CPU_PLUGIN.arch_id) print("Loading CPU plugin %s" % (args[1])) elif l.startswith("show bytes "): args = l.split() APP.show_bytes = int(args[2]) elif l.startswith("area "): args = l.split() assert len(args) == 4 start, end = parse_range(args[2]) a = engine.ADDRESS_SPACE.add_area(start, end, { "name": args[1], "access": args[3].upper() }) print("Adding area: %s" % engine.str_area(a)) else: assert 0, "Unknown directive: " + l
def parse_disasm_def(fname): global CPU_PLUGIN with open(fname) as f: for l in f: l = filter_config_line(l) if not l: continue #print(l) while True: if not l: #return break if l[0] == "[": section = l[1:-1] print("Processing section: %s" % section) if section == "entrypoints": l = parse_entrypoints(f) elif section == "subareas": l = parse_subareas(f) else: assert 0, "Unknown section: " + section else: break if not l: break if l.startswith("load"): args = l.split() if args[2][0] in string.digits: addr = str2int(args[2]) print("Loading %s @0x%x" % (args[1], addr)) engine.ADDRESS_SPACE.load_content(open(args[1], "rb"), addr) else: print("Loading %s (%s plugin)" % (args[1], args[2])) loader = __import__(args[2]) load_target_file(loader, args[1]) elif l.startswith("cpu "): args = l.split() CPU_PLUGIN = __import__(args[1]) if hasattr(CPU_PLUGIN, "arch_id"): engine.set_arch_id(CPU_PLUGIN.arch_id) print("Loading CPU plugin %s" % (args[1])) elif l.startswith("show bytes "): args = l.split() APP.show_bytes = int(args[2]) elif l.startswith("area "): args = l.split() assert len(args) == 4 start, end = parse_range(args[2]) a = engine.ADDRESS_SPACE.add_area(start, end, {"name": args[1], "access": args[3].upper()}) print("Adding area: %s" % engine.str_area(a)) else: assert 0, "Unknown directive: " + l
import default_plugins for loader_id in default_plugins.loaders: loader = __import__(loader_id) arch_id = loader.detect(args.file) if arch_id: break if not arch_id: print("Error: file '%s' not recognized by default loaders" % args.file) sys.exit(1) if arch_id not in default_plugins.cpus: print("Error: no plugin for CPU '%s' as detected for file '%s'" % (arch_id, args.file)) sys.exit(1) engine.set_arch_id(arch_id) load_target_file(loader, args.file) CPU_PLUGIN = __import__(default_plugins.cpus[arch_id]) project_name = args.file p = CPU_PLUGIN.PROCESSOR_ENTRY() if hasattr(p, "config"): p.config() engine.set_processor(p) if hasattr(p, "help_text"): help.set_cpu_help(p.help_text) APP.cpu_plugin = p APP.aspace = engine.ADDRESS_SPACE APP.is_ui = False engine.ADDRESS_SPACE.is_loading = True
project_name = args.file.rsplit(".", 1)[0] else: import default_plugins for loader_id in default_plugins.loaders: loader = __import__(loader_id) arch_id = loader.detect(args.file) if arch_id: break if not arch_id: print("Error: file '%s' not recognized by default loaders" % args.file) sys.exit(1) if arch_id not in default_plugins.cpus: print("Error: no plugin for CPU '%s' as detected for file '%s'" % (arch_id, args.file)) sys.exit(1) engine.set_arch_id(arch_id) load_target_file(loader, args.file) CPU_PLUGIN = __import__(default_plugins.cpus[arch_id]) project_name = args.file p = CPU_PLUGIN.PROCESSOR_ENTRY() if hasattr(p, "config"): p.config() engine.set_processor(p) if hasattr(p, "help_text"): help.set_cpu_help(p.help_text) APP.cpu_plugin = p APP.aspace = engine.ADDRESS_SPACE APP.is_ui = False engine.ADDRESS_SPACE.is_loading = True