marcel_os::allocator

Function init_heap

Source
pub fn init_heap(
    mapper: &mut impl Mapper<Size4KiB>,
    frame_allocator: &mut impl FrameAllocator<Size4KiB>,
) -> Result<(), MapToError<Size4KiB>>
Expand description

Initializes the heap by mapping the required memory pages and setting up the allocator. This function maps a range of pages for the heap, allocates frames, and sets up the heap allocator.

§Arguments

  • mapper - A mutable reference to the Mapper for mapping pages.
  • frame_allocator - A mutable reference to the FrameAllocator used to allocate physical frames.

§Returns

A Result indicating success or failure. Returns Ok(()) if the heap is successfully initialized, or an error if frame allocation or mapping fails.