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 * Frank Mehnert <fm3@os.inf.tu-dresden.de>,
9 * Jork Löser <jork@os.inf.tu-dresden.de>
10 * economic rights: Technische Universität Dresden (Germany)
11 * This file is part of TUD:OS and distributed under the terms of the
12 * GNU Lesser General Public License 2.1.
13 * Please see the COPYING-LGPL-2.1 file for details.
14 */
15#ifndef __UTIL_H
16#define __UTIL_H
17
18#include <l4/sys/types.h>
19#include <l4/sys/compiler.h>
20#include <l4/sys/ipc.h>
21
23
33
38
39/* Suspend thread for a period of \a us microseconds.
40 * \param us Time in microseconds
41 * WARNING: This function is mostly bogus since the timer resolution of
42 * current L4 implementations is about 1ms! */
43L4_CV void l4_usleep(int us) L4_NOTHROW;
44
50L4_INLINE void l4_sleep_forever(void) L4_NOTHROW __attribute__((noreturn));
51
52L4_INLINE void
54{
55 for (;;)
57}
58
60static inline void
61l4_touch_ro(const void*addr, unsigned size) L4_NOTHROW
62{
63 const char *bptr, *eptr;
64
65 bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
66 eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
67 for(;bptr<=eptr;bptr+=L4_PAGESIZE){
68 asm volatile("or %0,%%eax \n"
69 :
70 : "m" (*(const unsigned*)bptr)
71 : "eax" );
72 }
73}
74
75
77static inline void
78l4_touch_rw(const void*addr, unsigned size) L4_NOTHROW
79{
80 const char *bptr, *eptr;
81
82 bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
83 eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
84 for(;bptr<=eptr;bptr+=L4_PAGESIZE){
85 asm volatile("orb $0,%0 \n"
86 :
87 : "m" (*(const unsigned*)bptr)
88 );
89 }
90}
91
93
94#endif
95
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
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