feat: vspace: table: allow to get table vaddr

This commit is contained in:
Paul Pan 2024-06-14 16:44:13 +08:00
parent 03aa0edcc8
commit 42a7ea89c5
2 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,10 @@ impl<'a, T: TableLevel> TableOps<'a, T> for Table<'a, T> {
}
}
fn vaddr(&self) -> VirtAddr {
VirtAddr::from(self.entries.as_ptr())
}
fn map(&mut self, from: VirtAddr, to: PhysAddr, attr: MapAttr) -> PageResult {
if !from.is_aligned(T::LEVEL_SIZE) || !to.is_aligned(PAGE_SIZE) {
return Err(PageError::NotAligned);

View File

@ -5,6 +5,7 @@ pub trait TableOps<'a, T: TableLevel> {
/// # Safety
/// `location` must be a page-aligned virtual address and will not be dropped.
unsafe fn new(location: VirtAddr) -> Self;
fn vaddr(&self) -> VirtAddr;
// following methods only works at current level