diff --git a/src/arch/x86_64/paging/mod.rs b/src/arch/x86_64/paging/mod.rs index c34c0e660a480614577c110a362abad7c12b9a27..eff4acfbe1c568bfb3318824f8256cefdf9fd37d 100644 --- a/src/arch/x86_64/paging/mod.rs +++ b/src/arch/x86_64/paging/mod.rs @@ -335,6 +335,14 @@ impl InactivePageTable { } } +pub fn linear_phys_to_virt(physical: PhysicalAddress) -> Option<VirtualAddress> { + physical.data().checked_add(crate::KERNEL_OFFSET).map(VirtualAddress::new) +} +pub fn linear_virt_to_phys(virt: VirtualAddress) -> Option<PhysicalAddress> { + virt.data().checked_sub(crate::KERNEL_OFFSET).map(PhysicalAddress::new) +} + + /// Page #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Page {