Skip to content

Commit f34bae0

Browse files
committed
add map_range
1 parent f3be780 commit f34bae0

File tree

1 file changed

+28
-0
lines changed
  • src/structures/paging/mapper

1 file changed

+28
-0
lines changed

src/structures/paging/mapper/mod.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,34 @@ pub trait Mapper<S: PageSize> {
425425
})
426426
}
427427

428+
/// Maps frames from the allocator to the given range of virtual pages.
429+
///
430+
/// ## Safety
431+
///
432+
/// This is a convencience function that invokes [`Mapper::map_range_with_table_flags`] internally, so
433+
/// all safety requirements of it also apply for this function.
434+
///
435+
/// ## Errors
436+
///
437+
/// If an error occurs half-way through a [`MapperFlushRange<S>`] is returned that contains the frames that were successfully mapped.
438+
#[inline]
439+
unsafe fn map_range<A>(
440+
&mut self,
441+
pages: PageRange<S>,
442+
flags: PageTableFlags,
443+
frame_allocator: &mut A,
444+
) -> Result<MapperFlushRange<S>, (MapToError<S>, MapperFlushRange<S>)>
445+
where
446+
Self: Sized,
447+
A: FrameAllocator<Size4KiB> + FrameAllocator<S> + ?Sized,
448+
{
449+
let parent_table_flags = flags
450+
& (PageTableFlags::PRESENT
451+
| PageTableFlags::WRITABLE
452+
| PageTableFlags::USER_ACCESSIBLE);
453+
self.map_range_with_table_flags(pages, flags, parent_table_flags, frame_allocator)
454+
}
455+
428456
/// Removes a mapping from the page table and returns the frame that used to be mapped.
429457
///
430458
/// Note that no page tables or pages are deallocated.

0 commit comments

Comments
 (0)