@@ -173,30 +173,25 @@ pub trait Mapper<S: PageSize> {
173173 /// because of TLB races. It's worth noting that all the above requirements
174174 /// also apply to shared mappings, including the aliasing requirements.
175175 #[ inline]
176- unsafe fn map_to < A > (
176+ unsafe fn map_to (
177177 & mut self ,
178178 page : Page < S > ,
179179 frame : PhysFrame < S > ,
180180 flags : PageTableFlags ,
181- frame_allocator : & mut A ,
182181 ) -> Result < MapperFlush < S > , MapToError < S > >
183182 where
184183 Self : Sized ,
185- A : FrameAllocator < Size4KiB > + ?Sized ,
186184 {
187185 let parent_table_flags = flags
188186 & ( PageTableFlags :: PRESENT
189187 | PageTableFlags :: WRITABLE
190188 | PageTableFlags :: USER_ACCESSIBLE ) ;
191189
192- self . map_to_with_table_flags ( page, frame, flags, parent_table_flags, frame_allocator )
190+ self . map_to_with_table_flags ( page, frame, flags, parent_table_flags)
193191 }
194192
195193 /// Creates a new mapping in the page table.
196194 ///
197- /// This function might need additional physical frames to create new page tables. These
198- /// frames are allocated from the `allocator` argument. At most three frames are required.
199- ///
200195 /// The flags of the parent table(s) can be explicitly specified. Those flags are used for
201196 /// newly created table entries, and for existing entries the flags are added.
202197 ///
@@ -231,17 +226,15 @@ pub trait Mapper<S: PageSize> {
231226 /// the same in all address spaces, otherwise undefined behavior can occur
232227 /// because of TLB races. It's worth noting that all the above requirements
233228 /// also apply to shared mappings, including the aliasing requirements.
234- unsafe fn map_to_with_table_flags < A > (
229+ unsafe fn map_to_with_table_flags (
235230 & mut self ,
236231 page : Page < S > ,
237232 frame : PhysFrame < S > ,
238233 flags : PageTableFlags ,
239234 parent_table_flags : PageTableFlags ,
240- frame_allocator : & mut A ,
241235 ) -> Result < MapperFlush < S > , MapToError < S > >
242236 where
243- Self : Sized ,
244- A : FrameAllocator < Size4KiB > + ?Sized ;
237+ Self : Sized ;
245238
246239 /// Removes a mapping from the page table and returns the frame that used to be mapped.
247240 ///
@@ -276,20 +269,18 @@ pub trait Mapper<S: PageSize> {
276269 /// This is a convencience function that invokes [`Mapper::map_to`] internally, so
277270 /// all safety requirements of it also apply for this function.
278271 #[ inline]
279- unsafe fn identity_map < A > (
272+ unsafe fn identity_map (
280273 & mut self ,
281274 frame : PhysFrame < S > ,
282275 flags : PageTableFlags ,
283- frame_allocator : & mut A ,
284276 ) -> Result < MapperFlush < S > , MapToError < S > >
285277 where
286278 Self : Sized ,
287- A : FrameAllocator < Size4KiB > + ?Sized ,
288279 S : PageSize ,
289280 Self : Mapper < S > ,
290281 {
291282 let page = Page :: containing_address ( VirtAddr :: new ( frame. start_address ( ) . as_u64 ( ) ) ) ;
292- self . map_to ( page, frame, flags, frame_allocator )
283+ self . map_to ( page, frame, flags)
293284 }
294285}
295286
@@ -412,46 +403,36 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
412403 }
413404 }
414405
415- fn map_to_2mib < A > (
406+ fn map_to_2mib (
416407 & mut self ,
417408 page : Page < Size2MiB > ,
418409 frame : PhysFrame < Size2MiB > ,
419410 flags : PageTableFlags ,
420411 parent_table_flags : PageTableFlags ,
421- allocator : & mut A ,
422- ) -> Result < MapperFlush < Size2MiB > , MapToError < Size2MiB > >
423- where
424- A : FrameAllocator < Size4KiB > + ?Sized ,
425- {
412+ ) -> Result < MapperFlush < Size2MiB > , MapToError < Size2MiB > > {
426413 let mut is_alloc_4 = false ;
427414
428415 let p4;
429416
430417 if self . level_5_paging_enabled {
431418 let p5 = & mut self . page_table ;
432- let ( alloc, yes) = self . page_table_walker . create_next_table (
433- & mut p5[ page. p5_index ( ) ] ,
434- parent_table_flags,
435- allocator,
436- ) ?;
419+ let ( alloc, yes) = self
420+ . page_table_walker
421+ . create_next_table ( & mut p5[ page. p5_index ( ) ] , parent_table_flags) ?;
437422
438423 p4 = yes;
439424 is_alloc_4 = alloc;
440425 } else {
441426 p4 = & mut self . page_table ;
442427 }
443428
444- let ( is_alloc_3, p3) = self . page_table_walker . create_next_table (
445- & mut p4[ page. p4_index ( ) ] ,
446- parent_table_flags,
447- allocator,
448- ) ?;
429+ let ( is_alloc_3, p3) = self
430+ . page_table_walker
431+ . create_next_table ( & mut p4[ page. p4_index ( ) ] , parent_table_flags) ?;
449432
450- let ( is_alloc_2, p2) = self . page_table_walker . create_next_table (
451- & mut p3[ page. p3_index ( ) ] ,
452- parent_table_flags,
453- allocator,
454- ) ?;
433+ let ( is_alloc_2, p2) = self
434+ . page_table_walker
435+ . create_next_table ( & mut p3[ page. p3_index ( ) ] , parent_table_flags) ?;
455436
456437 if !p2[ page. p2_index ( ) ] . is_unused ( ) {
457438 return Err ( MapToError :: PageAlreadyMapped ( frame) ) ;
@@ -475,52 +456,40 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
475456 Ok ( MapperFlush :: new ( page) )
476457 }
477458
478- fn map_to_4kib < A > (
459+ fn map_to_4kib (
479460 & mut self ,
480461 page : Page < Size4KiB > ,
481462 frame : PhysFrame < Size4KiB > ,
482463 flags : PageTableFlags ,
483464 parent_table_flags : PageTableFlags ,
484- allocator : & mut A ,
485- ) -> Result < MapperFlush < Size4KiB > , MapToError < Size4KiB > >
486- where
487- A : FrameAllocator < Size4KiB > + ?Sized ,
488- {
465+ ) -> Result < MapperFlush < Size4KiB > , MapToError < Size4KiB > > {
489466 let p4;
490467
491468 let mut is_alloc_4 = false ;
492469
493470 if self . level_5_paging_enabled {
494471 let p5 = & mut self . page_table ;
495- let ( alloc, yes) = self . page_table_walker . create_next_table (
496- & mut p5[ page. p5_index ( ) ] ,
497- parent_table_flags,
498- allocator,
499- ) ?;
472+ let ( alloc, yes) = self
473+ . page_table_walker
474+ . create_next_table ( & mut p5[ page. p5_index ( ) ] , parent_table_flags) ?;
500475
501476 p4 = yes;
502477 is_alloc_4 = alloc;
503478 } else {
504479 p4 = & mut self . page_table ;
505480 }
506481
507- let ( is_alloc_3, p3) = self . page_table_walker . create_next_table (
508- & mut p4[ page. p4_index ( ) ] ,
509- parent_table_flags,
510- allocator,
511- ) ?;
482+ let ( is_alloc_3, p3) = self
483+ . page_table_walker
484+ . create_next_table ( & mut p4[ page. p4_index ( ) ] , parent_table_flags) ?;
512485
513- let ( is_alloc_2, p2) = self . page_table_walker . create_next_table (
514- & mut p3[ page. p3_index ( ) ] ,
515- parent_table_flags,
516- allocator,
517- ) ?;
486+ let ( is_alloc_2, p2) = self
487+ . page_table_walker
488+ . create_next_table ( & mut p3[ page. p3_index ( ) ] , parent_table_flags) ?;
518489
519- let ( is_alloc_1, p1) = self . page_table_walker . create_next_table (
520- & mut p2[ page. p2_index ( ) ] ,
521- parent_table_flags,
522- allocator,
523- ) ?;
490+ let ( is_alloc_1, p1) = self
491+ . page_table_walker
492+ . create_next_table ( & mut p2[ page. p2_index ( ) ] , parent_table_flags) ?;
524493
525494 if !p1[ page. p1_index ( ) ] . is_unused ( ) {
526495 return Err ( MapToError :: PageAlreadyMapped ( frame) ) ;
@@ -551,18 +520,14 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
551520
552521impl < ' a , P : PageTableFrameMapping > Mapper < Size2MiB > for MappedPageTable < ' a , P > {
553522 #[ inline]
554- unsafe fn map_to_with_table_flags < A > (
523+ unsafe fn map_to_with_table_flags (
555524 & mut self ,
556525 page : Page < Size2MiB > ,
557526 frame : PhysFrame < Size2MiB > ,
558527 flags : PageTableFlags ,
559528 parent_table_flags : PageTableFlags ,
560- allocator : & mut A ,
561- ) -> Result < MapperFlush < Size2MiB > , MapToError < Size2MiB > >
562- where
563- A : FrameAllocator < Size4KiB > + ?Sized ,
564- {
565- self . map_to_2mib ( page, frame, flags, parent_table_flags, allocator)
529+ ) -> Result < MapperFlush < Size2MiB > , MapToError < Size2MiB > > {
530+ self . map_to_2mib ( page, frame, flags, parent_table_flags)
566531 }
567532
568533 fn unmap (
@@ -675,18 +640,14 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
675640
676641impl < ' a , P : PageTableFrameMapping > Mapper < Size4KiB > for MappedPageTable < ' a , P > {
677642 #[ inline]
678- unsafe fn map_to_with_table_flags < A > (
643+ unsafe fn map_to_with_table_flags (
679644 & mut self ,
680645 page : Page < Size4KiB > ,
681646 frame : PhysFrame < Size4KiB > ,
682647 flags : PageTableFlags ,
683648 parent_table_flags : PageTableFlags ,
684- allocator : & mut A ,
685- ) -> Result < MapperFlush < Size4KiB > , MapToError < Size4KiB > >
686- where
687- A : FrameAllocator < Size4KiB > + ?Sized ,
688- {
689- self . map_to_4kib ( page, frame, flags, parent_table_flags, allocator)
649+ ) -> Result < MapperFlush < Size4KiB > , MapToError < Size4KiB > > {
650+ self . map_to_4kib ( page, frame, flags, parent_table_flags)
690651 }
691652
692653 fn unmap (
@@ -933,19 +894,15 @@ impl<P: PageTableFrameMapping> PageTableWalker<P> {
933894 /// Returns `MapToError::FrameAllocationFailed` if the entry is unused and the allocator
934895 /// returned `None`. Returns `MapToError::ParentEntryHugePage` if the `HUGE_PAGE` flag is set
935896 /// in the passed entry.
936- fn create_next_table < ' b , A > (
897+ fn create_next_table < ' b > (
937898 & self ,
938899 entry : & ' b mut PageTableEntry ,
939900 insert_flags : PageTableFlags ,
940- allocator : & mut A ,
941- ) -> Result < ( bool , & ' b mut PageTable ) , PageTableCreateError >
942- where
943- A : FrameAllocator < Size4KiB > + ?Sized ,
944- {
901+ ) -> Result < ( bool , & ' b mut PageTable ) , PageTableCreateError > {
945902 let created;
946903
947904 if entry. is_unused ( ) {
948- if let Some ( frame) = allocator . allocate_frame ( ) {
905+ if let Some ( frame) = unsafe { FRAME_ALLOCATOR . allocate_frame ( ) } {
949906 entry. set_frame ( frame, insert_flags) ;
950907 created = true ;
951908 } else {
@@ -1120,19 +1077,15 @@ unsafe impl PageTableFrameMapping for PhysOffset {
11201077
11211078impl < ' a > Mapper < Size2MiB > for OffsetPageTable < ' a > {
11221079 #[ inline]
1123- unsafe fn map_to_with_table_flags < A > (
1080+ unsafe fn map_to_with_table_flags (
11241081 & mut self ,
11251082 page : Page < Size2MiB > ,
11261083 frame : PhysFrame < Size2MiB > ,
11271084 flags : PageTableFlags ,
11281085 parent_table_flags : PageTableFlags ,
1129- allocator : & mut A ,
1130- ) -> Result < MapperFlush < Size2MiB > , MapToError < Size2MiB > >
1131- where
1132- A : FrameAllocator < Size4KiB > + ?Sized ,
1133- {
1086+ ) -> Result < MapperFlush < Size2MiB > , MapToError < Size2MiB > > {
11341087 self . inner
1135- . map_to_with_table_flags ( page, frame, flags, parent_table_flags, allocator )
1088+ . map_to_with_table_flags ( page, frame, flags, parent_table_flags)
11361089 }
11371090
11381091 #[ inline]
@@ -1160,19 +1113,15 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
11601113
11611114impl < ' a > Mapper < Size4KiB > for OffsetPageTable < ' a > {
11621115 #[ inline]
1163- unsafe fn map_to_with_table_flags < A > (
1116+ unsafe fn map_to_with_table_flags (
11641117 & mut self ,
11651118 page : Page < Size4KiB > ,
11661119 frame : PhysFrame < Size4KiB > ,
11671120 flags : PageTableFlags ,
11681121 parent_table_flags : PageTableFlags ,
1169- allocator : & mut A ,
1170- ) -> Result < MapperFlush < Size4KiB > , MapToError < Size4KiB > >
1171- where
1172- A : FrameAllocator < Size4KiB > + ?Sized ,
1173- {
1122+ ) -> Result < MapperFlush < Size4KiB > , MapToError < Size4KiB > > {
11741123 self . inner
1175- . map_to_with_table_flags ( page, frame, flags, parent_table_flags, allocator )
1124+ . map_to_with_table_flags ( page, frame, flags, parent_table_flags)
11761125 }
11771126
11781127 #[ inline]
0 commit comments