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
53L4_CV void l4_usleep(int us) L4_NOTHROW;
54
61
69L4_INLINE void
70l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW;
71
79L4_INLINE void
80l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW;
81
82
83
84/*
85 * Implementations
86 */
87
88L4_INLINE void
90{
91 for (;;)
93}
94
95L4_INLINE void
96l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
97{
98 l4_addr_t b, e;
99
100 b = l4_trunc_page((l4_addr_t)addr);
101 e = l4_trunc_page((l4_addr_t)addr + size - 1);
102
103 for (; b <= e; b += L4_PAGESIZE)
104 (void)(*(volatile char *)b);
105}
106
107
108L4_INLINE void
109l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
110{
111 l4_addr_t b, e;
112
113 b = l4_trunc_page((l4_addr_t)addr);
114 e = l4_trunc_page((l4_addr_t)addr + size - 1);
115
116 for (; b <= e; b += L4_PAGESIZE)
117 {
118 char x = *(volatile char *)b;
119 *(volatile char *)b = x;
120 }
121}
122
124
125#endif /* __L4UTIL__UTIL_H__ */
void l4_sleep(int ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
l4_timeout_s l4util_micros2l4to(unsigned int mus) L4_NOTHROW
Calculate l4 timeouts.
L4 compiler related defines.
unsigned long l4_addr_t
Address type.
Definition l4int.h:45
l4_msgtag_t l4_ipc_sleep(l4_timeout_t timeout) L4_NOTHROW
Sleep for an amount of time.
Definition ipc.h:601
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:82
#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:208
#define EXTERN_C_END
End section with C types and functions.
Definition compiler.h:193
void l4_sleep_forever(void) L4_NOTHROW)
Go sleep and never wake up.
Definition util.h:52
void l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
Touch data areas to force mapping (read-write)
Definition util.h:109
void l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
Touch data area to force mapping (read-only)
Definition util.h:96
Common L4 ABI Data Types.
Basic timeout specification.
Definition __timeout.h:47