Loading...
Searching...
No Matches
task.h
Go to the documentation of this file.
/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>,
* Björn Döbel <doebel@os.inf.tu-dresden.de>,
* Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/sys/types.h>
#include <l4/sys/utcb.h>
L4_INLINE 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;
L4_INLINE l4_msgtag_t
l4_task_map_u(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
l4_fpage_t snd_fpage, l4_umword_t snd_base, l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_unmap(l4_cap_idx_t task, l4_fpage_t fpage,
l4_umword_t map_mask) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_unmap_u(l4_cap_idx_t task, l4_fpage_t fpage,
l4_umword_t map_mask, l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE 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;
L4_INLINE l4_msgtag_t
l4_task_unmap_batch_u(l4_cap_idx_t task, l4_fpage_t const *fpages,
unsigned num_fpages, l4_umword_t map_mask,
l4_utcb_t *u) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_delete_obj(l4_cap_idx_t task, l4_cap_idx_t obj) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_delete_obj_u(l4_cap_idx_t task, l4_cap_idx_t obj,
l4_utcb_t *u) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_release_cap(l4_cap_idx_t task, l4_cap_idx_t cap) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_release_cap_u(l4_cap_idx_t task, l4_cap_idx_t cap,
l4_utcb_t *u) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_cap_valid(l4_cap_idx_t task, l4_cap_idx_t cap) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_cap_valid_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE 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;
L4_INLINE l4_msgtag_t
l4_task_add_ku_mem_u(l4_cap_idx_t task, l4_fpage_t *ku_mem,
l4_utcb_t *u) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_add_ku_mem(l4_cap_idx_t task, l4_fpage_t *ku_mem) L4_NOTHROW;
L4_INLINE l4_msgtag_t
l4_task_cap_equal_u(l4_cap_idx_t task, l4_cap_idx_t cap_a,
l4_cap_idx_t cap_b, l4_utcb_t *utcb) L4_NOTHROW;
enum L4_task_ops
{
L4_TASK_MAP_OP = 0UL,
L4_TASK_UNMAP_OP = 1UL,
L4_TASK_CAP_INFO_OP = 2UL,
L4_TASK_ADD_KU_MEM_OP = 3UL,
L4_TASK_LDT_SET_X86_OP = 0x11UL,
L4_TASK_MAP_VGICC_ARM_OP = 0x12UL,
};
/* IMPLEMENTATION -----------------------------------------------------------*/
#include <l4/sys/ipc.h>
L4_INLINE l4_msgtag_t
l4_task_map_u(l4_cap_idx_t dst_task, l4_cap_idx_t src_task,
l4_fpage_t snd_fpage, l4_umword_t snd_base, l4_utcb_t *u) L4_NOTHROW
{
l4_msg_regs_t *v = l4_utcb_mr_u(u);
v->mr[0] = L4_TASK_MAP_OP;
v->mr[3] = l4_map_obj_control(0,0);
v->mr[4] = l4_obj_fpage(src_task, 0, L4_CAP_FPAGE_RWS).raw;
v->mr[1] = snd_base;
v->mr[2] = snd_fpage.raw;
return l4_ipc_call(dst_task, u, l4_msgtag(L4_PROTO_TASK, 3, 1, 0), L4_IPC_NEVER);
}
L4_INLINE l4_msgtag_t
l4_task_unmap_u(l4_cap_idx_t task, l4_fpage_t fpage,
l4_umword_t map_mask, l4_utcb_t *u) L4_NOTHROW
{
l4_msg_regs_t *v = l4_utcb_mr_u(u);
v->mr[0] = L4_TASK_UNMAP_OP;
v->mr[1] = map_mask;
v->mr[2] = fpage.raw;
return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), L4_IPC_NEVER);
}
L4_INLINE l4_msgtag_t
l4_task_unmap_batch_u(l4_cap_idx_t task, l4_fpage_t const *fpages,
unsigned num_fpages, l4_umword_t map_mask,
l4_utcb_t *u) L4_NOTHROW
{
l4_msg_regs_t *v = l4_utcb_mr_u(u);
v->mr[0] = L4_TASK_UNMAP_OP;
v->mr[1] = map_mask;
__builtin_memcpy(&v->mr[2], fpages, num_fpages * sizeof(l4_fpage_t));
return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2 + num_fpages, 0, 0), L4_IPC_NEVER);
}
L4_INLINE l4_msgtag_t
l4_task_cap_valid_u(l4_cap_idx_t task, l4_cap_idx_t cap, l4_utcb_t *u) L4_NOTHROW
{
l4_msg_regs_t *v = l4_utcb_mr_u(u);
v->mr[0] = L4_TASK_CAP_INFO_OP;
v->mr[1] = cap & ~1UL;
return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
}
L4_INLINE l4_msgtag_t
l4_task_cap_equal_u(l4_cap_idx_t task, l4_cap_idx_t cap_a,
l4_cap_idx_t cap_b, l4_utcb_t *u) L4_NOTHROW
{
l4_msg_regs_t *v = l4_utcb_mr_u(u);
v->mr[0] = L4_TASK_CAP_INFO_OP;
v->mr[1] = cap_a;
v->mr[2] = cap_b;
return l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 3, 0, 0), L4_IPC_NEVER);
}
L4_INLINE l4_msgtag_t
l4_task_add_ku_mem_u(l4_cap_idx_t task, l4_fpage_t *ku_mem,
l4_utcb_t *u) L4_NOTHROW
{
l4_msg_regs_t *v = l4_utcb_mr_u(u);
l4_msgtag_t ret;
v->mr[0] = L4_TASK_ADD_KU_MEM_OP;
v->mr[1] = ku_mem->raw;
ret = l4_ipc_call(task, u, l4_msgtag(L4_PROTO_TASK, 2, 0, 0), L4_IPC_NEVER);
if (!l4_msgtag_has_error(ret))
{
l4_msg_regs_t *v = l4_utcb_mr_u(u);
ku_mem->raw = v->mr[0];
}
return ret;
}
L4_INLINE 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
{
return l4_task_map_u(dst_task, src_task, snd_fpage, snd_base, l4_utcb());
}
L4_INLINE l4_msgtag_t
l4_task_unmap(l4_cap_idx_t task, l4_fpage_t fpage,
l4_umword_t map_mask) L4_NOTHROW
{
return l4_task_unmap_u(task, fpage, map_mask, l4_utcb());
}
L4_INLINE 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
{
return l4_task_unmap_batch_u(task, fpages, num_fpages, map_mask,
l4_utcb());
}
L4_INLINE l4_msgtag_t
l4_task_delete_obj_u(l4_cap_idx_t task, l4_cap_idx_t obj,
l4_utcb_t *u) L4_NOTHROW
{
return l4_task_unmap_u(task, l4_obj_fpage(obj, 0, L4_CAP_FPAGE_RWSD),
L4_FP_DELETE_OBJ, u);
}
L4_INLINE l4_msgtag_t
l4_task_delete_obj(l4_cap_idx_t task, l4_cap_idx_t obj) L4_NOTHROW
{
return l4_task_delete_obj_u(task, obj, l4_utcb());
}
L4_INLINE l4_msgtag_t
l4_task_release_cap_u(l4_cap_idx_t task, l4_cap_idx_t cap,
l4_utcb_t *u) L4_NOTHROW
{
return l4_task_unmap_u(task, l4_obj_fpage(cap, 0, L4_CAP_FPAGE_RWSD),
L4_FP_ALL_SPACES, u);
}
L4_INLINE l4_msgtag_t
l4_task_release_cap(l4_cap_idx_t task, l4_cap_idx_t cap) L4_NOTHROW
{
return l4_task_release_cap_u(task, cap, l4_utcb());
}
L4_INLINE l4_msgtag_t
l4_task_cap_valid(l4_cap_idx_t task, l4_cap_idx_t cap) L4_NOTHROW
{
return l4_task_cap_valid_u(task, cap, l4_utcb());
}
L4_INLINE 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
{
return l4_task_cap_equal_u(task, cap_a, cap_b, l4_utcb());
}
L4_INLINE l4_msgtag_t
l4_task_add_ku_mem(l4_cap_idx_t task, l4_fpage_t *ku_mem) L4_NOTHROW
{
return l4_task_add_ku_mem_u(task, ku_mem, l4_utcb());
}
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_cap_idx_t
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
l4_obj_fpage
l4_fpage_t l4_obj_fpage(l4_cap_idx_t obj, unsigned int order, unsigned char rights) L4_NOTHROW
Create a kernel-object flexpage.
Definition __l4_fpage.h:715
L4_CAP_FPAGE_RWSD
@ L4_CAP_FPAGE_RWSD
Full rights for capability flexpages.
Definition __l4_fpage.h:212
L4_CAP_FPAGE_RWS
@ L4_CAP_FPAGE_RWS
Read, interface specific 'W', and 'S' rights for capability flexpages.
Definition __l4_fpage.h:206
l4_ipc_call
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:565
l4_map_obj_control
l4_umword_t l4_map_obj_control(l4_umword_t spot, unsigned grant) L4_NOTHROW
Create the first word for a map item that is a send item for the object space.
Definition __l4_fpage.h:749
l4_msgtag_has_error
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
Test for error indicator flag.
Definition types.h:440
l4_msgtag
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:405
L4_PROTO_TASK
@ L4_PROTO_TASK
Protocol for messages to a task object.
Definition types.h:53
L4_task_ops
L4_task_ops
Operations on task objects.
Definition task.h:342
L4_TASK_LDT_SET_X86_OP
@ L4_TASK_LDT_SET_X86_OP
x86: LDT set
Definition task.h:347
L4_TASK_MAP_VGICC_ARM_OP
@ L4_TASK_MAP_VGICC_ARM_OP
Arm: Map virtual GICC area.
Definition task.h:348
L4_TASK_ADD_KU_MEM_OP
@ L4_TASK_ADD_KU_MEM_OP
Add kernel-user memory.
Definition task.h:346
L4_TASK_CAP_INFO_OP
@ L4_TASK_CAP_INFO_OP
Cap info.
Definition task.h:345
L4_TASK_MAP_OP
@ L4_TASK_MAP_OP
Map.
Definition task.h:343
L4_TASK_UNMAP_OP
@ L4_TASK_UNMAP_OP
Unmap.
Definition task.h:344
l4_task_cap_equal
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 permissions (only considering se...
Definition task.h:490
l4_task_unmap_batch
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:447
l4_task_add_ku_mem
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:497
l4_task_cap_valid
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:484
l4_task_map
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:433
l4_task_unmap
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:440
l4_task_delete_obj
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:463
l4_task_release_cap
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:478
L4_FP_DELETE_OBJ
@ L4_FP_DELETE_OBJ
Flag that indicates that an unmap operation on object capabilities shall try to delete the correspond...
Definition consts.h:197
L4_FP_ALL_SPACES
@ L4_FP_ALL_SPACES
Flag to tell the unmap operation to revoke permissions from all child mappings including the mapping ...
Definition consts.h:183
L4_IPC_NEVER
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
l4_utcb_t
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
L4_NOTHROW
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:161
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
ipc.h
Common IPC interface.
types.h
Common L4 ABI Data Types.
utcb.h
UTCB definitions.
l4_msgtag_t
Message tag data structure.
Definition types.h:154
l4_fpage_t
L4 flexpage type.
Definition __l4_fpage.h:76
l4_fpage_t::raw
l4_umword_t raw
Raw value.
Definition __l4_fpage.h:78
l4_msg_regs_t
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:68
l4_msg_regs_t::mr
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:69