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 * 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
47
56typedef struct l4_utcb_t l4_utcb_t;
57
58typedef struct l4_exc_regs_t l4_exc_regs_t;
59
65L4_INLINE l4_utcb_t *l4_utcb_direct(void) L4_NOTHROW L4_PURE;
66
75
85
90L4_INLINE unsigned long l4_utcb_exc_typeval(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
91
102
108
120
121#include <l4/sys/arch/utcb.h>
122
127
132typedef union l4_msg_regs_t
133{
134 l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE];
135 l4_uint64_t mr64[L4_UTCB_GENERIC_DATA_SIZE / (sizeof(l4_uint64_t)/sizeof(l4_umword_t))];
137
147typedef struct l4_buf_regs_t
148{
151
153 l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE];
155
190
192
203L4_CV l4_utcb_t *l4_utcb_wrap(void) L4_NOTHROW L4_PURE;
204
210
217
222L4_INLINE l4_msg_regs_t *l4_utcb_mr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
223
231
236L4_INLINE l4_buf_regs_t *l4_utcb_br_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
237
244
249L4_INLINE l4_thread_regs_t *l4_utcb_tcr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
250
256
264
269L4_INLINE l4_exc_regs_t *l4_utcb_exc_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
270
275L4_INLINE void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW;
276
280L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW;
281
293 l4_umword_t flags) L4_NOTHROW;
294
310l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t pint, int br,
311 l4_utcb_t *utcb) L4_NOTHROW;
327
336unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW;
337
338/**************************************************************************
339 * Implementations
340 **************************************************************************/
341
343{ return (l4_msg_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
344
346{ return (l4_buf_regs_t*)((char*)u + L4_UTCB_BUF_REGS_OFFSET); }
347
349{ return (l4_thread_regs_t*)((char*)u + L4_UTCB_THREAD_REGS_OFFSET); }
350
352{ return (l4_exc_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
353
354L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW
355{
356 if (switch_on)
357 l4_utcb_br_u(u)->bdr |= L4_UTCB_INHERIT_FPU;
358 else
359 l4_utcb_br_u(u)->bdr &= ~L4_UTCB_INHERIT_FPU;
360}
361
364{
365 // flags (bits 24..31) are already shifted!
366 return (mem << 0) | (io << 5) | (obj << 10) | flags;
367}
368
370{
371#ifdef L4SYS_USE_UTCB_WRAP
372 return l4_utcb_wrap();
373#else
374 return l4_utcb_direct();
375#endif
376}
377
378
379
380
382{ return l4_utcb_mr_u(l4_utcb()); }
383
385{ return l4_utcb_br_u(l4_utcb()); }
386
388{ return l4_utcb_tcr_u(l4_utcb()); }
389
391{ return l4_utcb_exc_u(l4_utcb()); }
392
394{ l4_utcb_inherit_fpu_u(l4_utcb(), switch_on); }
395
397l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t val, int pos,
398 l4_utcb_t *utcb) L4_NOTHROW
399{
400 union T
401 {
403 l4_umword_t m[sizeof(l4_kernel_clock_t)/sizeof(l4_umword_t)];
404 };
405 l4_timeout_s to;
406 to.t = 0x8000 | pos;
407 ((union T*)(l4_utcb_br_u(utcb)->br + pos))->t = val;
408 return to;
409}
410
413{ return l4_timeout_abs_u(val, pos, l4_utcb()); }
414
416{ return idx / (sizeof(l4_uint64_t) / sizeof(l4_umword_t)); }
417
419
420#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:412
unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW
Get index into 64bit message registers alias from native-sized index.
Definition utcb.h:415
l4_msg_regs_t * l4_utcb_mr(void) L4_NOTHROW L4_PURE
Get the message-register block of a UTCB.
Definition utcb.h:381
l4_thread_regs_t * l4_utcb_tcr(void) L4_NOTHROW L4_PURE
Get the thread-control-register block of a UTCB.
Definition utcb.h:387
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:369
l4_buf_regs_t * l4_utcb_br(void) L4_NOTHROW L4_PURE
Get the buffer-register block of a UTCB.
Definition utcb.h:384
l4_umword_t l4_bdr(l4_umword_t mem, l4_umword_t io, l4_umword_t obj, l4_umword_t flags) L4_NOTHROW
Create a buffer descriptor.
Definition utcb.h:362
void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW
Enable or disable inheritance of FPU state to receiver.
Definition utcb.h:393
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:102
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:107
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:390
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:97
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:82
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:92
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:87
#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:167
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
#define L4_BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:171
#define L4_END_DECLS
End section with C types and functions.
Definition compiler.h:172
Fixed sized integer types, generic version.
Common L4 ABI Data Types.
Encapsulation of the buffer-registers block in the UTCB.
Definition utcb.h:148
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition utcb.h:153
l4_umword_t bdr
Buffer descriptor.
Definition utcb.h:150
UTCB structure for exceptions.
Definition utcb.h:28
Encapsulation of the thread-control-register block of the UTCB.
Definition utcb.h:165
l4_umword_t free_marker
Kernel free marker.
Definition utcb.h:185
l4_umword_t error
System call error code (see l4_ipc_tcr_error_t).
Definition utcb.h:171
l4_umword_t user[3]
User values (ignored and preserved by the kernel).
Definition utcb.h:188
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:133
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition utcb.h:134
l4_uint64_t mr64[L4_UTCB_GENERIC_DATA_SIZE/(sizeof(l4_uint64_t)/sizeof(l4_umword_t))]
Message registers 64bit alias.
Definition utcb.h:135