@@ -173,30 +173,25 @@ pub trait Mapper<S: PageSize> {
173
173
/// because of TLB races. It's worth noting that all the above requirements
174
174
/// also apply to shared mappings, including the aliasing requirements.
175
175
#[ inline]
176
- unsafe fn map_to < A > (
176
+ unsafe fn map_to (
177
177
& mut self ,
178
178
page : Page < S > ,
179
179
frame : PhysFrame < S > ,
180
180
flags : PageTableFlags ,
181
- frame_allocator : & mut A ,
182
181
) -> Result < MapperFlush < S > , MapToError < S > >
183
182
where
184
183
Self : Sized ,
185
- A : FrameAllocator < Size4KiB > + ?Sized ,
186
184
{
187
185
let parent_table_flags = flags
188
186
& ( PageTableFlags :: PRESENT
189
187
| PageTableFlags :: WRITABLE
190
188
| PageTableFlags :: USER_ACCESSIBLE ) ;
191
189
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)
193
191
}
194
192
195
193
/// Creates a new mapping in the page table.
196
194
///
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
- ///
200
195
/// The flags of the parent table(s) can be explicitly specified. Those flags are used for
201
196
/// newly created table entries, and for existing entries the flags are added.
202
197
///
@@ -231,17 +226,15 @@ pub trait Mapper<S: PageSize> {
231
226
/// the same in all address spaces, otherwise undefined behavior can occur
232
227
/// because of TLB races. It's worth noting that all the above requirements
233
228
/// 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 (
235
230
& mut self ,
236
231
page : Page < S > ,
237
232
frame : PhysFrame < S > ,
238
233
flags : PageTableFlags ,
239
234
parent_table_flags : PageTableFlags ,
240
- frame_allocator : & mut A ,
241
235
) -> Result < MapperFlush < S > , MapToError < S > >
242
236
where
243
- Self : Sized ,
244
- A : FrameAllocator < Size4KiB > + ?Sized ;
237
+ Self : Sized ;
245
238
246
239
/// Removes a mapping from the page table and returns the frame that used to be mapped.
247
240
///
@@ -276,20 +269,18 @@ pub trait Mapper<S: PageSize> {
276
269
/// This is a convencience function that invokes [`Mapper::map_to`] internally, so
277
270
/// all safety requirements of it also apply for this function.
278
271
#[ inline]
279
- unsafe fn identity_map < A > (
272
+ unsafe fn identity_map (
280
273
& mut self ,
281
274
frame : PhysFrame < S > ,
282
275
flags : PageTableFlags ,
283
- frame_allocator : & mut A ,
284
276
) -> Result < MapperFlush < S > , MapToError < S > >
285
277
where
286
278
Self : Sized ,
287
- A : FrameAllocator < Size4KiB > + ?Sized ,
288
279
S : PageSize ,
289
280
Self : Mapper < S > ,
290
281
{
291
282
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)
293
284
}
294
285
}
295
286
@@ -412,46 +403,36 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
412
403
}
413
404
}
414
405
415
- fn map_to_2mib < A > (
406
+ fn map_to_2mib (
416
407
& mut self ,
417
408
page : Page < Size2MiB > ,
418
409
frame : PhysFrame < Size2MiB > ,
419
410
flags : PageTableFlags ,
420
411
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 > > {
426
413
let mut is_alloc_4 = false ;
427
414
428
415
let p4;
429
416
430
417
if self . level_5_paging_enabled {
431
418
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) ?;
437
422
438
423
p4 = yes;
439
424
is_alloc_4 = alloc;
440
425
} else {
441
426
p4 = & mut self . page_table ;
442
427
}
443
428
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) ?;
449
432
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) ?;
455
436
456
437
if !p2[ page. p2_index ( ) ] . is_unused ( ) {
457
438
return Err ( MapToError :: PageAlreadyMapped ( frame) ) ;
@@ -475,52 +456,40 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
475
456
Ok ( MapperFlush :: new ( page) )
476
457
}
477
458
478
- fn map_to_4kib < A > (
459
+ fn map_to_4kib (
479
460
& mut self ,
480
461
page : Page < Size4KiB > ,
481
462
frame : PhysFrame < Size4KiB > ,
482
463
flags : PageTableFlags ,
483
464
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 > > {
489
466
let p4;
490
467
491
468
let mut is_alloc_4 = false ;
492
469
493
470
if self . level_5_paging_enabled {
494
471
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) ?;
500
475
501
476
p4 = yes;
502
477
is_alloc_4 = alloc;
503
478
} else {
504
479
p4 = & mut self . page_table ;
505
480
}
506
481
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) ?;
512
485
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) ?;
518
489
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) ?;
524
493
525
494
if !p1[ page. p1_index ( ) ] . is_unused ( ) {
526
495
return Err ( MapToError :: PageAlreadyMapped ( frame) ) ;
@@ -551,18 +520,14 @@ impl<'a, P: PageTableFrameMapping> MappedPageTable<'a, P> {
551
520
552
521
impl < ' a , P : PageTableFrameMapping > Mapper < Size2MiB > for MappedPageTable < ' a , P > {
553
522
#[ inline]
554
- unsafe fn map_to_with_table_flags < A > (
523
+ unsafe fn map_to_with_table_flags (
555
524
& mut self ,
556
525
page : Page < Size2MiB > ,
557
526
frame : PhysFrame < Size2MiB > ,
558
527
flags : PageTableFlags ,
559
528
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)
566
531
}
567
532
568
533
fn unmap (
@@ -675,18 +640,14 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
675
640
676
641
impl < ' a , P : PageTableFrameMapping > Mapper < Size4KiB > for MappedPageTable < ' a , P > {
677
642
#[ inline]
678
- unsafe fn map_to_with_table_flags < A > (
643
+ unsafe fn map_to_with_table_flags (
679
644
& mut self ,
680
645
page : Page < Size4KiB > ,
681
646
frame : PhysFrame < Size4KiB > ,
682
647
flags : PageTableFlags ,
683
648
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)
690
651
}
691
652
692
653
fn unmap (
@@ -933,19 +894,15 @@ impl<P: PageTableFrameMapping> PageTableWalker<P> {
933
894
/// Returns `MapToError::FrameAllocationFailed` if the entry is unused and the allocator
934
895
/// returned `None`. Returns `MapToError::ParentEntryHugePage` if the `HUGE_PAGE` flag is set
935
896
/// in the passed entry.
936
- fn create_next_table < ' b , A > (
897
+ fn create_next_table < ' b > (
937
898
& self ,
938
899
entry : & ' b mut PageTableEntry ,
939
900
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 > {
945
902
let created;
946
903
947
904
if entry. is_unused ( ) {
948
- if let Some ( frame) = allocator . allocate_frame ( ) {
905
+ if let Some ( frame) = unsafe { FRAME_ALLOCATOR . allocate_frame ( ) } {
949
906
entry. set_frame ( frame, insert_flags) ;
950
907
created = true ;
951
908
} else {
@@ -1120,19 +1077,15 @@ unsafe impl PageTableFrameMapping for PhysOffset {
1120
1077
1121
1078
impl < ' a > Mapper < Size2MiB > for OffsetPageTable < ' a > {
1122
1079
#[ inline]
1123
- unsafe fn map_to_with_table_flags < A > (
1080
+ unsafe fn map_to_with_table_flags (
1124
1081
& mut self ,
1125
1082
page : Page < Size2MiB > ,
1126
1083
frame : PhysFrame < Size2MiB > ,
1127
1084
flags : PageTableFlags ,
1128
1085
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 > > {
1134
1087
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)
1136
1089
}
1137
1090
1138
1091
#[ inline]
@@ -1160,19 +1113,15 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
1160
1113
1161
1114
impl < ' a > Mapper < Size4KiB > for OffsetPageTable < ' a > {
1162
1115
#[ inline]
1163
- unsafe fn map_to_with_table_flags < A > (
1116
+ unsafe fn map_to_with_table_flags (
1164
1117
& mut self ,
1165
1118
page : Page < Size4KiB > ,
1166
1119
frame : PhysFrame < Size4KiB > ,
1167
1120
flags : PageTableFlags ,
1168
1121
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 > > {
1174
1123
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)
1176
1125
}
1177
1126
1178
1127
#[ inline]
0 commit comments