Loading...
Searching...
No Matches
namespace_impl.h
Go to the documentation of this file.
/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#include <l4/re/namespace>
#include <l4/util/util.h>
#include <l4/sys/cxx/ipc_client>
#include <l4/sys/assert.h>
#include <string.h>
L4_RPC_DEF(L4Re::Namespace::query);
L4_RPC_DEF(L4Re::Namespace::register_obj);
L4_RPC_DEF(L4Re::Namespace::unlink);
namespace L4Re {
long
Namespace::_query(char const *name, unsigned len,
L4::Cap<void> const &target,
l4_umword_t *local_id, bool iterate) const noexcept
{
l4_assert(target.is_valid());
L4::Cap<Namespace> ns = c();
L4::Ipc::Array<char const, unsigned long> _name(len, name);
while (_name.length > 0)
{
L4::Ipc::Snd_fpage cap;
L4::Opcode dummy;
int err = query_t::call(ns, _name,
L4::Ipc::Small_buf(target.cap(),
local_id
? L4_RCV_ITEM_LOCAL_ID
: 0),
cap, dummy, _name);
if (err < 0)
return err;
bool const partly = err & Partly_resolved;
if (cap.id_received())
{
*local_id = cap.data();
return _name.length;
}
if (partly && iterate)
ns = L4::cap_cast<Namespace>(target);
else
return err;
}
return _name.length;
}
long
Namespace::query(char const *name, unsigned len, L4::Cap<void> const &target,
int timeout, l4_umword_t *local_id, bool iterate) const noexcept
{
if (L4_UNLIKELY(len == 0))
return -L4_EINVAL;
if (L4_UNLIKELY(timeout < 0))
return -L4_EINVAL;
long ret;
long rem = timeout;
long to = 0;
if (rem)
to = 10;
do
{
ret = _query(name, len, target, local_id, iterate);
if (ret >= 0)
return ret;
if (L4_UNLIKELY(ret != -L4_EAGAIN))
return ret;
if (rem == to)
return ret;
l4_sleep(to);
if (rem > 0)
{
rem -= to;
if (rem < 0)
{
to = rem = 0;
continue; // one final try
}
}
if (to < 100)
to += to;
}
while (486);
}
long
Namespace::query(char const *name, L4::Cap<void> const &target,
int timeout, l4_umword_t *local_id,
bool iterate) const noexcept
{
return query(name, __builtin_strlen(name), target,
timeout, local_id, iterate);
}
}
L4Re::Namespace::query
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.
Definition namespace_impl.h:114
L4Re::Namespace::register_obj
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
L4Re::Namespace::unlink
long unlink(char const *name)
Remove an entry from the name space.
Definition namespace:191
L4::Cap
C++ interface for capabilities.
Definition capability.h:224
L4::Ipc::Gen_fpage::data
l4_umword_t data() const noexcept
Return the raw flexpage descriptor.
Definition ipc_types:304
L4::Ipc::Snd_fpage::id_received
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
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
L4_EINVAL
@ L4_EINVAL
Invalid argument.
Definition err.h:46
L4_EAGAIN
@ L4_EAGAIN
Try again.
Definition err.h:38
L4_RCV_ITEM_LOCAL_ID
@ L4_RCV_ITEM_LOCAL_ID
The receiver requests to receive a local ID instead of a mapping whenever possible.
Definition consts.h:296
L4_UNLIKELY
#define L4_UNLIKELY(x)
Expression is unlikely to execute.
Definition compiler.h:284
l4_sleep
void l4_sleep(l4_uint32_t ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
ipc_client
L4_RPC_DEF
#define L4_RPC_DEF(name)
Generate the definition of an RPC stub.
Definition ipc_client:32
L4Re
L4Re C++ Interfaces.
Definition cmd_control:14
L4::Opcode
int Opcode
Data type for RPC opcodes.
Definition __typeinfo.h:36
L4::cap_cast
Cap< T > cap_cast(Cap< F > const &c) noexcept
static_cast for capabilities.
Definition capability.h:416
namespace
Namespace interface.
string.h
String.
assert.h
Low-level assert implementation.
l4_assert
#define l4_assert(expr)
Low-level assert.
Definition assert.h:32