1/**
2 * \file
3 * \brief Miscellaneous architecture-specific functions
4 */
5
6/*
7 * Copyright (c) 2008, 2009, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef ARCH_MISC_H
16#define ARCH_MISC_H
17
18#include <x86.h>
19#include <irq.h>
20
21extern volatile union segment_descriptor *curdisp;
22
23/**
24 * \brief Set thread-local-storage register.
25 */
26static inline void arch_set_thread_register(uintptr_t val)
27{
28    curdisp->d.lo_base = val & ((1 << 24) - 1);
29    curdisp->d.hi_base = val >> 24;
30    __asm volatile("mov %[fs], %%fs" :: [fs] "r" (GSEL(DISP_SEL, SEL_UPL)));
31}
32
33#define arch_get_cycle_count() rdtscp()
34
35#endif
36