Loading...
Searching...
No Matches
utcb.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>,
* 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)
*/
/*****************************************************************************/
#ifndef _L4_SYS_UTCB_H
#define _L4_SYS_UTCB_H
#include <l4/sys/types.h>
#include <l4/sys/compiler.h>
#include <l4/sys/l4int.h>
typedef struct l4_utcb_t l4_utcb_t;
typedef union l4_msg_regs_t
{
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE];
l4_uint64_t mr64[L4_UTCB_GENERIC_DATA_SIZE / (sizeof(l4_uint64_t)/sizeof(l4_umword_t))];
} l4_msg_regs_t;
typedef struct l4_buf_regs_t
{
l4_umword_t bdr;
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE];
} l4_buf_regs_t;
typedef struct l4_thread_regs_t
{
l4_umword_t error;
l4_umword_t free_marker;
l4_umword_t user[3];
} l4_thread_regs_t;
L4_BEGIN_DECLS
L4_CV l4_utcb_t *l4_utcb_wrap(void) L4_NOTHROW L4_PURE;
L4_INLINE l4_utcb_t *l4_utcb_direct(void) L4_NOTHROW L4_PURE;
L4_INLINE l4_utcb_t *l4_utcb(void) L4_NOTHROW L4_PURE;
L4_INLINE l4_msg_regs_t *l4_utcb_mr(void) L4_NOTHROW L4_PURE;
L4_INLINE l4_msg_regs_t *l4_utcb_mr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
L4_INLINE l4_buf_regs_t *l4_utcb_br(void) L4_NOTHROW L4_PURE;
L4_INLINE l4_buf_regs_t *l4_utcb_br_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
L4_INLINE l4_thread_regs_t *l4_utcb_tcr(void) L4_NOTHROW L4_PURE;
L4_INLINE l4_thread_regs_t *l4_utcb_tcr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
L4_INLINE l4_exc_regs_t *l4_utcb_exc(void) L4_NOTHROW L4_PURE;
L4_INLINE l4_exc_regs_t *l4_utcb_exc_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
L4_INLINE l4_umword_t l4_utcb_exc_pc(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
L4_INLINE void l4_utcb_exc_pc_set(l4_exc_regs_t *u, l4_addr_t pc) L4_NOTHROW;
L4_INLINE unsigned long l4_utcb_exc_typeval(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
L4_INLINE int l4_utcb_exc_is_pf(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
L4_INLINE l4_addr_t l4_utcb_exc_pfa(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
L4_INLINE int l4_utcb_exc_is_ex_regs_exception(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
L4_INLINE void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW;
L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW;
L4_INLINE
l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t pint, int br,
l4_utcb_t *utcb) L4_NOTHROW;
L4_INLINE
l4_timeout_s l4_timeout_abs(l4_kernel_clock_t pint, int br) L4_NOTHROW;
L4_INLINE
unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW;
/**************************************************************************
* Implementations
**************************************************************************/
L4_INLINE l4_msg_regs_t *l4_utcb_mr_u(l4_utcb_t *u) L4_NOTHROW
{ return (l4_msg_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
L4_INLINE l4_buf_regs_t *l4_utcb_br_u(l4_utcb_t *u) L4_NOTHROW
{ return (l4_buf_regs_t*)((char*)u + L4_UTCB_BUF_REGS_OFFSET); }
L4_INLINE l4_thread_regs_t *l4_utcb_tcr_u(l4_utcb_t *u) L4_NOTHROW
{ return (l4_thread_regs_t*)((char*)u + L4_UTCB_THREAD_REGS_OFFSET); }
L4_INLINE l4_exc_regs_t *l4_utcb_exc_u(l4_utcb_t *u) L4_NOTHROW
{ return (l4_exc_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW
{
if (switch_on)
l4_utcb_br_u(u)->bdr |= L4_UTCB_INHERIT_FPU;
else
l4_utcb_br_u(u)->bdr &= ~L4_UTCB_INHERIT_FPU;
}
L4_INLINE l4_utcb_t *l4_utcb(void) L4_NOTHROW
{
#ifdef L4SYS_USE_UTCB_WRAP
return l4_utcb_wrap();
#else
return l4_utcb_direct();
#endif
}
L4_INLINE l4_msg_regs_t *l4_utcb_mr(void) L4_NOTHROW
{ return l4_utcb_mr_u(l4_utcb()); }
L4_INLINE l4_buf_regs_t *l4_utcb_br(void) L4_NOTHROW
{ return l4_utcb_br_u(l4_utcb()); }
L4_INLINE l4_thread_regs_t *l4_utcb_tcr(void) L4_NOTHROW
{ return l4_utcb_tcr_u(l4_utcb()); }
L4_INLINE l4_exc_regs_t *l4_utcb_exc(void) L4_NOTHROW
{ return l4_utcb_exc_u(l4_utcb()); }
L4_INLINE void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW
{ l4_utcb_inherit_fpu_u(l4_utcb(), switch_on); }
L4_INLINE
l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t val, int pos,
l4_utcb_t *utcb) L4_NOTHROW
{
union T
{
l4_kernel_clock_t t;
l4_umword_t m[sizeof(l4_kernel_clock_t)/sizeof(l4_umword_t)];
};
l4_timeout_s to;
to.t = 0x8000 | pos;
((union T*)(l4_utcb_br_u(utcb)->br + pos))->t = val;
return to;
}
L4_INLINE
l4_timeout_s l4_timeout_abs(l4_kernel_clock_t val, int pos) L4_NOTHROW
{ return l4_timeout_abs_u(val, pos, l4_utcb()); }
L4_INLINE unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW
{ return idx / (sizeof(l4_uint64_t) / sizeof(l4_umword_t)); }
L4_END_DECLS
#endif /* ! _L4_SYS_UTCB_H */
compiler.h
L4 compiler related defines.
l4_umword_t
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
l4_addr_t
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
l4_kernel_clock_t
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
Definition l4int.h:53
l4_uint64_t
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
l4_timeout_abs
l4_timeout_s l4_timeout_abs(l4_kernel_clock_t pint, int br) L4_NOTHROW
Set an absolute timeout.
Definition utcb.h:389
l4_utcb_mr64_idx
unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW
Get index into 64bit message registers alias from native-sized index.
Definition utcb.h:392
l4_utcb_mr
l4_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
Definition utcb.h:358
l4_utcb_tcr
l4_thread_regs_t * l4_utcb_tcr(void) L4_NOTHROW L4_PURE
Get the thread-control-register block of a UTCB.
Definition utcb.h:364
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_utcb_br
l4_buf_regs_t * l4_utcb_br(void) L4_NOTHROW L4_PURE
Get the buffer-register block of a UTCB.
Definition utcb.h:361
l4_utcb_inherit_fpu
void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW
Enable or disable inheritance of FPU state to receiver.
Definition utcb.h:370
l4_utcb_exc_pfa
l4_addr_t l4_utcb_exc_pfa(l4_exc_regs_t const *u) L4_NOTHROW
Function to get the L4 style page fault address out of an exception.
Definition utcb.h:112
l4_utcb_exc_is_ex_regs_exception
int l4_utcb_exc_is_ex_regs_exception(l4_exc_regs_t const *u) L4_NOTHROW
Check whether an exception IPC was triggered via l4_thread_ex_regs().
Definition utcb.h:117
l4_utcb_exc
l4_exc_regs_t * l4_utcb_exc(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB (for an exception IPC).
Definition utcb.h:367
l4_utcb_exc_is_pf
int l4_utcb_exc_is_pf(l4_exc_regs_t const *u) L4_NOTHROW
Check whether an exception IPC is a page fault.
Definition utcb.h:107
l4_utcb_exc_pc
l4_umword_t l4_utcb_exc_pc(l4_exc_regs_t const *u) L4_NOTHROW
Access function to get the program counter of the exception state.
Definition utcb.h:92
l4_utcb_exc_typeval
l4_umword_t l4_utcb_exc_typeval(l4_exc_regs_t const *u) L4_NOTHROW
Get the value out of an exception UTCB that describes the type of exception.
Definition utcb.h:102
l4_utcb_exc_pc_set
void l4_utcb_exc_pc_set(l4_exc_regs_t *u, l4_addr_t pc) L4_NOTHROW
Set the program counter register in the exception state.
Definition utcb.h:97
L4_CV
#define L4_CV
Define calling convention.
Definition linkage.h:33
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
L4_BEGIN_DECLS
#define L4_BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:165
L4_END_DECLS
#define L4_END_DECLS
End section with C types and functions.
Definition compiler.h:166
l4int.h
Fixed sized integer types, generic version.
types.h
Common L4 ABI Data Types.
l4_buf_regs_t
Encapsulation of the buffer-registers block in the UTCB.
Definition utcb.h:83
l4_buf_regs_t::br
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:88
l4_buf_regs_t::bdr
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:85
l4_exc_regs_t
UTCB structure for exceptions.
Definition utcb.h:28
l4_thread_regs_t
Encapsulation of the thread-control-register block of the UTCB.
Definition utcb.h:100
l4_thread_regs_t::free_marker
l4_umword_t free_marker
Kernel free marker.
Definition utcb.h:120
l4_thread_regs_t::error
l4_umword_t error
System call error code (see l4_ipc_tcr_error_t).
Definition utcb.h:106
l4_thread_regs_t::user
l4_umword_t user[3]
User values (ignored and preserved by the kernel).
Definition utcb.h:123
l4_timeout_s
Basic timeout specification.
Definition __timeout.h:40
l4_timeout_s::t
l4_uint16_t t
timeout value
Definition __timeout.h:41
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
l4_msg_regs_t::mr64
l4_uint64_t mr64[L4_UTCB_GENERIC_DATA_SIZE/(sizeof(l4_uint64_t)/sizeof(l4_umword_t))]
Message registers 64bit alias.
Definition utcb.h:70