pub struct MapArea {
data_frames: MapRangeDict,
map_type: MapType,
map_perm: MapPermission,
pub map_file: Option<FileLike>,
}
Expand description
Map area for different segments or a chunk of memory for memory mapped file access.
Fields
data_frames: MapRangeDict
Range of the mapped virtual page numbers. Page aligned.
map_type: MapType
Direct or framed(virtual) mapping?
map_perm: MapPermission
Permissions which are the or of RWXU, where U stands for user.
map_file: Option<FileLike>
Implementations
Construct a new segment without without allocating memory
Return the reference count to the currently using file if exists.
Copier, but the physical pages are not allocated,
thus leaving data_frames
empty.
Map an included page in current area.
If the map_type
is Framed
, then physical pages shall be allocated by this function.
Otherwise, where map_type
is Identical
,
the virtual page will be mapped directly to the physical page with an identical address to the page.
Note
Vpn should be in this map area, but the check is not enforced in this function!
Unmap a page in current area.
If it is framed, then the physical pages will be removed from the data_frames
Btree.
This is unnecessary if the area is directly mapped.
Note
Vpn should be in this map area, but the check is not enforced in this function!
Map & allocate all virtual pages in current area to physical pages in the page table.
pub fn map_from_existed_page_table(
&mut self,
dst_page_table: &mut PageTable,
src_page_table: &mut PageTable
) -> Result
pub fn map_from_existed_page_table(
&mut self,
dst_page_table: &mut PageTable,
src_page_table: &mut PageTable
) -> Result
Map the same area in self
from dst_page_table
to src_page_table
, sharing the same physical address.
Convert map areas to physical pages.
Of Course…
Since the area is shared, the pages have been allocated.
Argument
dst_page_table
: The destination to be mapped into.
src_page_table
: The source to be mapped from. This is also the page table where self
should be included.
pub fn map_from_kernel_elf_area(
&mut self,
page_table: &mut PageTable,
start_vpn_in_kernel_elf_area: VirtPageNum
) -> Result
pub fn map_from_kernel_elf_area(
&mut self,
page_table: &mut PageTable,
start_vpn_in_kernel_elf_area: VirtPageNum
) -> Result
Map vpns in self
to the same ppns in kernel_elf_area
from start_vpn_in_kernel_elf_area
,
range is depend on self.vpn_range
.
ATTENTION
Suppose that the kernel_space.areas.last() is elf_area.
page_table
and self
should belong to the same memory_set.
vpn_range in kernel_elf_area
should be broader than (or at least equal to) self
.
WARNING
Author did not consider to reuse this function at the time he wrote it.
So be careful to use it in some other places besides from_elf
.
Unmap all pages in self
from page_table
using unmap_one()
data: start-aligned but maybe with shorter length assume that all frames were cleared before
If new_end
is lower than the current end of heap area, do nothing and return Ok(())
.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for MapArea
impl !UnwindSafe for MapArea
Blanket Implementations
Mutably borrows from an owned value. Read more