L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
factory
Go to the documentation of this file.
1// vi:set ft=cpp: -*- Mode: C++ -*-
6/*
7 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
8 * Alexander Warg <warg@os.inf.tu-dresden.de>
9 * economic rights: Technische Universität Dresden (Germany)
10 *
11 * License: see LICENSE.spdx (in this directory or the directories above)
12 */
13
14#pragma once
15
16#include <l4/sys/factory.h>
17#include <l4/sys/capability>
19#include <l4/sys/cxx/ipc_iface>
20#include <l4/sys/cxx/ipc_varg>
21
22namespace L4 {
23
38class Factory : public Kobject_t<Factory, Kobject, L4_PROTO_FACTORY>
39{
40public:
41
42 typedef l4_mword_t Proto;
43
47 struct Nil {};
48
54 struct Lstr
55 {
59 char const *s;
60
64 unsigned len;
65
70 Lstr(char const *s, unsigned len) noexcept : s(s), len(len) {}
71 };
72
79 class S
80 {
81 private:
82 l4_utcb_t *u;
85
86 template<typename T>
87 static T &&_move(T &c) { return static_cast<T &&>(c); }
88
89 public:
90 S(S const &) = delete;
91 S &operator = (S const &) & = delete;
92
98 S(S &&o) noexcept
99 : u(o.u), t(o.t), f(o.f)
100 { o.t.raw = 0; }
101
102 S &operator = (S &&o) & noexcept
103 {
104 u = o.u;
105 t = o.t;
106 f = o.f;
107 o.t.raw = 0;
108 return *this;
109 }
110
125 S(l4_cap_idx_t f, long obj, L4::Cap<void> target,
126 l4_utcb_t *utcb) noexcept
127 : u(utcb), t(l4_factory_create_start_u(obj, target.cap(), u)), f(f)
128 {}
129
139 ~S() noexcept
140 {
141 if (t.raw)
142 l4_factory_create_commit_u(f, t, u);
143 }
144
157 operator l4_msgtag_t () noexcept
158 {
159 l4_msgtag_t r = l4_factory_create_commit_u(f, t, u);
160 t.raw = 0;
161 return r;
162 }
163
169 void put(l4_mword_t i) noexcept
170 {
171 l4_factory_create_add_int_u(i, &t, u);
172 }
173
179 void put(l4_umword_t i) noexcept
180 {
181 l4_factory_create_add_uint_u(i, &t, u);
182 }
183
191 void put(char const *s) & noexcept
192 {
193 l4_factory_create_add_str_u(s, &t, u);
194 }
195
205 void put(Lstr const &s) & noexcept
206 {
207 l4_factory_create_add_lstr_u(s.s, s.len, &t, u);
208 }
209
213 void put(Nil) & noexcept
214 {
215 l4_factory_create_add_nil_u(&t, u);
216 }
217
223 void put(l4_fpage_t d) & noexcept
224 {
225 l4_factory_create_add_fpage_u(d, &t, u);
226 }
227
236 template<typename T>
237 S &operator << (T const &d) & noexcept
238 {
239 put(d);
240 return *this;
241 }
242
251 template<typename T>
252 S &&operator << (T const &d) && noexcept
253 {
254 put(d);
255 return _move(*this);
256 }
257 };
258
259
260public:
261
292 S create(Cap<void> target, long obj, l4_utcb_t *utcb = l4_utcb()) noexcept
293 {
294 return S(cap(), obj, target, utcb);
295 }
296
328 template<typename OBJ>
329 S create(Cap<OBJ> target, l4_utcb_t *utcb = l4_utcb()) noexcept
330 {
331 return S(cap(), OBJ::Protocol, target, utcb);
332 }
333
336 L4::Ipc::Varg const *args),
338
371 l4_fpage_t *utcb_area,
372 l4_utcb_t *utcb = l4_utcb()) noexcept
373 { return l4_factory_create_task_u(cap(), target_cap.cap(), utcb_area, utcb); }
374
405 unsigned long limit,
406 l4_utcb_t *utcb = l4_utcb()) noexcept
407 { return l4_factory_create_factory_u(cap(), target_cap.cap(), limit, utcb); }
408
441 Cap<Snd_destination> const &snd_dst_cap,
442 l4_umword_t label,
443 l4_utcb_t *utcb = l4_utcb()) noexcept
444 {
445 return l4_factory_create_gate_u(cap(), target_cap.cap(), snd_dst_cap.cap(),
446 label, utcb);
447 }
448
476 unsigned policy,
477 l4_utcb_t *utcb = l4_utcb()) noexcept
478 {
479 return l4_factory_create_thread_group_u(cap(), target_cap.cap(),
480 policy, utcb);
481 }
482
484};
485
486}
L4::Cap related definitions.
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition capability.h:49
C++ interface for capabilities.
Definition capability.h:224
Stream class for the create() argument stream.
Definition factory:80
S(S &&o) noexcept
Move constructor.
Definition factory:98
void put(Lstr const &s) &noexcept
Add a pascal string as next argument.
Definition factory:205
void put(l4_fpage_t d) &noexcept
Add a flexpage as next argument.
Definition factory:223
void put(l4_umword_t i) noexcept
Put a single l4_umword_t as next argument.
Definition factory:179
S & operator<<(T const &d) &noexcept
Add next argument.
Definition factory:237
~S() noexcept
Commit the create() operation if not already done explicitly via operator l4_msgtag_t().
Definition factory:139
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
void put(Nil) &noexcept
Add an empty argument.
Definition factory:213
void put(char const *s) &noexcept
Add a zero-terminated string as next argument.
Definition factory:191
void put(l4_mword_t i) noexcept
Put a single l4_mword_t as next argument.
Definition factory:169
C++ Factory interface, see Factory for the C interface.
Definition factory:39
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_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_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_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
S create(Cap< void > target, long obj, l4_utcb_t *utcb=l4_utcb()) noexcept
Generic create call to the factory.
Definition factory:292
S create(Cap< OBJ > target, l4_utcb_t *utcb=l4_utcb()) noexcept
Create call for typed capabilities.
Definition factory:329
Variably sized RPC argument.
Definition ipc_varg:97
Helper class to create an L4Re interface class that is derived from a single base class.
Definition __typeinfo.h:750
L4::Cap< Class > c() const noexcept
Get the capability to ourselves.
Definition __typeinfo.h:769
l4_cap_idx_t cap() const noexcept
Return capability selector.
Definition kobject:69
Common factory related definitions.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
signed long l4_mword_t
Signed machine word.
Definition l4int.h:37
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
Interface Definition Language.
#define L4_INLINE_RPC_NF(res, name, args...)
Define an inline RPC call type (the type only, no callable).
Definition ipc_iface:453
L4 low-level kernel interface.
The C++ Sender destination interface.
Special type to add a pascal string into the factory create stream.
Definition factory:55
Lstr(char const *s, unsigned len) noexcept
Definition factory:70
unsigned len
The number of characters in the buffer.
Definition factory:64
char const * s
The character buffer.
Definition factory:59
Special type to add a void argument into the factory create stream.
Definition factory:47
RPC attribute for an RPC call with required rights.
Definition ipc_iface:271
Mark an argument as a output value in an RPC signature.
Definition ipc_types:31
List of RPCs of an interface using a single operation without an opcode.
Definition __typeinfo.h:454
Message tag data structure.
Definition types.h:154
l4_mword_t raw
raw value
Definition types.h:155
L4 flexpage type.
Definition __l4_fpage.h:76