File tree 1 file changed +28
-0
lines changed
src/structures/paging/mapper
1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,34 @@ pub trait Mapper<S: PageSize> {
148
148
/// error otherwise.
149
149
fn translate_page ( & self , page : Page < S > ) -> Result < PhysFrame < S > , TranslateError > ;
150
150
151
+ /// Maps the given page to an unused frame obtained from the frame_allocator.
152
+ ///
153
+ /// This function allocates at least one physical frame from the given
154
+ /// frame allocator. It might also need additional physical frames to create
155
+ /// new page tables, which are also allocated from the `frame_allocator`
156
+ /// argument. At most four frames are required from the allocator in total.
157
+ ///
158
+ /// ## Safety
159
+ ///
160
+ /// This is a convencience function that invokes [`map_to`] internally, so
161
+ /// all safety requirements of it also apply for this function.
162
+ #[ inline]
163
+ unsafe fn map < A > (
164
+ & mut self ,
165
+ page : Page < S > ,
166
+ flags : PageTableFlags ,
167
+ frame_allocator : & mut A ,
168
+ ) -> Result < MapperFlush < S > , MapToError < S > >
169
+ where
170
+ Self : Sized ,
171
+ A : FrameAllocator < Size4KiB > + FrameAllocator < S > ,
172
+ {
173
+ let frame = frame_allocator
174
+ . allocate_frame ( )
175
+ . ok_or ( MapToError :: FrameAllocationFailed ) ?;
176
+ self . map_to ( page, frame, flags, frame_allocator)
177
+ }
178
+
151
179
/// Maps the given frame to the virtual page with the same address.
152
180
///
153
181
/// ## Safety
You can’t perform that action at this time.
0 commit comments