Esempio n. 1
0
def collect_environment_element(env_el, namespace, machine, pools,
                                image, bootinfo):
    """Collect the object environment for a program or PD."""
    env = Environment(namespace, machine, pools, image, bootinfo) 
    extra_ms = []

    # Collect any custom entries in the environment.
    if env_el is not None:
        for entry_el in env_el.find_children('entry'):
            value       = None
            cap_name    = None
            attach      = None

            if hasattr(entry_el, 'value'):
                value = entry_el.value

                env.add_entry(entry_el.key, value = value,
                              cap_name = cap_name, attach = attach)
            else:
                if not hasattr(entry_el, 'cap'):
                    raise MergeError, 'Value or cap attribute required.'

                cap_name = entry_el.cap

                if hasattr(entry_el, 'attach'):
                    attach = attach_to_elf_flags(entry_el.attach)

                # If the cap is not an AliasCap we add it as before
                env.add_entry(entry_el.key, value = value,
                              cap_name = cap_name, attach = attach)

    return env, extra_ms
Esempio n. 2
0
    def _collect_environment(self, env_el, env):
        """
        Collect the details of the environmen element.
        """

        # Collect any custom entries in the environment.
        if env_el is not None:
            for entry_el in env_el.find_children('entry'):
                cap_name = None
                attach = None

                if hasattr(entry_el, 'value'):
                    env.add_value_entry(entry_el.key, entry_el.value)
                else:
                    if not hasattr(entry_el, 'cap'):
                        raise MergeError, 'Value or cap attribute required.'

                    cap_name = entry_el.cap

                    if hasattr(entry_el, 'attach'):
                        attach = attach_to_elf_flags(entry_el.attach)

                    env.add_cap_entry(entry_el.key,
                                      cap_name=cap_name,
                                      attach=attach)
Esempio n. 3
0
def collect_memobj_attrs(el, namespace, image, machine):
    """Collect the attributes of a memory section like element."""

    assert el is not None

    values = image.new_attrs(namespace)

    if el.tag == "stack" or el.tag == "heap":
        values.name = el.tag
    else:
        values.name = el.name
        assert el.name is not None

    values.file      = getattr(el, 'file', values.file)
    values.size      = getattr(el, 'size', values.size)
    values.virt_addr = getattr(el, 'virt_addr', values.virt_addr)
    values.phys_addr = getattr(el, 'phys_addr', values.phys_addr)
    values.direct    = getattr(el, 'direct', values.direct)
    values.virtpool  = getattr(el, 'virtpool', values.virtpool)
    values.physpool  = getattr(el, 'physpool', values.physpool)
    values.align     = getattr(el, 'align', values.align)
    values.scrub     = getattr(el, 'zero', values.scrub)
    values.usermap   = getattr(el, 'user_map', values.usermap)

    if hasattr(el, 'attach'):
        values.attach = attach_to_elf_flags(el.attach)

    if hasattr(el, 'pager'):
        values.pager = make_pager_attr(el.pager)

    if hasattr(el, 'cache_policy'):
        values.cache_policy = machine.get_cache_policy(el.cache_policy)
    

    return values
Esempio n. 4
0
    def _collect_environment(self, env_el, env):
        """
        Collect the details of the environmen element.
        """

        # Collect any custom entries in the environment.
        if env_el is not None:
            for entry_el in env_el.find_children('entry'):
                cap_name    = None
                attach      = None

                if hasattr(entry_el, 'value'):
                    env.add_value_entry(entry_el.key, entry_el.value)
                else:
                    if not hasattr(entry_el, 'cap'):
                        raise MergeError, 'Value or cap attribute required.'

                    cap_name = entry_el.cap

                    if hasattr(entry_el, 'attach'):
                        attach = attach_to_elf_flags(entry_el.attach)

                    env.add_cap_entry(entry_el.key,
                                      cap_name = cap_name,
                                      attach = attach)
Esempio n. 5
0
def collect_environment_element(env_el, namespace, machine, pools,
                                image, bootinfo):
    """Collect the object environment for a program or PD."""
    env = weaver.bootinfo.Environment(namespace)

    # Collect any custom entries in the environment.
    if env_el is not None:
        for entry_el in env_el.find_children('entry'):
            value       = None
            cap_name    = None
            attach      = None

            if hasattr(entry_el, 'value'):
                value = entry_el.value

                env.add_entry(entry_el.key, value = value,
                              cap_name = cap_name, attach = attach)
            else:
                if not hasattr(entry_el, 'cap'):
                    raise MergeError, 'Value or cap attribute required.'

                cap_name = entry_el.cap

                if hasattr(entry_el, 'attach'):
                    attach = attach_to_elf_flags(entry_el.attach)

                # Check if the cap is an AliasCap.  If it is, ask the cap object
                # to create any implied objects now
                cap = env.scope.lookup(cap_name)

                if cap is None:
                    raise MergeError, "Cap %s not found." % cap_name

                if isinstance(cap, AliasCap):
                    # Always add the AliasCap before any implied object
                    # caps.  Because we will use this alias cap to generate
                    # their bootinfo just in time - nt
                    env.add_entry(entry_el.key, value = value, cap = cap,
                                  cap_name = cap_name, attach = attach)

                    # Add implicit object caps to the environment
                    # These caps are different from the alias cap!
                    cap_list = \
                             cap.get_object().create_implicit_objects(namespace,
                                                                      machine,
                                                                      pools, image,
                                                                      bootinfo)
                    if cap_list is not None:
                        for key, cap in cap_list.iteritems():
                            env.add_entry(key, cap = cap, attach = PF_R | PF_W)

                else:
                    # If the cap is not an AliasCap we add it as before
                    env.add_entry(entry_el.key, value = value,
                                  cap_name = cap_name, attach = attach)

    return env
Esempio n. 6
0
def collect_memobj_attrs(el, namespace, image, machine):
    """Collect the attributes of a memory section like element."""

    assert el is not None

    if el.tag == "stack" or el.tag == "heap":
        name = el.tag
    else:
        assert el.name is not None
        name = el.name

    values = image.new_attrs(namespace.add_namespace(name))

    values.file = getattr(el, 'file', values.file)
    values.size = getattr(el, 'size', values.size)
    values.virt_addr = getattr(el, 'virt_addr', values.virt_addr)
    values.phys_addr = getattr(el, 'phys_addr', values.phys_addr)
    values.direct = getattr(el, 'direct', values.direct)
    values.virtpool = getattr(el, 'virtpool', values.virtpool)
    values.physpool = getattr(el, 'physpool', values.physpool)
    values.align = getattr(el, 'align', values.align)
    values.scrub = getattr(el, 'zero', values.scrub)
    values.user_map = getattr(el, 'mem_type', values.user_map)

    if hasattr(el, 'mem_type'):
        values.mem_type = translate_mem_types(el.mem_type)

    if hasattr(el, 'attach'):
        values.attach = attach_to_elf_flags(el.attach)

    if hasattr(el, 'pager'):
        values.pager = make_pager_attr(el.pager)

    if hasattr(el, 'cache_policy'):
        values.cache_policy = machine.get_cache_policy(el.cache_policy)

    return values