L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
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
22
32
37
38/* Suspend thread for a period of \a us microseconds.
39 * \param us Time in microseconds
40 * WARNING: This function is mostly bogus since the timer resolution of
41 * current L4 implementations is about 1ms! */
42L4_CV void l4_usleep(int us) L4_NOTHROW;
43
49L4_INLINE void l4_sleep_forever(void) L4_NOTHROW __attribute__((noreturn));
50
51L4_INLINE void
57
59static inline void
60l4_touch_ro(const void*addr, unsigned size) L4_NOTHROW
61{
62 const char *bptr, *eptr;
63
64 bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
65 eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
66 for(;bptr<=eptr;bptr+=L4_PAGESIZE){
67 asm volatile("or %0,%%rax \n"
68 :
69 : "m" (*(const unsigned*)bptr)
70 : "rax" );
71 }
72}
73
74
76static inline void
77l4_touch_rw(const void*addr, unsigned size) L4_NOTHROW
78{
79 const char *bptr, *eptr;
80
81 bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
82 eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
83 for(;bptr<=eptr;bptr+=L4_PAGESIZE){
84 asm volatile("orb $0,%0 \n"
85 :
86 : "m" (*(const unsigned*)bptr)
87 );
88 }
89}
90
92
93#endif
94
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
#define L4_PAGESIZE
Minimal page size (in bytes).
Definition consts.h:380
#define L4_PAGEMASK
Mask for the page number.
Definition consts.h:389
#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 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
Common L4 ABI Data Types.
Basic timeout specification.
Definition __timeout.h:47