1/* [2009-07-30 ohodson] TODO: implement! */
2
3/**
4 * \file
5 * \brief Miscellaneous architecture-specific functions
6 */
7
8/*
9 * Copyright (c) 2008, 2009, ETH Zurich.
10 * All rights reserved.
11 *
12 * This file is distributed under the terms in the attached LICENSE file.
13 * If you do not find this file, copies can be found by writing to:
14 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
15 */
16
17#ifndef ARCH_MISC_H
18#define ARCH_MISC_H
19
20//
21// Helpers for pasting #defined values into inline assembler.
22//
23#define STR(x) #x
24#define XTR(x) STR(x)
25
26/**
27 * \brief Set thread-local-storage register.
28 */
29static inline void arch_set_thread_register(uintptr_t value)
30{
31    __asm (
32        "mov "XTR(THREAD_REGISTER)", %[value]" :: [value] "r" (value)
33          );
34}
35
36static inline uintptr_t arch_get_thread_register(void)
37{
38    uintptr_t result;
39    __asm (
40        "mov %[result]," XTR(THREAD_REGISTER) :  [result] "=r" (result)
41          );
42    return result;
43}
44
45#endif /* ARCH_MISC_H */
46