File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -495,7 +495,15 @@ impl PhysAddr {
495
495
where
496
496
U : Into < u64 > ,
497
497
{
498
- PhysAddr ( align_down ( self . 0 , align. into ( ) ) )
498
+ self . align_down_u64 ( align. into ( ) )
499
+ }
500
+
501
+ /// Aligns the physical address downwards to the given alignment.
502
+ ///
503
+ /// See the `align_down` function for more information.
504
+ #[ inline]
505
+ pub ( crate ) const fn align_down_u64 ( self , align : u64 ) -> Self {
506
+ PhysAddr ( align_down ( self . 0 , align) )
499
507
}
500
508
501
509
/// Checks whether the physical address has the demanded alignment.
@@ -504,7 +512,13 @@ impl PhysAddr {
504
512
where
505
513
U : Into < u64 > ,
506
514
{
507
- self . align_down ( align) == self
515
+ self . is_aligned_u64 ( align. into ( ) )
516
+ }
517
+
518
+ /// Checks whether the physical address has the demanded alignment.
519
+ #[ inline]
520
+ pub ( crate ) const fn is_aligned_u64 ( self , align : u64 ) -> bool {
521
+ self . align_down_u64 ( align) . as_u64 ( ) == self . as_u64 ( )
508
522
}
509
523
}
510
524
Original file line number Diff line number Diff line change @@ -21,8 +21,9 @@ impl<S: PageSize> PhysFrame<S> {
21
21
///
22
22
/// Returns an error if the address is not correctly aligned (i.e. is not a valid frame start).
23
23
#[ inline]
24
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
24
25
pub fn from_start_address ( address : PhysAddr ) -> Result < Self , AddressNotAligned > {
25
- if !address. is_aligned ( S :: SIZE ) {
26
+ if !address. is_aligned_u64 ( S :: SIZE ) {
26
27
return Err ( AddressNotAligned ) ;
27
28
}
28
29
@@ -46,9 +47,10 @@ impl<S: PageSize> PhysFrame<S> {
46
47
47
48
/// Returns the frame that contains the given physical address.
48
49
#[ inline]
50
+ #[ rustversion:: attr( since( 1.61 ) , const ) ]
49
51
pub fn containing_address ( address : PhysAddr ) -> Self {
50
52
PhysFrame {
51
- start_address : address. align_down ( S :: SIZE ) ,
53
+ start_address : address. align_down_u64 ( S :: SIZE ) ,
52
54
size : PhantomData ,
53
55
}
54
56
}
You can’t perform that action at this time.
0 commit comments