L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 * License: see LICENSE.spdx (in this directory or the directories above)
11 */
12#include <l4/re/namespace>
13
14#include <l4/util/util.h>
15#include <l4/sys/cxx/ipc_client>
16#include <l4/sys/assert.h>
17
18#include <string.h>
19
23
24namespace L4Re {
25
26long
27Namespace::_query(char const *name, unsigned len,
28 L4::Cap<void> const &target,
29 l4_umword_t *local_id, bool iterate) const noexcept
30{
31 l4_assert(target.is_valid());
32
33 L4::Cap<Namespace> ns = c();
35
36 while (_name.length > 0)
37 {
39 L4::Opcode dummy;
40 int err = query_t::call(ns, _name,
41 L4::Ipc::Small_buf(target.cap(),
42 local_id
44 : 0),
45 cap, dummy, _name);
46 if (err < 0)
47 return err;
48
49 bool const partly = err & Partly_resolved;
50 if (cap.id_received())
51 {
52 *local_id = cap.data();
53 return _name.length;
54 }
55
56 if (partly && iterate)
57 ns = L4::cap_cast<Namespace>(target);
58 else
59 return err;
60 }
61
62 return _name.length;
63}
64
65long
66Namespace::query(char const *name, unsigned len, L4::Cap<void> const &target,
67 int timeout, l4_umword_t *local_id, bool iterate) const noexcept
68{
69 if (L4_UNLIKELY(len == 0))
70 return -L4_EINVAL;
71
72 if (L4_UNLIKELY(timeout < 0))
73 return -L4_EINVAL;
74
75 long ret;
76 long rem = timeout;
77 long to = 0;
78
79 if (rem)
80 to = 10;
81
82 do
83 {
84 ret = _query(name, len, target, local_id, iterate);
85
86 if (ret >= 0)
87 return ret;
88
89 if (L4_UNLIKELY(ret != -L4_EAGAIN))
90 return ret;
91
92 if (rem == to)
93 return ret;
94
95 l4_sleep(to);
96
97 if (rem > 0)
98 {
99 rem -= to;
100 if (rem < 0)
101 {
102 to = rem = 0;
103 continue; // one final try
104 }
105 }
106
107 if (to < 100)
108 to += to;
109 }
110 while (486);
111}
112
113long
114Namespace::query(char const *name, L4::Cap<void> const &target,
115 int timeout, l4_umword_t *local_id,
116 bool iterate) const noexcept
117{
118 return query(name, __builtin_strlen(name), target,
119 timeout, local_id, iterate);
120}
121
122}
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:165
long unlink(char const *name)
Remove an entry from the name space.
Definition namespace:192
C++ interface for capabilities.
Definition capability.h:219
l4_umword_t data() const noexcept
Return the raw flexpage descriptor.
Definition ipc_types:304
A receive item for receiving a single object capability.
Definition ipc_types:258
Send item or return item.
Definition ipc_types:324
bool id_received() const noexcept
*(Defined for return items only.)* Check if an IPC gate label has been received instead of a mapping.
Definition ipc_types:512
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
@ L4_EINVAL
Invalid argument.
Definition err.h:46
@ L4_EAGAIN
Try again.
Definition err.h:38
@ L4_RCV_ITEM_LOCAL_ID
The receiver requests to receive a local ID instead of a mapping whenever possible.
Definition consts.h:300
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition compiler.h:275
void l4_sleep(l4_uint32_t ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
#define L4_RPC_DEF(name)
Generate the definition of an RPC stub.
Definition ipc_client:32
L4Re C++ Interfaces.
Definition cmd_control:14
int Opcode
Data type for RPC opcodes.
Definition __typeinfo.h:36
Namespace interface.
String.
Array data type for dynamically sized arrays in RPCs.
Definition ipc_array:82
Low-level assert implementation.
#define l4_assert(expr)
Low-level assert.
Definition assert.h:32