コード例 #1
0
ファイル: Process.py プロジェクト: ilibz2012/amitools
 def init_cli_struct(self):
   self.cli = self.ctx.alloc.alloc_struct(self.bin_basename + "_CLI",CLIDef)
   self.cli.access.w_s("cli_DefaultStack", self.stack_size / 4) # in longs
   self.cmd = self.ctx.alloc.alloc_bstr(self.bin_basename + "_cmd",self.bin_file)
   log_proc.info(self.cmd)
   self.cli.access.w_s("cli_CommandName", self.cmd.addr)
   log_proc.info(self.cli)
コード例 #2
0
ファイル: Process.py プロジェクト: ezrec/amitools
 def init_task_struct(self, input_fh, output_fh):
   # Inject arguments into input stream (Needed for C:Execute)
   self.ctx.file_mgr.ungets(input_fh, self.arg_text)
   self.this_task = self.ctx.alloc.alloc_struct(self.bin_basename + "_ThisTask",ProcessDef)
   self.this_task.access.w_s("pr_Task.tc_Node.ln_Type", NT_PROCESS)
   self.this_task.access.w_s("pr_CLI", self.cli.addr)
   self.this_task.access.w_s("pr_CIS", input_fh.b_addr<<2) # compensate BCPL auto-conversion
   self.this_task.access.w_s("pr_COS", output_fh.b_addr<<2) # compensate BCPL auto-conversion
   log_proc.info(self.this_task)
コード例 #3
0
 def init_task_struct(self, input_fh, output_fh):
   # Inject arguments into input stream (Needed for C:Execute)
   input_fh.ungets(self.arg_text)
   self.this_task = self.ctx.alloc.alloc_struct(self.bin_basename + "_ThisTask",ProcessDef)
   self.this_task.access.w_s("pr_Task.tc_Node.ln_Type", NT_PROCESS)
   self.this_task.access.w_s("pr_CLI", self.cli.addr)
   self.this_task.access.w_s("pr_CIS", input_fh.b_addr<<2) # compensate BCPL auto-conversion
   self.this_task.access.w_s("pr_COS", output_fh.b_addr<<2) # compensate BCPL auto-conversion
   log_proc.info(self.this_task)
コード例 #4
0
ファイル: Process.py プロジェクト: ezrec/amitools
 def init_cli_struct(self, input_fh, output_fh):
   self.cli = self.ctx.alloc.alloc_struct(self.bin_basename + "_CLI",CLIDef)
   self.cli.access.w_s("cli_DefaultStack", self.stack_size / 4) # in longs
   self.cmd = self.ctx.alloc.alloc_bstr(self.bin_basename + "_cmd",self.bin_file)
   log_proc.info(self.cmd)
   self.cli.access.w_s("cli_CommandName", self.cmd.addr)
   self.cli.access.w_s("cli_StandardInput", input_fh.b_addr)
   self.cli.access.w_s("cli_CurrentInput", input_fh.b_addr)
   self.cli.access.w_s("cli_StandardOutput", output_fh.b_addr)
   self.cli.access.w_s("cli_CurrentOutput", output_fh.b_addr)
   log_proc.info(self.cli)
コード例 #5
0
ファイル: Process.py プロジェクト: ezrec/amitools
 def init_args(self, bin_args):
   # setup arguments
   self.bin_args = bin_args
   self.arg_text = " ".join(bin_args) + "\n" # AmigaDOS appends a new line to the end
   self.arg_len  = len(self.arg_text)
   self.arg_size = self.arg_len + 1
   self.arg = self.ctx.alloc.alloc_memory(self.bin_basename + "_args", self.arg_size)
   self.arg_base = self.arg.addr
   self.ctx.mem.access.w_cstr(self.arg_base, self.arg_text)
   log_proc.info("args: '%s' (%d)", self.arg_text[:-1], self.arg_size)
   log_proc.info(self.arg)
コード例 #6
0
 def init_cli_struct(self, input_fh, output_fh):
   self.cli = self.ctx.alloc.alloc_struct(self.bin_basename + "_CLI",CLIDef)
   self.cli.access.w_s("cli_DefaultStack", self.stack_size / 4) # in longs
   self.cmd = self.ctx.alloc.alloc_bstr(self.bin_basename + "_cmd",self.bin_file)
   log_proc.info(self.cmd)
   self.cli.access.w_s("cli_CommandName", self.cmd.addr)
   self.cli.access.w_s("cli_StandardInput", input_fh.b_addr)
   self.cli.access.w_s("cli_CurrentInput", input_fh.b_addr)
   self.cli.access.w_s("cli_StandardOutput", output_fh.b_addr)
   self.cli.access.w_s("cli_CurrentOutput", output_fh.b_addr)
   log_proc.info(self.cli)
コード例 #7
0
 def init_args(self, bin_args):
   # setup arguments
   self.bin_args = bin_args
   self.arg_text = " ".join(bin_args) + "\n" # AmigaDOS appends a new line to the end
   self.arg_len  = len(self.arg_text)
   self.arg_size = self.arg_len + 1
   self.arg = self.ctx.alloc.alloc_memory(self.bin_basename + "_args", self.arg_size)
   self.arg_base = self.arg.addr
   self.ctx.mem.access.w_cstr(self.arg_base, self.arg_text)
   log_proc.info("args: '%s' (%d)", self.arg_text[:-1], self.arg_size)
   log_proc.info(self.arg)
コード例 #8
0
ファイル: Process.py プロジェクト: ezrec/amitools
 def load_binary(self, ami_bin_file):
   self.bin_basename = self.ctx.path_mgr.ami_name_of_path(ami_bin_file)
   self.bin_file = ami_bin_file
   self.bin_seg_list = self.ctx.seg_loader.load_seg(ami_bin_file)
   if self.bin_seg_list == None:
     log_proc.error("failed loading binary: %s", self.ctx.seg_loader.error)
     return False
   self.prog_start = self.bin_seg_list.prog_start
   log_proc.info("loaded binary: %s", self.bin_seg_list)
   for seg in self.bin_seg_list.segments:
     log_proc.info(seg)
   return True
コード例 #9
0
 def load_binary(self, ami_bin_file):
   self.bin_basename = self.ctx.path_mgr.ami_name_of_path(ami_bin_file)
   self.bin_file = ami_bin_file
   self.bin_seg_list = self.ctx.seg_loader.load_seg(ami_bin_file)
   if self.bin_seg_list == None:
     log_proc.error("failed loading binary: %s", self.ctx.seg_loader.error)
     return False
   self.prog_start = self.bin_seg_list.prog_start
   log_proc.info("loaded binary: %s", self.bin_seg_list)
   for seg in self.bin_seg_list.segments:
     log_proc.info(seg)
   return True
コード例 #10
0
ファイル: Process.py プロジェクト: ilibz2012/amitools
 def init_task_struct(self, input_fh, output_fh):
   if input_fh == None:
     input_fh = self.ctx.file_mgr.get_input()
   if output_fh == None:
     output_fh = self.ctx.file_mgr.get_output()
   self.input_fh = input_fh
   self.output_fh = output_fh
   self.this_task = self.ctx.alloc.alloc_struct(self.bin_basename + "_ThisTask",ProcessDef)
   self.this_task.access.w_s("pr_CLI", self.cli.addr)
   self.this_task.access.w_s("pr_CIS", input_fh.b_addr<<2) # compensate BCPL auto-conversion
   self.this_task.access.w_s("pr_COS", output_fh.b_addr<<2) # compensate BCPL auto-conversion
   log_proc.info(self.this_task)
コード例 #11
0
 def init_cwd(self, cwd, cwd_lock):
   self.cwd = cwd
   if cwd is not None and cwd_lock is None:
     lock_mgr = self.ctx.dos_lib.lock_mgr
     dos_list = self.ctx.dos_lib.dos_list
     entry = dos_list.get_entry_by_name('root')
     lock = entry.locks[0]
     self.cwd_lock = lock_mgr.create_lock(lock, cwd, False)
     log_proc.info("current dir: cwd=%s create lock=%s", cwd, self.cwd_lock)
     self.cwd_shared = False
   else:
     self.cwd_lock = cwd_lock
     self.cwd_shared = True
     log_proc.info("current dir: cwd=%s shared lock=%s", cwd, self.cwd_lock)
コード例 #12
0
 def init_stack(self, stack_size, exit_addr):
   self.exit_addr = exit_addr
   self.stack_size = stack_size
   self.stack = self.ctx.alloc.alloc_memory( self.bin_basename + "_stack", self.stack_size )
   self.stack_base = self.stack.addr
   self.stack_end = self.stack_base + self.stack_size
   log_proc.info("stack: base=%06x end=%06x", self.stack_base, self.stack_end)
   log_proc.info(self.stack)
   # prepare stack
   # TOP: size
   # TOP-4: return from program -> magic_ed
   self.stack_initial = self.stack_end - 4
   self.ctx.mem.access.w32(self.stack_initial, self.stack_size)
   self.stack_initial -= 4
   self.ctx.mem.access.w32(self.stack_initial, self.exit_addr)
コード例 #13
0
ファイル: Process.py プロジェクト: apiraino/amitools
 def init_stack(self, stack_size, exit_addr):
   self.exit_addr = exit_addr
   self.stack_size = stack_size
   self.stack = self.ctx.alloc.alloc_memory( self.bin_basename + "_stack", self.stack_size )
   self.stack_base = self.stack.addr
   self.stack_end = self.stack_base + self.stack_size
   log_proc.info("stack: base=%06x end=%06x", self.stack_base, self.stack_end)
   log_proc.info(self.stack)
   # prepare stack
   # TOP: size
   # TOP-4: return from program -> magic_ed
   self.stack_initial = self.stack_end - 4
   self.ctx.mem.access.w32(self.stack_initial, self.stack_size)
   self.stack_initial -= 4
   self.ctx.mem.access.w32(self.stack_initial, self.exit_addr)
コード例 #14
0
 def init_args(self, bin_args, fh):
   # setup arguments
   self.bin_args = bin_args
   text_args = ""
   gap = False
   for arg in bin_args:
     if gap:
       text_args = text_args + " "
     text_args = text_args + self.quote_arg(arg)
     gap = True
   self.arg_text = text_args + "\n" # AmigaDOS appends a new line to the end
   self.arg_len  = len(self.arg_text)
   fh.setbuf(self.arg_text) # Tripos makes the input line available as buffered input for ReadItem()
   self.arg_size = self.arg_len + 1
   self.arg = self.ctx.alloc.alloc_memory(self.bin_basename + "_args", self.arg_size)
   self.arg_base = self.arg.addr
   self.ctx.mem.access.w_cstr(self.arg_base, self.arg_text)
   log_proc.info("args: '%s' (%d)", self.arg_text[:-1], self.arg_size)
   log_proc.info(self.arg)
コード例 #15
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
   self.bin_seg_list = self.ctx.seg_loader.load_seg(lock,ami_bin_file)
   if self.bin_seg_list == None:
     log_proc.error("failed loading binary: %s", self.ctx.seg_loader.error)
     return False
   self.prog_start = self.bin_seg_list.prog_start
   # 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", self.bin_seg_list)
   for seg in self.bin_seg_list.segments:
     log_proc.info(seg)
   return True
コード例 #16
0
ファイル: Process.py プロジェクト: apiraino/amitools
 def init_args(self, bin_args, fh):
   # setup arguments
   self.bin_args = bin_args
   text_args = ""
   gap = False
   for arg in bin_args:
     if gap:
       text_args = text_args + " "
     text_args = text_args + self.quote_arg(arg)
     gap = True
   self.arg_text = text_args + "\n" # AmigaDOS appends a new line to the end
   self.arg_len  = len(self.arg_text)
   fh.setbuf(self.arg_text) # Tripos makes the input line available as buffered input for ReadItem()
   self.arg_size = self.arg_len + 1
   self.arg = self.ctx.alloc.alloc_memory(self.bin_basename + "_args", self.arg_size)
   self.arg_base = self.arg.addr
   self.ctx.mem.access.w_cstr(self.arg_base, self.arg_text)
   log_proc.info("args: '%s' (%d)", self.arg_text[:-1], self.arg_size)
   log_proc.info(self.arg)
コード例 #17
0
ファイル: Process.py プロジェクト: apiraino/amitools
 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
   self.bin_seg_list = self.ctx.seg_loader.load_seg(lock,ami_bin_file)
   if self.bin_seg_list == None:
     log_proc.error("failed loading binary: %s", self.ctx.seg_loader.error)
     return False
   self.prog_start = self.bin_seg_list.prog_start
   # 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", self.bin_seg_list)
   for seg in self.bin_seg_list.segments:
     log_proc.info(seg)
   return True
コード例 #18
0
 def init_cli_struct(self, input_fh, output_fh, name):
   self.cli = self.ctx.alloc.alloc_struct(self.bin_basename + "_CLI",CLIDef)
   self.cli.access.w_s("cli_DefaultStack", self.stack_size / 4) # in longs
   if input_fh != None:
     self.cli.access.w_s("cli_StandardInput", input_fh.b_addr)
     self.cli.access.w_s("cli_CurrentInput", input_fh.b_addr)
   if output_fh != None:
     self.cli.access.w_s("cli_StandardOutput", output_fh.b_addr)
     self.cli.access.w_s("cli_CurrentOutput", output_fh.b_addr)
   self.prompt  = self.ctx.alloc.alloc_memory("cli_Prompt",60)
   self.cmdname = self.ctx.alloc.alloc_memory("cli_CommandName",104)
   self.cmdfile = self.ctx.alloc.alloc_memory("cli_CommandFile",40)
   self.setname = self.ctx.alloc.alloc_memory("cli_SetName",80)
   self.cli.access.w_s("cli_Prompt",self.prompt.addr)
   self.cli.access.w_s("cli_CommandName",self.cmdname.addr)
   self.cli.access.w_s("cli_CommandFile",self.cmdfile.addr)
   self.cli.access.w_s("cli_SetName",self.setname.addr)
   if name != None:
     self.ctx.mem.access.w_bstr(self.cmdname.addr,name)
   log_proc.info(self.cli)
コード例 #19
0
ファイル: Process.py プロジェクト: apiraino/amitools
 def init_cli_struct(self, input_fh, output_fh, name):
   self.cli = self.ctx.alloc.alloc_struct(self.bin_basename + "_CLI",CLIDef)
   self.cli.access.w_s("cli_DefaultStack", self.stack_size / 4) # in longs
   if input_fh != None:
     self.cli.access.w_s("cli_StandardInput", input_fh.b_addr)
     self.cli.access.w_s("cli_CurrentInput", input_fh.b_addr)
   if output_fh != None:
     self.cli.access.w_s("cli_StandardOutput", output_fh.b_addr)
     self.cli.access.w_s("cli_CurrentOutput", output_fh.b_addr)
   self.prompt  = self.ctx.alloc.alloc_memory("cli_Prompt",60)
   self.cmdname = self.ctx.alloc.alloc_memory("cli_CommandName",104)
   self.cmdfile = self.ctx.alloc.alloc_memory("cli_CommandFile",40)
   self.setname = self.ctx.alloc.alloc_memory("cli_SetName",80)
   self.cli.access.w_s("cli_Prompt",self.prompt.addr)
   self.cli.access.w_s("cli_CommandName",self.cmdname.addr)
   self.cli.access.w_s("cli_CommandFile",self.cmdfile.addr)
   self.cli.access.w_s("cli_SetName",self.setname.addr)
   if name != None:
     self.ctx.mem.access.w_bstr(cmdname.addr,name)
   log_proc.info(self.cli)
コード例 #20
0
 def free_cwd(self):
   if self.cwd_lock is not None and not self.cwd_shared:
     log_proc.info("current_dir: free lock=%s", self.cwd_lock)
     lock_mgr = self.ctx.dos_lib.lock_mgr
     lock_mgr.release_lock(self.cwd_lock)