L4Re - L4 Runtime Environment
util.h
1 
4 /*
5  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
6  * Alexander Warg <warg@os.inf.tu-dresden.de>,
7  * Frank Mehnert <fm3@os.inf.tu-dresden.de>
8  * economic rights: Technische Universit├Ąt Dresden (Germany)
9  * This file is part of TUD:OS and distributed under the terms of the
10  * GNU Lesser General Public License 2.1.
11  * Please see the COPYING-LGPL-2.1 file for details.
12  */
13 #ifndef __L4UTIL__UTIL_H__
14 #define __L4UTIL__UTIL_H__
15 
16 #include <l4/sys/types.h>
17 #include <l4/sys/compiler.h>
18 #include <l4/sys/ipc.h>
19 
25 
35 
41 L4_CV void l4_sleep(int ms) L4_NOTHROW;
42 
51 L4_CV void l4_usleep(int us) L4_NOTHROW;
52 
58 L4_INLINE void l4_sleep_forever(void) L4_NOTHROW L4_NORETURN;
59 
67 L4_INLINE void
68 l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW;
69 
77 L4_INLINE void
78 l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW;
79 
80 
81 
82 /*
83  * Implementations
84  */
85 
86 L4_INLINE void
88 {
89  for (;;)
91 }
92 
93 L4_INLINE void
94 l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
95 {
96  l4_addr_t b, e;
97 
98  b = l4_trunc_page((l4_addr_t)addr);
99  e = l4_trunc_page((l4_addr_t)addr + size - 1);
100 
101  for (; b <= e; b += L4_PAGESIZE)
102  (void)(*(volatile char *)b);
103 }
104 
105 
106 L4_INLINE void
107 l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
108 {
109  l4_addr_t b, e;
110 
111  b = l4_trunc_page((l4_addr_t)addr);
112  e = l4_trunc_page((l4_addr_t)addr + size - 1);
113 
114  for (; b <= e; b += L4_PAGESIZE)
115  {
116  char x = *(volatile char *)b;
117  *(volatile char *)b = x;
118  }
119 }
120 
122 
123 #endif /* __L4UTIL__UTIL_H__ */
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
l4_addr_t l4_trunc_page(l4_addr_t address) L4_NOTHROW
Round an address down to the next lower page boundary.
Definition: consts.h:364
#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:307
#define L4_NORETURN
Noreturn function attribute.
Definition: compiler.h:202
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