L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
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
89l4_task_map(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
90 l4_fpage_t snd_fpage, l4_umword_t snd_base) L4_NOTHROW;
91
96l4_task_map_u(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
97 l4_fpage_t snd_fpage, l4_umword_t snd_base, l4_utcb_t *utcb) L4_NOTHROW;
98
124 l4_umword_t map_mask) L4_NOTHROW;
125
130l4_task_unmap_u(l4_cap_idx_t task, l4_fpage_t fpage,
131 l4_umword_t map_mask, l4_utcb_t *utcb) L4_NOTHROW;
132
154 unsigned num_fpages, l4_umword_t map_mask) L4_NOTHROW;
155
160l4_task_unmap_batch_u(l4_cap_idx_t task, l4_fpage_t const *fpages,
161 unsigned num_fpages, l4_umword_t map_mask,
163
187
192l4_task_delete_obj_u(l4_cap_idx_t task, l4_cap_idx_t obj,
194
213
218l4_task_release_cap_u(l4_cap_idx_t task, l4_cap_idx_t cap,
220
221
241
246l4_task_cap_valid_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
247
263
268l4_task_add_ku_mem_u(l4_cap_idx_t task, l4_fpage_t *ku_mem,
270
299
300
305l4_task_cap_equal_u(l4_cap_idx_t task, l4_cap_idx_t cap_a,
306 l4_cap_idx_t cap_b, l4_utcb_t *utcb) L4_NOTHROW;
307
321
322
323/* IMPLEMENTATION -----------------------------------------------------------*/
324
325#include <l4/sys/ipc.h>
326
327
329l4_task_map_u(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
330 l4_fpage_t snd_fpage, l4_umword_t snd_base, l4_utcb_t *u) L4_NOTHROW
331{
332 l4_msg_regs_t *v = l4_utcb_mr_u(u);
333 v->mr[0] = L4_TASK_MAP_OP;
334 v->mr[3] = l4_map_obj_control(0,0);
335 v->mr[4] = l4_obj_fpage(src_task, 0, L4_CAP_FPAGE_RWS).raw;
336 v->mr[1] = snd_base;
337 v->mr[2] = snd_fpage.raw;
338 return l4_ipc_call(dst_task, u, l4_msgtag(L4_PROTO_TASK, 3, 1, 0), L4_IPC_NEVER);
339}
340
342l4_task_unmap_u(l4_cap_idx_t task, l4_fpage_t fpage,
343 l4_umword_t map_mask, l4_utcb_t *u) L4_NOTHROW
344{
345 l4_msg_regs_t *v = l4_utcb_mr_u(u);
346 v->mr[0] = L4_TASK_UNMAP_OP;
347 v->mr[1] = map_mask;
348 v->mr[2] = fpage.raw;
349 return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), L4_IPC_NEVER);
350}
351
353l4_task_unmap_batch_u(l4_cap_idx_t task, l4_fpage_t const *fpages,
354 unsigned num_fpages, l4_umword_t map_mask,
356{
357 l4_msg_regs_t *v = l4_utcb_mr_u(u);
358 v->mr[0] = L4_TASK_UNMAP_OP;
359 v->mr[1] = map_mask;
360 __builtin_memcpy(&v->mr[2], fpages, num_fpages * sizeof(l4_fpage_t));
361 return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2 + num_fpages, 0, 0), L4_IPC_NEVER);
362}
363
365l4_task_cap_valid_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *u) L4_NOTHROW
366{
367 l4_msg_regs_t *v = l4_utcb_mr_u(u);
368 v->mr[0] = L4_TASK_CAP_INFO_OP;
369 v->mr[1] = cap & ~1UL;
370 return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
371}
372
374l4_task_cap_equal_u(l4_cap_idx_t task, l4_cap_idx_t cap_a,
376{
377 l4_msg_regs_t *v = l4_utcb_mr_u(u);
378 v->mr[0] = L4_TASK_CAP_INFO_OP;
379 v->mr[1] = cap_a;
380 v->mr[2] = cap_b;
381 return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), L4_IPC_NEVER);
382}
383
385l4_task_add_ku_mem_u(l4_cap_idx_t task, l4_fpage_t *ku_mem,
387{
388 l4_msg_regs_t *v = l4_utcb_mr_u(u);
389 l4_msgtag_t ret;
391 v->mr[1] = ku_mem->raw;
392 ret = l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
393 if (!l4_msgtag_has_error(ret))
394 {
395 l4_msg_regs_t *v = l4_utcb_mr_u(u);
396 ku_mem->raw = v->mr[0];
397 }
398 return ret;
399}
400
401
402
405 l4_fpage_t snd_fpage, l4_umword_t snd_base) L4_NOTHROW
406{
407 return l4_task_map_u(dst_task, src_task, snd_fpage, snd_base, l4_utcb());
408}
409
412 l4_umword_t map_mask) L4_NOTHROW
413{
414 return l4_task_unmap_u(task, fpage, map_mask, l4_utcb());
415}
416
419 unsigned num_fpages, l4_umword_t map_mask) L4_NOTHROW
420{
421 return l4_task_unmap_batch_u(task, fpages, num_fpages, map_mask,
422 l4_utcb());
423}
424
426l4_task_delete_obj_u(l4_cap_idx_t task, l4_cap_idx_t obj,
428{
429 return l4_task_unmap_u(task, l4_obj_fpage(obj, 0, L4_CAP_FPAGE_RWSD),
431}
432
435{
436 return l4_task_delete_obj_u(task, obj, l4_utcb());
437}
438
439
441l4_task_release_cap_u(l4_cap_idx_t task, l4_cap_idx_t cap,
443{
444 return l4_task_unmap_u(task, l4_obj_fpage(cap, 0, L4_CAP_FPAGE_RWSD),
446}
447
450{
451 return l4_task_release_cap_u(task, cap, l4_utcb());
452}
453
456{
457 return l4_task_cap_valid_u(task, cap, l4_utcb());
458}
459
463{
464 return l4_task_cap_equal_u(task, cap_a, cap_b, l4_utcb());
465}
466
469{
470 return l4_task_add_ku_mem_u(task, ku_mem, l4_utcb());
471}
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:359
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:680
@ L4_CAP_FPAGE_RWSD
Full rights for capability flex-pages.
Definition __l4_fpage.h:215
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flex-pages.
Definition __l4_fpage.h:209
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:576
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:714
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
Definition types.h:457
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:428
@ L4_PROTO_TASK
Protocol for messages to a task object.
Definition types.h:63
L4_task_ops
Operations on task objects.
Definition task.h:313
@ L4_TASK_LDT_SET_X86_OP
x86: LDT set
Definition task.h:318
@ L4_TASK_MAP_VGICC_ARM_OP
Arm: Map virtual GICC area.
Definition task.h:319
@ L4_TASK_ADD_KU_MEM_OP
Add kernel-user memory.
Definition task.h:317
@ L4_TASK_CAP_INFO_OP
Cap info.
Definition task.h:316
@ L4_TASK_MAP_OP
Map.
Definition task.h:314
@ L4_TASK_UNMAP_OP
Unmap.
Definition task.h:315
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:461
l4_msgtag_t l4_task_unmap_batch(l4_cap_idx_t task, l4_fpage_t const *fpages, unsigned num_fpages, l4_umword_t map_mask) L4_NOTHROW
Revoke rights from a task.
Definition task.h:418
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:468
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:455
l4_msgtag_t l4_task_map(l4_cap_idx_t dst_task, l4_cap_idx_t src_task, l4_fpage_t snd_fpage, l4_umword_t snd_base) L4_NOTHROW
Map resources available in the source task to a destination task.
Definition task.h:404
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:411
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:434
l4_msgtag_t l4_task_release_cap(l4_cap_idx_t task, l4_cap_idx_t cap) L4_NOTHROW
Release object capability.
Definition task.h:449
@ L4_FP_DELETE_OBJ
Flag that indicates that an unmap operation on object capabilities shall try to delete the correspond...
Definition consts.h:209
@ L4_FP_ALL_SPACES
Flag to tell the unmap operation to revoke permissions from all child mappings including the mapping ...
Definition consts.h:198
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:84
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:67
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:340
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:188
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:62
Common L4 ABI Data Types.
Message tag data structure.
Definition types.h:164
L4 flexpage type.
Definition __l4_fpage.h:85
l4_umword_t raw
Raw value.
Definition __l4_fpage.h:87
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:79
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:80