19#pragma GCC system_header
21#include "capability.h"
25#include <l4/sys/utcb.h>
28#include <l4/cxx/type_traits>
141inline Server_iface::~Server_iface() {}
166 class Stored_cap :
public Cap<void>
169 enum { Managed = 0x10 };
172 Stored_cap() =
default;
173 Stored_cap(
Cap<void> const &c,
bool managed =
false)
176 static_assert (!(
L4_CAP_MASK & Managed),
"conflicting bits used...");
179 bool managed()
const {
return cap() & Managed; }
237 if ((srv && cap) || (!srv && !cap))
240 _cap = Stored_cap(cap, managed);
266template<
typename RPC_IFACE,
typename BASE = Epiface>
281 {
return L4::cap_cast<RPC_IFACE>(BASE::obj_cap()); }
291template<
typename Derived,
typename BASE = Epiface,
292 bool = cxx::is_polymorphic<BASE>::value>
297 static_cast<Derived*
>(
this)->handle_irq();
306 {
return L4::cap_cast<L4::Irq>(BASE::obj_cap()); }
309template<
typename Derived,
typename BASE>
310struct Irqep_t<Derived, BASE, false> : Epiface_t0<void, BASE>
314 static_cast<Derived*
>(
this)->handle_irq();
323 {
return L4::cap_cast<L4::Irq>(BASE::obj_cap()); }
416inline Registry_iface::~Registry_iface() {}
423template<
typename IFACE>
426 long op_num_interfaces(L4::Meta::Rights)
429 long op_interface(L4::Meta::Rights,
l4_umword_t ifx,
long &proto, L4::Ipc::String<char> &name)
433 proto = L4::kobject_typeid<IFACE>()->proto();
434 if (
auto *n = L4::kobject_typeid<IFACE>()->name())
440 long op_supports(L4::Meta::Rights,
l4_mword_t proto)
441 {
return L4::kobject_typeid<IFACE>()->has_proto(proto); }
444template<
typename IFACE,
typename LIST>
448template<
typename IFACE>
449struct _Dispatch<IFACE, Iface_list_end>
451 template<
typename THIS,
typename A1,
typename A2 >
457template<
typename IFACE,
typename I,
typename LIST >
458struct _Dispatch<IFACE, Iface_list<I, LIST> >
461 template<
typename THIS >
465 using L4::Ipc::Msg::dispatch_call;
467 typedef Meta_svr<IFACE> Msvr;
468 return dispatch_call<Meta>(
static_cast<Msvr *
>(
nullptr), utcb, tag, r);
472 template<
typename THIS >
476 using L4::Ipc::Msg::dispatch_call;
477 return dispatch_call<typename I::iface_type::Rpcs>(self, utcb, t, r);
481 template<
typename THIS >
485 if (I::Proto == tag.
label())
486 return _f(self, tag, r, utcb,
489 return _Dispatch<IFACE, typename LIST::type>::f(self, tag, r, utcb);
493template<
typename IFACE>
495 _Dispatch<IFACE, typename L4::Kobject_typeid<IFACE>::Iface_list::type>
500template<
typename EPIFACE>
501struct Dispatch : Detail::Dispatch<typename EPIFACE::Interface>
512template<
typename Derived,
typename IFACE,
typename BASE =
L4::Epiface,
513 bool = cxx::is_polymorphic<BASE>::value>
519 typedef Ipc::Dispatch<Derived> Dispatch;
520 return Dispatch::f(
static_cast<Derived*
>(
this), tag, rights, utcb);
524template<
typename Derived,
typename IFACE,
typename BASE>
530 typedef Ipc::Dispatch<Derived> Dispatch;
531 return Dispatch::f(
static_cast<Derived*
>(
this), tag, rights, utcb);
550 {
return reinterpret_cast<Value*
>(label & ~3UL); }
Type information handling.
This registry returns the corresponding server object based on the label of an Ipc_gate.
static l4_msgtag_t dispatch(l4_msgtag_t tag, l4_umword_t label, l4_utcb_t *utcb)
The dispatch function called by the server loop.
static Value * find(l4_umword_t label)
Get the server object for an Ipc_gate label.
l4_cap_idx_t cap() const noexcept
Return capability selector.
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 realloc_rcv_cap(int index)=0
Allocate a new capability for the given receive buffer.
virtual int add_timeout(Timeout *timeout, l4_kernel_clock_t time)=0
Add a timeout to the server internal timeout queue.
virtual int remove_timeout(Timeout *timeout)=0
Remove the given timeout from the timer queue.
Server_iface()
Make a server interface.
virtual L4::Cap< void > get_rcv_cap(int index) const =0
Get capability slot allocated to the given receive buffer.
L4::Cap< void > rcv_cap(int index) const
Get receive cap with the given index as generic (void) type.
L4::Cap< T > rcv_cap(int index) const
Get given receive buffer as typed capability.
virtual int alloc_buffer_demand(Demand const &demand)=0
Tells the server to allocate buffers for the given demand.
Callback interface for Timeout_queue.
Abstract interface for object registries.
virtual void unregister_obj(L4::Epiface *o, bool unmap=true)=0
Unregister the given object o from the server.
virtual L4::Cap< L4::Irq > register_irq_obj(L4::Epiface *o)=0
Register o as server-side object for asynchronous IRQs.
virtual L4::Cap< void > register_obj(L4::Epiface *o, char const *service)=0
Register an L4::Epiface for an IPC gate available in the applications environment under the name serv...
virtual L4::Cap< L4::Rcv_endpoint > register_obj(L4::Epiface *o, L4::Cap< L4::Rcv_endpoint > ep)=0
Register o as server-side object for a pre-allocated capability.
virtual L4::Cap< void > register_obj(L4::Epiface *o)=0
Register o as server-side object for synchronous RPC.
Data type for expressing the needed receive buffers at the server-side of an interface.
unsigned long l4_umword_t
Unsigned machine word.
signed long l4_mword_t
Signed machine word.
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
@ L4_CAP_MASK
Mask to get only the relevant bits of an l4_cap_idx_t.
@ L4_EINVAL
Invalid argument.
@ L4_EBADPROTO
Unsupported protocol.
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
@ L4_PROTO_META
Meta information protocol.
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Common L4 ABI Data Types.
Definition of interface data-type helpers.
L4 low-level kernel interface.
Epiface mixin for generic Kobject-based interfaces.
Type_info::Demand get_buffer_demand() const
Get the server-side buffer demand based in IFACE.
Cap< RPC_IFACE > obj_cap() const
Get the (typed) capability to this object.
RPC_IFACE Interface
Data type of the IPC interface definition.
Epiface implementation for Kobject-based interface implementations.
l4_msgtag_t dispatch(l4_msgtag_t tag, unsigned rights, l4_utcb_t *utcb) final
The abstract handler for client requests to the object.
Base class for interface implementations.
Stored_cap obj_cap() const
Get the capability to the kernel object belonging to this object.
Ipc_svr::Server_iface::Demand Demand
Type for server-side receive buffer demand.
virtual ~Epiface()=0
Destroy the object.
Server_iface * server_iface() const
Get pointer to server interface at which the object is currently registered.
virtual l4_msgtag_t dispatch(l4_msgtag_t tag, unsigned rights, l4_utcb_t *utcb)=0
The abstract handler for client requests to the object.
void set_obj_cap(Cap< void > const &cap)
Deprecated server registration function.
virtual Demand get_buffer_demand() const =0
Get the server-side receive buffer demand for this object.
Ipc_svr::Server_iface Server_iface
Type for abstract server interface.
int set_server(Server_iface *srv, Cap< void > cap, bool managed=false)
Set server registration info for the object.
Epiface()
Make a server object.
Epiface implementation for interrupt handlers.
Cap< L4::Irq > obj_cap() const
Get the (typed) capability to this object.
l4_msgtag_t dispatch(l4_msgtag_t, unsigned, l4_utcb_t *) final
The abstract handler for client requests to the object.
T::__Kobject_typeid::Demand Demand
Data type expressing the static demand of receive buffers in a server.
Standard list of RPCs of an interface.
Message tag data structure.
long label() const L4_NOTHROW
Get the protocol value.