xref: /DragonOS/kernel/src/mm/mod.rs (revision 45b8371173b070028457f7ee64be33f68b4f9ada)
1 use crate::include::bindings::bindings::PAGE_OFFSET;
2 
3 pub mod allocator;
4 pub mod gfp;
5 pub mod mmio_buddy;
6 
7 /// @brief 将内核空间的虚拟地址转换为物理地址
8 #[inline(always)]
9 pub fn virt_2_phys(addr: usize) -> usize {
10     addr - PAGE_OFFSET as usize
11 }
12 
13 /// @brief 将物理地址转换为内核空间的虚拟地址
14 #[inline(always)]
15 pub fn phys_2_virt(addr: usize) -> usize {
16     addr + PAGE_OFFSET as usize
17 }
18