- Info
1
6
7
13
14 #ifndef _INCLUDE__RM_SESSION__RM_SESSION_H_
15 #define _INCLUDE__RM_SESSION__RM_SESSION_H_
16
17 #include <base/exception.h>
18 #include <base/stdint.h>
19 #include <base/signal.h>
20 #include <dataspace/capability.h>
21 #include <thread/capability.h>
22 #include <pager/capability.h>
23
24 namespace Genode {
25
26 class Rm_session
27 {
28 protected:
29
30 enum Opcode { ATTACH, DETACH, ADD_CLIENT, FAULT_HANDLER, STATE, DATASPACE };
31
32 public:
33
34 enum Fault_type {
35 READY = 0, READ_FAULT = 1, WRITE_FAULT = 2, EXEC_FAULT = 3
36 };
37
38
48 struct State
49 {
50
53 Fault_type type;
54
55
58 addr_t addr;
59
60
63 State() : type(READY), addr(0) { }
64
65
68 State(Fault_type fault_type, addr_t fault_addr) :
69 type(fault_type), addr(fault_addr) { }
70 };
71
72 static const char *service_name() { return "RM"; }
73
74
75
78
79 class Attach_failed : public Exception { };
80 class Invalid_dataspace : public Attach_failed { };
81 class Region_conflict : public Attach_failed { };
82
83 class Invalid_thread : public Exception { };
84 class Out_of_memory : public Exception { };
85
86
87
90 virtual ~Rm_session() { }
91
92
109 virtual void *attach(Dataspace_capability ds,
110 size_t size = 0, off_t offset = 0,
111 bool use_local_addr = false,
112 addr_t local_addr = 0) = 0;
113
114
117 void *attach_at(Dataspace_capability ds, addr_t local_addr,
118 size_t size = 0, off_t offset = 0) {
119 return attach(ds, size, offset, true, local_addr); }
120
121
124 virtual void detach(void *local_addr) = 0;
125
126
138 virtual Pager_capability add_client(Thread_capability thread) = 0;
139
140
143 virtual void fault_handler(Signal_context_capability handler) = 0;
144
145
148 virtual State state() = 0;
149
150
153 virtual Dataspace_capability dataspace() = 0;
154 };
155 }
156
157 #endif