1/**
2 * \file
3 * \brief Dispatcher architecture-specific code
4 */
5
6/*
7 * Copyright (c) 2015, 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, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef ARCH_AARCH64_BARRELFISH_CURDISPATCHER_H
16#define ARCH_AARCH64_BARRELFISH_CURDISPATCHER_H
17
18#include <barrelfish_kpi/dispatcher_handle.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 Returns pointer to current dispatcher, using thread register
28 */
29static inline dispatcher_handle_t curdispatcher(void) {
30    dispatcher_handle_t ret = 0;
31    /* The CPU driver maintains the user-space pointer to the shared
32     * dispatcher structure in the read-only thread ID register. */
33    __asm("mrs %[ret], tpidrro_el0" : [ret] "=r" (ret));
34    return ret;
35}
36
37#endif // ARCH_AARCH64_BARRELFISH_CURDISPATCHER_H
38