Struct memory_set::MemorySet
source · pub struct MemorySet<F: Copy, P, B: MappingBackend<F, P>> { /* private fields */ }Expand description
A container that maintains memory mappings (MemoryArea).
Implementations§
source§impl<F: Copy, P, B: MappingBackend<F, P>> MemorySet<F, P, B>
impl<F: Copy, P, B: MappingBackend<F, P>> MemorySet<F, P, B>
sourcepub fn iter(&self) -> impl Iterator<Item = &MemoryArea<F, P, B>>
pub fn iter(&self) -> impl Iterator<Item = &MemoryArea<F, P, B>>
Returns the iterator over all memory areas.
sourcepub fn overlaps(&self, range: VirtAddrRange) -> bool
pub fn overlaps(&self, range: VirtAddrRange) -> bool
Returns whether the given address range overlaps with any existing area.
sourcepub fn find(&self, addr: VirtAddr) -> Option<&MemoryArea<F, P, B>>
pub fn find(&self, addr: VirtAddr) -> Option<&MemoryArea<F, P, B>>
Finds the memory area that contains the given address.
sourcepub fn find_free_area(
&self,
hint: VirtAddr,
size: usize,
limit: VirtAddrRange,
) -> Option<VirtAddr>
pub fn find_free_area( &self, hint: VirtAddr, size: usize, limit: VirtAddrRange, ) -> Option<VirtAddr>
Finds a free area that can accommodate the given size.
The search starts from the given hint address, and the area should be
within the given limit range.
Returns the start address of the free area. Returns None if no such
area is found.
sourcepub fn map(
&mut self,
area: MemoryArea<F, P, B>,
page_table: &mut P,
unmap_overlap: bool,
) -> MappingResult
pub fn map( &mut self, area: MemoryArea<F, P, B>, page_table: &mut P, unmap_overlap: bool, ) -> MappingResult
Add a new memory mapping.
The mapping is represented by a MemoryArea.
If the new area overlaps with any existing area, the behavior is
determined by the unmap_overlap parameter. If it is true, the
overlapped regions will be unmapped first. Otherwise, it returns an
error.
sourcepub fn unmap(
&mut self,
start: VirtAddr,
size: usize,
page_table: &mut P,
) -> MappingResult
pub fn unmap( &mut self, start: VirtAddr, size: usize, page_table: &mut P, ) -> MappingResult
Remove memory mappings within the given address range.
All memory areas that are fully contained in the range will be removed directly. If the area intersects with the boundary, it will be shrinked. If the unmapped range is in the middle of an existing area, it will be split into two areas.
sourcepub fn clear(&mut self, page_table: &mut P) -> MappingResult
pub fn clear(&mut self, page_table: &mut P) -> MappingResult
Remove all memory areas and the underlying mappings.