Skip to content

Commit

Permalink
[mm] Add find_free_area function for mmap syscalls
Browse files Browse the repository at this point in the history
  • Loading branch information
Azure-stars committed Feb 14, 2025
1 parent 46273d1 commit e8e28f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/axhal/src/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 14 additions & 0 deletions modules/axmm/src/aspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<VirtAddr> {
self.areas.find_free_area(hint, size, limit)
}

/// Add a new linear mapping.
///
/// See [`Backend`] for more details about the mapping backends.
Expand Down

0 comments on commit e8e28f0

Please sign in to comment.