1/* @title: Anonymous VMA Chain */
2#pragma once
3#include <compiler/wrapper.h>
4#include <mem/page.h>
5#include <mem/vma_range.h>
6#include <structures/list.h>
7#include <structures/rbit.h>
8#include <types/types.h>
9
10struct anon_vma_chain {
11 struct vma_range *vma_range;
12 struct anon_vma *anon_vma;
13 struct list_node same_vma_range; /* on vma_range->anon_vma_chain */
14 struct rbit_node itnode; /* in anon_vma->tree */
15};
16
17struct anon_vma_chain *avc_alloc(void) cw_alloc();
18void avc_free(struct anon_vma_chain *avc);
19
20/* Link a vma_range to an anon_vma: push onto vma_range's list
21 * AND insert into av's tree */
22void avc_link(struct vma_range *vma_range, struct anon_vma *av,
23 struct anon_vma_chain *avc);
24void avc_unlink(struct anon_vma_chain *avc);
25
26/* re-key AVC after vma_range page range changed,
27 * reinsert tree node afterwards */
28void avc_rekey(struct anon_vma_chain *avc);
29
30/* what the tree is keyed on */
31static inline pgoff_t avc_first(const struct anon_vma_chain *a) {
32 return a->vma_range->pgoff;
33}
34
35static inline pgoff_t avc_last(const struct anon_vma_chain *a) {
36 return a->vma_range->pgoff + vma_range_pages(vma_range: a->vma_range) - 1;
37}
38