Example #1
0
 def load_binary(self, lock, ami_bin_file, shell=False):
   self.bin_basename = self.ctx.path_mgr.ami_name_of_path(lock,ami_bin_file)
   self.bin_file     = ami_bin_file
   sys_path, ami_path = self.ctx.path_mgr.ami_command_to_sys_path(lock, ami_bin_file)
   if not sys_path:
     log_proc.error("failed loading binary: %s -> %s", ami_bin_file, sys_path)
     return False
   self.bin_seg_list = self.ctx.seg_loader.load_sys_seglist(sys_path)
   info = self.ctx.seg_loader.get_info(self.bin_seg_list)
   self.prog_start = info.seglist.get_segment().get_addr()
   # set home dir and get lock
   self.home_dir = self.ctx.path_mgr.ami_dir_of_path(lock, ami_path)
   lock_mgr = self.ctx.dos_lib.lock_mgr
   self.home_lock = lock_mgr.create_lock(lock, self.home_dir, False)
   log_proc.info("home dir: %s", self.home_lock)
   # THOR: If this is a shell, then the seglist requires BCPL linkage and
   # initialization of the GlobVec. Fortunately, for the 3.9 shell all this
   # magic is not really required, and the BCPL call-in (we use) is at
   # offset +8
   if shell:
     self.prog_start += 8
     self.shell_start = self.prog_start
   log_proc.info("loaded binary: %s", info)
   for seg in info.seglist:
     log_proc.info(seg)
   return True
Example #2
0
 def load_binary(self, lock, ami_bin_file, shell=False):
     self.bin_basename = self.ctx.path_mgr.ami_name_of_path(
         lock, ami_bin_file)
     self.bin_file = ami_bin_file
     sys_path, ami_path = self.ctx.path_mgr.ami_command_to_sys_path(
         lock, ami_bin_file)
     if not sys_path:
         log_proc.error("failed loading binary: %s -> %s", ami_bin_file,
                        sys_path)
         return False
     self.bin_seg_list = self.ctx.seg_loader.load_sys_seglist(sys_path)
     info = self.ctx.seg_loader.get_info(self.bin_seg_list)
     self.prog_start = info.seglist.get_segment().get_addr()
     # set home dir and get lock
     self.home_dir = self.ctx.path_mgr.ami_dir_of_path(lock, ami_path)
     lock_mgr = self.ctx.dos_lib.lock_mgr
     self.home_lock = lock_mgr.create_lock(lock, self.home_dir, False)
     log_proc.info("home dir: %s", self.home_lock)
     # THOR: If this is a shell, then the seglist requires BCPL linkage and
     # initialization of the GlobVec. Fortunately, for the 3.9 shell all this
     # magic is not really required, and the BCPL call-in (we use) is at
     # offset +8
     if shell:
         self.prog_start += 8
         self.shell_start = self.prog_start
     log_proc.info("loaded binary: %s", info)
     for seg in info.seglist:
         log_proc.info(seg)
     return True
Example #3
0
    def create_main_proc(cls, proc_cfg, path_mgr, dos_ctx):
        # a single Amiga-like raw arg was passed
        cmd_cfg = proc_cfg.command
        if cmd_cfg.raw_arg:
            # check args
            if len(cmd_cfg.args) > 0:
                log_proc.error("raw arg only allows a single argument!")
                return None
            # parse raw arg
            cl = CommandLine()
            res = cl.parse_line(cmd_cfg.binary)
            if res != cl.LINE_OK:
                log_proc.error("raw arg is invalid! (error %d)", res)
                return None
            binary = cl.get_cmd()
            arg_str = cl.get_arg_str()
        else:
            # setup binary
            binary = cmd_cfg.binary
            if not cmd_cfg.pure_ami_path:
                # if path exists on host system then make an ami path
                if os.path.exists(binary):
                    sys_binary = binary
                    binary = path_mgr.from_sys_path(binary)
                    if not binary:
                        log_proc.error("can't map binary: %s", sys_binary)
                        return None
            # combine remaining args to arg_str
            arg_str = sys_args_to_ami_arg_str(cmd_cfg.args)

        # summary
        stack_size = proc_cfg.stack * 1024
        shell = proc_cfg.command.shell
        log_proc.info("binary: '%s'", binary)
        log_proc.info("args:   '%s'", arg_str[:-1])
        log_proc.info("stack:  %d", stack_size)

        cwd = str(path_mgr.get_cwd())
        proc = cls(dos_ctx,
                   binary,
                   arg_str,
                   stack_size=stack_size,
                   shell=shell,
                   cwd=cwd)
        if not proc.ok:
            return None
        log_proc.info("set main process: %s", proc)
        return proc
Example #4
0
  def create_main_proc(cls, proc_cfg, path_mgr, dos_ctx):
    # a single Amiga-like raw arg was passed
    cmd_cfg = proc_cfg.command
    if cmd_cfg.raw_arg:
      # check args
      if len(cmd_cfg.args) > 0:
        log_proc.error("raw arg only allows a single argument!")
        return None
      # parse raw arg
      cl = CommandLine()
      res = cl.parse_line(cmd_cfg.binary)
      if res != cl.LINE_OK:
        log_proc.error("raw arg is invalid! (error %d)", res)
        return None
      binary = cl.get_cmd()
      arg_str = cl.get_arg_str()
    else:
      # setup binary
      binary = cmd_cfg.binary
      if not cmd_cfg.pure_ami_path:
        # if path exists on host system then make an ami path
        if os.path.exists(binary):
          sys_binary = binary
          binary = path_mgr.from_sys_path(binary)
          if not binary:
            log_proc.error("can't map binary: %s", sys_binary)
            return None
      # combine remaining args to arg_str
      arg_str = sys_args_to_ami_arg_str(cmd_cfg.args)

    # summary
    stack_size = proc_cfg.stack * 1024
    shell = proc_cfg.command.shell
    log_proc.info("binary: '%s'", binary)
    log_proc.info("args:   '%s'", arg_str[:-1])
    log_proc.info("stack:  %d", stack_size)

    cwd = str(path_mgr.get_cwd())
    proc = cls(dos_ctx, binary, arg_str, stack_size=stack_size,
               shell=shell, cwd=cwd)
    if not proc.ok:
      return None
    log_proc.info("set main process: %s", proc)
    return proc