Add linear_phys_to_virt and vice versa.

However, since not all platforms will allow the entire physical address
space to be simultaneously mapped to part of the virtual address space,
we may still require some dynamic mapping.
This commit is contained in:
4lDO2
2020-12-25 17:47:14 +01:00
parent 5f4978a6dc
commit 16a31b0cd1

View File

@@ -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 {