3 * \brief Namespace client stub implementation
6 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7 * Alexander Warg <warg@os.inf.tu-dresden.de>
8 * economic rights: Technische Universität Dresden (Germany)
10 * This file is part of TUD:OS and distributed under the terms of the
11 * GNU General Public License 2.
12 * Please see the COPYING-GPL-2 file for details.
14 * As a special exception, you may use this file as part of a free software
15 * library without restriction. Specifically, if other files instantiate
16 * templates or use macros or inline functions from this file, or you compile
17 * this file and link it with other files to produce an executable, this
18 * file does not by itself cause the resulting executable to be covered by
19 * the GNU General Public License. This exception does not however
20 * invalidate any other reasons why the executable file might be covered by
21 * the GNU General Public License.
23 #include <l4/re/namespace>
24 #include <l4/re/namespace-sys.h>
25 #include <l4/re/protocols>
27 #include <l4/util/util.h>
29 #include <l4/cxx/exceptions>
30 #include <l4/cxx/ipc_helper>
31 #include <l4/cxx/ipc_stream>
33 #include <l4/sys/err.h>
40 Namespace::_query(char const *name, unsigned len,
41 L4::Cap<void> const &target,
42 l4_umword_t *local_id, bool iterate) const throw()
44 unsigned long res = len;
46 L4::Cap<Namespace> ns(cap());
49 L4::Ipc::Iostream io(l4_utcb());
50 io << L4::Opcode(L4Re::Namespace_::Query)
51 << L4::Ipc::buf_cp_out(n, res);
52 io << L4::Ipc::Small_buf(target.cap(), local_id ? L4_RCV_ITEM_LOCAL_ID : 0);
53 l4_msgtag_t r = io.call(ns.cap(), L4Re::Protocol::Namespace);
54 long err = l4_error(r);
59 bool const partly = err & Partly_resolved;
63 io >> dummy >> L4::Ipc::buf_in(n, res);
66 L4::Ipc::Snd_fpage cap;
68 if (cap.id_received())
70 *local_id = cap.data();
74 if (partly && iterate)
75 ns = L4::cap_cast<Namespace>(target);
84 Namespace::query(char const *name, unsigned len, L4::Cap<void> const &target,
85 int timeout, l4_umword_t *local_id, bool iterate) const throw()
95 ret = _query(name, len, target, local_id, iterate);
100 if (L4_UNLIKELY(ret < 0 && (ret != -L4_EAGAIN)))
118 Namespace::query(char const *name, L4::Cap<void> const &target,
119 int timeout, l4_umword_t *local_id,
120 bool iterate) const throw()
121 { return query(name, strlen(name), target, timeout, local_id, iterate); }
124 Namespace::register_obj(char const *name, L4::Cap<void> const &o,
125 unsigned flags) const throw()
127 L4::Ipc::Iostream io(l4_utcb());
128 io << L4::Opcode(L4Re::Namespace_::Register)
129 << flags << L4::Ipc::buf_cp_out(name, strlen(name));
131 io << L4::Ipc::Snd_fpage(o, L4_FPAGE_RWX & flags) ;
132 l4_msgtag_t res = io.call(cap(), L4Re::Protocol::Namespace);
133 return l4_error(res);
137 Namespace::unlink(char const *name) throw()
139 L4::Ipc::Iostream io(l4_utcb());
140 io << L4::Opcode(L4Re::Namespace_::Unlink) << name;
141 l4_msgtag_t res = io.call(cap(), L4Re::Protocol::Namespace);
142 return l4_error(res);
146 Namespace::link(char const *name, unsigned len,
147 L4::Cap<L4Re::Namespace> src_dir,
148 char const *src_name, unsigned src_len,
149 unsigned flags) throw()
151 L4::Ipc::Iostream io(l4_utcb());
152 io << L4::Opcode(L4Re::Namespace_::Link)
153 << flags << L4::Ipc::buf_cp_out(name, len)
154 << L4::Ipc::buf_cp_out(src_name, src_len)
155 << L4::Ipc::Snd_fpage(src_dir.fpage());
156 l4_msgtag_t res = io.call(cap(), L4Re::Protocol::Namespace);
157 return l4_error(res);