Merge large page support code.
[barrelfish] / include / barrelfish / vspace_mmu_aware.h
1 /**
2  * \file
3  * \brief
4  */
5
6 /*
7  * Copyright (c) 2010, 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, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
14  */
15
16 #ifndef LIBBARRELFISH_VSPACE_MMU_AWARE_H
17 #define LIBBARRELFISH_VSPACE_MMU_AWARE_H
18
19 #include <barrelfish/vregion.h>
20 #include <sys/cdefs.h>
21
22 __BEGIN_DECLS
23
24 struct vspace_mmu_vregion_list {
25     struct vregion vregion;
26     struct vspace_mmu_vregion_list *next;
27 };
28
29 /// Struct to support mmu_aware memory management
30 struct vspace_mmu_aware {
31     size_t size;
32     size_t alignment;
33     size_t consumed;
34     struct vregion vregion;           ///< Needs just one vregion
35     struct memobj_anon memobj;        ///< Needs just one memobj
36     lvaddr_t offset;    ///< Offset of free space in anon
37     lvaddr_t mapoffset; ///< Offset into the anon that has been mapped in
38 };
39
40 errval_t vspace_mmu_aware_init(struct vspace_mmu_aware *state, size_t size);
41 errval_t vspace_mmu_aware_init_aligned(struct vspace_mmu_aware *state,
42                                        size_t size, size_t alignment,
43                                        vregion_flags_t flags);
44 errval_t vspace_mmu_aware_reset(struct vspace_mmu_aware *state,
45                                 struct capref frame, size_t size);
46 errval_t vspace_mmu_aware_map(struct vspace_mmu_aware *state,
47                               struct capref frame, size_t req_size,
48                               void **retbuf, size_t *retsize);
49 errval_t vspace_mmu_aware_unmap(struct vspace_mmu_aware *state,
50                                 lvaddr_t base, size_t bytes);
51
52 __END_DECLS
53
54 #endif // LIBBARRELFISH_VSPACE_MMU_AWARE_H