def setup_bootinfo_pools(self, namespace, pools): """ Map elfweaver pools into iguana pools. """ for pool in pools.get_virtual_pools(): boot_pool = \ weaver.cells.iguana.bootinfo.VirtPool(pool.get_name(), pool) self.bootinfo.add_virtpool(boot_pool) # New namespace for the memory pool's caps. new_namespace = namespace.add_namespace(pool.get_name()) if pool.get_name() == "direct": master = weaver.cells.iguana.bootinfo.Cap("master", ["master"]) boot_pool.add_cap(master) new_namespace.add(master.get_name(), master) else: # Add the standard caps for the pool. create_standard_caps(boot_pool, new_namespace) for pool in pools.get_physical_pools(): boot_pool = \ weaver.cells.iguana.bootinfo.PhysPool(pool.get_name(), pool) self.bootinfo.add_physpool(boot_pool) # New namespace for the memory pool's caps. new_namespace = namespace.add_namespace(pool.get_name()) # Add the standard caps for the pool. create_standard_caps(boot_pool, new_namespace)
def collect_thread(elf, el, ignore_name, namespace, image, machine, pools, space, entry, name = None, namespace_thread_name = None, cell_create_thread = False): """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": user_main = None entry = start_to_value(entry, elf) user_main = start_to_value(user_main, elf) # XXX: Iguana only runs on Micro, so default prio is 100! priority = getattr(el, 'priority', 100) 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 = Thread(name, entry, user_main, priority) utcb = image.new_attrs(new_namespace.add_namespace("utcb")) # Create the cell thread and assign the entry point cell_thread = space.register_thread(entry, user_main, utcb, priority, create = cell_create_thread) cell_thread.ip = entry # 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) # Setup the stack for the new cell thread cell_thread.stack = stack_ms.get_ms().attrs # 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