Skip to content

Commit 0aa7b93

Browse files
committed
add an immutable getter for the level 4 page table
1 parent 230c303 commit 0aa7b93

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

src/structures/paging/mapper/mapped_page_table.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
3737
}
3838
}
3939

40+
/// Returns an immutable reference to the wrapped level 4 `PageTable` instance.
41+
pub fn level_4_table(&self) -> &PageTable {
42+
self.level_4_table
43+
}
44+
4045
/// 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
46+
pub fn level_4_table_mut(&mut self) -> &mut PageTable {
47+
self.level_4_table
4348
}
4449

4550
/// Helper function for implementing Mapper. Safe to limit the scope of unsafe, see

src/structures/paging/mapper/offset_page_table.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@ impl<'a> OffsetPageTable<'a> {
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 {
40+
/// Returns an immutable reference to the wrapped level 4 `PageTable` instance.
41+
pub fn level_4_table(&self) -> &PageTable {
4242
self.inner.level_4_table()
4343
}
44+
45+
/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
46+
pub fn level_4_table_mut(&mut self) -> &mut PageTable {
47+
self.inner.level_4_table_mut()
48+
}
4449
}
4550

4651
#[derive(Debug)]

src/structures/paging/mapper/recursive_page_table.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,14 @@ impl<'a> RecursivePageTable<'a> {
8383
}
8484
}
8585

86+
/// Returns an immutable reference to the wrapped level 4 `PageTable` instance.
87+
pub fn level_4_table(&self) -> &PageTable {
88+
self.p4
89+
}
90+
8691
/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
87-
pub fn level_4_table(&mut self) -> &mut PageTable {
88-
&mut self.p4
92+
pub fn level_4_table_mut(&mut self) -> &mut PageTable {
93+
self.p4
8994
}
9095

9196
/// Internal helper function to create the page table of the next level if needed.

0 commit comments

Comments
 (0)