Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
/*****************************************************************************/
/*
* (c) 2008-2013 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/l4int.h>
#include <l4/sys/compiler.h>
#include <l4/sys/consts.h>
enum L4_msgtag_protocol
{
L4_PROTO_NONE = 0,
L4_PROTO_ALLOW_SYSCALL = 1,
L4_PROTO_PF_EXCEPTION = 1,
L4_PROTO_IRQ = -1L,
L4_PROTO_PAGE_FAULT = -2L,
// -3L unused
// -4L unused
L4_PROTO_EXCEPTION = -5L,
L4_PROTO_SIGMA0 = -6L,
L4_PROTO_IO_PAGE_FAULT = -8L,
L4_PROTO_THREAD_GROUP = -9L,
L4_PROTO_KOBJECT = -10L,
L4_PROTO_TASK = -11L,
L4_PROTO_THREAD = -12L,
L4_PROTO_LOG = -13L,
L4_PROTO_SCHEDULER = -14L,
L4_PROTO_FACTORY = -15L,
L4_PROTO_VM = -16L,
L4_PROTO_DMA_SPACE = -17L,
L4_PROTO_IRQ_SENDER = -18L,
// -19L unused
L4_PROTO_SEMAPHORE = -20L,
L4_PROTO_META = -21L,
L4_PROTO_IOMMU = -22L,
L4_PROTO_DEBUGGER = -23L,
L4_PROTO_SMCCC = -24L,
L4_PROTO_VCPU_CONTEXT = -25L,
};
enum L4_varg_type
{
L4_VARG_TYPE_NIL = 0x00,
L4_VARG_TYPE_UMWORD = 0x01,
L4_VARG_TYPE_MWORD = 0x81,
L4_VARG_TYPE_STRING = 0x02,
L4_VARG_TYPE_FPAGE = 0x03,
L4_VARG_TYPE_SIGN = 0x80,
};
enum L4_msgtag_flags
{
// flags for received IPC
L4_MSGTAG_ERROR = 0x8000,
// flags for sending IPC
L4_MSGTAG_TRANSFER_FPU = 0x1000,
L4_MSGTAG_SCHEDULE = 0x2000,
L4_MSGTAG_PROPAGATE = 0x4000,
L4_MSGTAG_FLAGS = 0xf000,
};
typedef struct l4_msgtag_t
{
l4_mword_t raw;
#ifdef __cplusplus
long label() const L4_NOTHROW
{
#if defined(__cplusplus) && (__cplusplus >= 202002L)
return raw >> 16;
#else
return raw < 0 ? ~(~raw >> 16) : raw >> 16;
#endif
}
void label(long v) L4_NOTHROW { raw = (raw & 0x0ffff) | ((l4_umword_t)v << 16); }
unsigned words() const L4_NOTHROW { return raw & 0x3f; }
unsigned items() const L4_NOTHROW { return (raw >> 6) & 0x3f; }
unsigned flags() const L4_NOTHROW { return raw & 0xf000; }
bool is_page_fault() const L4_NOTHROW { return label() == L4_PROTO_PAGE_FAULT; }
bool is_exception() const L4_NOTHROW { return label() == L4_PROTO_EXCEPTION; }
bool is_sigma0() const L4_NOTHROW { return label() == L4_PROTO_SIGMA0; }
bool is_io_page_fault() const L4_NOTHROW { return label() == L4_PROTO_IO_PAGE_FAULT; }
bool has_error() const L4_NOTHROW { return raw & L4_MSGTAG_ERROR; }
#endif
} l4_msgtag_t;
L4_INLINE l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items,
unsigned flags) L4_NOTHROW;
L4_INLINE long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW;
L4_INLINE unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW;
L4_INLINE unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW;
L4_INLINE unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW;
L4_INLINE unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW;
L4_INLINE unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW;
L4_INLINE unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW;
L4_INLINE unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW;
L4_INLINE unsigned l4_msgtag_is_io_page_fault(l4_msgtag_t t) L4_NOTHROW;
typedef unsigned long l4_cap_idx_t;
L4_INLINE unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW;
L4_INLINE unsigned l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW;
L4_INLINE unsigned l4_capability_equal(l4_cap_idx_t c1, l4_cap_idx_t c2) L4_NOTHROW;
L4_INLINE l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW;
/* ************************************************************************* */
/* Implementation */
L4_INLINE unsigned
l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
{ return c & L4_INVALID_CAP_BIT; }
L4_INLINE unsigned
l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW
{ return !(c & L4_INVALID_CAP_BIT); }
L4_INLINE unsigned
l4_capability_equal(l4_cap_idx_t c1, l4_cap_idx_t c2) L4_NOTHROW
{ return (c1 >> L4_CAP_SHIFT) == (c2 >> L4_CAP_SHIFT); }
L4_INLINE
l4_msgtag_t l4_msgtag(long label, unsigned words, unsigned items,
unsigned flags) L4_NOTHROW
{
return (l4_msgtag_t){ (l4_mword_t)((l4_umword_t)label << 16)
| (l4_mword_t)(words & 0x3f)
| (l4_mword_t)((items & 0x3f) << 6)
| (l4_mword_t)(flags & 0xf000)};
}
L4_INLINE
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
{
#if defined(__cplusplus) && (__cplusplus >= 202002L)
return t.raw >> 16;
#else
return t.raw < 0 ? ~(~t.raw >> 16) : t.raw >> 16;
#endif
}
L4_INLINE
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
{ return t.raw & 0x3f; }
L4_INLINE
unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
{ return (t.raw >> 6) & 0x3f; }
L4_INLINE
unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW
{ return t.raw & 0xf000; }
L4_INLINE
unsigned l4_msgtag_has_error(l4_msgtag_t t) L4_NOTHROW
{ return t.raw & L4_MSGTAG_ERROR; }
L4_INLINE unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW
{ return l4_msgtag_label(t) == L4_PROTO_PAGE_FAULT; }
L4_INLINE unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
{ return l4_msgtag_label(t) == L4_PROTO_EXCEPTION; }
L4_INLINE unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW
{ return l4_msgtag_label(t) == L4_PROTO_SIGMA0; }
L4_INLINE unsigned l4_msgtag_is_io_page_fault(l4_msgtag_t t) L4_NOTHROW
{ return l4_msgtag_label(t) == L4_PROTO_IO_PAGE_FAULT; }
L4_INLINE l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW
{ return c + L4_CAP_OFFSET; }
#include <l4/sys/__l4_fpage.h>
#include <l4/sys/__timeout.h>
compiler.h
L4 compiler related defines.
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_mword_t
signed long l4_mword_t
Signed machine word.
Definition l4int.h:37
l4_cap_idx_t
unsigned long l4_cap_idx_t
Capability selector type.
Definition types.h:336
l4_is_invalid_cap
unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is the invalid capability.
Definition types.h:389
l4_capability_equal
unsigned l4_capability_equal(l4_cap_idx_t c1, l4_cap_idx_t c2) L4_NOTHROW
Test if the capability indices of two capability selectors are equal.
Definition types.h:397
l4_is_valid_cap
unsigned l4_is_valid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is a valid selector.
Definition types.h:393
L4_CAP_OFFSET
@ L4_CAP_OFFSET
Offset of two consecutive capability selectors.
Definition consts.h:146
L4_CAP_SHIFT
@ L4_CAP_SHIFT
Capability index shift.
Definition consts.h:142
l4_msgtag_is_sigma0
unsigned l4_msgtag_is_sigma0(l4_msgtag_t t) L4_NOTHROW
Test for sigma0 protocol.
Definition types.h:451
l4_msgtag_is_exception
unsigned l4_msgtag_is_exception(l4_msgtag_t t) L4_NOTHROW
Test for exception protocol.
Definition types.h:448
L4_msgtag_flags
L4_msgtag_flags
Flags for message tags.
Definition types.h:87
l4_msgtag_items
unsigned l4_msgtag_items(l4_msgtag_t t) L4_NOTHROW
Get the number of typed items.
Definition types.h:431
l4_msgtag_is_io_page_fault
unsigned l4_msgtag_is_io_page_fault(l4_msgtag_t t) L4_NOTHROW
Test for IO-page-fault protocol.
Definition types.h:454
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_msgtag_words
unsigned l4_msgtag_words(l4_msgtag_t t) L4_NOTHROW
Get the number of untyped words.
Definition types.h:427
L4_msgtag_protocol
L4_msgtag_protocol
Message tag for IPC operations.
Definition types.h:39
l4_msgtag_flags
unsigned l4_msgtag_flags(l4_msgtag_t t) L4_NOTHROW
Get the flags.
Definition types.h:435
l4_msgtag_label
long l4_msgtag_label(l4_msgtag_t t) L4_NOTHROW
Get the protocol of tag.
Definition types.h:417
l4_msgtag_is_page_fault
unsigned l4_msgtag_is_page_fault(l4_msgtag_t t) L4_NOTHROW
Test for page-fault protocol.
Definition types.h:445
L4_MSGTAG_FLAGS
@ L4_MSGTAG_FLAGS
Mask for all flags.
Definition types.h:133
L4_MSGTAG_ERROR
@ L4_MSGTAG_ERROR
Error indicator flag.
Definition types.h:93
L4_MSGTAG_SCHEDULE
@ L4_MSGTAG_SCHEDULE
Enable schedule in IPC flag.
Definition types.h:114
L4_MSGTAG_TRANSFER_FPU
@ L4_MSGTAG_TRANSFER_FPU
Enable FPU transfer flag for IPC.
Definition types.h:105
L4_PROTO_IRQ
@ L4_PROTO_IRQ
IRQ message.
Definition types.h:44
L4_PROTO_FACTORY
@ L4_PROTO_FACTORY
Protocol for messages to a factory object.
Definition types.h:57
L4_PROTO_DMA_SPACE
@ L4_PROTO_DMA_SPACE
Protocol for (creating) kernel DMA space objects.
Definition types.h:59
L4_PROTO_SCHEDULER
@ L4_PROTO_SCHEDULER
Protocol for messages to a scheduler object.
Definition types.h:56
L4_PROTO_EXCEPTION
@ L4_PROTO_EXCEPTION
Exception.
Definition types.h:48
L4_PROTO_IRQ_SENDER
@ L4_PROTO_IRQ_SENDER
Protocol for IRQ senders (IRQ -> IPC).
Definition types.h:60
L4_PROTO_KOBJECT
@ L4_PROTO_KOBJECT
Protocol for messages to a generic kobject.
Definition types.h:52
L4_PROTO_TASK
@ L4_PROTO_TASK
Protocol for messages to a task object.
Definition types.h:53
L4_PROTO_IO_PAGE_FAULT
@ L4_PROTO_IO_PAGE_FAULT
I/O page fault message.
Definition types.h:50
L4_PROTO_NONE
@ L4_PROTO_NONE
Default protocol tag to reply to kernel.
Definition types.h:40
L4_PROTO_VM
@ L4_PROTO_VM
Protocol for messages to a virtual machine object.
Definition types.h:58
L4_PROTO_SIGMA0
@ L4_PROTO_SIGMA0
Sigma0 protocol.
Definition types.h:49
L4_PROTO_THREAD_GROUP
@ L4_PROTO_THREAD_GROUP
Protocol for messages to a thread group obj.
Definition types.h:51
L4_PROTO_THREAD
@ L4_PROTO_THREAD
Protocol for messages to a thread object.
Definition types.h:54
L4_PROTO_PF_EXCEPTION
@ L4_PROTO_PF_EXCEPTION
Make an exception out of a page fault.
Definition types.h:42
L4_PROTO_META
@ L4_PROTO_META
Meta information protocol.
Definition types.h:63
L4_PROTO_PAGE_FAULT
@ L4_PROTO_PAGE_FAULT
Page fault message.
Definition types.h:45
L4_PROTO_IOMMU
@ L4_PROTO_IOMMU
Protocol ID for IO-MMUs.
Definition types.h:64
L4_PROTO_ALLOW_SYSCALL
@ L4_PROTO_ALLOW_SYSCALL
Allow an alien the system call.
Definition types.h:41
L4_PROTO_SEMAPHORE
@ L4_PROTO_SEMAPHORE
Protocol for semaphore objects.
Definition types.h:62
L4_PROTO_LOG
@ L4_PROTO_LOG
Protocol for messages to a log object.
Definition types.h:55
L4_PROTO_DEBUGGER
@ L4_PROTO_DEBUGGER
Protocol ID for the debugger.
Definition types.h:65
L4_PROTO_VCPU_CONTEXT
@ L4_PROTO_VCPU_CONTEXT
Protocol for hardware vCPU contexts.
Definition types.h:67
L4_PROTO_SMCCC
@ L4_PROTO_SMCCC
Protocol ID for ARM SMCCC calls.
Definition types.h:66
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
consts.h
Common constants.
l4int.h
Fixed sized integer types, generic version.
l4_capability_next
l4_cap_idx_t l4_capability_next(l4_cap_idx_t c) L4_NOTHROW
Get the next capability selector after c.
Definition types.h:457
l4_msgtag_t
Message tag data structure.
Definition types.h:154
l4_msgtag_t::label
long label() const L4_NOTHROW
Get the protocol value.
Definition types.h:158
l4_msgtag_t::is_page_fault
bool is_page_fault() const L4_NOTHROW
Test if protocol indicates page-fault protocol.
Definition types.h:180
l4_msgtag_t::is_sigma0
bool is_sigma0() const L4_NOTHROW
Test if protocol indicates sigma0 protocol.
Definition types.h:184
l4_msgtag_t::has_error
bool has_error() const L4_NOTHROW
Test if flags indicate an error.
Definition types.h:191
l4_msgtag_t::label
void label(long v) L4_NOTHROW
Set the protocol value.
Definition types.h:167
l4_msgtag_t::is_exception
bool is_exception() const L4_NOTHROW
Test if protocol indicates exception protocol.
Definition types.h:182
l4_msgtag_t::words
unsigned words() const L4_NOTHROW
Get the number of untyped words.
Definition types.h:169
l4_msgtag_t::is_io_page_fault
bool is_io_page_fault() const L4_NOTHROW
Test if protocol indicates IO-page-fault protocol.
Definition types.h:186
l4_msgtag_t::items
unsigned items() const L4_NOTHROW
Get the number of typed items.
Definition types.h:171
l4_msgtag_t::raw
l4_mword_t raw
raw value
Definition types.h:155
l4_msgtag_t::flags
unsigned flags() const L4_NOTHROW
Get the flags value.
Definition types.h:178