2 * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
9 #include <l4/cxx/iostream>
10 #include "name_space.h"
15 #include <l4/cxx/minmax>
16 #include <l4/re/consts>
24 static Dbg dbg(Dbg::Name_space, "ns");
26 Name_space::Name_space()
27 : L4Re::Util::Names::Name_space(dbg, Err())
29 Gate_alloc::registry.register_obj(this);
32 Name_space::~Name_space()
34 Gate_alloc::registry.unregister_obj(this);
39 Name_space::alloc_dynamic_entry(Names::Name const &name, unsigned flags)
41 char *na = (char*)malloc(name.len());
45 memcpy(na, name.start(), name.len());
46 Names::Name new_name(na, name.len());
47 Entry *e = new Ldr::Entry(new_name, Names::Obj(flags), true);
57 Name_space::free_dynamic_entry(Names::Entry *n)
59 free(const_cast<char*>(n->name().start()));
60 assert (!n->next_link());
61 delete static_cast<Ldr::Entry*>(n);
65 Name_space::get_capability(L4::Ipc::Snd_fpage const &cap_fp, L4::Cap<void> *cap,
66 L4::Server_object **so)
68 if (cap_fp.id_received())
70 L4::Server_object *o = L4::Basic_registry::find(cap_fp.data());
81 if (cap_fp.cap_received())
91 Name_space::save_capability(L4::Cap<void> *cap)
93 if (*cap != Glbl::rcv_cap)
96 L4::Cap<void> nc = L4Re::Util::cap_alloc.alloc<void>();
101 nc.move(Glbl::rcv_cap);
107 Name_space::free_capability(L4::Cap<void> cap)
109 L4Re::Util::cap_alloc.free(cap);
116 #include <l4/cxx/iostream>
118 namespace L4Re { namespace Util { namespace Names {
121 Name_space::dump(bool rec, int indent) const
124 //L4::cout << "loader: Name space dump (" << obj_cap() << ")\n";
125 for (Const_iterator i = begin(); i != end(); ++i)
127 for (int x = 0; x < indent; ++x)
130 L4::cout << " " << i->name() << " -> "
131 << i->obj()->cap().cap()
132 << " o=" << (void*)i->obj()->obj() << " f="
133 << i->obj()->flags() << '\n';
134 if (rec && i->obj()->is_valid()
135 && (n = dynamic_cast<Name_space const *>(i->obj()->obj())))
136 n->dump(rec, indent + 1);