pub struct AddressSpace {
page_ptr: VirtAddr,
vmas: BTreeSet<Vma>,
}Expand description
Type to represent the memory of a process or the kernel by holding a pointer to its page tables and VMAs
Fields§
§page_ptr: VirtAddr§vmas: BTreeSet<Vma>Implementations§
Source§impl AddressSpace
impl AddressSpace
Sourcepub fn empty(page_ptr: VirtAddr) -> Self
pub fn empty(page_ptr: VirtAddr) -> Self
Creates a new AddressSpace instance which contains the given page table pointer and no VMAs
Sourcepub unsafe fn new_user_addr_space() -> Self
pub unsafe fn new_user_addr_space() -> Self
Create a new address space with a zeroed root page, and copy the kernel mappings into the higher half
§Safety
The caller must guarantee that boot stage 2 has already been completed
Sourcepub fn setup_kernel_vmas(
&mut self,
boot_mappings: &[BootMapping; 4],
) -> Result<(), VmmError>
pub fn setup_kernel_vmas( &mut self, boot_mappings: &[BootMapping; 4], ) -> Result<(), VmmError>
Initializes Kernel VMAs on self Do not call this ever, unless you are initializing the kernel’s address space
Sourcepub fn insert_vma(&mut self, vma: Vma) -> Result<(), VmmError>
pub fn insert_vma(&mut self, vma: Vma) -> Result<(), VmmError>
Add a VMA to the AddressSpace
Sourcepub fn remove_vma(&mut self, vma_start_addr: VirtAddr) -> Option<Vma>
pub fn remove_vma(&mut self, vma_start_addr: VirtAddr) -> Option<Vma>
Remove a VMA from the AddressSpace
Returns whether the element to remove existed and could be removed or not
Sourcepub fn find_vma(&self, addr: VirtAddr) -> Option<&Vma>
pub fn find_vma(&self, addr: VirtAddr) -> Option<&Vma>
Search for a VMA in the AddressSpace which applies VMA flags to the given VirtAddr
Returns a reference to the VMA wrapped in an option incase it is not found
Sourcepub fn find_free_range(
&self,
from: VirtAddr,
to: VirtAddr,
size: u64,
) -> Option<VirtAddr>
pub fn find_free_range( &self, from: VirtAddr, to: VirtAddr, size: u64, ) -> Option<VirtAddr>
Search for a VMA-free range of size bytes in [from, to)
Returns the lowest address where such a range fits, or [None] if such a
range couldn’t be found between VMAs