File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,15 @@ impl VirtAddr {
177
177
where
178
178
U : Into < u64 > ,
179
179
{
180
- VirtAddr :: new_truncate ( align_down ( self . 0 , align. into ( ) ) )
180
+ self . align_down_u64 ( align. into ( ) )
181
+ }
182
+
183
+ /// Aligns the virtual address downwards to the given alignment.
184
+ ///
185
+ /// See the `align_down` function for more information.
186
+ #[ inline]
187
+ pub ( crate ) const fn align_down_u64 ( self , align : u64 ) -> Self {
188
+ VirtAddr :: new_truncate ( align_down ( self . 0 , align) )
181
189
}
182
190
183
191
/// Checks whether the virtual address has the demanded alignment.
@@ -186,7 +194,13 @@ impl VirtAddr {
186
194
where
187
195
U : Into < u64 > ,
188
196
{
189
- self . align_down ( align) == self
197
+ self . is_aligned_u64 ( align. into ( ) )
198
+ }
199
+
200
+ /// Checks whether the virtual address has the demanded alignment.
201
+ #[ inline]
202
+ pub ( crate ) const fn is_aligned_u64 ( self , align : u64 ) -> bool {
203
+ self . align_down_u64 ( align) . as_u64 ( ) == self . as_u64 ( )
190
204
}
191
205
192
206
/// Returns the 12-bit page offset of this virtual address.
Original file line number Diff line number Diff line change @@ -306,6 +306,10 @@ impl PageTableIndex {
306
306
pub const fn new_truncate ( index : u16 ) -> Self {
307
307
Self ( index % ENTRY_COUNT as u16 )
308
308
}
309
+
310
+ pub ( crate ) const fn into_u64 ( self ) -> u64 {
311
+ self . 0 as u64
312
+ }
309
313
}
310
314
311
315
impl From < PageTableIndex > for u16 {
@@ -325,7 +329,7 @@ impl From<PageTableIndex> for u32 {
325
329
impl From < PageTableIndex > for u64 {
326
330
#[ inline]
327
331
fn from ( index : PageTableIndex ) -> Self {
328
- u64 :: from ( index. 0 )
332
+ index. into_u64 ( )
329
333
}
330
334
}
331
335
You can’t perform that action at this time.
0 commit comments