pub fn allocate_frames_deferred(
    requested_paddr: Option<PhysicalAddress>,
    num_frames: usize
) -> Result<(AllocatedFrames<Page4K>, DeferredAllocAction<'static>), &'static str>
Expand description

The core frame allocation routine that allocates the given number of physical frames, optionally at the requested starting PhysicalAddress.

This simply reserves a range of frames; it does not perform any memory mapping. Thus, the memory represented by the returned AllocatedFrames isn’t directly accessible until you map virtual pages to them.

Allocation is based on a red-black tree and is thus O(log(n)). Fragmentation isn’t cleaned up until we’re out of address space, but that’s not really a big deal.

Arguments

  • requested_paddr: if Some, the returned AllocatedFrames will start at the Frame containing this PhysicalAddress. If None, the first available Frame range will be used, starting at any random physical address.
  • num_frames: the number of Frames to be allocated.

Return

If successful, returns a tuple of two items:

  • the frames that were allocated, and
  • an opaque struct representing details of bookkeeping-related actions that may cause heap allocation. Those actions are deferred until this returned DeferredAllocAction struct object is dropped, allowing the caller (such as the heap implementation itself) to control when heap allocation may occur.