L4Re - L4 Runtime Environment
Main Page
Related Pages
Modules
Namespaces
Data Structures
Examples
All
Data Structures
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
util.h
1
5
/*
6
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7
* Alexander Warg <warg@os.inf.tu-dresden.de>,
8
* Torsten Frenzel <frenzel@os.inf.tu-dresden.de>
9
* economic rights: Technische Universität Dresden (Germany)
10
* This file is part of TUD:OS and distributed under the terms of the
11
* GNU Lesser General Public License 2.1.
12
* Please see the COPYING-LGPL-2.1 file for details.
13
*/
14
#ifndef __UTIL_H
15
#define __UTIL_H
16
17
#include <l4/sys/types.h>
18
#include <l4/sys/compiler.h>
19
#include <l4/sys/ipc.h>
20
21
EXTERN_C_BEGIN
22
29
L4_CV
l4_timeout_s
l4util_micros2l4to
(
unsigned
int
mus)
L4_NOTHROW
;
30
32
L4_CV
void
l4_sleep(
int
ms)
L4_NOTHROW
;
33
34
/* Suspend thread for a period of <us> micro seconds.
35
* WARNING: This function is mostly bogus since the timer resolution of
36
* current L4 implementations is about 1ms! */
37
L4_CV
void
l4_usleep(
int
us)
L4_NOTHROW
;
38
44
L4_INLINE
void
l4_sleep_forever
(
void
)
L4_NOTHROW
__attribute__((noreturn));
45
46
L4_INLINE
void
47
l4_sleep_forever
(
void
)
L4_NOTHROW
48
{
49
for
(;;)
50
l4_ipc_sleep
(
L4_IPC_NEVER
);
51
}
52
54
static
inline
void
55
l4_touch_ro(
const
void
*addr,
unsigned
size)
L4_NOTHROW
56
{
57
const
char
*bptr, *eptr;
58
59
bptr = (
const
char
*)(((
l4_addr_t
)addr) &
L4_PAGEMASK
);
60
eptr = (
const
char
*)(((
l4_addr_t
)addr+size-1) &
L4_PAGEMASK
);
61
for
(;bptr<=eptr;bptr+=
L4_PAGESIZE
){
62
asm
volatile
(
"or %0,%%rax \n"
63
:
64
:
"m"
(*(
const
unsigned
*)bptr)
65
:
"rax"
);
66
}
67
}
68
69
71
static
inline
void
72
l4_touch_rw(
const
void
*addr,
unsigned
size)
L4_NOTHROW
73
{
74
const
char
*bptr, *eptr;
75
76
bptr = (
const
char
*)(((
l4_addr_t
)addr) &
L4_PAGEMASK
);
77
eptr = (
const
char
*)(((
l4_addr_t
)addr+size-1) & L4_PAGEMASK);
78
for
(;bptr<=eptr;bptr+=
L4_PAGESIZE
){
79
asm
volatile
(
"or $0,%0 \n"
80
:
81
:
"m"
(*(
const
unsigned
*)bptr)
82
);
83
}
84
}
85
86
EXTERN_C_END
87
88
#endif
89
L4Re - L4 Runtime Environment