Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an immutable getter for the level 4 page table #327

Merged
merged 1 commit into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/structures/paging/mapper/mapped_page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
}
}

/// Returns an immutable reference to the wrapped level 4 `PageTable` instance.
pub fn level_4_table(&self) -> &PageTable {
self.level_4_table
}

/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
pub fn level_4_table(&mut self) -> &mut PageTable {
&mut self.level_4_table
pub fn level_4_table_mut(&mut self) -> &mut PageTable {
self.level_4_table
}

/// Helper function for implementing Mapper. Safe to limit the scope of unsafe, see
Expand Down
9 changes: 7 additions & 2 deletions src/structures/paging/mapper/offset_page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,15 @@ impl<'a> OffsetPageTable<'a> {
}
}

/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
pub fn level_4_table(&mut self) -> &mut PageTable {
/// Returns an immutable reference to the wrapped level 4 `PageTable` instance.
pub fn level_4_table(&self) -> &PageTable {
self.inner.level_4_table()
}

/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
pub fn level_4_table_mut(&mut self) -> &mut PageTable {
self.inner.level_4_table_mut()
}
}

#[derive(Debug)]
Expand Down
9 changes: 7 additions & 2 deletions src/structures/paging/mapper/recursive_page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ impl<'a> RecursivePageTable<'a> {
}
}

/// Returns an immutable reference to the wrapped level 4 `PageTable` instance.
pub fn level_4_table(&self) -> &PageTable {
self.p4
}

/// Returns a mutable reference to the wrapped level 4 `PageTable` instance.
pub fn level_4_table(&mut self) -> &mut PageTable {
&mut self.p4
pub fn level_4_table_mut(&mut self) -> &mut PageTable {
self.p4
}

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