Пример #1
0
def collect_memory_pool_el(memory_pool_el, namespace, machine,
                           bootinfo, pools, virtual):
    """ Record a memory pool."""

    if virtual:
        pool = weaver.bootinfo.VirtPool(memory_pool_el.name, machine,
                                        pools)
        bootinfo.add_virtpool(pool)
    else:
        pool = weaver.bootinfo.PhysPool(memory_pool_el.name, machine,
                                        pools)
        bootinfo.add_physpool(pool)

    # New namespace for the memory pool's caps.
    new_namespace = namespace.add_namespace(memory_pool_el.name)

    # Add the standard caps for the pool.
    create_standard_caps(pool, new_namespace)

    for el in memory_pool_el.children:
        if el.tag == 'memory':
            src  = getattr(el, 'src', None)
            base = getattr(el, 'base', None)
            size = getattr(el, 'size', None)
            
            pool.add_memory(src = src, base = base, size = size,
                            machine=machine, pools=pools)

    if not virtual and getattr(memory_pool_el, "direct", False):
        pool.set_direct(True)

        for base, end, mem_type in pool.pool.get_freelist():
            size = end - base + 1
            pools.add_direct_memory(base, size, mem_type)
Пример #2
0
def collect_thread(elf, el, ignore_name, namespace, image, machine,
                   pools, entry, name = None,
                   namespace_thread_name = None):
    """Collect the attributes of a thread element."""
    if entry is None:
        raise MergeError, "No entry point specified for thread %s" % name

    # el can be a program element or a thread element.
    if name is None:
        name = el.name

    user_main = getattr(el, 'start', None)

    # HACK:  There is no easy way for a PD to specify the main thread,
    # so is the user entry point is '_start' (the traditional entry
    # point symbol), then start there rather then the thread entry
    # point.
    if user_main == "_start":
        start = "_start"
        user_main = None

    entry = start_to_value(entry, elf)
    user_main = start_to_value(user_main, elf)

    priority = getattr(el, 'priority', None)
    physpool = getattr(el, 'physpool', None)
    virtpool = getattr(el, 'virtpool', None)

    # New namespace for objects living in the thread.
    if namespace_thread_name is None:
        namespace_thread_name = name
    new_namespace = namespace.add_namespace(namespace_thread_name)

    # Push the overriding pools for the thread.
    image.push_attrs(virtual = virtpool,
                     physical = physpool)

    # Create the thread desription object.
    thread = weaver.bootinfo.Thread(name, entry, user_main, priority)

    # Add the standard caps for the thread.
    create_standard_caps(thread, new_namespace)

    # Collect the stack.  Is there no element, create a fake one for
    # the collection code to use.
    stack_el = el.find_child('stack')

    if stack_el is None:
        stack_el = ParsedElement('stack')

    stack_ms = collect_memsection_element(stack_el, ignore_name,
                                          new_namespace, image,
                                          machine, pools)
    thread.attach_stack(stack_ms)
    image.add_group(0, [stack_ms.get_ms()])

    # Collect any command line arguments.
    commandline_el = el.find_child('commandline')

    if commandline_el is not None:
        for arg_el in commandline_el.find_children("arg"):
            thread.add_argv(arg_el.value)

    image.pop_attrs()

    return thread