1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use crate::{Pte, VmMeta, PPN};
use core::marker::PhantomData;
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[repr(transparent)]
pub struct VmFlags<Meta: VmMeta>(pub usize, PhantomData<Meta>);
impl<Meta: VmMeta> VmFlags<Meta> {
#[inline]
pub const unsafe fn from_raw(raw: usize) -> Self {
Self(raw, PhantomData)
}
#[inline]
pub fn is_leaf(self) -> bool {
Meta::is_leaf(self.0)
}
#[inline]
pub fn is_huge(self, level: usize) -> bool {
Meta::is_huge(self.0, level)
}
#[inline]
pub fn valid(self) -> bool {
Meta::is_valid(self.0)
}
#[inline]
pub fn build_pte(mut self, ppn: PPN<Meta>) -> Pte<Meta> {
Meta::set_ppn(&mut self.0, ppn);
Pte(self.0, PhantomData)
}
}