Implement shifts for PhysAddr

This commit is contained in:
Berkus Decker 2020-12-13 22:30:51 +02:00
parent 01906a02bc
commit d3f561d214
1 changed files with 17 additions and 0 deletions

View File

@ -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::*;