| 126 | } |
| 127 | static OTHER_VIRT: AtomicU64 = AtomicU64::new(0x_5000_0000_0000); |
| 128 | pub fn create_virt_from_phys( |
| 129 | mapper: &mut impl Mapper<Size4KiB>, |
| 130 | frame_allocator: &mut impl FrameAllocator<Size4KiB>, |
| 131 | frame: PhysFrame, |
| 132 | ) -> Result<Page, MapToError<Size4KiB>> { |
| 133 | let start = VirtAddr::new(OTHER_VIRT.fetch_add(4096, Ordering::Relaxed) as u64); |
| 134 | let page = Page::containing_address(start); |
| 135 | let flags = |
| 136 | PageTableFlags::PRESENT | PageTableFlags::WRITABLE | PageTableFlags::USER_ACCESSIBLE; |
| 137 | unsafe { mapper.map_to(page, frame, flags, frame_allocator)?.flush() }; |
| 138 | return Ok(page); |
| 139 | } |
| 140 | |
| 141 | pub fn create_identity_virt_from_phys( |
| 142 | mapper: &mut impl Mapper<Size4KiB>, |