L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 * License: see LICENSE.spdx (in this directory or the directories above)
10 */
11#ifndef __L4UTIL__UTIL_H__
12#define __L4UTIL__UTIL_H__
13
14#include <l4/sys/types.h>
15#include <l4/sys/compiler.h>
16#include <l4/sys/ipc.h>
17
23
35
42
50
57
65L4_INLINE void
66l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW;
67
75L4_INLINE void
76l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW;
77
78
79
80/*
81 * Implementations
82 */
83
84L4_INLINE void
90
91L4_INLINE void
92l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
93{
94 l4_addr_t b, e;
95
96 b = l4_trunc_page((l4_addr_t)addr);
97 e = l4_trunc_page((l4_addr_t)addr + size - 1);
98
99 for (; b <= e; b += L4_PAGESIZE)
100 (void)(*(volatile char *)b);
101}
102
103
104L4_INLINE void
105l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
106{
107 l4_addr_t b, e;
108
109 b = l4_trunc_page((l4_addr_t)addr);
110 e = l4_trunc_page((l4_addr_t)addr + size - 1);
111
112 for (; b <= e; b += L4_PAGESIZE)
113 *(volatile char *)b |= 0;
114}
115
117
118#endif /* __L4UTIL__UTIL_H__ */
L4 compiler related defines.
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
l4_msgtag_t l4_ipc_sleep(l4_timeout_t timeout) L4_NOTHROW
Sleep for an amount of time.
Definition ipc.h:611
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:452
#define L4_PAGESIZE
Minimal page size (in bytes).
Definition consts.h:395
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
#define __END_DECLS
End section with C types and functions.
Definition compiler.h:167
#define L4_CV
Define calling convention.
Definition linkage.h:33
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:159
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
#define __BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:164
#define L4_NORETURN
Noreturn function attribute.
Definition compiler.h:197
void l4_sleep_forever(void) L4_NOTHROW L4_NORETURN
Go sleep and never wake up.
Definition util.h:85
void l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
Touch data areas to force mapping (read-write)
Definition util.h:105
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:92
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:40