17#include <l4/sys/cxx/ipc_server_loop>
25namespace L4Re {
namespace Util {
49 struct Null_handler :
L4::Epiface_t<Null_handler, L4::Kobject>
58 Null_handler _null_handler;
68 : _server(
L4Re::
Env::env()->main_thread()),
69 _factory(
L4Re::
Env::env()->factory()),
84 : _server(server), _factory(factory), _sif(sif)
104 err =
l4_error(ep->bind_thread(_server,
id));
112 Demand
const &demand)
118 return _register_ep(o, cap, demand);
127 auto cap = L4Re::Util::make_unique_cap<L4::Kobject>();
133 err =
l4_error(_factory->create_gate(cap.get(), _server,
id));
141 return cap.release();
145 Demand
const &demand)
151 auto cap = L4Re::Util::make_unique_cap<L4::Irq>();
157 err =
l4_error(_factory->create(cap.get()));
165 err =
l4_error(cap->bind_thread(_server,
id));
169 return cap.release();
176 static Demand _get_buffer_demand(T *,
196 return _register_ep(o, service, _get_buffer_demand(o));
213 return _register_gate(o, _get_buffer_demand(o));
229 return _register_irq(o, _get_buffer_demand(o));
248 return _register_ep(o, ep, _get_buffer_demand(o));
264 L4::Epiface::Stored_cap c;
266 if (!o || !o->
obj_cap().is_valid())
279 _server->modify_senders(todo);
292template<
typename LOOP_HOOKS = L4::Ipc_svr::Default_loop_hooks >
319 : _registry(this, server, factory)
330 : _registry(this, server, factory)
345 { Base::template loop<L4::Runtime_error, Object_registry &>(_registry, utcb); }
355 template <
typename Pr
inter>
358 Base::template loop_dbg<L4::Runtime_error, Object_registry &, Printer>
359 (_registry, printer, utcb);
C++ interface of the initial environment that is provided to an L4 task.
static Env const * env() noexcept
Returns the initial environment for the current task.
L4::Cap< T > get_cap(char const *name, unsigned l) const noexcept
Get the capability selector for the object named name.
A registry that manages server objects and their attached IPC gates for a single server loop for a sp...
L4::Cap< L4::Rcv_endpoint > register_obj(L4::Epiface *o, L4::Cap< L4::Rcv_endpoint > ep) override
Register a handler for an already existing interrupt.
L4::Cap< L4::Irq > register_irq_obj(L4::Epiface *o) override
Register a handler for an interrupt.
L4::Cap< void > register_obj(L4::Epiface *o, char const *service) override
Register a new server object to a pre-allocated receive endpoint.
L4::Cap< void > register_obj(L4::Epiface *o) override
Register a new server object on a newly allocated capability.
Object_registry(L4::Ipc_svr::Server_iface *sif, L4::Cap< L4::Thread > server, L4::Cap< L4::Factory > factory)
Create a registry for arbitrary threads.
Object_registry(L4::Ipc_svr::Server_iface *sif)
Create a registry for the main thread of the task using the default factory.
void unregister_obj(L4::Epiface *o, bool unmap=true) override
Remove a server object from the handler list.
A server loop object which has a Object_registry included.
Object_registry const * registry() const
Return registry of this server loop.
void L4_NORETURN loop(l4_utcb_t *utcb=l4_utcb())
Start the server loop.
Registry_server(L4::Cap< L4::Thread > server, L4::Cap< L4::Factory > factory)
Create a new server loop object for an arbitrary thread and factory.
Registry_server(l4_utcb_t *, L4::Cap< L4::Thread > server, L4::Cap< L4::Factory > factory)
Create a new server loop object for an arbitrary thread and factory.
Registry_server()
Create a new server loop object for the main thread of the task.
Object_registry * registry()
Return registry of this server loop.
void L4_NORETURN loop_dbg(Printer printer, l4_utcb_t *utcb=l4_utcb())
Start the server loop with error printing.
void free(L4::Cap< void > cap, l4_cap_idx_t task=L4_INVALID_CAP, unsigned unmap_flags=L4_FP_ALL_SPACES) noexcept override
Free a capability.
This registry returns the corresponding server object based on the label of an Ipc_gate.
bool is_valid() const noexcept
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
C++ interface for capabilities.
Interface for server-loop related functions.
L4::Type_info::Demand Demand
Data type expressing server-side demand for receive buffers.
virtual int alloc_buffer_demand(Demand const &demand)=0
Tells the server to allocate buffers for the given demand.
Interface for kernel objects that allow to receive IPC from them.
Abstract interface for object registries.
Basic server loop for handling client requests.
Class wrapping a list of rules which modify the sender label of IPC messages inbound to this thread.
int add(l4_umword_t match_mask, l4_umword_t match, l4_umword_t del_bits, l4_umword_t add_bits) noexcept
Add a rule.
Common factory related definitions.
unsigned long l4_umword_t
Unsigned machine word.
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Get IPC error code if any or message tag label otherwise for an IPC call.
@ L4_FP_ALL_SPACES
Flag to tell the unmap operation to revoke permissions from all child mappings including the mapping ...
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
_Cap_alloc & cap_alloc
Capability allocator.
#define L4_NORETURN
Noreturn function attribute.
#define L4_DEPRECATED(s)
Mark symbol deprecated.
The C++ IPC gate interface.
Epiface implementation for Kobject-based interface implementations.
Base class for interface implementations.
Stored_cap obj_cap() const
Get the capability to the kernel object belonging to this object.
virtual Demand get_buffer_demand() const =0
Get the server-side receive buffer demand for this object.
int set_server(Server_iface *srv, Cap< void > cap, bool managed=false)
Set server registration info for the object.
T::__Kobject_typeid::Demand Demand
Data type expressing the static demand of receive buffers in a server.
Common thread related definitions.
Common task related definitions.
Unique_cap / Unique_del_cap.