MCPcopy Create free account
hub / github.com/Ruddle/Fomos / create_virt_from_phys

Function create_virt_from_phys

bootloader/kernel/src/main.rs:128–139  ·  view source on GitHub ↗
(
    mapper: &mut impl Mapper<Size4KiB>,
    frame_allocator: &mut impl FrameAllocator<Size4KiB>,
    frame: PhysFrame,
)

Source from the content-addressed store, hash-verified

126}
127static OTHER_VIRT: AtomicU64 = AtomicU64::new(0x_5000_0000_0000);
128pub 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
141pub fn create_identity_virt_from_phys(
142 mapper: &mut impl Mapper<Size4KiB>,

Callers

nothing calls this directly

Calls 1

flushMethod · 0.45

Tested by

no test coverage detected