1/**
2 * \file
3 * \brief Pmap definition common for the x86 archs, but private to libbarrelfish
4 */
5
6/*
7 * Copyright (c) 2011, ETH Zurich.
8 * Copyright (c) 2014, HP Labs.
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, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
14 */
15
16#ifndef TARGET_X86_BARRELFISH_PMAP_X86_H
17#define TARGET_X86_BARRELFISH_PMAP_X86_H
18
19struct pmap;
20
21errval_t pmap_x86_serialise(struct pmap *pmap, void *buf, size_t buflen);
22errval_t pmap_x86_deserialise(struct pmap *pmap, void *buf, size_t buflen);
23errval_t pmap_x86_determine_addr(struct pmap *pmap, struct memobj *memobj,
24                                 size_t alignment, genvaddr_t *vaddr);
25
26/**
27 * \brief check whether vnode `root` has children in [entry .. entry+len).
28 * \return * true iff `root` has children in [entry .. entry+len) and
29 *           only_pages false
30 *         * true iff `root` has valid page mappings in [entry .. entry+len)
31 *           and only_pages true
32 */
33bool has_vnode(struct vnode *root, uint32_t entry, size_t len,
34               bool only_pages);
35/**
36 * \return vnode at `entry` in `root`. NULL if no vnode there.
37 */
38struct vnode *find_vnode(struct vnode *root, uint16_t entry);
39
40/**
41 * \return true iff [entry..entry+npages) inside a child of `root`.
42 */
43bool inside_region(struct vnode *root, uint32_t entry, uint32_t npages);
44
45/**
46 * \brief remove vnode `item` from list of children of `root`.
47 */
48void remove_vnode(struct vnode *root, struct vnode *item);
49
50/**
51 * \brief allocate vnode as child of `root` with type `type`. Allocates the
52 * struct vnode with `pmap`'s slab allocator.
53 * \arg entry the entry at which the new vnode is inserted
54 * \arg retvnode pointer to the new vnode.
55 */
56errval_t alloc_vnode(struct pmap_x86 *pmap, struct vnode *root,
57                     enum objtype type, uint32_t entry,
58                     struct vnode **retvnode);
59
60/**
61 * \brief remove vnodes with no leafs in [entry .. entry+len), destroy their
62 * associated capabilities and free their slabs.
63 */
64void remove_empty_vnodes(struct pmap_x86 *pmap, struct vnode *root,
65                         uint32_t entry, size_t len);
66
67#endif // TARGET_X86_BARRELFISH_PMAP_X86_H
68