Loading...
Searching...
No Matches
util.h
/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>,
* Frank Mehnert <fm3@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#ifndef __L4UTIL__UTIL_H__
#define __L4UTIL__UTIL_H__
#include <l4/sys/types.h>
#include <l4/sys/compiler.h>
#include <l4/sys/ipc.h>
L4_BEGIN_DECLS
L4_CV l4_timeout_s l4util_micros2l4to(l4_uint64_t us) L4_NOTHROW;
L4_CV void l4_sleep(l4_uint32_t ms) L4_NOTHROW;
L4_CV void l4_usleep(l4_uint64_t us) L4_NOTHROW;
L4_INLINE void l4_sleep_forever(void) L4_NOTHROW L4_NORETURN;
L4_INLINE void
l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW;
L4_INLINE void
l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW;
/*
* Implementations
*/
L4_INLINE void
l4_sleep_forever(void) L4_NOTHROW
{
for (;;)
l4_ipc_sleep(L4_IPC_NEVER);
}
L4_INLINE void
l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
{
l4_addr_t b, e;
b = l4_trunc_page((l4_addr_t)addr);
e = l4_trunc_page((l4_addr_t)addr + size - 1);
for (; b <= e; b += L4_PAGESIZE)
(void)(*(volatile char *)b);
}
L4_INLINE void
l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
{
l4_addr_t b, e;
b = l4_trunc_page((l4_addr_t)addr);
e = l4_trunc_page((l4_addr_t)addr + size - 1);
for (; b <= e; b += L4_PAGESIZE)
*(volatile char *)b |= 0;
}
L4_END_DECLS
#endif /* __L4UTIL__UTIL_H__ */
compiler.h
L4 compiler related defines.
l4_addr_t
unsigned long l4_addr_t
Address type.
Definition l4int.h:34
l4_uint32_t
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:29
l4_uint64_t
unsigned long long l4_uint64_t
Unsigned 64bit value.
Definition l4int.h:31
l4_ipc_sleep
l4_msgtag_t l4_ipc_sleep(l4_timeout_t timeout) L4_NOTHROW
Sleep for an amount of time.
Definition ipc.h:611
l4_trunc_page
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:448
L4_PAGESIZE
#define L4_PAGESIZE
Minimal page size (in bytes).
Definition consts.h:391
L4_IPC_NEVER
#define L4_IPC_NEVER
never timeout
Definition __timeout.h:76
L4_CV
#define L4_CV
Define calling convention.
Definition linkage.h:33
L4_NOTHROW
#define L4_NOTHROW
Mark a function declaration and definition as never throwing an exception.
Definition compiler.h:161
L4_INLINE
#define L4_INLINE
L4 Inline function attribute.
Definition compiler.h:51
L4_BEGIN_DECLS
#define L4_BEGIN_DECLS
Start section with C types and functions.
Definition compiler.h:165
L4_END_DECLS
#define L4_END_DECLS
End section with C types and functions.
Definition compiler.h:166
L4_NORETURN
#define L4_NORETURN
Noreturn function attribute.
Definition compiler.h:201
l4_sleep_forever
void l4_sleep_forever(void) L4_NOTHROW L4_NORETURN
Go sleep and never wake up.
Definition util.h:85
l4util_micros2l4to
L4_BEGIN_DECLS l4_timeout_s l4util_micros2l4to(l4_uint64_t us) L4_NOTHROW
Calculate l4 timeouts.
l4_touch_rw
void l4_touch_rw(const void *addr, unsigned size) L4_NOTHROW
Touch data areas to force mapping (read-write).
Definition util.h:105
l4_usleep
void l4_usleep(l4_uint64_t us) L4_NOTHROW
Suspend thread for a period of us microseconds.
l4_sleep
void l4_sleep(l4_uint32_t ms) L4_NOTHROW
Suspend thread for a period of ms milliseconds.
l4_touch_ro
void l4_touch_ro(const void *addr, unsigned size) L4_NOTHROW
Touch data area to force mapping (read-only).
Definition util.h:92
ipc.h
Common IPC interface.
types.h
Common L4 ABI Data Types.
l4_timeout_s
Basic timeout specification.
Definition __timeout.h:40