L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ipc_server
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 * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
10 * economic rights: Technische Universität Dresden (Germany)
11 *
12 * License: see LICENSE.spdx (in this directory or the directories above)
13 */
14#pragma once
15
16#include <l4/sys/capability>
17#include <l4/sys/typeinfo_svr>
18#include <l4/sys/err.h>
19#include <l4/cxx/ipc_stream>
20#include <l4/sys/cxx/ipc_epiface>
21#include <l4/sys/cxx/ipc_server_loop>
22#include <l4/cxx/type_traits>
23#include <l4/cxx/exceptions>
24
25namespace L4 {
26
38class Server_object : public Epiface
39{
40public:
58 virtual int dispatch(unsigned long rights, Ipc::Iostream &ios) = 0;
59
60 l4_msgtag_t dispatch(l4_msgtag_t tag, unsigned rights, l4_utcb_t *utcb) override
61 {
62 L4::Ipc::Iostream ios(utcb);
63 ios.tag() = tag;
64 int r = dispatch(rights, ios);
65 return ios.prepare_ipc(r);
66 }
67
68 Cap<Kobject> obj_cap() const
69 { return cap_cast<Kobject>(Epiface::obj_cap()); }
70};
71
79template<typename IFACE, typename BASE = L4::Server_object>
80struct Server_object_t : BASE
81{
83 typedef IFACE Interface;
84
86 typename BASE::Demand get_buffer_demand() const override
87 { return typename L4::Kobject_typeid<IFACE>::Demand(); }
88
100 { return L4::Util::handle_meta_request<IFACE>(ios); }
101
113 template<typename THIS>
114 static int proto_dispatch(THIS *self, l4_umword_t rights, L4::Ipc::Iostream &ios)
115 {
116 l4_msgtag_t t;
117 ios >> t;
118 return Kobject_typeid<IFACE>::proto_dispatch(self, t.label(), rights, ios);
119 }
120};
121
142template<typename Derived, typename IFACE, typename BASE = L4::Server_object>
143struct Server_object_x : Server_object_t<IFACE, BASE>
144{
147 {
148 return Server_object_t<IFACE, BASE>::proto_dispatch(static_cast<Derived *>(this),
149 r, ios);
150 }
151};
152
162
163}
L4::Cap related definitions.
C++ interface for capabilities.
Definition capability.h:219
Input/Output stream for IPC [un]marshalling.
Definition ipc_stream:790
Abstract server object to be used with L4::Server and L4::Basic_registry.
Definition ipc_server:39
virtual int dispatch(unsigned long rights, Ipc::Iostream &ios)=0
The abstract handler for client requests to the object.
l4_msgtag_t dispatch(l4_msgtag_t tag, unsigned rights, l4_utcb_t *utcb) override
The abstract handler for client requests to the object.
Definition ipc_server:60
Error codes.
Base exceptions.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
IPC stream.
L4 low-level kernel interface.
Base class for interface implementations.
Definition ipc_epiface:146
Stored_cap obj_cap() const
Get the capability to the kernel object belonging to this object.
Definition ipc_epiface:206
Server object base class for handling IRQ messages.
Definition ipc_server:161
static int proto_dispatch(THIS *self, long proto, A1 a1, A2 &a2)
Protocol based server-side dispatch function.
Definition __typeinfo.h:660
T::__Kobject_typeid::Demand Demand
Data type expressing the static demand of receive buffers in a server.
Definition __typeinfo.h:622
Base class (template) for server implementing server objects.
Definition ipc_server:81
static int proto_dispatch(THIS *self, l4_umword_t rights, L4::Ipc::Iostream &ios)
Implementation of protocol-based dispatch for this server object.
Definition ipc_server:114
int dispatch_meta_request(L4::Ipc::Iostream &ios)
Implementation of the meta protocol based on IFACE.
Definition ipc_server:99
IFACE Interface
Data type of the IPC interface definition.
Definition ipc_server:83
BASE::Demand get_buffer_demand() const override
Definition ipc_server:86
Helper class to implement p_dispatch based server objects.
Definition ipc_server:144
int dispatch(l4_umword_t r, L4::Ipc::Iostream &ios)
Implementation forwarding to p_dispatch().
Definition ipc_server:146
Message tag data structure.
Definition types.h:153
long label() const L4_NOTHROW
Get the protocol value.
Definition types.h:157
Type information server template.