19 #pragma GCC system_header 21 #include "capability.h" 25 #include <l4/sys/utcb.h> 28 #include <l4/cxx/type_traits> 138 inline Server_iface::~Server_iface() {}
144 Epiface(Epiface
const &) =
delete;
145 Epiface &operator = (Epiface
const &) =
delete;
152 class Stored_cap :
public Cap<void>
155 enum { Managed = 0x10 };
158 Stored_cap() =
default;
159 Stored_cap(
Cap<void> const &c,
bool managed =
false)
162 static_assert (!(
L4_CAP_MASK & Managed),
"conflicting bits used...");
165 bool managed()
const {
return cap() & Managed; }
169 Epiface() : _data(0) {}
192 virtual Demand get_buffer_demand()
const = 0;
195 virtual ~Epiface() = 0;
203 Stored_cap obj_cap()
const {
return _cap; }
210 Server_iface *server_iface()
const {
return _data; }
221 int set_server(Server_iface *srv,
Cap<void> cap,
bool managed =
false)
223 if ((srv && cap) || (!srv && !cap))
226 _cap = Stored_cap(cap, managed);
236 void set_obj_cap(
Cap<void> const &cap) { _cap = cap; }
243 inline Epiface::~Epiface() {}
245 template<
typename RPC_IFACE,
typename BASE = Epiface>
246 struct Epiface_t0 : BASE
249 typedef RPC_IFACE Interface;
263 template<
typename Derived,
typename BASE = Epiface,
264 bool = cxx::is_polymorphic<BASE>::value>
265 struct Irqep_t : Epiface_t0<void, BASE>
269 static_cast<Derived*
>(
this)->handle_irq();
281 template<
typename Derived,
typename BASE>
282 struct Irqep_t<Derived, BASE, false> : Epiface_t0<void, BASE>
286 static_cast<Derived*
>(
this)->handle_irq();
323 register_obj(L4::Epiface *o,
char const *service) = 0;
340 register_obj(L4::Epiface *o) = 0;
375 {
return cap_reinterpret_cast<L4::Irq>(register_obj(o, cap_reinterpret_cast<L4::Rcv_endpoint>(irq))); }
390 unregister_obj(L4::Epiface *o,
bool unmap =
true) = 0;
393 inline Registry_iface::~Registry_iface() {}
400 template<
typename IFACE>
403 long op_num_interfaces(L4::Meta::Rights)
406 long op_interface(L4::Meta::Rights,
l4_umword_t ifx,
long &proto, L4::Ipc::String<char> &name)
410 proto = L4::kobject_typeid<IFACE>()->proto();
411 name.copy_in(L4::kobject_typeid<IFACE>()->name());
415 long op_supports(L4::Meta::Rights,
l4_mword_t proto)
416 {
return L4::kobject_typeid<IFACE>()->has_proto(proto); }
419 template<
typename IFACE,
typename LIST>
423 template<
typename IFACE>
424 struct _Dispatch<IFACE, Iface_list_end>
426 template<
typename THIS,
typename A1,
typename A2 >
432 template<
typename IFACE,
typename I,
typename LIST >
433 struct _Dispatch<IFACE, Iface_list<I, LIST> >
436 template<
typename THIS >
440 using L4::Ipc::Msg::dispatch_call;
442 typedef Meta_svr<IFACE> Msvr;
443 return dispatch_call<Meta>((Msvr *)0, utcb, tag, r);
447 template<
typename THIS >
451 using L4::Ipc::Msg::dispatch_call;
452 return dispatch_call<typename I::iface_type::Rpcs>(
self, utcb, t, r);
456 template<
typename THIS >
460 if (I::Proto == tag.
label())
463 return _Dispatch<IFACE, typename LIST::type>::f(
self, tag, r, utcb);
467 template<
typename IFACE>
469 _Dispatch<IFACE, typename L4::Kobject_typeid<IFACE>::Iface_list::type>
474 template<
typename EPIFACE>
475 struct Dispatch : Detail::Dispatch<typename EPIFACE::Interface>
481 template<
typename Derived,
typename IFACE,
typename BASE = L4::Epiface,
482 bool = cxx::is_polymorphic<BASE>::value>
483 struct Epiface_t : Epiface_t0<IFACE, BASE>
488 typedef Ipc::Dispatch<Derived> Dispatch;
489 return Dispatch::f(static_cast<Derived*>(
this), tag, rights, utcb);
493 template<
typename Derived,
typename IFACE,
typename BASE>
494 struct Epiface_t<Derived, IFACE, BASE, false> : Epiface_t0<IFACE, BASE>
499 typedef Ipc::Dispatch<Derived> Dispatch;
500 return Dispatch::f(static_cast<Derived*>(
this), tag, rights, utcb);
512 typedef Epiface Value;
519 {
return reinterpret_cast<Value*
>(label & ~3UL); }
537 return find(label)->dispatch(tag, label, utcb);
Abstract interface for object registries.
Data type for expressing the needed receive buffers at the server-side of an interface.
Standard list of RPCs of an interface.
Interface for server-loop related functions.
signed long l4_mword_t
Signed machine word.
Common L4 ABI Data Types.
L4 low-level kernel interface.
virtual int add_timeout(Timeout *timeout, l4_kernel_clock_t time)=0
Add a timeout to the server internal timeout queue.
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Server_iface()
Make a server interface.
This registry returns the corresponding server object based on the label of an Ipc_gate.
Type information handling.
Callback interface for Timeout_queue.
virtual int realloc_rcv_cap(int index)=0
Allocate a new capability for the given receive buffer.
L4::Type_info::Demand Demand
Data type expressing server-side demand for receive buffers.
long label() const
Get the protocol value.
Cap< T > cap_reinterpret_cast(Cap< F > const &c)
reinterpret_cast for capabilities.
L4::Cap< void > rcv_cap(int index) const
Get receive cap with the given index as generic (void) type.
virtual L4::Cap< void > get_rcv_cap(int index) const =0
Get capability slot allocated to the given receive buffer.
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.
T::__Kobject_typeid::Demand Demand
Data type expressing the static demand of receive buffers in a server.
l4_cap_idx_t cap() const
Return capability selector.
unsigned long l4_umword_t
Unsigned machine word.
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
Mask to get only the relevant bits of an l4_cap_idx_t.
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
L4::Cap< T > rcv_cap(int index) const
Get given receive buffer as typed capability.
Definition of interface data-type helpers.
virtual int alloc_buffer_demand(Demand const &demand)=0
Tells the server to allocate buffers for the given demand.
Cap< T > cap_cast(Cap< F > const &c)
static_cast for capabilities.
Meta information protocol.
C++ interface for capabilities.
Message tag data structure.
static Value * find(l4_umword_t label)
Get the server object for an Ipc_gate label.
#define L4_DEPRECATED(s)
Mark symbol deprecated.
virtual int remove_timeout(Timeout *timeout)=0
Remove the given timeout from the timer queue.