pub struct PageTable<T: TableMeta, A: FrameAllocator> { /* private fields */ }Implementations§
Source§impl<T: TableMeta, A: FrameAllocator> PageTable<T, A>
impl<T: TableMeta, A: FrameAllocator> PageTable<T, A>
pub const VALID_BITS: usize = Frame<T, A>::PT_VALID_BITS
Sourcepub fn new(allocator: A) -> PagingResult<Self>
pub fn new(allocator: A) -> PagingResult<Self>
创建一个新的页表
pub fn valid_bits(&self) -> usize
Methods from Deref<Target = PageTableRef<T, A>>§
Sourcepub fn map(&mut self, config: &MapConfig) -> PagingResult
pub fn map(&mut self, config: &MapConfig) -> PagingResult
映射虚拟地址范围到物理地址范围
Sourcepub fn unmap_with_config(&mut self, config: &UnmapConfig) -> PagingResult<()>
pub fn unmap_with_config(&mut self, config: &UnmapConfig) -> PagingResult<()>
使用配置对象取消映射
Sourcepub fn walk_all(&self, config: WalkConfig) -> PageTableWalker<'_, T, A> ⓘ
pub fn walk_all(&self, config: WalkConfig) -> PageTableWalker<'_, T, A> ⓘ
创建页表遍历迭代器
pub fn walk( &self, start_vaddr: VirtAddr, end_vaddr: VirtAddr, ) -> impl Iterator<Item = PteInfo<T::P>> + '_
Sourcepub fn walk_valid(&self) -> impl Iterator<Item = PteInfo<T::P>> + '_
pub fn walk_valid(&self) -> impl Iterator<Item = PteInfo<T::P>> + '_
遍历所有有效的最终映射页表项(过滤掉无效项和中间级别的页表指针)
Sourcepub unsafe fn deallocate(&mut self)
pub unsafe fn deallocate(&mut self)
释放页表占用的所有页表帧
与destroy()不同,这个方法保留PageTable结构, 但释放所有关联的页表帧。调用后PageTable不再可用。
释放行为:
- 释放所有页表帧
- 清除所有页表项(设为invalid)
- 不释放映射的物理页(数据页/大页)
§Safety
调用者必须确保:
- 没有其他代码在访问这个页表
- 没有CPU正在使用这个页表进行地址翻译
Sourcepub fn deallocate_range(
&mut self,
start_vaddr: VirtAddr,
end_vaddr: VirtAddr,
) -> PagingResult
pub fn deallocate_range( &mut self, start_vaddr: VirtAddr, end_vaddr: VirtAddr, ) -> PagingResult
释放页表中的指定映射区域
释放指定虚拟地址范围内的所有页表项和子页表帧 在释放前将相关PTE设为invalid
Sourcepub fn translate_phys(&self, vaddr: VirtAddr) -> PagingResult<PhysAddr>
pub fn translate_phys(&self, vaddr: VirtAddr) -> PagingResult<PhysAddr>
Sourcepub fn root_paddr(&self) -> PhysAddr
pub fn root_paddr(&self) -> PhysAddr
获取页表的根帧物理地址
Trait Implementations§
Auto Trait Implementations§
impl<T, A> Freeze for PageTable<T, A>where
A: Freeze,
impl<T, A> RefUnwindSafe for PageTable<T, A>where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> Send for PageTable<T, A>
impl<T, A> Sync for PageTable<T, A>
impl<T, A> Unpin for PageTable<T, A>
impl<T, A> UnwindSafe for PageTable<T, A>where
A: UnwindSafe,
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more