@@ -8,7 +8,7 @@ use core::marker::PhantomData;
88pub struct Rv32PageTableWith < ' a , V : VirtualAddress + AddressL2 , FL : MapperFlushable > {
99 root_table : & ' a mut PageTableX32 ,
1010 linear_offset : u64 , // VA = PA + linear_offset
11- phantom : PhantomData < fn ( ) -> ( V , FL ) > ,
11+ phantom : PhantomData < fn ( ) -> ( V , FL ) > ,
1212}
1313
1414impl < ' a , V : VirtualAddress + AddressL2 , FL : MapperFlushable > Rv32PageTableWith < ' a , V , FL > {
@@ -26,9 +26,7 @@ impl<'a, V: VirtualAddress + AddressL2, FL: MapperFlushable> Rv32PageTableWith<'
2626 allocator : & mut impl FrameAllocatorFor < <Self as Mapper >:: P > ,
2727 ) -> Result < & mut PageTableX32 , MapToError > {
2828 if self . root_table [ p2_index] . is_unused ( ) {
29- let frame = allocator
30- . alloc ( )
31- . ok_or ( MapToError :: FrameAllocationFailed ) ?;
29+ let frame = allocator. alloc ( ) . ok_or ( MapToError :: FrameAllocationFailed ) ?;
3230 self . root_table [ p2_index] . set ( frame. clone ( ) , F :: VALID ) ;
3331 let p1_table: & mut PageTableX32 = unsafe { frame. as_kernel_mut ( self . linear_offset ) } ;
3432 p1_table. zero ( ) ;
@@ -66,7 +64,8 @@ impl<'a, V: VirtualAddress + AddressL2, FL: MapperFlushable> Mapper
6664 fn unmap (
6765 & mut self ,
6866 page : <Self as MapperExt >:: Page ,
69- ) -> Result < ( <Self as MapperExt >:: Frame , Self :: MapperFlush ) , UnmapError < <Self as Mapper >:: P > > {
67+ ) -> Result < ( <Self as MapperExt >:: Frame , Self :: MapperFlush ) , UnmapError < <Self as Mapper >:: P > >
68+ {
7069 if self . root_table [ page. p2_index ( ) ] . is_unused ( ) {
7170 return Err ( UnmapError :: PageNotMapped ) ;
7271 }
@@ -99,7 +98,7 @@ impl<'a, V: VirtualAddress + AddressL2, FL: MapperFlushable> Mapper
9998pub struct Rv39PageTableWith < ' a , V : VirtualAddress + AddressL3 , FL : MapperFlushable > {
10099 root_table : & ' a mut PageTableX64 ,
101100 linear_offset : u64 , // VA = PA + linear_offset
102- phantom : PhantomData < fn ( ) -> ( V , FL ) > ,
101+ phantom : PhantomData < fn ( ) -> ( V , FL ) > ,
103102}
104103
105104impl < ' a , V : VirtualAddress + AddressL3 , FL : MapperFlushable > Rv39PageTableWith < ' a , V , FL > {
@@ -118,9 +117,7 @@ impl<'a, V: VirtualAddress + AddressL3, FL: MapperFlushable> Rv39PageTableWith<'
118117 allocator : & mut impl FrameAllocatorFor < <Self as Mapper >:: P > ,
119118 ) -> Result < & mut PageTableX64 , MapToError > {
120119 let p2_table = if self . root_table [ p3_index] . is_unused ( ) {
121- let frame = allocator
122- . alloc ( )
123- . ok_or ( MapToError :: FrameAllocationFailed ) ?;
120+ let frame = allocator. alloc ( ) . ok_or ( MapToError :: FrameAllocationFailed ) ?;
124121 self . root_table [ p3_index] . set ( frame. clone ( ) , F :: VALID ) ;
125122 let p2_table: & mut PageTableX64 = unsafe { frame. as_kernel_mut ( self . linear_offset ) } ;
126123 p2_table. zero ( ) ;
@@ -130,9 +127,7 @@ impl<'a, V: VirtualAddress + AddressL3, FL: MapperFlushable> Rv39PageTableWith<'
130127 unsafe { frame. as_kernel_mut ( self . linear_offset ) }
131128 } ;
132129 if p2_table[ p2_index] . is_unused ( ) {
133- let frame = allocator
134- . alloc ( )
135- . ok_or ( MapToError :: FrameAllocationFailed ) ?;
130+ let frame = allocator. alloc ( ) . ok_or ( MapToError :: FrameAllocationFailed ) ?;
136131 p2_table[ p2_index] . set ( frame. clone ( ) , F :: VALID ) ;
137132 let p1_table: & mut PageTableX64 = unsafe { frame. as_kernel_mut ( self . linear_offset ) } ;
138133 p1_table. zero ( ) ;
@@ -170,7 +165,8 @@ impl<'a, V: VirtualAddress + AddressL3, FL: MapperFlushable> Mapper
170165 fn unmap (
171166 & mut self ,
172167 page : <Self as MapperExt >:: Page ,
173- ) -> Result < ( <Self as MapperExt >:: Frame , Self :: MapperFlush ) , UnmapError < <Self as Mapper >:: P > > {
168+ ) -> Result < ( <Self as MapperExt >:: Frame , Self :: MapperFlush ) , UnmapError < <Self as Mapper >:: P > >
169+ {
174170 if self . root_table [ page. p3_index ( ) ] . is_unused ( ) {
175171 return Err ( UnmapError :: PageNotMapped ) ;
176172 }
@@ -235,9 +231,7 @@ impl<'a, V: VirtualAddress + AddressL4, FL: MapperFlushable> Rv48PageTableWith<'
235231 allocator : & mut impl FrameAllocatorFor < <Self as Mapper >:: P > ,
236232 ) -> Result < & mut PageTableX64 , MapToError > {
237233 let p3_table = if self . root_table [ p4_index] . is_unused ( ) {
238- let frame = allocator
239- . alloc ( )
240- . ok_or ( MapToError :: FrameAllocationFailed ) ?;
234+ let frame = allocator. alloc ( ) . ok_or ( MapToError :: FrameAllocationFailed ) ?;
241235 self . root_table [ p4_index] . set ( frame. clone ( ) , F :: VALID ) ;
242236 let p3_table: & mut PageTableX64 = unsafe { frame. as_kernel_mut ( self . linear_offset ) } ;
243237 p3_table. zero ( ) ;
@@ -248,9 +242,7 @@ impl<'a, V: VirtualAddress + AddressL4, FL: MapperFlushable> Rv48PageTableWith<'
248242 } ;
249243
250244 let p2_table = if p3_table[ p3_index] . is_unused ( ) {
251- let frame = allocator
252- . alloc ( )
253- . ok_or ( MapToError :: FrameAllocationFailed ) ?;
245+ let frame = allocator. alloc ( ) . ok_or ( MapToError :: FrameAllocationFailed ) ?;
254246 p3_table[ p3_index] . set ( frame. clone ( ) , F :: VALID ) ;
255247 let p2_table: & mut PageTableX64 = unsafe { frame. as_kernel_mut ( self . linear_offset ) } ;
256248 p2_table. zero ( ) ;
@@ -261,9 +253,7 @@ impl<'a, V: VirtualAddress + AddressL4, FL: MapperFlushable> Rv48PageTableWith<'
261253 } ;
262254
263255 if p2_table[ p2_index] . is_unused ( ) {
264- let frame = allocator
265- . alloc ( )
266- . ok_or ( MapToError :: FrameAllocationFailed ) ?;
256+ let frame = allocator. alloc ( ) . ok_or ( MapToError :: FrameAllocationFailed ) ?;
267257 p2_table[ p2_index] . set ( frame. clone ( ) , F :: VALID ) ;
268258 let p1_table: & mut PageTableX64 = unsafe { frame. as_kernel_mut ( self . linear_offset ) } ;
269259 p1_table. zero ( ) ;
@@ -306,7 +296,8 @@ impl<'a, V: VirtualAddress + AddressL4, FL: MapperFlushable> Mapper
306296 fn unmap (
307297 & mut self ,
308298 page : <Self as MapperExt >:: Page ,
309- ) -> Result < ( <Self as MapperExt >:: Frame , Self :: MapperFlush ) , UnmapError < <Self as Mapper >:: P > > {
299+ ) -> Result < ( <Self as MapperExt >:: Frame , Self :: MapperFlush ) , UnmapError < <Self as Mapper >:: P > >
300+ {
310301 if self . root_table [ page. p4_index ( ) ] . is_unused ( ) {
311302 return Err ( UnmapError :: PageNotMapped ) ;
312303 }
0 commit comments