示例#1
0
文件: mgr.py 项目: ryanm101/amitools
    def open_lib(
        self, full_name, version=0, cwd_lock=None, run_sp=None, progdir_lock=None
    ):
        """open a library

       return lib_base addr or 0
    """
        # get base name
        base_name = LibLoader.get_lib_base_name(full_name)
        log_libmgr.info(
            "open_lib: '%s' ver=%d -> base_name='%s'", full_name, version, base_name
        )
        # get lib params
        lib_cfg = self.cfg.get_cfg(full_name, base_name)
        log_libmgr.info("-> cfg: %s", lib_cfg)
        # handle mode
        mode = lib_cfg.get_create_mode()
        if mode == LibCfg.CREATE_MODE_OFF:
            return 0
        try_vlib, try_alib, fake = self._map_mode(mode)

        # try vamos first
        addr = 0
        vlib = None
        if try_vlib:
            # get presented version of lib
            lib_version = 0
            force_version = lib_cfg.get_force_version()
            if force_version is not None:
                lib_version = force_version
            log_libmgr.info("vlib: version=%d, fake=%s", lib_version, fake)
            # open vlib
            vlib = self.vlib_mgr.open_lib_name(
                base_name, version=lib_version, fake=fake, lib_cfg=lib_cfg
            )
            if vlib:
                addr = vlib.get_addr()
                log_libmgr.info("got vlib: @%06x", addr)

        # try amiga lib
        if try_alib and addr == 0:
            addr = self.alib_mgr.open_lib(full_name, cwd_lock, run_sp, progdir_lock)
            if addr > 0:
                log_libmgr.info("got alib: @%06x", addr)

        # got a lib? check version
        if addr > 0:
            save_addr = addr
            if version > 0:
                addr = self._check_version(full_name, addr, version)
            # lib is too old: close again
            if addr == 0:
                if vlib:
                    self.vlib_mgr.close_lib(vlib)
                else:
                    self.alib_mgr.close_lib(save_addr, run_sp=run_sp)

        # result lib base
        return addr
示例#2
0
文件: mgr.py 项目: cnvogelg/amitools
  def open_lib(self, full_name, version=0, cwd_lock=None, run_sp=None,
               progdir_lock=None):
    """open a library

       return lib_base addr or 0
    """
    # get base name
    base_name = LibLoader.get_lib_base_name(full_name)
    log_libmgr.info("open_lib: '%s' ver=%d -> base_name='%s'",
                    full_name, version, base_name)
    # get lib params
    lib_cfg = self.cfg.get_cfg(full_name, base_name)
    log_libmgr.info("-> cfg: %s", lib_cfg)
    # handle mode
    mode = lib_cfg.get_create_mode()
    if mode == LibCfg.CREATE_MODE_OFF:
      return 0
    try_vlib, try_alib, fake = self._map_mode(mode)

    # try vamos first
    addr = 0
    vlib = None
    if try_vlib:
      # get presented version of lib
      lib_version = 0
      force_version = lib_cfg.get_force_version()
      if force_version is not None:
        lib_version = force_version
      log_libmgr.info("vlib: version=%d, fake=%s", lib_version, fake)
      # open vlib
      vlib = self.vlib_mgr.open_lib_name(base_name,
                                         version=lib_version,
                                         fake=fake,
                                         lib_cfg=lib_cfg)
      if vlib:
        addr = vlib.get_addr()
        log_libmgr.info("got vlib: @%06x", addr)

    # try amiga lib
    if try_alib and addr == 0:
      addr = self.alib_mgr.open_lib(full_name, cwd_lock, run_sp, progdir_lock)
      if addr > 0:
        log_libmgr.info("got alib: @%06x", addr)

    # got a lib? check version
    if addr > 0:
      save_addr = addr
      if version > 0:
        addr = self._check_version(full_name, addr, version)
      # lib is too old: close again
      if addr == 0:
        if vlib:
          self.vlib_mgr.close_lib(vlib)
        else:
          self.alib_mgr.close_lib(save_addr, run_sp=run_sp)

    # result lib base
    return addr
示例#3
0
    def open_lib(self,
                 full_name,
                 open_ver=0,
                 lock=None,
                 run_sp=None,
                 mode=None,
                 version=None):
        """open a library

       return lib_base addr or 0
    """
        # get base name
        base_name = LibLoader.get_lib_base_name(full_name)
        log_libmgr.info("open_lib: '%s' ver=%d -> base_name='%s'", full_name,
                        open_ver, base_name)
        # get lib params
        mode, version = self._get_lib_params(full_name, base_name, mode,
                                             version)
        log_libmgr.info("params: mode=%s, version=%d", mode, version)
        # handle mode
        if mode == self.MODE_OFF:
            return 0
        try_vlib, try_alib, fake = self._map_mode(mode)

        # try vamos first
        addr = 0
        vlib = None
        if try_vlib:
            vlib = self.vlib_mgr.open_lib_name(base_name,
                                               version=version,
                                               fake=fake)
            if vlib:
                addr = vlib.get_addr()
                log_libmgr.info("got vlib: @%06x", addr)
        # try amiga lib
        if try_alib and addr == 0:
            addr = self.alib_mgr.open_lib(full_name, lock, run_sp)
            if addr > 0:
                log_libmgr.info("got alib: @%06x", addr)

        # got a lib? check version
        if addr > 0:
            save_addr = addr
            if open_ver > 0:
                addr = self._check_version(full_name, addr, open_ver)
            # lib is too old: close again
            if addr == 0:
                if vlib:
                    self.vlib_mgr.close_lib(vlib)
                else:
                    self.alib_mgr.close_lib(save_addr, run_sp=run_sp)
        # result lib base
        return addr
示例#4
0
def setup(path_mgr=None):
    machine = Machine()
    mem = machine.get_mem()
    alloc = MemoryAlloc.for_machine(machine)
    segload = SegmentLoader(alloc, path_mgr=path_mgr)
    loader = LibLoader(machine, alloc, segload)
    sp = machine.get_ram_begin() - 4
    # setup exec
    exec_lib = ExecLibrary.alloc(alloc, "exec.library", "bla", 520 * 6)
    exec_lib.setup()
    exec_lib.fill_funcs()
    exec_base = exec_lib.get_addr()
    mem.w32(4, exec_base)
    machine.set_zero_mem(0, exec_base)
    return loader, segload, alloc, mem, sp, exec_lib
示例#5
0
def setup(path_mgr=None):
    machine = Machine()
    mem = machine.get_mem()
    alloc = MemoryAlloc.for_machine(machine)
    segload = SegmentLoader(alloc, path_mgr=path_mgr)
    loader = LibLoader(machine, alloc, segload)
    sp = machine.get_ram_begin() - 4
    # setup exec
    exec_lib = ExecLibrary.alloc(alloc,
                                 name="exec.library",
                                 id_string="bla",
                                 neg_size=520 * 6)
    assert exec_lib.LibNode.neg_size.val == 520 * 6
    exec_lib.new_lib()
    exec_lib.fill_funcs()
    exec_base = exec_lib.get_addr()
    mem.w32(4, exec_base)
    machine.set_zero_mem(0, exec_base)
    return loader, segload, alloc, mem, sp, exec_lib