L4Re – L4 Runtime Environment
rm.h
Go to the documentation of this file.
1 
5 /*
6  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7  * Alexander Warg <warg@os.inf.tu-dresden.de>
8  * economic rights: Technische Universität Dresden (Germany)
9  *
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU General Public License 2.
12  * Please see the COPYING-GPL-2 file for details.
13  *
14  * As a special exception, you may use this file as part of a free software
15  * library without restriction. Specifically, if other files instantiate
16  * templates or use macros or inline functions from this file, or you compile
17  * this file and link it with other files to produce an executable, this
18  * file does not by itself cause the resulting executable to be covered by
19  * the GNU General Public License. This exception does not however
20  * invalidate any other reasons why the executable file might be covered by
21  * the GNU General Public License.
22  */
23 #pragma once
24 
31 #include <l4/re/env.h>
32 #include <l4/re/c/dataspace.h>
33 
35 
41  L4RE_RM_F_R = L4RE_DS_F_R,
42  L4RE_RM_F_W = L4RE_DS_F_W,
43  L4RE_RM_F_X = L4RE_DS_F_X,
44  L4RE_RM_F_RX = L4RE_DS_F_RX,
45  L4RE_RM_F_RW = L4RE_DS_F_RW,
46  L4RE_RM_F_RWX = L4RE_DS_F_RWX,
47 
49  L4RE_RM_F_PAGER = 0x400,
56 
61 
64 
67 
69  L4RE_RM_F_IN_AREA = 0x40000,
70  L4RE_RM_F_EAGER_MAP = 0x80000,
72 };
73 
74 typedef l4_uint32_t l4re_rm_flags_t;
75 typedef l4_uint64_t l4re_rm_offset_t;
76 
84 L4_CV L4_INLINE int
85 l4re_rm_reserve_area(l4_addr_t *start, unsigned long size,
86  l4re_rm_flags_t flags, unsigned char align) L4_NOTHROW;
87 
95 L4_CV L4_INLINE int
97 
106 L4_CV L4_INLINE int
107 l4re_rm_attach(void **start, unsigned long size, l4re_rm_flags_t flags,
108  l4re_ds_t mem,
109  l4re_rm_offset_t offs,
110  unsigned char align) L4_NOTHROW;
111 
112 
123 L4_CV L4_INLINE int
124 l4re_rm_detach(void *addr) L4_NOTHROW;
125 
138 L4_CV L4_INLINE int
139 l4re_rm_detach_ds(void *addr, l4re_ds_t *ds) L4_NOTHROW;
140 
152 L4_CV L4_INLINE int
154 
167 L4_CV L4_INLINE int
168 l4re_rm_detach_ds_unmap(void *addr, l4re_ds_t *ds,
169  l4_cap_idx_t task) L4_NOTHROW;
170 
171 
177 L4_CV L4_INLINE int
178 l4re_rm_find(l4_addr_t *addr, unsigned long *size,
179  l4re_rm_offset_t *offset,
180  l4re_rm_flags_t *flags, l4re_ds_t *m) L4_NOTHROW;
181 
188 L4_CV L4_INLINE void
190 
191 
192 /*
193  * Variants of functions that also take a capability of the region map
194  * service.
195  */
196 
197 
202 L4_CV int
203 l4re_rm_reserve_area_srv(l4_cap_idx_t rm, l4_addr_t *start, unsigned long size,
204  l4re_rm_flags_t flags, unsigned char align) L4_NOTHROW;
205 
210 L4_CV int
212 
217 L4_CV int
218 l4re_rm_attach_srv(l4_cap_idx_t rm, void **start, unsigned long size,
219  l4re_rm_flags_t flags, l4re_ds_t mem,
220  l4re_rm_offset_t offs,
221  unsigned char align) L4_NOTHROW;
222 
223 
228 L4_CV int
230  l4re_ds_t *ds, l4_cap_idx_t task) L4_NOTHROW;
231 
232 
237 L4_CV int
239  unsigned long *size, l4re_rm_offset_t *offset,
240  l4re_rm_flags_t *flags, l4re_ds_t *m) L4_NOTHROW;
241 
246 L4_CV void
248 
249 
250 /********** Implementations ***************************/
251 
252 L4_CV L4_INLINE int
253 l4re_rm_reserve_area(l4_addr_t *start, unsigned long size,
254  l4re_rm_flags_t flags, unsigned char align) L4_NOTHROW
255 {
256  return l4re_rm_reserve_area_srv(l4re_global_env->rm, start, size,
257  flags, align);
258 }
259 
260 L4_CV L4_INLINE int
262 {
263  return l4re_rm_free_area_srv(l4re_global_env->rm, addr);
264 }
265 
266 L4_CV L4_INLINE int
267 l4re_rm_attach(void **start, unsigned long size, l4re_rm_flags_t flags,
268  l4re_ds_t mem, l4re_rm_offset_t offs,
269  unsigned char align) L4_NOTHROW
270 {
271  return l4re_rm_attach_srv(l4re_global_env->rm, start, size,
272  flags, mem, offs, align);
273 }
274 
275 
276 L4_CV L4_INLINE int
278 {
279  return l4re_rm_detach_srv(l4re_global_env->rm,
280  (l4_addr_t)addr, 0, L4_BASE_TASK_CAP);
281 }
282 
283 L4_CV L4_INLINE int
285 {
286  return l4re_rm_detach_srv(l4re_global_env->rm, addr, 0, task);
287 }
288 
289 L4_CV L4_INLINE int
291 {
292  return l4re_rm_detach_srv(l4re_global_env->rm, (l4_addr_t)addr,
293  ds, L4_BASE_TASK_CAP);
294 }
295 
296 L4_CV L4_INLINE int
298 {
299  return l4re_rm_detach_srv(l4re_global_env->rm, (l4_addr_t)addr,
300  ds, task);
301 }
302 
303 L4_CV L4_INLINE int
304 l4re_rm_find(l4_addr_t *addr, unsigned long *size,
305  l4re_rm_offset_t *offset,
306  l4re_rm_flags_t *flags, l4re_ds_t *m) L4_NOTHROW
307 {
308  return l4re_rm_find_srv(l4re_global_env->rm, addr, size, offset, flags, m);
309 }
310 
311 L4_CV L4_INLINE void
313 {
314  l4re_rm_show_lists_srv(l4re_global_env->rm);
315 }
316 
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:186
#define EXTERN_C_BEGIN
Start section with C types and functions.
Definition: compiler.h:190
#define EXTERN_C_END
End section with C types and functions.
Definition: compiler.h:191
Data space C interface.
Environment interface.
l4_cap_idx_t l4re_ds_t
Dataspace type.
Definition: dataspace.h:39
@ L4RE_DS_F_BUFFERABLE
request bufferable (write buffered) mappings
Definition: dataspace.h:70
@ L4RE_DS_F_NORMAL
request normal memory mapping
Definition: dataspace.h:68
@ L4RE_DS_F_CACHING_MASK
mask for caching flags
Definition: dataspace.h:72
@ L4RE_DS_F_UNCACHEABLE
request uncacheable memory mappings
Definition: dataspace.h:71
int l4re_rm_attach(void **start, unsigned long size, l4re_rm_flags_t flags, l4re_ds_t mem, l4re_rm_offset_t offs, unsigned char align) L4_NOTHROW
Definition: rm.h:267
int l4re_rm_detach(void *addr) L4_NOTHROW
Detach and unmap in current task.
Definition: rm.h:277
void l4re_rm_show_lists_srv(l4_cap_idx_t rm) L4_NOTHROW
Dump region map internal data structures.
int l4re_rm_attach_srv(l4_cap_idx_t rm, void **start, unsigned long size, l4re_rm_flags_t flags, l4re_ds_t mem, l4re_rm_offset_t offs, unsigned char align) L4_NOTHROW
int l4re_rm_reserve_area_srv(l4_cap_idx_t rm, l4_addr_t *start, unsigned long size, l4re_rm_flags_t flags, unsigned char align) L4_NOTHROW
void l4re_rm_show_lists(void) L4_NOTHROW
Dump region map internal data structures.
Definition: rm.h:312
int l4re_rm_find(l4_addr_t *addr, unsigned long *size, l4re_rm_offset_t *offset, l4re_rm_flags_t *flags, l4re_ds_t *m) L4_NOTHROW
Definition: rm.h:304
int l4re_rm_detach_ds(void *addr, l4re_ds_t *ds) L4_NOTHROW
Detach, unmap and return affected dataspace in current task.
Definition: rm.h:290
int l4re_rm_detach_srv(l4_cap_idx_t rm, l4_addr_t addr, l4re_ds_t *ds, l4_cap_idx_t task) L4_NOTHROW
int l4re_rm_detach_unmap(l4_addr_t addr, l4_cap_idx_t task) L4_NOTHROW
Detach and unmap in specified task.
Definition: rm.h:284
l4re_rm_flags_values
Flags for region operations.
Definition: rm.h:40
int l4re_rm_find_srv(l4_cap_idx_t rm, l4_addr_t *addr, unsigned long *size, l4re_rm_offset_t *offset, l4re_rm_flags_t *flags, l4re_ds_t *m) L4_NOTHROW
int l4re_rm_free_area_srv(l4_cap_idx_t rm, l4_addr_t addr) L4_NOTHROW
int l4re_rm_reserve_area(l4_addr_t *start, unsigned long size, l4re_rm_flags_t flags, unsigned char align) L4_NOTHROW
Definition: rm.h:253
int l4re_rm_detach_ds_unmap(void *addr, l4re_ds_t *ds, l4_cap_idx_t task) L4_NOTHROW
Detach and unmap in specified task.
Definition: rm.h:297
int l4re_rm_free_area(l4_addr_t addr) L4_NOTHROW
Definition: rm.h:261
@ L4RE_RM_F_CACHE_BUFFERED
Cache bits for buffered (write combining) memory.
Definition: rm.h:63
@ L4RE_RM_REGION_FLAGS
Mask of all region flags.
Definition: rm.h:57
@ L4RE_RM_F_CACHE_UNCACHED
Cache bits for uncached memory.
Definition: rm.h:66
@ L4RE_RM_CACHING_SHIFT
Start of region mapper cache bits.
Definition: rm.h:52
@ L4RE_RM_F_SEARCH_ADDR
Search for a suitable address range.
Definition: rm.h:68
@ L4RE_RM_F_PAGER
Region has a pager.
Definition: rm.h:49
@ L4RE_RM_F_R
Region is read-only.
Definition: rm.h:41
@ L4RE_RM_F_IN_AREA
Search only in area, or map into area.
Definition: rm.h:69
@ L4RE_RM_F_CACHE_NORMAL
Cache bits for normal cacheable memory.
Definition: rm.h:60
@ L4RE_RM_F_ATTACH_FLAGS
Mask of all attach flags.
Definition: rm.h:71
@ L4RE_RM_F_RESERVED
Region is reserved (blocked)
Definition: rm.h:50
@ L4RE_RM_F_EAGER_MAP
Eagerly map the attached data space in.
Definition: rm.h:70
@ L4RE_RM_F_NO_ALIAS
The region contains exclusive memory that is not mapped anywhere else.
Definition: rm.h:48
@ L4RE_RM_F_CACHING
Mask of all region manager cache bits.
Definition: rm.h:55
unsigned long l4_addr_t
Address type.
Definition: l4int.h:45
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition: l4int.h:40
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition: l4int.h:42
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
@ L4_BASE_TASK_CAP
Capability selector for the current task.
Definition: consts.h:243
#define L4_CV
Define calling convention.
Definition: linkage.h:44
l4_cap_idx_t rm
Region map object-capability.
Definition: env.h:112