L4Re - L4 Runtime Environment
util.h
Go to the documentation of this file.
1 
5 /*
6  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7  * Alexander Warg <warg@os.inf.tu-dresden.de>,
8  * Frank Mehnert <fm3@os.inf.tu-dresden.de>,
9  * Jork Löser <jork@os.inf.tu-dresden.de>
10  * economic rights: Technische Universität Dresden (Germany)
11  * This file is part of TUD:OS and distributed under the terms of the
12  * GNU Lesser General Public License 2.1.
13  * Please see the COPYING-LGPL-2.1 file for details.
14  */
15 #ifndef __UTIL_H
16 #define __UTIL_H
17 
18 #include <l4/sys/types.h>
19 #include <l4/sys/compiler.h>
20 #include <l4/sys/ipc.h>
21 
23 
31 
35 L4_CV void l4_sleep(int ms) L4_NOTHROW;
36 
37 /* Suspend thread for a period of \a us microseconds.
38  * \param us Time in microseconds
39  * WARNING: This function is mostly bogus since the timer resolution of
40  * current L4 implementations is about 1ms! */
41 L4_CV void l4_usleep(int us) L4_NOTHROW;
42 
48 L4_INLINE void l4_sleep_forever(void) L4_NOTHROW __attribute__((noreturn));
49 
50 L4_INLINE void
52 {
53  for (;;)
55 }
56 
58 static inline void
59 l4_touch_ro(const void*addr, unsigned size) L4_NOTHROW
60 {
61  const char *bptr, *eptr;
62 
63  bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
64  eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
65  for(;bptr<=eptr;bptr+=L4_PAGESIZE){
66  asm volatile("or %0,%%eax \n"
67  :
68  : "m" (*(const unsigned*)bptr)
69  : "eax" );
70  }
71 }
72 
73 
75 static inline void
76 l4_touch_rw(const void*addr, unsigned size) L4_NOTHROW
77 {
78  const char *bptr, *eptr;
79 
80  bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
81  eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
82  for(;bptr<=eptr;bptr+=L4_PAGESIZE){
83  asm volatile("orb $0,%0 \n"
84  :
85  : "m" (*(const unsigned*)bptr)
86  );
87  }
88 }
89 
91 
92 #endif
93 
l4_timeout_s l4util_micros2l4to(unsigned int mus) L4_NOTHROW
Calculate l4 timeouts.
Common L4 ABI Data Types.
#define EXTERN_C_END
End section with C types and functions.
Definition: compiler.h:187
#define L4_PAGEMASK
Mask for the page number.
Definition: consts.h:286
#define L4_IPC_NEVER
never timeout
Definition: __timeout.h:80
void l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
Touch data area to force mapping (read-only)
Definition: util.h:94
L4 compiler related defines.
void l4_usleep(int us) L4_NOTHROW
Suspend thread for a period of us microseconds.
#define L4_PAGESIZE
Minimal page size (in bytes).
Definition: consts.h:277
Basic timeout specification.
Definition: __timeout.h:45
#define EXTERN_C_BEGIN
Start section with C types and functions.
Definition: compiler.h:186
l4_msgtag_t l4_ipc_sleep(l4_timeout_t timeout) L4_NOTHROW
Sleep for an amount of time.
Definition: ipc.h:496
#define L4_CV
Define calling convention.
Definition: linkage.h:44
void l4_sleep(int ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
void l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
Touch data areas to force mapping (read-write)
Definition: util.h:107
unsigned long l4_addr_t
Address type.
Definition: l4int.h:45
void l4_sleep_forever(void) L4_NOTHROW)
Go sleep and never wake up.
Definition: util.h:50
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition: compiler.h:185