Loading...
Searching...
No Matches
factory
Go to the documentation of this file.
// vi:set ft=cpp: -*- Mode: C++ -*-
/*
* (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)
*/
#pragma once
#include <l4/sys/factory.h>
#include <l4/sys/capability>
#include <l4/sys/snd_destination>
#include <l4/sys/cxx/ipc_iface>
#include <l4/sys/cxx/ipc_varg>
namespace L4 {
class Factory : public Kobject_t<Factory, Kobject, L4_PROTO_FACTORY>
{
public:
typedef l4_mword_t Proto;
struct Nil {};
struct Lstr
{
char const *s;
unsigned len;
Lstr(char const *s, unsigned len) noexcept : s(s), len(len) {}
};
class S
{
private:
l4_utcb_t *u;
l4_msgtag_t t;
l4_cap_idx_t f;
template<typename T>
static T &&_move(T &c) { return static_cast<T &&>(c); }
public:
S(S const &) = delete;
S &operator = (S const &) & = delete;
S(S &&o) noexcept
: u(o.u), t(o.t), f(o.f)
{ o.t.raw = 0; }
S &operator = (S &&o) & noexcept
{
u = o.u;
t = o.t;
f = o.f;
o.t.raw = 0;
return *this;
}
S(l4_cap_idx_t f, long obj, L4::Cap<void> target,
l4_utcb_t *utcb) noexcept
: u(utcb), t(l4_factory_create_start_u(obj, target.cap(), u)), f(f)
{}
~S() noexcept
{
if (t.raw)
l4_factory_create_commit_u(f, t, u);
}
operator l4_msgtag_t () noexcept
{
l4_msgtag_t r = l4_factory_create_commit_u(f, t, u);
t.raw = 0;
return r;
}
void put(l4_mword_t i) noexcept
{
l4_factory_create_add_int_u(i, &t, u);
}
void put(l4_umword_t i) noexcept
{
l4_factory_create_add_uint_u(i, &t, u);
}
void put(char const *s) & noexcept
{
l4_factory_create_add_str_u(s, &t, u);
}
void put(Lstr const &s) & noexcept
{
l4_factory_create_add_lstr_u(s.s, s.len, &t, u);
}
void put(Nil) & noexcept
{
l4_factory_create_add_nil_u(&t, u);
}
void put(l4_fpage_t d) & noexcept
{
l4_factory_create_add_fpage_u(d, &t, u);
}
template<typename T>
S &operator << (T const &d) & noexcept
{
put(d);
return *this;
}
template<typename T>
S &&operator << (T const &d) && noexcept
{
put(d);
return _move(*this);
}
};
public:
S create(Cap<void> target, long obj, l4_utcb_t *utcb = l4_utcb()) noexcept
{
return S(cap(), obj, target, utcb);
}
template<typename OBJ>
S create(Cap<OBJ> target, l4_utcb_t *utcb = l4_utcb()) noexcept
{
return S(cap(), OBJ::Protocol, target, utcb);
}
L4_INLINE_RPC_NF(
l4_msgtag_t, create, (L4::Ipc::Out<L4::Cap<void> > target, l4_mword_t obj,
L4::Ipc::Varg const *args),
L4::Ipc::Call_t<L4_CAP_FPAGE_S>);
l4_msgtag_t create_task(Cap<Task> const & target_cap,
l4_fpage_t *utcb_area,
l4_utcb_t *utcb = l4_utcb()) noexcept
{ return l4_factory_create_task_u(cap(), target_cap.cap(), utcb_area, utcb); }
l4_msgtag_t create_factory(Cap<Factory> const &target_cap,
unsigned long limit,
l4_utcb_t *utcb = l4_utcb()) noexcept
{ return l4_factory_create_factory_u(cap(), target_cap.cap(), limit, utcb); }
l4_msgtag_t create_gate(Cap<void> const &target_cap,
Cap<Snd_destination> const &snd_dst_cap,
l4_umword_t label,
l4_utcb_t *utcb = l4_utcb()) noexcept
{
return l4_factory_create_gate_u(cap(), target_cap.cap(), snd_dst_cap.cap(),
label, utcb);
}
l4_msgtag_t create_thread_group(Cap<Thread_group> const &target_cap,
unsigned policy,
l4_utcb_t *utcb = l4_utcb()) noexcept
{
return l4_factory_create_thread_group_u(cap(), target_cap.cap(),
policy, utcb);
}
typedef L4::Typeid::Rpc_nocode<create_t> Rpcs;
};
}
capability
L4::Cap related definitions.
L4::Cap_base::cap
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition capability.h:49
L4::Cap
C++ interface for capabilities.
Definition capability.h:224
L4::Factory::S
Stream class for the create() argument stream.
Definition factory:80
L4::Factory::S::S
S(S &&o) noexcept
Move constructor.
Definition factory:98
L4::Factory::S::put
void put(Lstr const &s) &noexcept
Add a pascal string as next argument.
Definition factory:205
L4::Factory::S::put
void put(l4_fpage_t d) &noexcept
Add a flexpage as next argument.
Definition factory:223
L4::Factory::S::put
void put(l4_umword_t i) noexcept
Put a single l4_umword_t as next argument.
Definition factory:179
L4::Factory::S::operator<<
S & operator<<(T const &d) &noexcept
Add next argument.
Definition factory:237
L4::Factory::S::~S
~S() noexcept
Commit the create() operation if not already done explicitly via operator l4_msgtag_t().
Definition factory:139
L4::Factory::S::S
S(l4_cap_idx_t f, long obj, L4::Cap< void > target, l4_utcb_t *utcb) noexcept
Create a stream for a specific create() call.
Definition factory:125
L4::Factory::S::put
void put(Nil) &noexcept
Add an empty argument.
Definition factory:213
L4::Factory::S::put
void put(char const *s) &noexcept
Add a zero-terminated string as next argument.
Definition factory:191
L4::Factory::S::put
void put(l4_mword_t i) noexcept
Put a single l4_mword_t as next argument.
Definition factory:169
L4::Factory
C++ Factory interface, see Factory for the C interface.
Definition factory:39
L4::Factory::create_factory
l4_msgtag_t create_factory(Cap< Factory > const &target_cap, unsigned long limit, l4_utcb_t *utcb=l4_utcb()) noexcept
Create a new factory.
Definition factory:404
L4::Factory::create_task
l4_msgtag_t create_task(Cap< Task > const &target_cap, l4_fpage_t *utcb_area, l4_utcb_t *utcb=l4_utcb()) noexcept
Create a new task.
Definition factory:370
L4::Factory::create_thread_group
l4_msgtag_t create_thread_group(Cap< Thread_group > const &target_cap, unsigned policy, l4_utcb_t *utcb=l4_utcb()) noexcept
Create a new thread group.
Definition factory:475
L4::Factory::create_gate
l4_msgtag_t create_gate(Cap< void > const &target_cap, Cap< Snd_destination > const &snd_dst_cap, l4_umword_t label, l4_utcb_t *utcb=l4_utcb()) noexcept
Create a new IPC gate, optionally bound to a send destination (a thread or thread group).
Definition factory:440
L4::Factory::create
S create(Cap< void > target, long obj, l4_utcb_t *utcb=l4_utcb()) noexcept
Generic create call to the factory.
Definition factory:292
L4::Factory::create
S create(Cap< OBJ > target, l4_utcb_t *utcb=l4_utcb()) noexcept
Create call for typed capabilities.
Definition factory:329
L4::Ipc::Varg
Variably sized RPC argument.
Definition ipc_varg:97
L4::Kobject_t
Helper class to create an L4Re interface class that is derived from a single base class.
Definition __typeinfo.h:750
L4::Kobject_t< Factory, Kobject, L4_PROTO_FACTORY >::c
L4::Cap< Class > c() const noexcept
Definition __typeinfo.h:769
L4::Kobject::cap
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition kobject:69
factory.h
Common factory related definitions.
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_mword_t
signed long l4_mword_t
Signed machine word.
Definition l4int.h:37
l4_cap_idx_t
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
l4_msgtag_t
struct l4_msgtag_t l4_msgtag_t
Message tag data structure.
l4_utcb_t
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
ipc_iface
Interface Definition Language.
L4_INLINE_RPC_NF
#define L4_INLINE_RPC_NF(res, name, args...)
Define an inline RPC call type (the type only, no callable).
Definition ipc_iface:453
L4
L4 low-level kernel interface.
Definition l4sys-l4f-groups.dox:50
snd_destination
The C++ Sender destination interface.
L4::Factory::Lstr
Special type to add a pascal string into the factory create stream.
Definition factory:55
L4::Factory::Lstr::Lstr
Lstr(char const *s, unsigned len) noexcept
Definition factory:70
L4::Factory::Lstr::len
unsigned len
The number of characters in the buffer.
Definition factory:64
L4::Factory::Lstr::s
char const * s
The character buffer.
Definition factory:59
L4::Factory::Nil
Special type to add a void argument into the factory create stream.
Definition factory:47
L4::Ipc::Call_t
RPC attribute for an RPC call with required rights.
Definition ipc_iface:271
L4::Ipc::Out
Mark an argument as a output value in an RPC signature.
Definition ipc_types:31
L4::Typeid::Rpc_nocode
List of RPCs of an interface using a single operation without an opcode.
Definition __typeinfo.h:454
l4_msgtag_t
Message tag data structure.
Definition types.h:154
l4_msgtag_t::raw
l4_mword_t raw
raw value
Definition types.h:155
l4_fpage_t
L4 flexpage type.
Definition __l4_fpage.h:76