28 #include <l4/sys/cxx/ipc_server_loop> 36 namespace L4Re {
namespace Util {
60 struct Null_handler : L4::Epiface_t<Null_handler, L4::Kobject>
69 Null_handler _null_handler;
79 : _server(
L4Re::
Env::env()->main_thread()),
80 _factory(
L4Re::
Env::env()->factory()),
95 : _server(server), _factory(factory), _sif(sif)
104 Demand
const &demand)
115 err = o->set_server(_sif, ep);
122 L4::Cap<void> _register_ep(L4::Epiface *o,
char const *service,
123 Demand
const &demand)
129 return _register_ep(o, cap, demand);
132 L4::Cap<void> _register_gate(L4::Epiface *o, Demand
const &demand)
138 auto cap = L4Re::Util::make_unique_cap<L4::Kobject>();
148 err = o->set_server(_sif, cap.get(),
true);
152 return cap.release();
156 Demand
const &demand)
162 auto cap = L4Re::Util::make_unique_cap<L4::Irq>();
176 err = o->set_server(_sif, cap.get(),
true);
180 return cap.release();
183 static Demand _get_buffer_demand(L4::Epiface *o)
184 {
return o->get_buffer_demand(); }
187 static Demand _get_buffer_demand(T *,
203 return _register_ep(o, service, _get_buffer_demand(o));
217 return _register_gate(o, _get_buffer_demand(o));
231 return _register_irq(o, _get_buffer_demand(o));
249 return _register_ep(o, ep, _get_buffer_demand(o));
265 L4::Epiface::Stored_cap c;
267 if (!o || !o->obj_cap().is_valid())
274 todo.
add(~3UL, reinterpret_cast<l4_umword_t>(o),
275 ~0UL, reinterpret_cast<l4_umword_t>((L4::Epiface*)&_null_handler));
292 template<
typename LOOP_HOOKS = L4::Ipc_svr::Default_loop_hooks >
317 : Base(utcb), _registry(this, server, factory)
329 { Base::template loop<L4::Runtime_error, Object_registry &>(_registry); }
Abstract interface for object registries.
Object_registry(L4::Ipc_svr::Server_iface *sif)
Create a registry for the main thread of the task using the default factory.
Data type for expressing the needed receive buffers at the server-side of an interface.
void L4_NORETURN loop()
Start the server loop.
L4::Cap< L4::Irq > register_irq_obj(L4::Epiface *o) override
Register a handler for an interrupt.
Unique_cap / Unique_del_cap.
Interface for server-loop related functions.
int add(l4_umword_t match_mask, l4_umword_t match, l4_umword_t del_bits, l4_umword_t add_bits)
Add a rule.
Wrapper class for modifying senders.
C++ interface of the initial environment that is provided to an L4 task.
l4_msgtag_t create_gate(Cap< void > const &target_cap, Cap< Thread > const &thread_cap, l4_umword_t label, l4_utcb_t *utcb=l4_utcb())
Create a new IPC gate.
L4::Cap< void > register_obj(L4::Epiface *o) override
Register a new server object on a newly allocated capability.
Object_registry * registry()
Return registry of this server loop.
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
This registry returns the corresponding server object based on the label of an Ipc_gate.
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.
Common task related definitions.
Registry_server()
Create a new server loop object for the main thread of the task.
Registry_server(l4_utcb_t *utcb, L4::Cap< L4::Thread > server, L4::Cap< L4::Factory > factory)
Create a new server loop object for an arbitrary thread and factory.
Basic server loop for handling client requests.
Object_registry(L4::Ipc_svr::Server_iface *sif, L4::Cap< L4::Thread > server, L4::Cap< L4::Factory > factory)
Create a registry for arbitrary threads.
#define L4_NORETURN
Noreturn function attribute.
Flag to tell the unmap operation to unmap all child mappings including the mapping in the invoked tas...
bool free(L4::Cap< void > cap, l4_cap_idx_t task=L4_INVALID_CAP, unsigned unmap_flags=L4_FP_ALL_SPACES)
Free the capability.
Common thread related definitions.
static Env const * env()
Returns the initial environment for the current task.
T::__Kobject_typeid::Demand Demand
Data type expressing the static demand of receive buffers in a server.
_Cap_alloc & cap_alloc
Capability allocator.
Object_registry const * registry() const
Return registry of this server loop.
unsigned long l4_umword_t
Unsigned machine word.
S create(Cap< void > target, long obj, l4_utcb_t *utcb=l4_utcb())
Generic create call to the factory.
Interface for kernel objects that allow to receive IPC from them.
A server loop object which has a Object_registry included.
void unregister_obj(L4::Epiface *o, bool unmap=true) override
Remove a server object from the handler list.
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
bool is_valid() const
Test whether the capability is a valid capability index (i.e., not L4_INVALID_CAP).
virtual L4::Cap< L4::Irq > register_irq_obj(L4::Epiface *o)=0
Register o as server-side object for asynchronous IRQs.
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Return error code of a system call return message tag.
Common factory related definitions.
L4::Cap< void > register_obj(L4::Epiface *o, char const *service) override
Register a new server object to a pre-allocated receive endpoint.
virtual int alloc_buffer_demand(Demand const &demand)=0
Tells the server to allocate buffers for the given demand.
L4::Cap< T > get_cap(char const *name, unsigned l) const
Get the capability selector for the object named name.
The C++ IPC gate interface.
A registry that manages server objects and their attached IPC gates for a single server loop for a sp...
l4_msgtag_t modify_senders(Modify_senders const &todo)
Apply sender modification rules.
l4_msgtag_t bind_thread(Ipc::Opt< Ipc::Cap< Thread > > t, l4_umword_t label)
Bind a thread to an IPC receive endpoint.