1pub static mut ALLOC_START: usize = 0;
2pub const PAGE_SIZE: usize = 1 << PAGE_ORDER;
3pub const PAGE_ORDER: usize = 12;
4
5#[repr(usize)]
8#[derive(Copy, Clone)]
9pub enum EntryBits {
10 None = 0,
11 Valid = 1 << 0,
12 Read = 1 << 1,
13 Write = 1 << 2,
14 Execute = 1 << 3,
15 User = 1 << 4,
16 Global = 1 << 5,
17 Access = 1 << 6,
18 Dirty = 1 << 7,
19
20 ReadWrite = 1 << 1 | 1 << 2,
22 ReadExecute = 1 << 1 | 1 << 3,
23 ReadWriteExecute = 1 << 1 | 1 << 2 | 1 << 3,
24
25 UserReadWrite = 1 << 1 | 1 << 2 | 1 << 4,
27 UserReadExecute = 1 << 1 | 1 << 3 | 1 << 4,
28 UserReadWriteExecute = 1 << 1 | 1 << 2 | 1 << 3 | 1 << 4,
29}
30
31impl EntryBits {
32 pub fn value(self) -> usize {
33 return self as usize;
34 }
35}
36
37#[derive(Clone, Copy, Debug)]
38pub struct Entry {
39 pub entry: usize,
40}
41
42impl Entry {
43 pub fn valid(&self) -> bool {
44 return self.entry & EntryBits::Valid.value() != 0;
45 }
46
47 pub fn invalid(&self) -> bool {
50 return !self.valid();
51 }
52
53 pub fn leaf(&self) -> bool {
55 return self.entry & 0xe != 0;
56 }
57
58 pub fn branch(&self) -> bool {
59 return !self.leaf();
60 }
61
62 pub fn set_entry(&mut self, entry: usize) {
63 self.entry = entry;
64 }
65}
66
67#[derive(Clone, Copy, Debug)]
68pub struct Table {
69 pub entries: [Entry; 512],
70}
71
72impl Table {
73 pub fn length() -> usize {
74 return 512;
75 }
76}
77
78