Exemplo n.º 1
0
 def _create_vlib(self, lib_info, fake, lib_cfg=None):
     # get lib ctx
     name = lib_info.get_name()
     ctx = self.ctx_map.get(name, None)
     # create new context?
     if not ctx:
         ctx = LibCtx(self.machine)
         self.ctx_map[name] = ctx
         self._add_ctx_extra_attr(ctx)
     # get impl
     if fake:
         impl = None
     else:
         name = lib_info.get_name()
         impl_cls = self.lib_reg.get_lib_impl(name)
         if impl_cls:
             impl = impl_cls()
             # adjust version?
             if lib_info.version == 0:
                 lib_info.version = impl.get_version()
         else:
             return None
     # create lib
     vlib = self.creator.create_lib(lib_info, ctx, impl, lib_cfg)
     # store vlib in context
     ctx.vlib = vlib
     return vlib
Exemplo n.º 2
0
 def __init__(self, machine, alloc, seg_loader, path_mgr, vamos):
     LibCtx.__init__(self, machine)
     self.alloc = alloc
     self.path_mgr = path_mgr
     self.seg_loader = seg_loader
     self.vamos = vamos
     # compat for process
     self.process = None
     self.exec_lib = None
     self.dos_lib = None
Exemplo n.º 3
0
 def __init__(self, machine, alloc, seg_loader, path_mgr):
     LibCtx.__init__(self, machine)
     self.machine = machine
     self.traps = machine.get_traps()
     self.cpu_type = machine.get_cpu_type()
     self.ram_size = self.mem.get_ram_size_bytes()
     self.label_mgr = machine.get_label_mgr()
     self.alloc = alloc
     self.seg_loader = seg_loader
     self.path_mgr = path_mgr
     self.process = None
Exemplo n.º 4
0
 def __init__(self, machine, alloc, seg_loader, path_mgr):
   LibCtx.__init__(self, machine)
   self.machine = machine
   self.traps = machine.get_traps()
   self.cpu_type = machine.get_cpu_type()
   self.cpu_name = machine.get_cpu_name()
   self.ram_size = self.mem.get_ram_size_bytes()
   self.label_mgr = machine.get_label_mgr()
   self.alloc = alloc
   self.seg_loader = seg_loader
   self.path_mgr = path_mgr
   self.process = None
Exemplo n.º 5
0
 def __init__(self, cpu, mem, cpu_type, ram_size, label_mgr, alloc, traps,
              seg_loader, path_mgr):
     LibCtx.__init__(self, cpu, mem)
     self.cpu_type = cpu_type
     self.ram_size = ram_size
     self.label_mgr = label_mgr
     self.lib_mgr = None
     self.alloc = alloc
     self.traps = traps
     self.process = None
     self.seg_loader = seg_loader
     self.path_mgr = path_mgr
Exemplo n.º 6
0
 def __init__(self, machine, alloc, seg_loader, path_mgr, run_command,
              start_sub_process):
     LibCtx.__init__(self, machine)
     self.alloc = alloc
     self.path_mgr = path_mgr
     self.seg_loader = seg_loader
     self.run_command = run_command
     self.start_sub_process = start_sub_process
     # compat for process
     self.process = None
     self.exec_lib = None
     self.dos_lib = None
Exemplo n.º 7
0
 def __init__(self, machine, alloc, seg_loader, path_mgr,
              scheduler, odg_base):
   LibCtx.__init__(self, machine)
   self.alloc = alloc
   self.path_mgr = path_mgr
   self.seg_loader = seg_loader
   self.scheduler = scheduler
   self.odg_base = odg_base
   # compat for process
   self.process = None
   self.exec_lib = None
   self.dos_lib = None
Exemplo n.º 8
0
def setup():
    mem = MockMemory(fill=23)
    traps = MockTraps()
    cpu = MockCPU()
    alloc = MemoryAlloc(mem)
    ctx = LibCtx(cpu, mem)
    return mem, traps, alloc, ctx
Exemplo n.º 9
0
def setup():
    machine = MockMachine(fill=23)
    mem = machine.get_mem()
    traps = machine.get_traps()
    cpu = machine.get_cpu()
    alloc = MemoryAlloc.for_machine(machine)
    ctx = LibCtx(machine)
    return mem, traps, alloc, ctx
Exemplo n.º 10
0
 def _setup_libcall_proxy(self, name, fd, base_addr, run_sp):
     type_name = self._get_proxy_type_name(name)
     # cached proxy?
     proxy_type = self.proxy_cache.get(type_name, None)
     if not proxy_type:
         log_libmgr.info("proxy: create libcall type '%s'", type_name)
         # no, create it
         proxy_type = self.proxy_gen.gen_proxy_for_libcall(type_name, fd)
         self.proxy_cache[type_name] = proxy_type
     # create instance
     ctx = LibCtx(self.lib_mgr.machine)
     log_libmgr.info("proxy: create libcall proxy %s@%08x", type_name,
                     base_addr)
     return proxy_type(ctx, base_addr, run_sp=run_sp)
Exemplo n.º 11
0
def _create_ctx():
    machine = MockMachine()
    return LibCtx(machine)
Exemplo n.º 12
0
def _create_ctx():
    cpu = MockCPU()
    mem = MockMemory()
    return LibCtx(cpu, mem)
Exemplo n.º 13
0
def _create_ctx():
    machine = MockMachine()
    # prepare PrintString()
    machine.mem.w_cstr(0x10, "hello, world!")
    machine.cpu.w_reg(REG_A0, 0x10)
    return LibCtx(machine)