当前位置: 首页>>代码示例>>Python>>正文


Python AccessStruct.AccessStruct类代码示例

本文整理汇总了Python中amitools.vamos.AccessStruct.AccessStruct的典型用法代码示例。如果您正苦于以下问题:Python AccessStruct类的具体用法?Python AccessStruct怎么用?Python AccessStruct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AccessStruct类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AddSemaphore

 def AddSemaphore(self,ctx):
   addr     = ctx.cpu.r_reg(REG_A1)
   sstruct  = AccessStruct(ctx.mem,SignalSemaphoreDef,addr)
   name_ptr = sstruct.r_s("ss_Link.ln_Name")
   name     = ctx.mem.access.r_cstr(name_ptr)
   self.semaphore_mgr.AddSemaphore(addr,name)
   log_exec.info("AddSemaphore(%06x,%s)" % (addr,name))
开发者ID:cmsj,项目名称:amitools,代码行数:7,代码来源:ExecLibrary.py

示例2: AddLibrary

 def AddLibrary(self, ctx):
   lib_ptr = ctx.cpu.r_reg(REG_A1)
   lib = AccessStruct(ctx.mem, LibraryDef, lib_ptr)
   # Set up lib_Node
   lib.w_s("lib_Node.ln_Succ", lib_ptr)
   lib.w_s("lib_Node.ln_Pred", lib_ptr)
   lib.w_s("lib_Node.ln_Type", NT_LIBRARY)
   return lib_ptr
开发者ID:ezrec,项目名称:amitools,代码行数:8,代码来源:ExecLibrary.py

示例3: Remove

 def Remove(self, ctx):
   node_addr = ctx.cpu.r_reg(REG_A1)
   n = AccessStruct(ctx.mem, NodeDef, node_addr)
   succ = n.r_s("ln_Succ")
   pred = n.r_s("ln_Pred")
   log_exec.info("Remove(%06x): ln_Pred=%06x ln_Succ=%06x" % (node_addr, pred, succ))
   AccessStruct(ctx.mem, NodeDef, pred).w_s("ln_Succ", succ)
   AccessStruct(ctx.mem, NodeDef, succ).w_s("ln_Pred", pred)
   return node_addr
开发者ID:gbraad,项目名称:amitools,代码行数:9,代码来源:ExecLibrary.py

示例4: volume_name_of_lock

 def volume_name_of_lock(self, lock):
   if lock == None:
     return "SYS:"
   else:
     vol_addr  = lock.mem.access.r_s("fl_Volume")
     volnode   = AccessStruct(self.mem,DosListVolumeDef,vol_addr)
     name_addr = volnode.r_s("dol_Name")
     name = self.mem.access.r_bstr(name_addr) + ":"
     return name
开发者ID:apiraino,项目名称:amitools,代码行数:9,代码来源:LockManager.py

示例5: AddTail

 def AddTail(self, ctx):
   list_addr = ctx.cpu.r_reg(REG_A0)
   node_addr = ctx.cpu.r_reg(REG_A1)
   log_exec.info("AddTail(%06x, %06x)" % (list_addr, node_addr))
   l = AccessStruct(ctx.mem, ListDef, list_addr)
   n = AccessStruct(ctx.mem, NodeDef, node_addr)
   n.w_s("ln_Succ", l.s_get_addr("lh_Tail"))
   tp = l.r_s("lh_TailPred")
   n.w_s("ln_Pred", tp)
   AccessStruct(ctx.mem, NodeDef, tp).w_s("ln_Succ", node_addr)
   l.w_s("lh_TailPred", node_addr)
开发者ID:gbraad,项目名称:amitools,代码行数:11,代码来源:ExecLibrary.py

示例6: CloseDevice

 def CloseDevice(self,ctx):
   io_addr  = ctx.cpu.r_reg(REG_A1)
   if io_addr != 0:
     io       = AccessStruct(ctx.mem, IORequestDef, io_addr)
     dev_addr = io.r_s("io_Device")
     if dev_addr != 0:
       dev = self.lib_mgr.close_dev(dev_addr,ctx)
       io.w_s("io_Device",0)
       if dev != None:
         log_exec.info("CloseDevice: '%s' -> %06x" % (dev, dev.addr_base))
       else:
         raise VamosInternalError("CloseDevice: Unknown library to close: ptr=%06x" % dev_addr)
开发者ID:cmsj,项目名称:amitools,代码行数:12,代码来源:ExecLibrary.py

示例7: _release_locklist

 def _release_locklist(self, entry):
   alist_addr    = entry.access.r_s("dol_List")
   entry.access.w_s("dol_List",0)
   entry.alist   = []
   while alist_addr != 0:
     alist        = AccessStruct(self.mem,AssignListDef,alist_addr)
     oldlock_addr = alist.r_s("al_Lock")
     oldlock      = self.lock_mgr.get_by_b_addr(oldlock_addr >> 2)
     self.lock_mgr.release_lock(oldlock)
     entry.alist.remove(alist)
     nextaddr     = alist.access.r_s("al_Next")
     self.alloc.free_struct(alist.mem)
     alist_addr   = nextaddr
开发者ID:cmsj,项目名称:amitools,代码行数:13,代码来源:DosList.py

示例8: RemTail

 def RemTail(self, ctx):
   list_addr = ctx.cpu.r_reg(REG_A0)
   l = AccessStruct(ctx.mem, ListDef, list_addr)
   node_addr = l.r_s("lh_TailPred")
   n = AccessStruct(ctx.mem, NodeDef, node_addr)
   succ = n.r_s("ln_Succ")
   pred = n.r_s("ln_Pred")
   if pred == 0:
     log_exec.info("RemTail(%06x): null" % list_addr)
     return 0
   AccessStruct(ctx.mem, NodeDef, pred).w_s("ln_Succ", succ)
   AccessStruct(ctx.mem, NodeDef, succ).w_s("ln_Pred", pred)
   log_exec.info("RemTail(%06x): %06x" % (list_addr, node_addr))
   return node_addr
开发者ID:apiraino,项目名称:amitools,代码行数:14,代码来源:ExecLibrary.py

示例9: DateToStr

 def DateToStr(self, ctx):
   dt_ptr = ctx.cpu.r_reg(REG_D1)
   dt = AccessStruct(ctx.mem,DateTimeDef,struct_addr=dt_ptr)
   ds_day = dt.r_s("dat_Stamp.ds_Days")
   ds_min = dt.r_s("dat_Stamp.ds_Minute")
   ds_tick = dt.r_s("dat_Stamp.ds_Tick")
   format = dt.r_s("dat_Format")
   flags = dt.r_s("dat_Flags")
   str_day_ptr = dt.r_s("dat_StrDay")
   str_date_ptr = dt.r_s("dat_StrDate")
   str_time_ptr = dt.r_s("dat_StrTime")
   at = AmiTime(ds_day, ds_min, ds_tick)
   st = at.to_sys_time()
   log_dos.info("DateToStr: ptr=%06x format=%x flags=%x day_ptr=%06x date_ptr=%06x time_ptr=%06x %s => sys_time=%d", \
     dt_ptr, format, flags, str_day_ptr, str_date_ptr, str_time_ptr, at, st)
   t = time.gmtime(st)
   day_str = time.strftime("%A", t)
   date_str = time.strftime("%d-%m-%y", t)
   time_str = time.strftime("%H:%M:%S", t)
   log_dos.info("DateToStr: result day='%s' date='%s' time='%s'", day_str, date_str, time_str)
   if str_day_ptr != 0:
     ctx.mem.access.w_cstr(str_day_ptr, day_str)
   if str_date_ptr != 0:
     ctx.mem.access.w_cstr(str_date_ptr, date_str)
   if str_time_ptr != 0:
     ctx.mem.access.w_cstr(str_time_ptr, time_str)
   return self.DOSTRUE
开发者ID:ezrec,项目名称:amitools,代码行数:27,代码来源:DosLibrary.py

示例10: GetDeviceProc

  def GetDeviceProc(self, ctx):
    name_ptr = ctx.cpu.r_reg(REG_D1)
    last_devproc = ctx.cpu.r_reg(REG_D2)
    name = ctx.mem.access.r_cstr(name_ptr)

    # get volume of path 
    abs_name = self.path_mgr.ami_abs_path(name)
    volume = self.path_mgr.ami_volume_of_path(abs_name)
    vol_lock = self.lock_mgr.create_lock(volume+":", False)
    fs_port = self.file_mgr.get_fs_handler_port()
    addr = self._alloc_mem("DevProc:%s" % name, DevProcDef.get_size())
    log_dos.info("GetDeviceProc: name='%s' devproc=%06x -> volume=%s devproc=%06x", name, last_devproc, volume, addr)
    devproc = AccessStruct(self.ctx.mem,DevProcDef,struct_addr=addr)
    devproc.w_s('dvp_Port', fs_port)
    devproc.w_s('dvp_Lock', vol_lock.b_addr)
    self.io_err = NO_ERROR
    return addr
开发者ID:ezrec,项目名称:amitools,代码行数:17,代码来源:DosLibrary.py

示例11: StackSwap

 def StackSwap(self, ctx):
   stsw_ptr = ctx.cpu.r_reg(REG_A0)
   stsw = AccessStruct(ctx.mem,StackSwapDef,struct_addr=stsw_ptr)
   # get new stack values
   new_lower = stsw.r_s('stk_Lower')
   new_upper = stsw.r_s('stk_Upper')
   new_pointer = stsw.r_s('stk_Pointer')
   # retrieve current (old) stack
   old_lower = self.stk_lower
   old_upper = self.stk_upper
   old_pointer = ctx.cpu.r_reg(REG_A7) # addr of sys call return
   # get adress of callee
   callee = ctx.mem.access.r32(old_pointer)
   # we report the old stack befor callee
   old_pointer += 4
   log_exec.info("StackSwap: old(lower=%06x,upper=%06x,ptr=%06x) new(lower=%06x,upper=%06x,ptr=%06x)" % (old_lower,old_upper,old_pointer,new_lower,new_upper,new_pointer))
   stsw.w_s('stk_Lower', old_lower)
   stsw.w_s('stk_Upper', old_upper)
   stsw.w_s('stk_Pointer', old_pointer)
   self.stk_lower = new_lower
   self.stk_upper = new_upper
   # put callee's address on new stack
   new_pointer -= 4
   ctx.mem.access.w32(new_pointer,callee)
   # activate new stack
   ctx.cpu.w_reg(REG_A7, new_pointer)
开发者ID:rmtew,项目名称:amitools,代码行数:26,代码来源:ExecLibrary.py

示例12: DateStamp

 def DateStamp(self, ctx):
   ds_ptr = ctx.cpu.r_reg(REG_D1)
   ds = AccessStruct(ctx.mem,DateStampDef,struct_addr=ds_ptr)
   t = time.time()
   at = sys_to_ami_time(t)
   log_dos.info("DateStamp: ptr=%06x sys_time=%d time=%s", ds_ptr, t, at)
   ds.w_s("ds_Days",at.tday)
   ds.w_s("ds_Minute",at.tmin)
   ds.w_s("ds_Tick",at.tick)
   return ds_ptr
开发者ID:ezrec,项目名称:amitools,代码行数:10,代码来源:DosLibrary.py

示例13: examine_file

 def examine_file(self, fib_mem, name, sys_path):
   # name
   name_addr = fib_mem.s_get_addr('fib_FileName')
   # clear 32 name bytes
   fib_mem.clear_data(name_addr, 32, 0)
   fib_mem.w_cstr(name_addr, name)
   # comment
   comment_addr = fib_mem.s_get_addr('fib_Comment')
   fib_mem.w_cstr(comment_addr, "")
   # create the "inode" information
   key = self.keygen(sys_path)
   fib_mem.w_s('fib_DiskKey',key)
   log_lock.debug("examine key: %08x", key)
   # type
   if os.path.isdir(sys_path):
     dirEntryType = 2
   else:
     dirEntryType = (-3) & 0xffffffff
   fib_mem.w_s('fib_DirEntryType', dirEntryType )
   fib_mem.w_s('fib_EntryType',    dirEntryType )
   # protection
   prot = DosProtection(0)
   try:
     os_stat = os.stat(sys_path)
     mode = os_stat.st_mode
     if mode & stat.S_IXUSR == 0:
       prot.clr(DosProtection.FIBF_EXECUTE)
     if mode & stat.S_IRUSR == 0:
       prot.clr(DosProtection.FIBF_READ)
     if mode & stat.S_IWUSR == 0:
       prot.clr(DosProtection.FIBF_WRITE)
     log_lock.debug("examine lock: '%s' mode=%03o: prot=%s", name, mode, prot)
   except OSError:
     return ERROR_OBJECT_IN_USE
   fib_mem.w_s('fib_Protection', prot.mask)
   # size
   if os.path.isfile(sys_path):
     size = os.path.getsize(sys_path)
     fib_mem.w_s('fib_Size', size)
     blocks = int((size + 511) / 512)
     fib_mem.w_s('fib_NumBlocks', blocks)
   else:
     fib_mem.w_s('fib_NumBlocks', 1)
   # date (use mtime here)
   date_addr = fib_mem.s_get_addr('fib_Date')
   date = AccessStruct(fib_mem.mem, DateStampDef, date_addr)
   t = os.path.getmtime(sys_path)
   at = sys_to_ami_time(t)
   date.w_s('ds_Days', at.tday)
   date.w_s('ds_Minute', at.tmin)
   date.w_s('ds_Tick', at.tick)
   # fill in UID/GID
   fib_mem.w_s('fib_OwnerUID', 0)
   fib_mem.w_s('fib_OwnerGID', 0)
   return NO_ERROR
开发者ID:cmsj,项目名称:amitools,代码行数:55,代码来源:Lock.py

示例14: examine_file

 def examine_file(self, fib_mem, name, sys_path):
   # name
   name_addr = fib_mem.s_get_addr('fib_FileName')
   fib_mem.w_cstr(name_addr, name)
   # dummy key
   fib_mem.w_s('fib_DiskKey',0xcafebabe)
   # type
   if os.path.isdir(sys_path):
     dirEntryType = 0x2 # dir
   else:
     dirEntryType = 0xfffffffd # file
   fib_mem.w_s('fib_DirEntryType', dirEntryType )
   # protection
   prot = DosProtection(0)
   try:
     os_stat = os.stat(sys_path)
     mode = os_stat.st_mode
     if mode & stat.S_IXUSR == 0:
       prot.clr(DosProtection.FIBF_EXECUTE)
     if mode & stat.S_IRUSR == 0:
       prot.clr(DosProtection.FIBF_READ)
     if mode & stat.S_IWUSR == 0:
       prot.clr(DosProtection.FIBF_WRITE)
     log_lock.debug("examine lock: '%s' mode=%03o: prot=%s", name, mode, prot)
   except OSError:
     return ERROR_OBJECT_IN_USE
   fib_mem.w_s('fib_Protection', prot.mask)
   # size
   if os.path.isfile(sys_path):
     size = os.path.getsize(sys_path)
     fib_mem.w_s('fib_Size', size)
   # date (use mtime here)
   date_addr = fib_mem.s_get_addr('fib_Date')
   date = AccessStruct(fib_mem.mem, DateStampDef, date_addr)
   t = os.path.getmtime(sys_path)
   at = sys_to_ami_time(t)
   date.w_s('ds_Days', at.tday)
   date.w_s('ds_Minute', at.tmin)
   date.w_s('ds_Tick', at.tick)
   return NO_ERROR
开发者ID:gbraad,项目名称:amitools,代码行数:40,代码来源:Lock.py

示例15: put_msg

 def put_msg(self, port_mgr, msg_addr):
   msg = AccessStruct(self.ctx.mem,MessageDef,struct_addr=msg_addr)
   dos_pkt_addr = msg.r_s("mn_Node.ln_Name")
   dos_pkt = AccessStruct(self.ctx.mem,DosPacketDef,struct_addr=dos_pkt_addr)
   reply_port_addr = dos_pkt.r_s("dp_Port")
   pkt_type = dos_pkt.r_s("dp_Type")
   log_dos.info("DosPacket: msg=%06x -> pkt=%06x: reply_port=%06x type=%06x", msg_addr, dos_pkt_addr, reply_port_addr, pkt_type)
   # handle packet
   if pkt_type == ord('R'): # read
     fh_b_addr = dos_pkt.r_s("dp_Arg1")
     buf_ptr   = dos_pkt.r_s("dp_Arg2")
     size      = dos_pkt.r_s("dp_Arg3")
     # get fh and read
     fh = self.file_mgr.get_by_b_addr(fh_b_addr)
     data = self.file_mgr.read(fh, size)
     self.ctx.mem.access.w_data(buf_ptr, data)
     got = len(data)
     log_dos.info("DosPacket: Read fh_b_addr=%06x buf=%06x len=%06x -> got=%06x fh=%s", fh_b_addr, buf_ptr, size, got, fh)
     dos_pkt.w_s("dp_Res1", got)
   elif pkt_type == ord('W'): # write
     fh_b_addr = dos_pkt.r_s("dp_Arg1")
     buf_ptr   = dos_pkt.r_s("dp_Arg2")
     size      = dos_pkt.r_s("dp_Arg3")
     fh = self.file_mgr.get_by_b_addr(fh_b_addr)
     data = self.ctx.mem.access.r_data(buf_ptr, size)
     self.file_mgr.write(fh, data)
     put = len(data)
     log_dos.info("DosPacket: Write fh=%06x buf=%06x len=%06x -> put=%06x fh=%s", fh_b_addr, buf_ptr, size, put, fh)
     dos_pkt.w_s("dp_Res1", put)
   else:
     raise UnsupportedFeatureError("Unsupported DosPacket: type=%d" % pkt_type)
   # do reply
   if not self.port_mgr.has_port(reply_port_addr):
     self.port_mgr.add_port(reply_port_addr)
   self.port_mgr.put_msg(reply_port_addr, msg_addr)
开发者ID:ezrec,项目名称:amitools,代码行数:35,代码来源:DosLibrary.py


注:本文中的amitools.vamos.AccessStruct.AccessStruct类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。