00001 #ifndef __L4UTIL__UTIL_H__
00002 #define __L4UTIL__UTIL_H__
00003
00004 #include <l4/sys/types.h>
00005 #include <l4/sys/compiler.h>
00006 #include <l4/sys/ipc.h>
00007
00008 EXTERN_C_BEGIN
00009
00016 L4_CV l4_timeout_s l4util_micros2l4to(unsigned int mus);
00017
00019 L4_CV void l4_sleep(int ms);
00020
00021
00022
00023
00024 L4_CV void l4_usleep(int us);
00025
00027 L4_INLINE void l4_sleep_forever(void) __attribute__((noreturn));
00028
00029 L4_INLINE void
00030 l4_sleep_forever(void)
00031 {
00032 for (;;)
00033 l4_ipc_sleep(L4_IPC_NEVER);
00034 }
00035
00037 static inline void
00038 l4_touch_ro(const void*addr, unsigned size)
00039 {
00040 volatile const char *bptr, *eptr;
00041
00042 bptr = (const char*)(((unsigned)addr) & L4_PAGEMASK);
00043 eptr = (const char*)(((unsigned)addr+size-1) & L4_PAGEMASK);
00044 for(;bptr<=eptr;bptr+=L4_PAGESIZE) {
00045 (void)(*bptr);
00046 }
00047 }
00048
00049
00051 static inline void
00052 l4_touch_rw(const void*addr, unsigned size)
00053 {
00054 volatile char *bptr;
00055 volatile const char *eptr;
00056
00057 bptr = (char*)(((unsigned)addr) & L4_PAGEMASK);
00058 eptr = (const char*)(((unsigned)addr+size-1) & L4_PAGEMASK);
00059 for(;bptr<=eptr;bptr+=L4_PAGESIZE) {
00060 char x = *bptr;
00061 *bptr = x;
00062 }
00063 }
00064
00065 EXTERN_C_END
00066
00067
00068 #endif