L4Re - L4 Runtime Environment
task.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  * Björn Döbel <doebel@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 #include <l4/sys/types.h>
27 #include <l4/sys/utcb.h>
28 
60 L4_INLINE l4_msgtag_t
61 l4_task_map(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
62  l4_fpage_t snd_fpage, l4_addr_t snd_base) L4_NOTHROW;
63 
67 L4_INLINE l4_msgtag_t
68 l4_task_map_u(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
69  l4_fpage_t snd_fpage, l4_addr_t snd_base, l4_utcb_t *utcb) L4_NOTHROW;
70 
89 L4_INLINE l4_msgtag_t
91  l4_umword_t map_mask) L4_NOTHROW;
92 
96 L4_INLINE l4_msgtag_t
97 l4_task_unmap_u(l4_cap_idx_t task, l4_fpage_t fpage,
98  l4_umword_t map_mask, l4_utcb_t *utcb) L4_NOTHROW;
99 
123 L4_INLINE l4_msgtag_t
124 l4_task_unmap_batch(l4_cap_idx_t task, l4_fpage_t const *fpages,
125  unsigned num_fpages, unsigned long map_mask) L4_NOTHROW;
126 
130 L4_INLINE l4_msgtag_t
131 l4_task_unmap_batch_u(l4_cap_idx_t task, l4_fpage_t const *fpages,
132  unsigned num_fpages, unsigned long map_mask,
133  l4_utcb_t *u) L4_NOTHROW;
134 
150 L4_INLINE l4_msgtag_t
152 
156 L4_INLINE l4_msgtag_t
157 l4_task_delete_obj_u(l4_cap_idx_t task, l4_cap_idx_t obj,
158  l4_utcb_t *u) L4_NOTHROW;
159 
171 L4_INLINE l4_msgtag_t
173 
177 L4_INLINE l4_msgtag_t
178 l4_task_release_cap_u(l4_cap_idx_t task, l4_cap_idx_t cap,
179  l4_utcb_t *u) L4_NOTHROW;
180 
181 
195 L4_INLINE l4_msgtag_t
197 
201 L4_INLINE l4_msgtag_t
202 l4_task_cap_valid_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
203 
216 L4_INLINE l4_msgtag_t
218  L4_DEPRECATED("Do not use. Future uncertain.");
219 
223 L4_INLINE l4_msgtag_t
224 l4_task_cap_has_child_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
225 
238 L4_INLINE l4_msgtag_t
240  l4_cap_idx_t cap_b) L4_NOTHROW;
241 
245 L4_INLINE l4_msgtag_t
246 l4_task_add_ku_mem_u(l4_cap_idx_t task, l4_fpage_t ku_mem,
247  l4_utcb_t *u) L4_NOTHROW;
248 
258 L4_INLINE l4_msgtag_t
260 
261 
265 L4_INLINE l4_msgtag_t
266 l4_task_cap_equal_u(l4_cap_idx_t task, l4_cap_idx_t cap_a,
267  l4_cap_idx_t cap_b, l4_utcb_t *utcb) L4_NOTHROW;
268 
274 {
280 };
281 
282 
283 /* IMPLEMENTATION -----------------------------------------------------------*/
284 
285 #include <l4/sys/ipc.h>
286 
287 
288 L4_INLINE l4_msgtag_t
289 l4_task_map_u(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
290  l4_fpage_t snd_fpage, unsigned long snd_base, l4_utcb_t *u) L4_NOTHROW
291 {
292  l4_msg_regs_t *v = l4_utcb_mr_u(u);
293  v->mr[0] = L4_TASK_MAP_OP;
294  v->mr[3] = l4_map_obj_control(0,0);
295  v->mr[4] = l4_obj_fpage(src_task, 0, L4_FPAGE_RWX).raw;
296  v->mr[1] = snd_base;
297  v->mr[2] = snd_fpage.raw;
298  return l4_ipc_call(dst_task, u, l4_msgtag(L4_PROTO_TASK, 3, 1, 0), L4_IPC_NEVER);
299 }
300 
301 L4_INLINE l4_msgtag_t
302 l4_task_unmap_u(l4_cap_idx_t task, l4_fpage_t fpage,
303  unsigned long map_mask, l4_utcb_t *u) L4_NOTHROW
304 {
305  l4_msg_regs_t *v = l4_utcb_mr_u(u);
306  v->mr[0] = L4_TASK_UNMAP_OP;
307  v->mr[1] = map_mask;
308  v->mr[2] = fpage.raw;
309  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), L4_IPC_NEVER);
310 }
311 
312 L4_INLINE l4_msgtag_t
313 l4_task_unmap_batch_u(l4_cap_idx_t task, l4_fpage_t const *fpages,
314  unsigned num_fpages, unsigned long map_mask,
316 {
317  l4_msg_regs_t *v = l4_utcb_mr_u(u);
318  v->mr[0] = L4_TASK_UNMAP_OP;
319  v->mr[1] = map_mask;
320  __builtin_memcpy(&v->mr[2], fpages, num_fpages * sizeof(l4_fpage_t));
321  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2 + num_fpages, 0, 0), L4_IPC_NEVER);
322 }
323 
324 L4_INLINE l4_msgtag_t
325 l4_task_cap_valid_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *u) L4_NOTHROW
326 {
327  l4_msg_regs_t *v = l4_utcb_mr_u(u);
328  v->mr[0] = L4_TASK_CAP_INFO_OP;
329  v->mr[1] = cap & ~1UL;
330  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
331 }
332 
333 L4_INLINE l4_msgtag_t
334 l4_task_cap_has_child_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *u) L4_NOTHROW
335 {
336  l4_msg_regs_t *v = l4_utcb_mr_u(u);
337  v->mr[0] = L4_TASK_CAP_INFO_OP;
338  v->mr[1] = cap | 1UL;
339  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
340 }
341 
342 L4_INLINE l4_msgtag_t
343 l4_task_cap_equal_u(l4_cap_idx_t task, l4_cap_idx_t cap_a,
345 {
346  l4_msg_regs_t *v = l4_utcb_mr_u(u);
347  v->mr[0] = L4_TASK_CAP_INFO_OP;
348  v->mr[1] = cap_a;
349  v->mr[2] = cap_b;
350  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), L4_IPC_NEVER);
351 }
352 
353 L4_INLINE l4_msgtag_t
354 l4_task_add_ku_mem_u(l4_cap_idx_t task, l4_fpage_t ku_mem,
356 {
357  l4_msg_regs_t *v = l4_utcb_mr_u(u);
358  v->mr[0] = L4_TASK_ADD_KU_MEM_OP;
359  v->mr[1] = ku_mem.raw;
360  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
361 }
362 
363 
364 
365 L4_INLINE l4_msgtag_t
367  l4_fpage_t snd_fpage, unsigned long snd_base) L4_NOTHROW
368 {
369  return l4_task_map_u(dst_task, src_task, snd_fpage, snd_base, l4_utcb());
370 }
371 
372 L4_INLINE l4_msgtag_t
374  unsigned long map_mask) L4_NOTHROW
375 {
376  return l4_task_unmap_u(task, fpage, map_mask, l4_utcb());
377 }
378 
379 L4_INLINE l4_msgtag_t
381  unsigned num_fpages, unsigned long map_mask) L4_NOTHROW
382 {
383  return l4_task_unmap_batch_u(task, fpages, num_fpages, map_mask,
384  l4_utcb());
385 }
386 
387 L4_INLINE l4_msgtag_t
388 l4_task_delete_obj_u(l4_cap_idx_t task, l4_cap_idx_t obj,
390 {
391  return l4_task_unmap_u(task, l4_obj_fpage(obj, 0, L4_CAP_FPAGE_RWSD),
392  L4_FP_DELETE_OBJ, u);
393 }
394 
395 L4_INLINE l4_msgtag_t
397 {
398  return l4_task_delete_obj_u(task, obj, l4_utcb());
399 }
400 
401 
402 L4_INLINE l4_msgtag_t
403 l4_task_release_cap_u(l4_cap_idx_t task, l4_cap_idx_t cap,
405 {
406  return l4_task_unmap_u(task, l4_obj_fpage(cap, 0, L4_CAP_FPAGE_RWSD),
407  L4_FP_ALL_SPACES, u);
408 }
409 
410 L4_INLINE l4_msgtag_t
412 {
413  return l4_task_release_cap_u(task, cap, l4_utcb());
414 }
415 
416 L4_INLINE l4_msgtag_t
418 {
419  return l4_task_cap_valid_u(task, cap, l4_utcb());
420 }
421 
422 L4_INLINE l4_msgtag_t
424 {
425  return l4_task_cap_has_child_u(task, cap, l4_utcb());
426 }
427 
428 L4_INLINE l4_msgtag_t
430  l4_cap_idx_t cap_b) L4_NOTHROW
431 {
432  return l4_task_cap_equal_u(task, cap_a, cap_b, l4_utcb());
433 }
434 
435 L4_INLINE l4_msgtag_t
437 {
438  return l4_task_add_ku_mem_u(task, ku_mem, l4_utcb());
439 }
Encapsulation of the message-register block in the UTCB.
Definition: utcb.h:78
l4_msgtag_t l4_task_cap_has_child(l4_cap_idx_t task, l4_cap_idx_t cap) L4_NOTHROW
Test whether a capability has child mappings (in another task).
Definition: task.h:423
Flag that indicates that the unmap operation on a capability shall try to delete the corresponding ob...
Definition: consts.h:173
l4_msgtag_t l4_task_cap_equal(l4_cap_idx_t task, l4_cap_idx_t cap_a, l4_cap_idx_t cap_b) L4_NOTHROW
Test whether two capabilities point to the same object with the same rights.
Definition: task.h:429
l4_msgtag_t l4_task_add_ku_mem(l4_cap_idx_t task, l4_fpage_t ku_mem) L4_NOTHROW
Add kernel-user memory.
Definition: task.h:436
x86: LDT set
Definition: task.h:279
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition: utcb.h:80
Common L4 ABI Data Types.
l4_msgtag_t l4_task_delete_obj(l4_cap_idx_t task, l4_cap_idx_t obj) L4_NOTHROW
Release capability and delete object.
Definition: task.h:396
Read-write-execute flex page.
Definition: __l4_fpage.h:114
l4_msgtag_t l4_ipc_call(l4_cap_idx_t object, l4_utcb_t *utcb, l4_msgtag_t tag, l4_timeout_t timeout) L4_NOTHROW
Object call (usual invocation).
Definition: ipc.h:445
l4_msgtag_t l4_task_unmap(l4_cap_idx_t task, l4_fpage_t fpage, l4_umword_t map_mask) L4_NOTHROW
Revoke rights from the task.
Definition: task.h:373
unsigned long l4_cap_idx_t
L4 Capability selector Type.
Definition: types.h:342
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
L4_task_ops
Operations on task objects.
Definition: task.h:273
#define L4_IPC_NEVER
never timeout
Definition: __timeout.h:80
Map.
Definition: task.h:275
l4_msgtag_t l4_task_unmap_batch(l4_cap_idx_t task, l4_fpage_t const *fpages, unsigned num_fpages, unsigned long map_mask) L4_NOTHROW
Revoke rights from a task.
Definition: task.h:380
Flag to tell the unmap operation to unmap all child mappings including the mapping in the invoked tas...
Definition: consts.h:165
Protocol for messages to a task object.
Definition: types.h:63
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
l4_msgtag_t l4_task_release_cap(l4_cap_idx_t task, l4_cap_idx_t cap) L4_NOTHROW
Release capability.
Definition: task.h:411
l4_umword_t raw
Raw value.
Definition: __l4_fpage.h:83
Unmap.
Definition: task.h:276
l4_umword_t l4_map_obj_control(l4_umword_t spot, unsigned grant) L4_NOTHROW
Create the first word for a map item for the object space.
Definition: __l4_fpage.h:679
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition: utcb.h:340
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items, unsigned flags) L4_NOTHROW
Create a message tag from the specified values.
Definition: types.h:408
l4_msgtag_t l4_task_map(l4_cap_idx_t dst_task, l4_cap_idx_t src_task, l4_fpage_t snd_fpage, l4_addr_t snd_base) L4_NOTHROW
Map resources available in the source task to a destination task.
Definition: task.h:366
L4 flexpage type.
Definition: __l4_fpage.h:81
Add kernel-user memory.
Definition: task.h:278
Cap info.
Definition: task.h:277
l4_msgtag_t l4_task_cap_valid(l4_cap_idx_t task, l4_cap_idx_t cap) L4_NOTHROW
Check whether a capability is present (refers to an object).
Definition: task.h:417
Message tag data structure.
Definition: types.h:159
unsigned long l4_addr_t
Address type.
Definition: l4int.h:45
Full rights for capability flex-pages.
Definition: __l4_fpage.h:196
l4_fpage_t l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW
Create a kernel-object flex page.
Definition: __l4_fpage.h:645
#define L4_DEPRECATED(s)
Mark symbol deprecated.
Definition: compiler.h:239
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185