File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
src/structures/paging/mapper Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,34 @@ pub trait Mapper<S: PageSize> {
321
321
/// error otherwise.
322
322
fn translate_page ( & self , page : Page < S > ) -> Result < PhysFrame < S > , TranslateError > ;
323
323
324
+ /// Maps the given page to an unused frame obtained from the frame_allocator.
325
+ ///
326
+ /// This function allocates at least one physical frame from the given
327
+ /// frame allocator. It might also need additional physical frames to create
328
+ /// new page tables, which are also allocated from the `frame_allocator`
329
+ /// argument. At most four frames are required from the allocator in total.
330
+ ///
331
+ /// ## Safety
332
+ ///
333
+ /// This is a convencience function that invokes [`map_to`] internally, so
334
+ /// all safety requirements of it also apply for this function.
335
+ #[ inline]
336
+ unsafe fn map < A > (
337
+ & mut self ,
338
+ page : Page < S > ,
339
+ flags : PageTableFlags ,
340
+ frame_allocator : & mut A ,
341
+ ) -> Result < MapperFlush < S > , MapToError < S > >
342
+ where
343
+ Self : Sized ,
344
+ A : FrameAllocator < Size4KiB > + FrameAllocator < S > ,
345
+ {
346
+ let frame = frame_allocator
347
+ . allocate_frame ( )
348
+ . ok_or ( MapToError :: FrameAllocationFailed ) ?;
349
+ self . map_to ( page, frame, flags, frame_allocator)
350
+ }
351
+
324
352
/// Maps the given frame to the virtual page with the same address.
325
353
///
326
354
/// ## Safety
You can’t perform that action at this time.
0 commit comments