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