00001
00002
00003
00004
00005 #ifndef __UTIL_H
00006 #define __UTIL_H
00007
00008 #include <l4/sys/types.h>
00009 #include <l4/sys/compiler.h>
00010
00011 EXTERN_C_BEGIN
00012
00019 L4_CV l4_timeout_s l4util_micros2l4to(unsigned int mus);
00020
00022 L4_CV void l4_sleep(int ms);
00023
00024
00025
00026
00027 L4_CV void l4_usleep(int us);
00028
00030 L4_INLINE void l4_sleep_forever(void) __attribute__((noreturn));
00031
00032 L4_INLINE void
00033 l4_sleep_forever(void)
00034 {
00035 for (;;)
00036 {
00037 __asm__ __volatile("xor %%eax,%%eax \n\t"
00038 "mov %%eax,%%ebp \n\t"
00039 "mov %%eax,%%esi \n\t"
00040 "mov %%eax,%%edi \n\t"
00041 "mov %%eax,%%ecx \n\t"
00042 "dec %%eax \n\t"
00043 "int $0x30 \n\t"
00044 : : : "memory");
00045 }
00046 }
00047
00049 static inline void
00050 l4_touch_ro(const void*addr, unsigned size)
00051 {
00052 const char *bptr, *eptr;
00053
00054 bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
00055 eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
00056 for(;bptr<=eptr;bptr+=L4_PAGESIZE){
00057 asm volatile("or %0,%%eax \n"
00058 :
00059 : "m" (*(const unsigned*)bptr)
00060 : "eax" );
00061 }
00062 }
00063
00064
00066 static inline void
00067 l4_touch_rw(const void*addr, unsigned size)
00068 {
00069 const char *bptr, *eptr;
00070
00071 bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
00072 eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
00073 for(;bptr<=eptr;bptr+=L4_PAGESIZE){
00074 asm volatile("or $0,%0 \n"
00075 :
00076 : "m" (*(const unsigned*)bptr)
00077 );
00078 }
00079 }
00080
00081 EXTERN_C_END
00082
00083 #endif
00084