1/*
2 * Copyright (c) 2012, ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
8 */
9
10#ifndef DISTCAPS_H
11#define DISTCAPS_H
12
13#include <kernel.h>
14#include <barrelfish_kpi/types.h>
15#include <barrelfish_kpi/capabilities.h>
16#include <barrelfish_kpi/distcaps.h>
17#include <mdb/mdb.h>
18#include <capabilities.h>
19
20struct cte;
21
22static inline distcap_state_t
23distcap_get_state(struct cte *dcap)
24{
25    distcap_state_t result = 0;
26    if (dcap->mdbnode.owner != my_core_id) {
27        result |= DISTCAP_STATE_FOREIGN;
28    }
29    if (dcap->mdbnode.locked || dcap->mdbnode.in_delete) {
30        result |= DISTCAP_STATE_BUSY;
31    }
32    return result;
33}
34
35static inline bool
36distcap_is_foreign(struct cte *dcap)
37{
38    return dcap->mdbnode.owner != my_core_id;
39}
40
41static inline bool
42distcap_is_in_delete(struct cte *dcap)
43{
44    return dcap->mdbnode.in_delete;
45}
46
47static inline void
48distcap_set_deleted(struct cte *dcap)
49{
50    dcap->mdbnode.in_delete = true;
51}
52
53#endif
54