diff --git a/modules/axhal/src/paging.rs b/modules/axhal/src/paging.rs index d34ba0bd02..f09b1d8479 100644 --- a/modules/axhal/src/paging.rs +++ b/modules/axhal/src/paging.rs @@ -79,7 +79,7 @@ pub fn set_kernel_page_table_root(root_paddr: PhysAddr) { /// /// # Panics /// -/// It must be called after [`set_kernel_page_table`], otherwise it will panic. +/// It must be called after [`set_kernel_page_table_root`], otherwise it will panic. pub fn kernel_page_table_root() -> PhysAddr { *KERNEL_PAGE_TABLE_ROOT .get() diff --git a/modules/axmm/src/aspace.rs b/modules/axmm/src/aspace.rs index 7992c458bc..39e377e065 100644 --- a/modules/axmm/src/aspace.rs +++ b/modules/axmm/src/aspace.rs @@ -74,6 +74,20 @@ impl AddrSpace { Ok(()) } + /// 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. + pub fn find_free_area( + &self, + hint: VirtAddr, + size: usize, + limit: VirtAddrRange, + ) -> Option { + self.areas.find_free_area(hint, size, limit) + } + /// Add a new linear mapping. /// /// See [`Backend`] for more details about the mapping backends.