ros666::mm::memory_set

Struct MapArea

Source
pub struct MapArea {
    vpn_range: VPNRange,
    data: BTreeMap<VirtualPageNumber, FrameTracker>,
    map_type: MapType,
    permission: MapPermission,
}
Expand description

逻辑段

逻辑段管理了一段虚拟内存,提供映射和访存权限控制

在内核和应用程序初始化时,需要根据编译链接到的代码段、数据段等信息,创建逻辑段

Fields§

§vpn_range: VPNRange§data: BTreeMap<VirtualPageNumber, FrameTracker>§map_type: MapType§permission: MapPermission

Implementations§

Source§

impl MapArea

Source

pub fn new( vpn_range: VPNRange, map_type: MapType, permission: MapPermission, ) -> Self

创建新的 MapArea

§参数
  • vpn_range - 虚拟页号范围
  • map_type - 映射类型
  • permission - 映射权限
Source

pub fn map(&mut self, page_table: &mut PageTable)

映射虚拟页到物理页

§参数
  • page_table - 页表
Source

pub fn unmap(&mut self, page_table: &mut PageTable)

取消映射虚拟页

§参数
  • page_table - 页表
Source

pub fn get_frame(&self, vpn: VirtualPageNumber) -> Option<&FrameTracker>

获取虚拟页对应的物理页框

§参数
  • vpn - 虚拟页号
§返回值

返回对应的物理页框

Source

pub fn get_permission(&self) -> MapPermission

获取映射权限

§返回值

返回映射权限

Source

pub fn map_one(&mut self, vpn: VirtualPageNumber, page_table: &mut PageTable)

映射单个虚拟页到物理页

§参数
  • vpn - 虚拟页号
  • page_table - 页表
Source

pub fn unmap_one(&mut self, vpn: VirtualPageNumber, page_table: &mut PageTable)

取消映射单个虚拟页

§参数
  • vpn - 虚拟页号
  • page_table - 页表
Source

pub fn copy_from(&mut self, page_table: &mut PageTable, src: &[u8])

从源数据复制到映射区域

§参数
  • page_table - 页表
  • src - 源数据
Source

pub fn from_another(another: &MapArea) -> Self

从另一个 MapArea 创建新的 MapArea

§参数
  • another - 另一个 MapArea
§返回值

返回新的 MapArea

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.