1/*
2 * Copyright 2014, General Dynamics C4 Systems
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#pragma once
8
9#include <types.h>
10#include <api/failures.h>
11#include <api/types.h>
12#include <object/structures.h>
13
14struct lookupCap_ret {
15    exception_t status;
16    cap_t cap;
17};
18typedef struct lookupCap_ret lookupCap_ret_t;
19
20struct lookupCapAndSlot_ret {
21    exception_t status;
22    cap_t cap;
23    cte_t *slot;
24};
25typedef struct lookupCapAndSlot_ret lookupCapAndSlot_ret_t;
26
27struct lookupSlot_raw_ret {
28    exception_t status;
29    cte_t *slot;
30};
31typedef struct lookupSlot_raw_ret lookupSlot_raw_ret_t;
32
33struct lookupSlot_ret {
34    exception_t status;
35    cte_t *slot;
36};
37typedef struct lookupSlot_ret lookupSlot_ret_t;
38
39struct resolveAddressBits_ret {
40    exception_t status;
41    cte_t *slot;
42    word_t bitsRemaining;
43};
44typedef struct resolveAddressBits_ret resolveAddressBits_ret_t;
45
46lookupCap_ret_t lookupCap(tcb_t *thread, cptr_t cPtr);
47lookupCapAndSlot_ret_t lookupCapAndSlot(tcb_t *thread, cptr_t cPtr);
48lookupSlot_raw_ret_t lookupSlot(tcb_t *thread, cptr_t capptr);
49lookupSlot_ret_t lookupSlotForCNodeOp(bool_t isSource,
50                                      cap_t root, cptr_t capptr,
51                                      word_t depth);
52lookupSlot_ret_t lookupSourceSlot(cap_t root, cptr_t capptr,
53                                  word_t depth);
54lookupSlot_ret_t lookupTargetSlot(cap_t root, cptr_t capptr,
55                                  word_t depth);
56lookupSlot_ret_t lookupPivotSlot(cap_t root, cptr_t capptr,
57                                 word_t depth);
58resolveAddressBits_ret_t resolveAddressBits(cap_t nodeCap,
59                                            cptr_t capptr,
60                                            word_t n_bits);
61
62