MCPcopy Create free account
hub / github.com/bendudson/EuraliOS / create_consecutive_pages

Function create_consecutive_pages

kernel/src/memory.rs:434–457  ·  view source on GitHub ↗

Allocates a consecutive set of frames start_addr Starting virtual address in page table num_frames Number of consecutive frames max_physaddr Maximum physical address e.g 32-bit addressable 0xFFFF_FFFF

(
    level_4_physaddr: u64,
    start_addr: VirtAddr,
    num_frames: u64,
    max_physaddr: u64)

Source from the content-addressed store, hash-verified

432/// max_physaddr Maximum physical address
433/// e.g 32-bit addressable 0xFFFF_FFFF
434pub fn create_consecutive_pages(
435 level_4_physaddr: u64,
436 start_addr: VirtAddr,
437 num_frames: u64,
438 max_physaddr: u64)
439 -> Result<PhysAddr, MapToError<Size4KiB>> {
440
441 // Try to allocate a consecutive set of frames
442 let start_frame = {
443 let memory_info = unsafe {MEMORY_INFO.as_mut().unwrap()};
444 let frame_allocator = &mut memory_info.frame_allocator;
445
446 frame_allocator
447 .allocate_consecutive_frames(num_frames, max_physaddr)
448 .ok_or(MapToError::FrameAllocationFailed)?
449 };
450
451 let start_page = Page::containing_address(start_addr);
452
453 map_consecutive_pages(level_4_physaddr,
454 start_page,
455 start_frame,
456 num_frames)
457}
458
459/// Create a mapping to a specific range of physical memory
460///

Callers 1

new_memory_chunkFunction · 0.85

Calls 2

map_consecutive_pagesFunction · 0.85

Tested by

no test coverage detected