Exemple #1
0
 def TaggedOpenLibrary(self, ctx):
   tag = ctx.cpu.r_reg(REG_D0)
   tags = ["graphics.library","layers.library","intuition.library","dos.library","icon.library","expansion.library",
           "utility.library","keymap.library","gadtools.library","workbench.library"]
   if tag > 0 and tag <= len(tags):
     name = tags[tag - 1]
     addr = self.lib_mgr.open_lib(name, 0)
     log_exec.info("TaggedOpenLibrary: %d('%s') -> %06x", tag, name, addr)
     return addr
   else:
     log_exec.warn("TaggedOpenLibrary: %d invalid tag -> NULL" % tag)
     return 0
Exemple #2
0
 def TaggedOpenLibrary(self, ctx):
   tag = ctx.cpu.r_reg(REG_D0)
   tags = ["graphics.library","layers.library","intuition.library","dos.library","icon.library","expansion.library",
           "utility.library","keymap.library","gadtools.library","workbench.library"]
   if tag > 0 and tag <= len(tags):
     name = tags[tag - 1]
     lib  = self.lib_mgr.open_lib(name, 0, ctx)
     if lib == None:
       log_exec.info("TaggedOpenLibrary: %d('%s') -> NULL" % (tag, name))
       return 0
     else:
       log_exec.info("TaggedOpenLibrary: %d('%s') -> %s@0x%06x" % (tag, name, lib, lib.addr_base_open))
       return lib.addr_base_open
   else:
     log_exec.warn("TaggedOpenLibrary: %d invalid tag -> NULL" % tag)
     return 0
Exemple #3
0
 def TaggedOpenLibrary(self, ctx):
   tag = ctx.cpu.r_reg(REG_D0)
   tags = ["graphics.library","layers.library","intuition.library","dos.library","icon.library","expansion.library",
           "utility.library","keymap.library","gadtools.library","workbench.library"]
   if tag > 0 and tag <= len(tags):
     name = tags[tag - 1]
     lib  = self.lib_mgr.open_lib(name, 0, ctx)
     if lib == None:
       log_exec.info("TaggedOpenLibrary: %d('%s') -> NULL" % (tag, name))
       return 0
     else:
       log_exec.info("TaggedOpenLibrary: %d('%s') -> %s@0x%06x" % (tag, name, lib, lib.addr_base_open))
       return lib.addr_base_open
   else:
     log_exec.warn("TaggedOpenLibrary: %d invalid tag -> NULL" % tag)
     return 0
Exemple #4
0
def allocate(ctx, mh_addr, num_bytes):
    # nothing to allocate
    if num_bytes == 0:
        return 0

    # round size to nearest 8 byte
    ex = num_bytes & 7
    if ex != 0:
        num_bytes += 8 - ex

    # read mem header
    mh = MemHdr()
    mh.read(ctx, mh_addr)
    log_exec.debug("read: %s", mh)

    # enough total free?
    if mh.free < num_bytes:
        return 0
    if mh.first == 0:
        return 0

    # find chunk with enough free bytes
    mc_last = None
    mc = mh.read_first(ctx)
    log_exec.debug("read: %s", mc)
    while mc.bytes < num_bytes:
        mc_next = mc.read_next(ctx)
        log_exec.debug("read: %s", mc_next)
        if mc_next is None:
            log_exec.warn("invalid mem chunk list!")
            return 0
        mc_last = mc
        mc = mc_next

    # what's left in chunk?
    rem = mc.bytes - num_bytes
    if rem > 0:
        # some bytes left in chunk -> adjust size and keep it
        mc.bytes = rem
        mc.write(ctx)
        # allocate at end of chunk
        res_addr = mc.addr + rem
        log_exec.debug("shrink: %s", mc)
    else:
        # remove whole chunk
        if mc_last is None:
            # set new first
            mh.first = mc.next
            # mh will be written below
        else:
            mc_last.next = mc.next
            mc_last.write(ctx)
        # result is whole chunk
        res_addr = mc.addr
        log_exec.debug("remove: %s", mc)

    # update header
    mh.free -= num_bytes
    mh.write(ctx)
    log_exec.debug("done: %s", mh)

    return res_addr
Exemple #5
0
def allocate(ctx, mh_addr, num_bytes):
  # nothing to allocate
  if num_bytes == 0:
    return 0

  # round size to nearest 8 byte
  ex = num_bytes & 7
  if ex != 0:
    num_bytes += 8 - ex

  # read mem header
  mh = MemHdr()
  mh.read(ctx, mh_addr)
  log_exec.debug("read: %s", mh)

  # enough total free?
  if mh.free < num_bytes:
    return 0
  if mh.first == 0:
    return 0

  # find chunk with enough free bytes
  mc_last = None
  mc = mh.read_first(ctx)
  log_exec.debug("read: %s", mc)
  while mc.bytes < num_bytes:
    mc_next = mc.read_next(ctx)
    log_exec.debug("read: %s", mc_next)
    if mc_next is None:
      log_exec.warn("invalid mem chunk list!")
      return 0
    mc_last = mc
    mc = mc_next

  # what's left in chunk?
  rem = mc.bytes - num_bytes
  if rem > 0:
    # some bytes left in chunk -> adjust size and keep it
    mc.bytes = rem
    mc.write(ctx)
    # allocate at end of chunk
    res_addr = mc.addr + rem
    log_exec.debug("shrink: %s", mc)
  else:
    # remove whole chunk
    if mc_last is None:
      # set new first
      mh.first = mc.next
      # mh will be written below
    else:
      mc_last.next = mc.next
      mc_last.write(ctx)
    # result is whole chunk
    res_addr = mc.addr
    log_exec.debug("remove: %s", mc)

  # update header
  mh.free -= num_bytes
  mh.write(ctx)
  log_exec.debug("done: %s", mh)

  return res_addr