L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
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 * This file is part of TUD:OS and distributed under the terms of the
14 * GNU General Public License 2.
15 * Please see the COPYING-GPL-2 file for details.
16 *
17 * As a special exception, you may use this file as part of a free software
18 * library without restriction. Specifically, if other files instantiate
19 * templates or use macros or inline functions from this file, or you compile
20 * this file and link it with other files to produce an executable, this
21 * file does not by itself cause the resulting executable to be covered by
22 * the GNU General Public License. This exception does not however
23 * invalidate any other reasons why the executable file might be covered by
24 * the GNU General Public License.
25 */
26/*****************************************************************************/
27#ifndef _L4_SYS_UTCB_H
28#define _L4_SYS_UTCB_H
29
30#include <l4/sys/types.h>
31#include <l4/sys/compiler.h>
32#include <l4/sys/l4int.h>
33
67typedef struct l4_utcb_t l4_utcb_t;
68
78typedef union l4_msg_regs_t
79{
80 l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE];
81 l4_uint64_t mr64[L4_UTCB_GENERIC_DATA_SIZE / (sizeof(l4_uint64_t)/sizeof(l4_umword_t))];
83
93typedef struct l4_buf_regs_t
94{
97
99 l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE];
101
119
121
132L4_CV l4_utcb_t *l4_utcb_wrap(void) L4_NOTHROW L4_PURE;
133
139L4_INLINE l4_utcb_t *l4_utcb_direct(void) L4_NOTHROW L4_PURE;
140
146
153
158L4_INLINE l4_msg_regs_t *l4_utcb_mr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
159
167
172L4_INLINE l4_buf_regs_t *l4_utcb_br_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
173
180
185L4_INLINE l4_thread_regs_t *l4_utcb_tcr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
186
200
205L4_INLINE l4_exc_regs_t *l4_utcb_exc_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
206
215
225
230L4_INLINE unsigned long l4_utcb_exc_typeval(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
231
242
248
249
261
266L4_INLINE void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW;
267
271L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW;
272
288l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t pint, int br,
289 l4_utcb_t *utcb) L4_NOTHROW;
305
314unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW;
315
316/**************************************************************************
317 * Implementations
318 **************************************************************************/
319
321{ return (l4_msg_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
322
324{ return (l4_buf_regs_t*)((char*)u + L4_UTCB_BUF_REGS_OFFSET); }
325
327{ return (l4_thread_regs_t*)((char*)u + L4_UTCB_THREAD_REGS_OFFSET); }
328
330{ return (l4_exc_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
331
332L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW
333{
334 if (switch_on)
335 l4_utcb_br_u(u)->bdr |= L4_UTCB_INHERIT_FPU;
336 else
337 l4_utcb_br_u(u)->bdr &= ~L4_UTCB_INHERIT_FPU;
338}
339
341{
342#ifdef L4SYS_USE_UTCB_WRAP
343 return l4_utcb_wrap();
344#else
345 return l4_utcb_direct();
346#endif
347}
348
349
350
351
353{ return l4_utcb_mr_u(l4_utcb()); }
354
356{ return l4_utcb_br_u(l4_utcb()); }
357
359{ return l4_utcb_tcr_u(l4_utcb()); }
360
362{ return l4_utcb_exc_u(l4_utcb()); }
363
365{ l4_utcb_inherit_fpu_u(l4_utcb(), switch_on); }
366
368l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t val, int pos,
369 l4_utcb_t *utcb) L4_NOTHROW
370{
371 union T
372 {
374 l4_umword_t m[sizeof(l4_kernel_clock_t)/sizeof(l4_umword_t)];
375 };
376 l4_timeout_s to;
377 to.t = 0x8000 | pos;
378 ((union T*)(l4_utcb_br_u(utcb)->br + pos))->t = val;
379 return to;
380}
381
384{ return l4_timeout_abs_u(val, pos, l4_utcb()); }
385
387{ return idx / (sizeof(l4_uint64_t) / sizeof(l4_umword_t)); }
388
390
391#endif /* ! _L4_SYS_UTCB_H */
L4 compiler related defines.
unsigned long l4_umword_t
Unsigned machine word.
Definition l4int.h:51
unsigned long l4_addr_t
Address type.
Definition l4int.h:45
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
Definition l4int.h:64
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42
l4_timeout_s l4_timeout_abs(l4_kernel_clock_t pint, int br) L4_NOTHROW
Set an absolute timeout.
Definition utcb.h:383
unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW
Get index into 64bit message registers alias from native-sized index.
Definition utcb.h:386
l4_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
Definition utcb.h:352
l4_thread_regs_t * l4_utcb_tcr(void) L4_NOTHROW L4_PURE
Get the thread-control-register block of a UTCB.
Definition utcb.h:358
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
l4_buf_regs_t * l4_utcb_br(void) L4_NOTHROW L4_PURE
Get the buffer-register block of a UTCB.
Definition utcb.h:355
void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW
Enable or disable inheritance of FPU state to receiver.
Definition utcb.h:364
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:123
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:128
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:361
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:118
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:103
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:113
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:108
#define __END_DECLS
End section with C types and functions.
Definition compiler.h:199
#define L4_CV
Define calling convention.
Definition linkage.h:44
#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
#define __BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:196
Common L4 ABI Data Types.
Encapsulation of the buffer-registers block in the UTCB.
Definition utcb.h:94
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:99
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:96
UTCB structure for exceptions.
Definition utcb.h:39
Encapsulation of the thread-control-register block of the UTCB.
Definition utcb.h:111
l4_umword_t free_marker
Kernel free marker.
Definition utcb.h:115
l4_umword_t error
System call error codes.
Definition utcb.h:113
l4_umword_t user[3]
User values (ignored and preserved by the kernel)
Definition utcb.h:117
Basic timeout specification.
Definition __timeout.h:48
l4_uint16_t t
timeout value
Definition __timeout.h:49
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
l4_uint64_t mr64[L4_UTCB_GENERIC_DATA_SIZE/(sizeof(l4_uint64_t)/sizeof(l4_umword_t))]
Message registers 64bit alias.
Definition utcb.h:81