1/**
2 * \file
3 * \brief Architecture specific dispatcher struct shared between kernel and user
4 */
5
6/*
7 * Copyright (c) 2010, ETH Zurich.
8 * Copyright (c) 2015, Hewlett Packard Enterprise Development LP.
9 * All rights reserved.
10 *
11 * This file is distributed under the terms in the attached LICENSE file.
12 * If you do not find this file, copies can be found by writing to:
13 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
14 */
15
16#ifndef ARCH_AARCH64_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
17#define ARCH_AARCH64_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
18
19#include <target/aarch64/barrelfish_kpi/dispatcher_shared_target.h>
20
21/**
22 * \brief Returns whether dispatcher is currently disabled, given IP.
23 *
24 * \param disp  Pointer to dispatcher
25 * \param ip    User-level instruction pointer.
26 *
27 * \return true if dispatcher disabled, false otherwise.
28 */
29static inline bool dispatcher_is_disabled_ip(dispatcher_handle_t handle,
30                                             uintptr_t rip)
31{
32    struct dispatcher_shared_generic *disp =
33        get_dispatcher_shared_generic(handle);
34    /* one crit_pc pair */
35    struct dispatcher_shared_aarch64 *dispaarch64 =
36        get_dispatcher_shared_aarch64(handle);
37    return disp->disabled ||
38        (dispaarch64->crit_pc_low <= rip && rip < dispaarch64->crit_pc_high);
39}
40
41static inline arch_registers_state_t*
42dispatcher_get_enabled_save_area(dispatcher_handle_t handle)
43{
44    return &((struct dispatcher_shared_aarch64 *)handle)->enabled_save_area;
45}
46
47static inline arch_registers_state_t*
48dispatcher_get_disabled_save_area(dispatcher_handle_t handle)
49{
50    return &((struct dispatcher_shared_aarch64 *)handle)->disabled_save_area;
51}
52
53static inline arch_registers_state_t*
54dispatcher_get_trap_save_area(dispatcher_handle_t handle)
55{
56    return &((struct dispatcher_shared_aarch64 *)handle)->trap_save_area;
57}
58
59#endif // ARCH_AARCH64_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
60