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 
198 L4_INLINE l4_msgtag_t
200 
204 L4_INLINE l4_msgtag_t
205 l4_task_cap_valid_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
206 
219 L4_INLINE l4_msgtag_t
221  L4_DEPRECATED("Do not use. Future uncertain.");
222 
226 L4_INLINE l4_msgtag_t
227 l4_task_cap_has_child_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
228 
241 L4_INLINE l4_msgtag_t
243  l4_cap_idx_t cap_b) L4_NOTHROW;
244 
248 L4_INLINE l4_msgtag_t
249 l4_task_add_ku_mem_u(l4_cap_idx_t task, l4_fpage_t ku_mem,
250  l4_utcb_t *u) L4_NOTHROW;
251 
261 L4_INLINE l4_msgtag_t
263 
264 
268 L4_INLINE l4_msgtag_t
269 l4_task_cap_equal_u(l4_cap_idx_t task, l4_cap_idx_t cap_a,
270  l4_cap_idx_t cap_b, l4_utcb_t *utcb) L4_NOTHROW;
271 
277 {
283 };
284 
285 
286 /* IMPLEMENTATION -----------------------------------------------------------*/
287 
288 #include <l4/sys/ipc.h>
289 
290 
291 L4_INLINE l4_msgtag_t
292 l4_task_map_u(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
293  l4_fpage_t snd_fpage, unsigned long snd_base, l4_utcb_t *u) L4_NOTHROW
294 {
295  l4_msg_regs_t *v = l4_utcb_mr_u(u);
296  v->mr[0] = L4_TASK_MAP_OP;
297  v->mr[3] = l4_map_obj_control(0,0);
298  v->mr[4] = l4_obj_fpage(src_task, 0, L4_FPAGE_RWX).raw;
299  v->mr[1] = snd_base;
300  v->mr[2] = snd_fpage.raw;
301  return l4_ipc_call(dst_task, u, l4_msgtag(L4_PROTO_TASK, 3, 1, 0), L4_IPC_NEVER);
302 }
303 
304 L4_INLINE l4_msgtag_t
305 l4_task_unmap_u(l4_cap_idx_t task, l4_fpage_t fpage,
306  unsigned long map_mask, l4_utcb_t *u) L4_NOTHROW
307 {
308  l4_msg_regs_t *v = l4_utcb_mr_u(u);
309  v->mr[0] = L4_TASK_UNMAP_OP;
310  v->mr[1] = map_mask;
311  v->mr[2] = fpage.raw;
312  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), L4_IPC_NEVER);
313 }
314 
315 L4_INLINE l4_msgtag_t
316 l4_task_unmap_batch_u(l4_cap_idx_t task, l4_fpage_t const *fpages,
317  unsigned num_fpages, unsigned long map_mask,
319 {
320  l4_msg_regs_t *v = l4_utcb_mr_u(u);
321  v->mr[0] = L4_TASK_UNMAP_OP;
322  v->mr[1] = map_mask;
323  __builtin_memcpy(&v->mr[2], fpages, num_fpages * sizeof(l4_fpage_t));
324  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2 + num_fpages, 0, 0), L4_IPC_NEVER);
325 }
326 
327 L4_INLINE l4_msgtag_t
328 l4_task_cap_valid_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *u) L4_NOTHROW
329 {
330  l4_msg_regs_t *v = l4_utcb_mr_u(u);
331  v->mr[0] = L4_TASK_CAP_INFO_OP;
332  v->mr[1] = cap & ~1UL;
333  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
334 }
335 
336 L4_INLINE l4_msgtag_t
337 l4_task_cap_has_child_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *u) L4_NOTHROW
338 {
339  l4_msg_regs_t *v = l4_utcb_mr_u(u);
340  v->mr[0] = L4_TASK_CAP_INFO_OP;
341  v->mr[1] = cap | 1UL;
342  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
343 }
344 
345 L4_INLINE l4_msgtag_t
346 l4_task_cap_equal_u(l4_cap_idx_t task, l4_cap_idx_t cap_a,
348 {
349  l4_msg_regs_t *v = l4_utcb_mr_u(u);
350  v->mr[0] = L4_TASK_CAP_INFO_OP;
351  v->mr[1] = cap_a;
352  v->mr[2] = cap_b;
353  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), L4_IPC_NEVER);
354 }
355 
356 L4_INLINE l4_msgtag_t
357 l4_task_add_ku_mem_u(l4_cap_idx_t task, l4_fpage_t ku_mem,
359 {
360  l4_msg_regs_t *v = l4_utcb_mr_u(u);
361  v->mr[0] = L4_TASK_ADD_KU_MEM_OP;
362  v->mr[1] = ku_mem.raw;
363  return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
364 }
365 
366 
367 
368 L4_INLINE l4_msgtag_t
370  l4_fpage_t snd_fpage, unsigned long snd_base) L4_NOTHROW
371 {
372  return l4_task_map_u(dst_task, src_task, snd_fpage, snd_base, l4_utcb());
373 }
374 
375 L4_INLINE l4_msgtag_t
377  unsigned long map_mask) L4_NOTHROW
378 {
379  return l4_task_unmap_u(task, fpage, map_mask, l4_utcb());
380 }
381 
382 L4_INLINE l4_msgtag_t
384  unsigned num_fpages, unsigned long map_mask) L4_NOTHROW
385 {
386  return l4_task_unmap_batch_u(task, fpages, num_fpages, map_mask,
387  l4_utcb());
388 }
389 
390 L4_INLINE l4_msgtag_t
391 l4_task_delete_obj_u(l4_cap_idx_t task, l4_cap_idx_t obj,
393 {
394  return l4_task_unmap_u(task, l4_obj_fpage(obj, 0, L4_CAP_FPAGE_RWSD),
395  L4_FP_DELETE_OBJ, u);
396 }
397 
398 L4_INLINE l4_msgtag_t
400 {
401  return l4_task_delete_obj_u(task, obj, l4_utcb());
402 }
403 
404 
405 L4_INLINE l4_msgtag_t
406 l4_task_release_cap_u(l4_cap_idx_t task, l4_cap_idx_t cap,
408 {
409  return l4_task_unmap_u(task, l4_obj_fpage(cap, 0, L4_CAP_FPAGE_RWSD),
410  L4_FP_ALL_SPACES, u);
411 }
412 
413 L4_INLINE l4_msgtag_t
415 {
416  return l4_task_release_cap_u(task, cap, l4_utcb());
417 }
418 
419 L4_INLINE l4_msgtag_t
421 {
422  return l4_task_cap_valid_u(task, cap, l4_utcb());
423 }
424 
425 L4_INLINE l4_msgtag_t
427 {
428  return l4_task_cap_has_child_u(task, cap, l4_utcb());
429 }
430 
431 L4_INLINE l4_msgtag_t
433  l4_cap_idx_t cap_b) L4_NOTHROW
434 {
435  return l4_task_cap_equal_u(task, cap_a, cap_b, l4_utcb());
436 }
437 
438 L4_INLINE l4_msgtag_t
440 {
441  return l4_task_add_ku_mem_u(task, ku_mem, l4_utcb());
442 }
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:426
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:432
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:439
x86: LDT set
Definition: task.h:282
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:399
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:376
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:276
#define L4_IPC_NEVER
never timeout
Definition: __timeout.h:80
Map.
Definition: task.h:278
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:383
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:414
l4_umword_t raw
Raw value.
Definition: __l4_fpage.h:83
Unmap.
Definition: task.h:279
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:369
L4 flexpage type.
Definition: __l4_fpage.h:81
Add kernel-user memory.
Definition: task.h:281
Cap info.
Definition: task.h:280
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:420
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