pub struct PageTableRef<T, A>where
T: TableMeta,
A: FrameAllocator,{
pub root: Frame<T, A>,
}Fields§
§root: Frame<T, A>Implementations§
Source§impl<T, A> PageTableRef<T, A>where
T: TableMeta,
A: FrameAllocator,
impl<T, A> PageTableRef<T, A>where
T: TableMeta,
A: FrameAllocator,
Sourcepub unsafe fn new(allocator: A) -> Result<PageTableRef<T, A>, PagingError>
pub unsafe fn new(allocator: A) -> Result<PageTableRef<T, A>, PagingError>
pub fn from_paddr(paddr: PhysAddr, allocator: A) -> PageTableRef<T, A>
Sourcepub fn unmap_with_config(
&mut self,
config: &UnmapConfig,
) -> Result<(), PagingError>
pub fn unmap_with_config( &mut self, config: &UnmapConfig, ) -> Result<(), PagingError>
使用配置对象取消映射
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 as TableMeta>::P>>
Sourcepub fn walk_valid(&self) -> impl Iterator<Item = PteInfo<<T as TableMeta>::P>>
pub fn walk_valid(&self) -> impl Iterator<Item = PteInfo<<T as TableMeta>::P>>
遍历所有有效的最终映射页表项(过滤掉无效项和中间级别的页表指针)
pub const fn page_size() -> usize
pub const fn table_levels() -> usize
pub const fn valid_bits() -> usize
Sourcepub unsafe fn destroy(self)
pub unsafe fn destroy(self)
销毁整个页表结构
此方法会:
- 递归释放根帧及所有子页表帧
- 清除所有页表项(设为invalid)
- 不释放映射的物理页(数据页/大页)
§Safety
调用者必须确保:
- 没有其他代码在访问这个页表
- 没有CPU正在使用这个页表进行地址翻译
- 调用后不再使用这个PageTable实例
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,
) -> Result<(), PagingError>
pub fn deallocate_range( &mut self, start_vaddr: VirtAddr, end_vaddr: VirtAddr, ) -> Result<(), PagingError>
释放页表中的指定映射区域
释放指定虚拟地址范围内的所有页表项和子页表帧 在释放前将相关PTE设为invalid
Sourcepub fn translate(
&self,
vaddr: VirtAddr,
) -> Result<(PhysAddr, <T as TableMeta>::P), PagingError>
pub fn translate( &self, vaddr: VirtAddr, ) -> Result<(PhysAddr, <T as TableMeta>::P), PagingError>
Sourcepub fn translate_phys(&self, vaddr: VirtAddr) -> Result<PhysAddr, PagingError>
pub fn translate_phys(&self, vaddr: VirtAddr) -> Result<PhysAddr, PagingError>
Sourcepub fn root_paddr(&self) -> PhysAddr
pub fn root_paddr(&self) -> PhysAddr
获取页表的根帧物理地址
Trait Implementations§
Source§impl<T, A> Clone for PageTableRef<T, A>
impl<T, A> Clone for PageTableRef<T, A>
Source§fn clone(&self) -> PageTableRef<T, A>
fn clone(&self) -> PageTableRef<T, A>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<T, A> Copy for PageTableRef<T, A>
Source§impl<T, A> Debug for PageTableRef<T, A>
impl<T, A> Debug for PageTableRef<T, A>
Source§impl<T, A> PageTableOp for PageTableRef<T, A>where
T: TableMeta,
A: FrameAllocator,
impl<T, A> PageTableOp for PageTableRef<T, A>where
T: TableMeta,
A: FrameAllocator,
Auto Trait Implementations§
impl<T, A> Freeze for PageTableRef<T, A>where
A: Freeze,
impl<T, A> RefUnwindSafe for PageTableRef<T, A>where
A: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, A> Send for PageTableRef<T, A>
impl<T, A> Sync for PageTableRef<T, A>
impl<T, A> Unpin for PageTableRef<T, A>
impl<T, A> UnsafeUnpin for PageTableRef<T, A>where
A: UnsafeUnpin,
impl<T, A> UnwindSafe for PageTableRef<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.