L4Re - L4 Runtime Environment
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 
67 typedef struct l4_utcb_t l4_utcb_t;
68 
78 typedef union l4_msg_regs_t
79 {
83 
93 typedef struct l4_buf_regs_t
94 {
97 
100 } l4_buf_regs_t;
101 
110 typedef struct l4_thread_regs_t
111 {
117  l4_umword_t user[3];
119 
120 __BEGIN_DECLS
121 
132 L4_CV l4_utcb_t *l4_utcb_wrap(void) L4_NOTHROW L4_PURE;
133 
139 L4_INLINE l4_utcb_t *l4_utcb_direct(void) L4_NOTHROW L4_PURE;
140 
145 L4_INLINE l4_utcb_t *l4_utcb(void) L4_NOTHROW L4_PURE;
146 
152 L4_INLINE l4_msg_regs_t *l4_utcb_mr(void) L4_NOTHROW L4_PURE;
153 
158 L4_INLINE l4_msg_regs_t *l4_utcb_mr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
159 
166 L4_INLINE l4_buf_regs_t *l4_utcb_br(void) L4_NOTHROW L4_PURE;
167 
172 L4_INLINE l4_buf_regs_t *l4_utcb_br_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
173 
179 L4_INLINE l4_thread_regs_t *l4_utcb_tcr(void) L4_NOTHROW L4_PURE;
180 
185 L4_INLINE l4_thread_regs_t *l4_utcb_tcr_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
186 
199 L4_INLINE l4_exc_regs_t *l4_utcb_exc(void) L4_NOTHROW L4_PURE;
200 
205 L4_INLINE l4_exc_regs_t *l4_utcb_exc_u(l4_utcb_t *u) L4_NOTHROW L4_PURE;
206 
214 L4_INLINE l4_umword_t l4_utcb_exc_pc(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
215 
225 
230 L4_INLINE unsigned long l4_utcb_exc_typeval(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
231 
241 L4_INLINE int l4_utcb_exc_is_pf(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
242 
247 L4_INLINE l4_addr_t l4_utcb_exc_pfa(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
248 
249 
260 L4_INLINE int l4_utcb_exc_is_ex_regs_exception(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE;
261 
266 L4_INLINE void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW;
267 
271 L4_INLINE void l4_utcb_inherit_fpu_u(l4_utcb_t *u, int switch_on) L4_NOTHROW;
272 
287 L4_INLINE
288 l4_timeout_s l4_timeout_abs_u(l4_kernel_clock_t pint, int br,
289  l4_utcb_t *utcb) L4_NOTHROW;
303 L4_INLINE
305 
313 L4_INLINE
314 unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW;
315 
316 /**************************************************************************
317  * Implementations
318  **************************************************************************/
319 
320 L4_INLINE l4_msg_regs_t *l4_utcb_mr_u(l4_utcb_t *u) L4_NOTHROW
321 { return (l4_msg_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
322 
323 L4_INLINE l4_buf_regs_t *l4_utcb_br_u(l4_utcb_t *u) L4_NOTHROW
324 { return (l4_buf_regs_t*)((char*)u + L4_UTCB_BUF_REGS_OFFSET); }
325 
326 L4_INLINE l4_thread_regs_t *l4_utcb_tcr_u(l4_utcb_t *u) L4_NOTHROW
327 { return (l4_thread_regs_t*)((char*)u + L4_UTCB_THREAD_REGS_OFFSET); }
328 
329 L4_INLINE l4_exc_regs_t *l4_utcb_exc_u(l4_utcb_t *u) L4_NOTHROW
330 { return (l4_exc_regs_t*)((char*)u + L4_UTCB_MSG_REGS_OFFSET); }
331 
332 L4_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 
340 L4_INLINE l4_utcb_t *l4_utcb(void) L4_NOTHROW
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 
352 L4_INLINE l4_msg_regs_t *l4_utcb_mr(void) L4_NOTHROW
353 { return l4_utcb_mr_u(l4_utcb()); }
354 
355 L4_INLINE l4_buf_regs_t *l4_utcb_br(void) L4_NOTHROW
356 { return l4_utcb_br_u(l4_utcb()); }
357 
358 L4_INLINE l4_thread_regs_t *l4_utcb_tcr(void) L4_NOTHROW
359 { return l4_utcb_tcr_u(l4_utcb()); }
360 
361 L4_INLINE l4_exc_regs_t *l4_utcb_exc(void) L4_NOTHROW
362 { return l4_utcb_exc_u(l4_utcb()); }
363 
364 L4_INLINE void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW
365 { l4_utcb_inherit_fpu_u(l4_utcb(), switch_on); }
366 
367 L4_INLINE
368 l4_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 
382 L4_INLINE
384 { return l4_timeout_abs_u(val, pos, l4_utcb()); }
385 
386 L4_INLINE unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW
387 { return idx / (sizeof(l4_uint64_t) / sizeof(l4_umword_t)); }
388 
390 
391 #endif /* ! _L4_SYS_UTCB_H */
Encapsulation of the message-register block in the UTCB.
Definition: utcb.h:78
Total number of message register (MRs) available.
Definition: utcb.h:47
unsigned l4_utcb_mr64_idx(unsigned idx) L4_NOTHROW
Get index into 64bit message registers alias from native-sized index.
Definition: utcb.h:386
int l4_utcb_exc_is_pf(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE
Check whether an exception IPC is a page fault.
Definition: utcb.h:105
int l4_utcb_exc_is_ex_regs_exception(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE
Check whether an exception IPC was triggered via l4_thread_ex_regs().
Definition: utcb.h:115
l4_umword_t mr[L4_UTCB_GENERIC_DATA_SIZE]
Message registers.
Definition: utcb.h:80
Common L4 ABI Data Types.
#define __END_DECLS
End section with C types and functions.
Definition: compiler.h:193
struct l4_utcb_t l4_utcb_t
Opaque type for the UTCB.
Definition: utcb.h:67
BDR flag to accept reception of FPU state.
Definition: utcb.h:62
Encapsulation of the buffer-registers block in the UTCB.
Definition: utcb.h:93
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
Timeout pair.
Definition: __timeout.h:57
unsigned long l4_utcb_exc_typeval(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE
Get the value out of an exception UTCB that describes the type of exception.
Definition: utcb.h:100
Offset of MR[0] relative to the UTCB pointer.
Definition: utcb.h:53
L4 compiler related defines.
l4_buf_regs_t * l4_utcb_br(void) L4_NOTHROW L4_PURE
Get the buffer-register block of a UTCB.
Definition: utcb.h:355
l4_timeout_s l4_timeout_abs(l4_kernel_clock_t pint, int br) L4_NOTHROW
Set an absolute timeout.
Definition: utcb.h:383
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_umword_t bdr
Buffer descriptor.
Definition: utcb.h:96
Total number of buffer registers (BRs) available.
Definition: utcb.h:50
Basic timeout specification.
Definition: __timeout.h:45
struct l4_thread_regs_t l4_thread_regs_t
Encapsulation of the thread-control-register block of the UTCB.
unsigned long l4_umword_t
Unsigned machine word.
Definition: l4int.h:52
l4_addr_t l4_utcb_exc_pfa(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE
Function to get the L4 style page fault address out of an exception.
Definition: utcb.h:110
struct l4_buf_regs_t l4_buf_regs_t
Encapsulation of the buffer-registers block in the UTCB.
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
Definition: l4int.h:65
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
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:95
Offset of BR[0] relative to the UTCB pointer.
Definition: utcb.h:56
#define L4_CV
Define calling convention.
Definition: linkage.h:44
l4_utcb_t * l4_utcb(void) L4_NOTHROW L4_PURE
Get the UTCB address.
Definition: utcb.h:340
Offset of TCR[0] relative to the UTCB pointer.
Definition: utcb.h:59
l4_uint16_t t
timeout value
Definition: __timeout.h:46
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
l4_timeout_t xfer
Message transfer timeout.
Definition: utcb.h:115
union l4_msg_regs_t l4_msg_regs_t
Encapsulation of the message-register block in the UTCB.
UTCB structure for exceptions.
Definition: utcb.h:38
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition: l4int.h:42
l4_umword_t error
System call error codes.
Definition: utcb.h:113
unsigned long l4_addr_t
Address type.
Definition: l4int.h:45
l4_umword_t br[L4_UTCB_GENERIC_BUFFERS_SIZE]
Buffer registers.
Definition: utcb.h:99
l4_umword_t l4_utcb_exc_pc(l4_exc_regs_t const *u) L4_NOTHROW L4_PURE
Access function to get the program counter of the exception state.
Definition: utcb.h:90
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185
void l4_utcb_inherit_fpu(int switch_on) L4_NOTHROW
Enable or disable inheritance of FPU state to receiver.
Definition: utcb.h:364
Encapsulation of the thread-control-register block of the UTCB.
Definition: utcb.h:110