Skip to content

Commit

Permalink
Merge pull request #327 from Freax13/page-table-getter
Browse files Browse the repository at this point in the history
add an immutable getter for the level 4 page table
  • Loading branch information
Freax13 authored Dec 5, 2021
2 parents 230c303 + 0aa7b93 commit 0dd0f56
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
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

0 comments on commit 0dd0f56

Please sign in to comment.