Skip to content

Commit 3d988fc

Browse files
authored
Merge pull request #184 from rust-osdev/access-level-4-table
Provide functions for accessing the underlying L4 table for mapper types
2 parents 0afc070 + ee89ef2 commit 3d988fc

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/structures/paging/mapper/mapped_page_table.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ impl<'a, P: PhysToVirt> MappedPageTable<'a, P> {
3737
}
3838
}
3939

40+
/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
41+
pub fn level_4_table(&mut self) -> &mut PageTable {
42+
&mut self.level_4_table
43+
}
44+
4045
/// Helper function for implementing Mapper. Safe to limit the scope of unsafe, see
4146
/// https://github.com/rust-lang/rfcs/pull/2585.
4247
fn map_to_1gib<A>(

src/structures/paging/mapper/offset_page_table.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ impl<'a> OffsetPageTable<'a> {
3636
inner: MappedPageTable::new(level_4_table, phys_offset),
3737
}
3838
}
39+
40+
/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
41+
pub fn level_4_table(&mut self) -> &mut PageTable {
42+
self.inner.level_4_table()
43+
}
3944
}
4045

4146
#[derive(Debug)]

src/structures/paging/mapper/recursive_page_table.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ impl<'a> RecursivePageTable<'a> {
8181
}
8282
}
8383

84+
/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
85+
pub fn level_4_table(&mut self) -> &mut PageTable {
86+
&mut self.p4
87+
}
88+
8489
/// Internal helper function to create the page table of the next level if needed.
8590
///
8691
/// If the passed entry is unused, a new frame is allocated from the given allocator, zeroed,

0 commit comments

Comments
 (0)