def setup_device_namespace(self, namespace, machine): """ Populate the /dev namespace with Iguana aliases to the physical devices. """ dev_ns = namespace.root.add_namespace("dev") for device in machine.physical_device.values(): create_alias_cap(PhysicalDevice(device), dev_ns)
def collect_program_element(program_el, ignore_name, namespace, image, machine, bootinfo, pools, kernel, cell): """Collect the attributes of a program element.""" pd, env, prog_namespace, extra_ms = \ _init_program_pd(program_el, image, bootinfo, machine, pools, namespace) space = cell.register_space(prog_namespace, program_el.name, create = False) elf, segs = _init_elf_file(program_el, image, prog_namespace, machine, pools, bootinfo, pd, kernel) # Collect remaining threads. threads = collect_thread_elements(program_el, ignore_name, elf, prog_namespace, image, machine, pools, env, pd, space) bootinfo.add_elf_info(name = os.path.join(program_el._path, program_el.file), elf_type = image.PROGRAM, entry_point = elf.entry_point) # Collect the main thread. thread = collect_thread(elf, program_el, ignore_name, prog_namespace, image, machine, pools, space, entry = elf.entry_point, name = program_el.name, namespace_thread_name = "main") # Record the main thread and its stack in the environment. env.add_entry(key = "MAIN", cap_name = 'main/master') env.add_entry(key = "MAIN/STACK", cap_name = 'main/stack/master', attach = thread.get_stack().get_attrs().attach) pd.add_thread(thread) pd.server_thread = thread # Add the virtual device elements # Virtual devices always get added to the global namespace because they # should be globally unique server_spawn_nvdevs = 0 dev_ns = namespace.root.get_namespace("dev") if dev_ns is None: raise MergeError, "Device namespace does not exist!" for v_el in program_el.find_children('virt_device'): virt_dev = pd.add_virt_dev(v_el.name, program_el.name, pd, thread, server_spawn_nvdevs) create_alias_cap(virt_dev, dev_ns) server_spawn_nvdevs += 1 # If marked, sure that the program is exported to every # environment so that it can be found by other programs. # if hasattr(program_el, 'server'): bootinfo.add_server( key = program_el.server, cap_name = prog_namespace.abs_path('main') + '/stack/master') # Collect any other memsections in the program. collect_memsection_elements(program_el, ignore_name, prog_namespace, image, machine, pools, env, pd) # Collect any zones in the program. collect_zone_elements(program_el, ignore_name, prog_namespace, image, machine, pools, bootinfo, env, pd) # Collect the heap. Is there no element, create a fake one for # the collection code to use. heap_el = program_el.find_child('heap') if heap_el is None: heap_el = ParsedElement('heap') heap_ms = collect_memsection_element(heap_el, ignore_name, prog_namespace, image, machine, pools) pd.attach_heap(heap_ms) threads.append(thread) image.add_group(None, [segs[0], pd.env_ms.get_ms(), pd.callback.get_ms(), heap_ms.get_ms()] + [thread.get_stack().get_ms() for thread in threads] + [ms.get_ms() for ms in extra_ms]) # Fill env with default values. env.add_entry(key = "HEAP", cap_name = 'heap/master', attach = heap_ms.get_attrs().attach) env.add_entry(key = "HEAP_BASE", base = heap_ms) env.add_entry(key = "HEAP_SIZE", value = heap_ms.get_attrs().size) pd.add_environment(env) bootinfo.add_pd(pd) image.pop_attrs()