L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
utcb.h
Go to the documentation of this file.
1/*****************************************************************************/
7/*
8 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
9 * Alexander Warg <warg@os.inf.tu-dresden.de>,
10 * Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
11 * economic rights: Technische Universität Dresden (Germany)
12 *
13 * License: see LICENSE.spdx (in this directory or the directories above)
14 */
15/*****************************************************************************/
16#ifndef _L4_SYS_UTCB_H
17#define _L4_SYS_UTCB_H
18
19#include <l4/sys/types.h>
20#include <l4/sys/compiler.h>
21#include <l4/sys/l4int.h>
22
56typedef struct l4_utcb_t l4_utcb_t;
57
67typedef union l4_msg_regs_t
68{
69 l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE];
70 l4_uint64_t mr64[L4_UTCB_GENERIC_DATA_SIZE / (sizeof(l4_uint64_t)/sizeof(l4_umword_t))];
72
82typedef struct l4_buf_regs_t
83{
86
88 l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE];
90
125
127
138L4_CV l4_utcb_t *l4_utcb_wrap(void) L4_NOTHROW L4_PURE;
139
145L4_INLINE l4_utcb_t *l4_utcb_direct(void) L4_NOTHROW L4_PURE;
146
152
159
164L4_INLINE l4_msg_regs_t *l4_utcb_mr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
165
173
178L4_INLINE l4_buf_regs_t *l4_utcb_br_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
179
186
191L4_INLINE l4_thread_regs_t *l4_utcb_tcr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
192
206
211L4_INLINE l4_exc_regs_t *l4_utcb_exc_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
212
221
231
236L4_INLINE unsigned long l4_utcb_exc_typeval(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
237
248
254
255
267
272L4_INLINE void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW;
273
277L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW;
278
294l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t pint, int br,
295 l4_utcb_t *utcb) L4_NOTHROW;
311
320unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW;
321
322/**************************************************************************
323 * Implementations
324 **************************************************************************/
325
327{ return (l4_msg_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
328
330{ return (l4_buf_regs_t*)((char*)u + L4_UTCB_BUF_REGS_OFFSET); }
331
333{ return (l4_thread_regs_t*)((char*)u + L4_UTCB_THREAD_REGS_OFFSET); }
334
336{ return (l4_exc_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
337
338L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW
339{
340 if (switch_on)
341 l4_utcb_br_u(u)->bdr |= L4_UTCB_INHERIT_FPU;
342 else
343 l4_utcb_br_u(u)->bdr &= ~L4_UTCB_INHERIT_FPU;
344}
345
347{
348#ifdef L4SYS_USE_UTCB_WRAP
349 return l4_utcb_wrap();
350#else
351 return l4_utcb_direct();
352#endif
353}
354
355
356
357
359{ return l4_utcb_mr_u(l4_utcb()); }
360
362{ return l4_utcb_br_u(l4_utcb()); }
363
365{ return l4_utcb_tcr_u(l4_utcb()); }
366
368{ return l4_utcb_exc_u(l4_utcb()); }
369
371{ l4_utcb_inherit_fpu_u(l4_utcb(), switch_on); }
372
374l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t val, int pos,
375 l4_utcb_t *utcb) L4_NOTHROW
376{
377 union T
378 {
380 l4_umword_t m[sizeof(l4_kernel_clock_t)/sizeof(l4_umword_t)];
381 };
382 l4_timeout_s to;
383 to.t = 0x8000 | pos;
384 ((union T*)(l4_utcb_br_u(utcb)->br + pos))->t = val;
385 return to;
386}
387
390{ return l4_timeout_abs_u(val, pos, l4_utcb()); }
391
393{ return idx / (sizeof(l4_uint64_t) / sizeof(l4_umword_t)); }
394
396
397#endif /* ! _L4_SYS_UTCB_H */
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:40
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
Definition l4int.h:53
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
l4_timeout_s l4_timeout_abs(l4_kernel_clock_t pint, int br) L4_NOTHROW
Set an absolute timeout.
Definition utcb.h:389
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_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
Definition utcb.h:358
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
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition utcb.h:56
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition utcb.h:346
l4_buf_regs_t * l4_utcb_br(void) L4_NOTHROW L4_PURE
Get the buffer-register block of a UTCB.
Definition utcb.h:361
void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW
Enable or disable inheritance of FPU state to receiver.
Definition utcb.h:370
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
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_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
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_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_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
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
#define __END_DECLS
End section with C types and functions.
Definition compiler.h:167
#define L4_CV
Define calling convention.
Definition linkage.h:33
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:159
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
#define __BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:164
Common L4 ABI Data Types.
Encapsulation of the buffer-registers block in the UTCB.
Definition utcb.h:83
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:88
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:85
UTCB structure for exceptions.
Definition utcb.h:28
Encapsulation of the thread-control-register block of the UTCB.
Definition utcb.h:100
l4_umword_t free_marker
Kernel free marker.
Definition utcb.h:120
l4_umword_t error
System call error code (see l4_ipc_tcr_error_t).
Definition utcb.h:106
l4_umword_t user[3]
User values (ignored and preserved by the kernel)
Definition utcb.h:123
Basic timeout specification.
Definition __timeout.h:40
l4_uint16_t t
timeout value
Definition __timeout.h:41
Encapsulation of the message-register block in the UTCB.
Definition utcb.h:68
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:69
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