def open_lib_proxy(self, full_name, version=0, run_sp=None): """Try to open library (vlib or alib) and return a python call proxy""" # try to open lib base_addr = self.lib_mgr.open_lib(full_name, version=version, run_sp=run_sp) if base_addr == 0: log_libmgr.warning("proxy: open_lib '%s' failed!", full_name) return None # is a vlib? vlib = self.lib_mgr.get_vlib_by_addr(base_addr) if vlib: return self._setup_stub_proxy(vlib, base_addr) else: # is an alib? ainfo = self.lib_mgr.get_alib_info_by_addr(base_addr) if ainfo: fd = ainfo.get_lib_fd() name = ainfo.get_name() # if an fd is available then we could create a proxy if fd: return self._setup_libcall_proxy(name, fd, base_addr, run_sp) else: log_libmgr.warning("proxy: no FD for '%s'", full_name) return None else: raise VamosInternalError("Neither vlib nor alib?!")
def _check_version(self, name, addr, open_ver): # check version lib = Library(self.mem, addr) lib_ver = lib.version if lib_ver < open_ver: log_libmgr.warning("lib '%s' has too low version: %d < %d", name, lib_ver, open_ver) return 0 else: log_libmgr.info("lib '%s' version %d ok for open version %d", name, lib_ver, open_ver) return addr
def _expunge_list(self, node_list): left_libs = 0 for node in node_list: lib_base = node.get_addr() # is it a vlib? if lib_base in self.addr_vlib: vlib = self.addr_vlib[lib_base] if not self.expunge_lib(vlib): lib = vlib.get_library() log_libmgr.warning( "can't expunge: '%s' with open count %d", lib.name, lib.open_cnt) left_libs += 1 return left_libs
def shutdown(self, run_sp=None): """cleanup libs try to expunge all libs and report still open ones """ log_libmgr.info("+shutdown") aleft = self.alib_mgr.shutdown(run_sp) if aleft > 0: log_libmgr.warning("shutdown: can't expunge %d amiga libs/devs!", aleft) vleft = self.vlib_mgr.shutdown() if vleft > 0: log_libmgr.warning("shutdown: can't expunge %d vamos libs/devs!", vleft) left = vleft + aleft log_libmgr.info("-shutdwon: aleft=%d, vleft=%d", aleft, vleft) return left
def _load_common(self, lib_name, seglist_baddr, run_sp): # find resident in first hunk seglist = SegList(self.alloc, seglist_baddr) seg = seglist.get_segment() res = Resident.find(self.mem, seg.get_addr(), seg.get_size()) # unload seglist if no resident was found if not res: log_libmgr.warning("%s: no resident found!", lib_name) self.segloader.unload_seglist(seglist_baddr) return 0, 0 # init resident lib_base, _ = self.initres.init_resident(res.get_addr(), seglist.get_baddr(), run_sp=run_sp) # unload seglist on error if lib_base == 0: log_libmgr.warning("%s: init resident failed!", lib_name) self.segloader.unload_seglist(seglist_baddr) return 0, 0 return lib_base, seglist_baddr