Crate page_allocator

source ·
Expand description

Provides an allocator for virtual memory pages. The minimum unit of allocation is a single page.

This also supports early allocation of pages (up to 32 separate chunks) before heap allocation is available, and does so behind the scenes using the same single interface.

Once heap allocation is available, it uses a dynamically-allocated list of page chunks to track allocations.

The core allocation function is allocate_pages_deferred(), but there are several convenience functions that offer simpler interfaces for general usage.

Notes and Missing Features

This allocator currently does not merge freed chunks (de-fragmentation) upon deallocation. It only merges free chunks lazily upon request, i.e., when we run out of address space or when a requested address is in a chunk that needs to be merged with a nearby chunk.

Structs

Represents a range of allocated VirtualAddresses, specified in Pages.
A series of pending actions related to page allocator bookkeeping, which may result in heap allocation.

Functions

Allocates the given number of pages with no constraints on the starting virtual address.
Allocates the given number of pages starting at (inclusive of) the page containing the given VirtualAddress.
Allocates pages with no constraints on the starting virtual address, with a size given by the number of bytes.
Allocates pages starting at the given VirtualAddress with a size given in number of bytes.
Similar to allocated_pages_deferred(), but accepts a size value for the allocated pages in number of bytes instead of number of pages.
The core page allocation routine that allocates the given number of virtual pages, optionally at the requested starting VirtualAddress.
Initialize the page allocator.