L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
namespace_impl.h
Go to the documentation of this file.
1
5/*
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)
9 *
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.
13 *
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.
22 */
23#include <l4/re/namespace>
24
25#include <l4/util/util.h>
26#include <l4/sys/cxx/ipc_client>
27#include <l4/sys/assert.h>
28
29#include <cstring>
30
34
35namespace L4Re {
36
37long
38Namespace::_query(char const *name, unsigned len,
39 L4::Cap<void> const &target,
40 l4_umword_t *local_id, bool iterate) const noexcept
41{
42 l4_assert(target.is_valid());
43
44 L4::Cap<Namespace> ns = c();
46
47 while (_name.length > 0)
48 {
50 L4::Opcode dummy;
51 int err = query_t::call(ns, _name,
52 L4::Ipc::Small_buf(target.cap(),
53 local_id
55 : 0),
56 cap, dummy, _name);
57 if (err < 0)
58 return err;
59
60 bool const partly = err & Partly_resolved;
61 if (cap.id_received())
62 {
63 *local_id = cap.data();
64 return _name.length;
65 }
66
67 if (partly && iterate)
68 ns = L4::cap_cast<Namespace>(target);
69 else
70 return err;
71 }
72
73 return _name.length;
74}
75
76long
77Namespace::query(char const *name, unsigned len, L4::Cap<void> const &target,
78 int timeout, l4_umword_t *local_id, bool iterate) const noexcept
79{
80 if (L4_UNLIKELY(len == 0))
81 return -L4_EINVAL;
82
83 if (L4_UNLIKELY(timeout < 0))
84 return -L4_EINVAL;
85
86 long ret;
87 long rem = timeout;
88 long to = 0;
89
90 if (rem)
91 to = 10;
92
93 do
94 {
95 ret = _query(name, len, target, local_id, iterate);
96
97 if (ret >= 0)
98 return ret;
99
100 if (L4_UNLIKELY(ret != -L4_EAGAIN))
101 return ret;
102
103 if (rem == to)
104 return ret;
105
106 l4_sleep(to);
107
108 if (rem > 0)
109 {
110 rem -= to;
111 if (rem < 0)
112 {
113 to = rem = 0;
114 continue; // one final try
115 }
116 }
117
118 if (to < 100)
119 to += to;
120 }
121 while (486);
122}
123
124long
125Namespace::query(char const *name, L4::Cap<void> const &target,
126 int timeout, l4_umword_t *local_id,
127 bool iterate) const noexcept
128{
129 return query(name, __builtin_strlen(name), target,
130 timeout, local_id, iterate);
131}
132
133}
void l4_sleep(int ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
long query(char const *name, L4::Cap< void > const &cap, int timeout=To_default, l4_umword_t *local_id=0, bool iterate=true) const noexcept
Query the name space for a named object.
long register_obj(char const *name, L4::Ipc::Cap< void > obj, unsigned flags=Rw) const noexcept
Register an object with a name.
Definition namespace:176
long unlink(char const *name)
Remove an entry from the name space.
Definition namespace:203
C++ interface for capabilities.
Definition capability.h:222
Generic RPC wrapper for L4 flex-pages.
Definition ipc_types:322
bool id_received() const noexcept
Check if a label was received instead of a mapping.
Definition ipc_types:454
l4_umword_t data() const noexcept
Return the raw flex page descriptor.
Definition ipc_types:474
A receive item for receiving a single object capability.
Definition ipc_types:269
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
@ L4_EINVAL
Invalid argument.
Definition err.h:56
@ L4_EAGAIN
Try again.
Definition err.h:49
@ L4_RCV_ITEM_LOCAL_ID
The receiver requests to receive a local ID instead of a mapping whenever possible.
Definition consts.h:285
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition compiler.h:285
#define L4_RPC_DEF(name)
Generate the definition of an RPC stub.
Definition ipc_client:43
L4Re C++ Interfaces.
Definition cmd_control:15
int Opcode
Data type for RPC opcodes.
Definition __typeinfo.h:47
Namespace interface.
Array data type for dynamically sized arrays in RPCs.
Definition ipc_array:93
Low-level assert implementation.
#define l4_assert(expr)
Low-level assert.
Definition assert.h:43