@@ -77,8 +77,9 @@ impl<S: PageSize> Page<S> {
77
77
///
78
78
/// Returns an error if the address is not correctly aligned (i.e. is not a valid page start).
79
79
#[ inline]
80
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
80
81
pub fn from_start_address ( address : VirtAddr ) -> Result < Self , AddressNotAligned > {
81
- if !address. is_aligned ( S :: SIZE ) {
82
+ if !address. is_aligned_u64 ( S :: SIZE ) {
82
83
return Err ( AddressNotAligned ) ;
83
84
}
84
85
Ok ( Page :: containing_address ( address) )
@@ -100,9 +101,10 @@ impl<S: PageSize> Page<S> {
100
101
101
102
/// Returns the page that contains the given virtual address.
102
103
#[ inline]
104
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
103
105
pub fn containing_address ( address : VirtAddr ) -> Self {
104
106
Page {
105
- start_address : address. align_down ( S :: SIZE ) ,
107
+ start_address : address. align_down_u64 ( S :: SIZE ) ,
106
108
size : PhantomData ,
107
109
}
108
110
}
@@ -185,47 +187,50 @@ impl<S: NotGiantPageSize> Page<S> {
185
187
impl Page < Size1GiB > {
186
188
/// Returns the 1GiB memory page with the specified page table indices.
187
189
#[ inline]
190
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
188
191
pub fn from_page_table_indices_1gib (
189
192
p4_index : PageTableIndex ,
190
193
p3_index : PageTableIndex ,
191
194
) -> Self {
192
195
let mut addr = 0 ;
193
- addr |= u64 :: from ( p4_index) << 39 ;
194
- addr |= u64 :: from ( p3_index) << 30 ;
196
+ addr |= p4_index. into_u64 ( ) << 39 ;
197
+ addr |= p3_index. into_u64 ( ) << 30 ;
195
198
Page :: containing_address ( VirtAddr :: new_truncate ( addr) )
196
199
}
197
200
}
198
201
199
202
impl Page < Size2MiB > {
200
203
/// Returns the 2MiB memory page with the specified page table indices.
201
204
#[ inline]
205
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
202
206
pub fn from_page_table_indices_2mib (
203
207
p4_index : PageTableIndex ,
204
208
p3_index : PageTableIndex ,
205
209
p2_index : PageTableIndex ,
206
210
) -> Self {
207
211
let mut addr = 0 ;
208
- addr |= u64 :: from ( p4_index) << 39 ;
209
- addr |= u64 :: from ( p3_index) << 30 ;
210
- addr |= u64 :: from ( p2_index) << 21 ;
212
+ addr |= p4_index. into_u64 ( ) << 39 ;
213
+ addr |= p3_index. into_u64 ( ) << 30 ;
214
+ addr |= p2_index. into_u64 ( ) << 21 ;
211
215
Page :: containing_address ( VirtAddr :: new_truncate ( addr) )
212
216
}
213
217
}
214
218
215
219
impl Page < Size4KiB > {
216
220
/// Returns the 4KiB memory page with the specified page table indices.
217
221
#[ inline]
222
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
218
223
pub fn from_page_table_indices (
219
224
p4_index : PageTableIndex ,
220
225
p3_index : PageTableIndex ,
221
226
p2_index : PageTableIndex ,
222
227
p1_index : PageTableIndex ,
223
228
) -> Self {
224
229
let mut addr = 0 ;
225
- addr |= u64 :: from ( p4_index) << 39 ;
226
- addr |= u64 :: from ( p3_index) << 30 ;
227
- addr |= u64 :: from ( p2_index) << 21 ;
228
- addr |= u64 :: from ( p1_index) << 12 ;
230
+ addr |= p4_index. into_u64 ( ) << 39 ;
231
+ addr |= p3_index. into_u64 ( ) << 30 ;
232
+ addr |= p2_index. into_u64 ( ) << 21 ;
233
+ addr |= p1_index. into_u64 ( ) << 12 ;
229
234
Page :: containing_address ( VirtAddr :: new_truncate ( addr) )
230
235
}
231
236
0 commit comments