Implement shifts for PhysAddr
This commit is contained in:
parent
01906a02bc
commit
d3f561d214
|
@ -2,6 +2,7 @@
|
|||
* SPDX-License-Identifier: BlueOak-1.0.0
|
||||
* Copyright (c) Berkus Decker <berkus+vesper@metta.systems>
|
||||
*/
|
||||
use core::ops::{Shl, Shr};
|
||||
use {
|
||||
crate::mm::{align_down, align_up},
|
||||
bit_field::BitField,
|
||||
|
@ -489,6 +490,22 @@ impl Sub<PhysAddr> for PhysAddr {
|
|||
}
|
||||
}
|
||||
|
||||
impl Shr<usize> for PhysAddr {
|
||||
type Output = PhysAddr;
|
||||
|
||||
fn shr(self, shift: usize) -> Self::Output {
|
||||
PhysAddr::new(self.0 >> shift)
|
||||
}
|
||||
}
|
||||
|
||||
impl Shl<usize> for PhysAddr {
|
||||
type Output = PhysAddr;
|
||||
|
||||
fn shl(self, shift: usize) -> Self::Output {
|
||||
PhysAddr::new(self.0 << shift)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// use super::*;
|
||||
|
|
Loading…
Reference in New Issue