3 * \brief Utilities, amd64 version
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.
17 #include <l4/sys/types.h>
18 #include <l4/sys/compiler.h>
19 #include <l4/sys/ipc.h>
23 /** Calculate l4 timeouts
24 * \param mus time in microseconds. Special cases:
26 * - ~0U -> timeout NEVER
27 * \return the corresponding l4_timeout value
29 L4_CV l4_timeout_s l4util_micros2l4to(unsigned int mus) L4_NOTHROW;
31 /** Suspend thread for a period of <ms> milliseconds */
32 L4_CV void l4_sleep(int ms) L4_NOTHROW;
34 /* Suspend thread for a period of <us> micro seconds.
35 * WARNING: This function is mostly bogus since the timer resolution of
36 * current L4 implementations is about 1ms! */
37 L4_CV void l4_usleep(int us) L4_NOTHROW;
40 * \brief Go sleep and never wake up.
44 L4_INLINE void l4_sleep_forever(void) L4_NOTHROW __attribute__((noreturn));
47 l4_sleep_forever(void) L4_NOTHROW
50 l4_ipc_sleep(L4_IPC_NEVER);
53 /** Touch data areas to force mapping read-only */
55 l4_touch_ro(const void*addr, unsigned size) L4_NOTHROW
57 const char *bptr, *eptr;
59 bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
60 eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
61 for(;bptr<=eptr;bptr+=L4_PAGESIZE){
62 asm volatile("or %0,%%rax \n"
64 : "m" (*(const unsigned*)bptr)
70 /** Touch data areas to force mapping read-write */
72 l4_touch_rw(const void*addr, unsigned size) L4_NOTHROW
74 const char *bptr, *eptr;
76 bptr = (const char*)(((l4_addr_t)addr) & L4_PAGEMASK);
77 eptr = (const char*)(((l4_addr_t)addr+size-1) & L4_PAGEMASK);
78 for(;bptr<=eptr;bptr+=L4_PAGESIZE){
79 asm volatile("or $0,%0 \n"
81 : "m" (*(const unsigned*)bptr)