L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
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
37
44
52
59
67L4_INLINE void
68l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW;
69
77L4_INLINE void
78l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW;
79
80
81
82/*
83 * Implementations
84 */
85
86L4_INLINE void
92
93L4_INLINE void
94l4_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
106L4_INLINE void
107l4_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 *(volatile char *)b |= 0;
116}
117
119
120#endif /* __L4UTIL__UTIL_H__ */
L4 compiler related defines.
unsigned long l4_addr_t
Address type.
Definition l4int.h:45
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:40
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:42
l4_msgtag_t l4_ipc_sleep(l4_timeout_t timeout) L4_NOTHROW
Sleep for an amount of time.
Definition ipc.h:622
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:437
#define L4_PAGESIZE
Minimal page size (in bytes).
Definition consts.h:380
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:84
#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 EXTERN_C_BEGIN
Start section with C types and functions.
Definition compiler.h:192
#define L4_NORETURN
Noreturn function attribute.
Definition compiler.h:218
#define EXTERN_C_END
End section with C types and functions.
Definition compiler.h:193
void l4_sleep_forever(void) L4_NOTHROW L4_NORETURN
Go sleep and never wake up.
Definition util.h:87
void l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
Touch data areas to force mapping (read-write)
Definition util.h:107
void l4_usleep(l4_uint64_t us) L4_NOTHROW
Suspend thread for a period of us microseconds.
void l4_sleep(l4_uint32_t ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
void l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
Touch data area to force mapping (read-only)
Definition util.h:94
l4_timeout_s l4util_micros2l4to(l4_uint64_t us) L4_NOTHROW
Calculate l4 timeouts.
Common L4 ABI Data Types.
Basic timeout specification.
Definition __timeout.h:48