1 /*
2 * \brief Root interface
3 * \author Norman Feske
4 * \date 2006-05-11
5 */
6
7 /*
8 * Copyright (C) 2006-2013 Genode Labs GmbH
9 *
10 * This file is part of the Genode OS framework, which is distributed
11 * under the terms of the GNU General Public License version 2.
12 */
13
14 #ifndef _INCLUDE__ROOT__ROOT_H_
15 #define _INCLUDE__ROOT__ROOT_H_
16
17 #include <base/exception.h>
18 #include <base/rpc.h>
19 #include <base/rpc_args.h>
20 #include <base/affinity.h>
21 #include <session/capability.h>
22
23 namespace Genode {
24
25 struct Root
26 {
27 /*********************
28 ** Exception types **
29 *********************/
30
31 class Exception : public ::Genode::Exception { };
32 class Unavailable : public Exception { };
33 class Quota_exceeded : public Exception { };
34 class Invalid_args : public Exception { };
35
36 typedef Rpc_in_buffer<160> Session_args;
37 typedef Rpc_in_buffer<160> Upgrade_args;
38
39 virtual ~Root() { }
40
41 /**
42 * Create session
43 *
44 * \throw Unavailable
45 * \throw Quota_exceeded
46 * \throw Invalid_args
47 *
48 * \return capability to new session
49 */
50 virtual Session_capability session(Session_args const &args,
51 Affinity const &affinity) = 0;
52
53 /**
54 * Extend resource donation to an existing session
55 */
56 virtual void upgrade(Session_capability session, Upgrade_args const &args) = 0;
57
58 /**
59 * Close session
60 */
61 virtual void close(Session_capability session) = 0;
62
63
64 /*********************
65 ** RPC declaration **
66 *********************/
67
68 GENODE_RPC_THROW(Rpc_session, Session_capability, session,
69 GENODE_TYPE_LIST(Unavailable, Quota_exceeded, Invalid_args),
70 Session_args const &, Affinity const &);
71 GENODE_RPC_THROW(Rpc_upgrade, void, upgrade,
72 GENODE_TYPE_LIST(Invalid_args),
73 Session_capability, Upgrade_args const &);
74 GENODE_RPC(Rpc_close, void, close, Session_capability);
75
76 GENODE_RPC_INTERFACE(Rpc_session, Rpc_upgrade, Rpc_close);
77 };
78
79
80 /**
81 * Root interface supplemented with information about the managed
82 * session type
83 *
84 * This class template is used to automatically propagate the
85 * correct session type to `Parent::announce()` when announcing
86 * a service.
87 */
88 template <typename SESSION_TYPE>
89 struct Typed_root : Root
90 {
91 typedef SESSION_TYPE Session_type;
92 };
93 }
94
95 #endif /* _INCLUDE__ROOT__ROOT_H_ */