Skip to main content

islet_rmm/mm/page_table/
mod.rs

1pub mod attr;
2pub mod entry;
3
4use self::entry::Entry;
5use crate::config::PAGE_SIZE;
6
7use vmsa::page_table::{HasSubtable, Level};
8
9// Safety/TODO:
10//  - As of now, concurrency safety for RTT and Realm page table is achieved by a big lock.
11//  - If we want to use entry-level locking for a better efficiency, several pieces of codes in this file should be modified accordingly.
12
13/// The Level 0 Table
14pub enum L0Table {}
15impl Level for L0Table {
16    const THIS_LEVEL: usize = 0;
17    const TABLE_SIZE: usize = PAGE_SIZE;
18    const TABLE_ALIGN: usize = PAGE_SIZE;
19    const NUM_ENTRIES: usize = (Self::TABLE_SIZE / core::mem::size_of::<Entry>());
20}
21impl HasSubtable for L0Table {
22    type NextLevel = L1Table;
23}
24
25/// The Level 1 Table
26pub enum L1Table {}
27impl Level for L1Table {
28    const THIS_LEVEL: usize = 1;
29    const TABLE_SIZE: usize = PAGE_SIZE;
30    const TABLE_ALIGN: usize = PAGE_SIZE;
31    const NUM_ENTRIES: usize = (Self::TABLE_SIZE / core::mem::size_of::<Entry>());
32}
33
34impl HasSubtable for L1Table {
35    type NextLevel = L2Table;
36}
37
38/// The Level 2 Table
39pub enum L2Table {}
40impl Level for L2Table {
41    const THIS_LEVEL: usize = 2;
42    const TABLE_SIZE: usize = PAGE_SIZE;
43    const TABLE_ALIGN: usize = PAGE_SIZE;
44    const NUM_ENTRIES: usize = (Self::TABLE_SIZE / core::mem::size_of::<Entry>());
45}
46
47impl HasSubtable for L2Table {
48    type NextLevel = L3Table;
49}
50
51/// The Level 3 Table (Doesn't have Subtable!)
52pub enum L3Table {}
53impl Level for L3Table {
54    const THIS_LEVEL: usize = 3;
55    const TABLE_SIZE: usize = PAGE_SIZE;
56    const TABLE_ALIGN: usize = PAGE_SIZE;
57    const NUM_ENTRIES: usize = (Self::TABLE_SIZE / core::mem::size_of::<Entry>());
58}