L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
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 * This file is part of TUD:OS and distributed under the terms of the
13 * GNU General Public License 2.
14 * Please see the COPYING-GPL-2 file for details.
15 *
16 * As a special exception, you may use this file as part of a free software
17 * library without restriction. Specifically, if other files instantiate
18 * templates or use macros or inline functions from this file, or you compile
19 * this file and link it with other files to produce an executable, this
20 * file does not by itself cause the resulting executable to be covered by
21 * the GNU General Public License. This exception does not however
22 * invalidate any other reasons why the executable file might be covered by
23 * the GNU General Public License.
24 */
25#pragma once
26
27#include <l4/sys/capability>
28#include <l4/sys/typeinfo_svr>
29#include <l4/sys/err.h>
30#include <l4/cxx/ipc_stream>
31#include <l4/sys/cxx/ipc_epiface>
32#include <l4/sys/cxx/ipc_server_loop>
33#include <l4/cxx/type_traits>
34#include <l4/cxx/exceptions>
35
36namespace L4 {
37
49class Server_object : public Epiface
50{
51public:
69 virtual int dispatch(unsigned long rights, Ipc::Iostream &ios) = 0;
70
71 l4_msgtag_t dispatch(l4_msgtag_t tag, unsigned rights, l4_utcb_t *utcb) override
72 {
73 L4::Ipc::Iostream ios(utcb);
74 ios.tag() = tag;
75 int r = dispatch(rights, ios);
76 return ios.prepare_ipc(r);
77 }
78
79 Cap<Kobject> obj_cap() const
80 { return cap_cast<Kobject>(Epiface::obj_cap()); }
81};
82
90template<typename IFACE, typename BASE = L4::Server_object>
91struct Server_object_t : BASE
92{
94 typedef IFACE Interface;
95
97 typename BASE::Demand get_buffer_demand() const override
98 { return typename L4::Kobject_typeid<IFACE>::Demand(); }
99
111 { return L4::Util::handle_meta_request<IFACE>(ios); }
112
124 template<typename THIS>
125 static int proto_dispatch(THIS *self, l4_umword_t rights, L4::Ipc::Iostream &ios)
126 {
127 l4_msgtag_t t;
128 ios >> t;
129 return Kobject_typeid<IFACE>::proto_dispatch(self, t.label(), rights, ios);
130 }
131};
132
153template<typename Derived, typename IFACE, typename BASE = L4::Server_object>
154struct Server_object_x : Server_object_t<IFACE, BASE>
155{
158 {
159 return Server_object_t<IFACE, BASE>::proto_dispatch(static_cast<Derived *>(this),
160 r, ios);
161 }
162};
163
173
174}
L4::Cap related definitions.
C++ interface for capabilities.
Definition capability.h:222
Input/Output stream for IPC [un]marshalling.
Definition ipc_stream:801
Abstract server object to be used with L4::Server and L4::Basic_registry.
Definition ipc_server:50
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:71
Error codes.
Base exceptions.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
IPC stream.
L4 low-level kernel interface.
Base class for interface implementations.
Definition ipc_epiface:157
Stored_cap obj_cap() const
Get the capability to the kernel object belonging to this object.
Definition ipc_epiface:217
Server object base class for handling IRQ messages.
Definition ipc_server:172
static int proto_dispatch(THIS *self, long proto, A1 a1, A2 &a2)
Protocol based server-side dispatch function.
Definition __typeinfo.h:670
T::__Kobject_typeid::Demand Demand
Data type expressing the static demand of receive buffers in a server.
Definition __typeinfo.h:632
Base class (template) for server implementing server objects.
Definition ipc_server:92
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:125
int dispatch_meta_request(L4::Ipc::Iostream &ios)
Implementation of the meta protocol based on IFACE.
Definition ipc_server:110
IFACE Interface
Data type of the IPC interface definition.
Definition ipc_server:94
BASE::Demand get_buffer_demand() const override
Definition ipc_server:97
Helper class to implement p_dispatch based server objects.
Definition ipc_server:155
int dispatch(l4_umword_t r, L4::Ipc::Iostream &ios)
Implementation forwarding to p_dispatch().
Definition ipc_server:157
Message tag data structure.
Definition types.h:163
long label() const L4_NOTHROW
Get the protocol value.
Definition types.h:167
Type information server template.