ros666::mm::page_table

Struct PageTable

Source
pub struct PageTable {
    pub root: PhysicalPageNumber,
    pub frames: Vec<FrameTracker>,
}
Expand description

页表

包含根页表的物理页号和帧跟踪器的向量

Fields§

§root: PhysicalPageNumber

根页表的物理页号

§frames: Vec<FrameTracker>

帧跟踪器的向量

Implementations§

Source§

impl PageTable

Source

pub fn new() -> Self

创建一个新的页表

分配一个根页表帧,并初始化页表结构体

Source

pub fn token(&self) -> usize

获取页表的 token

token 即 satp (satp: Supervisor Address Translation and Protection) 寄存器的值

在启用 Sv39 页表时,satp 即作为三级页表的根节点。其第 60-63 位为模式位,为 0b100 时启用 Sv39 页表

Source

pub fn map( &mut self, vpn: VirtualPageNumber, ppn: PhysicalPageNumber, flags: PTEFlags, )

映射虚拟页号到物理页号

根据虚拟页号查找页表项,并将其映射到给定的物理页号和标志位

Source

pub fn unmap(&mut self, vpn: VirtualPageNumber)

取消映射虚拟页号

根据虚拟页号查找页表项,并将其设置为默认值,取消映射

Source

pub fn find_pte_mut( &mut self, vpn: VirtualPageNumber, ) -> Option<&mut PageTableEntry>

查找并返回可变的页表项

根据虚拟页号查找页表项,如果不存在则分配新的页表项

Source

pub fn find_pte(&self, vpn: VirtualPageNumber) -> Option<&mut PageTableEntry>

查找并返回不可变的页表项

根据虚拟页号查找页表项,如果不存在则返回 None

Source

pub fn translate(&self, vpn: VirtualPageNumber) -> Option<PageTableEntry>

翻译虚拟页号到页表项

根据虚拟页号查找页表项,并返回其副本

Source

pub fn translate_addr(&self, va: VirtualAddress) -> Option<PhysicalAddress>

翻译虚拟地址到物理地址

根据虚拟地址查找页表项,并计算物理地址

Source

pub fn from_satp(satp: usize) -> Self

从 SATP 寄存器创建页表

根据 SATP 寄存器中的值创建页表结构体

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.