1/**
2 * \file
3 * \brief Architecture specific dispatcher struct shared between kernel and user
4 */
5
6/*
7 * Copyright (c) 2010, 2011, 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, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef ARCH_X86_64_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
16#define ARCH_X86_64_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
17
18#include <target/x86_64/barrelfish_kpi/dispatcher_shared_target.h>
19
20/**
21 * \brief Returns whether dispatcher is currently disabled, given IP.
22 *
23 * \param disp  Pointer to dispatcher
24 * \param ip    User-level instruction pointer.
25 *
26 * \return true if dispatcher disabled, false otherwise.
27 */
28static inline bool dispatcher_is_disabled_ip(dispatcher_handle_t handle,
29                                             uintptr_t rip)
30{
31    /* one crit_pc pair */
32    struct dispatcher_shared_generic *disp =
33        get_dispatcher_shared_generic(handle);
34    struct dispatcher_shared_x86_64 *disp64 =
35        get_dispatcher_shared_x86_64(handle);
36    return disp->disabled ||
37        (disp64->crit_pc_low <= rip && rip < disp64->crit_pc_high);
38}
39
40static inline arch_registers_state_t*
41dispatcher_get_enabled_save_area(dispatcher_handle_t handle)
42{
43    return dispatcher_x86_64_get_enabled_save_area(handle);
44}
45
46static inline arch_registers_state_t*
47dispatcher_get_disabled_save_area(dispatcher_handle_t handle)
48{
49    return dispatcher_x86_64_get_disabled_save_area(handle);
50}
51
52static inline arch_registers_state_t*
53dispatcher_get_trap_save_area(dispatcher_handle_t handle)
54{
55    return dispatcher_x86_64_get_trap_save_area(handle);
56}
57
58#endif // ARCH_X86_64_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
59