def AllocPooled(self, ctx): poolid = ctx.cpu.r_reg(REG_A0) size = (ctx.cpu.r_reg(REG_D0) + 7) & -8 pc = self.get_callee_pc(ctx) name = "AllocPooled(%06x)" % pc if poolid in self._pools: pool = self._pools[poolid] mem = pool.AllocPooled(ctx.label_mgr, name, size) log_exec.info("AllocPooled: from pool 0x%x size %d -> 0x%06x" % (poolid, size, mem.addr)) return mem.addr else: raise VamosInternalError( "AllocPooled: invalid memory pool: ptr=%06x" % poolid)
def FreeMem(self, ctx): size = ctx.cpu.r_reg(REG_D0) addr = ctx.cpu.r_reg(REG_A1) if addr == 0 or size == 0: log_exec.info("FreeMem: freeing NULL") return mb = self.alloc.get_memory(addr) if mb != None: log_exec.info("FreeMem: 0x%06x %d bytes -> %s" % (addr, size, mb)) self.alloc.free_memory(mb) else: raise VamosInternalError( "FreeMem: Unknown memory to free: ptr=%06x size=%06x" % (addr, size))
def WaitPort(self, ctx): port_addr = ctx.cpu.r_reg(REG_A0) log_exec.info("WaitPort: port=%06x" % (port_addr)) has_port = self.port_mgr.has_port(port_addr) if not has_port: raise VamosInternalError( "WaitPort: on invalid Port (%06x) called!" % port_addr) has_msg = self.port_mgr.has_msg(port_addr) if not has_msg: raise UnsupportedFeatureError( "WaitPort on empty message queue called: Port (%06x)" % port_addr) msg_addr = self.port_mgr.get_msg(port_addr) log_exec.info("WaitPort: got message %06x" % (msg_addr)) return msg_addr
def get_by_b_addr(self, b_addr, none_if_missing=False): if b_addr == 0: return None else: raw_lock = AccessStruct(self.mem, FileLockStruct, b_addr << 2) key = raw_lock.r_s("fl_Key") lock_key = self.keys[key] log_lock.debug( "lookup key in baddr=%08x: %s -> lock_key=%r", b_addr, key, lock_key ) lock = lock_key.find_lock_by_baddr(b_addr) if lock: return lock else: raise VamosInternalError("lock not found by b_addr?!")